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 ( ) ; 我們一直在尋找社區的貢獻。這是您可以提供幫助的方式: