nucleus rn
1.0.3
要开始使用Nucleus,请在Nucleus上创建一个帐户并获取应用程序ID,然后使用SDK开始跟踪事件。
该软件包具有@react-native-async-storage/async-storage和@react-native-community/netinfo作为同行依赖。如果没有它们,请先安装它们
yarn add @react-native-async-storage/async-storage @react-native-community/netinfo然后继续将nucleus-rn作为NPM包装安装(建议)
# with yarn
yarn add nucleus-rn import Nucleus from 'nucleus-rn' ;
Nucleus . init ( 'YOUR_APP_ID' ) ;将'YOUR_APP_ID'替换为应用程序的唯一ID。您可以在这里得到它。
您可以在此处查看使用不同框架的示例。
核支持将以下选项作为第二个参数传递给Nucleus.init()方法:
Nucleus . init ( 'APP_ID' , {
appVersion : '0.0.0' , // the version of your application
endpoint : 'wss://app.nucleus.sh' , // only option, we don't allow self hosting yet :(
disableInDev : true , // disable in development mode. We recommend not to call
// `init` method, as that will be more reliable.
debug : false , // if set to `true`, will log a bunch of things.
disableTracking : false , // will not track anything. You can also use `Nucleus.disableTracking()`.
// note that some events will still be added to the queue, so if you call
// Nucleus.enableTracking() again, they will be sent to the server.
reportInterval : 2 * 1000 , // at which interval the events are sent to the server.
sessionTimeout : 60 * 30 * 1000 , // time after which the session is ended
cutoff : 60 * 60 * 48 * 1000 , // time after which event that were not sent yet are deleted
disableErrorReports : false , // wether to disable error tracking
} )使用可选的自定义数据跟踪事件
Nucleus . track ( "click" , { foo : 'bar' } ) ;用名称和错误对象跟踪错误。
Nucleus . trackError ( name , error ) ;默认情况下,Nucleus为ErrorUtils.setGlobalHandler注册了一个将'GlobalError'错误发送到API的处理程序。如果您想禁用此行为,则可以将disableErrorReports设置为true :
Nucleus . init ( 'APP_ID' , { disableErrorReports : true } )并使用Nucleus.trackError('an error', errObject) 。
通过唯一的ID标识用户,并选择设置自定义属性。
Nucleus . identify ( '04f8846d-ecca-4a81-8740-f6428ceb7f7b' , { firstName : 'Jordan' , lastName : 'Walke' } ) ;带有屏幕名称和可选参数的轨道屏幕视图。
Nucleus . page ( '/about' , { foo : 'baz' } ) ;禁用跟踪
Nucleus . disableTracking ( ) ;启用跟踪
Nucleus . enableTracking ( ) ; 我们一直在寻找社区的贡献。这是您可以提供帮助的方式: