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は、次のオプションをNucleus.init()メソッドに2番目の引数として渡すことをサポートしています。
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は、APIに'GlobalError'エラーを送信するErrorUtils.setGlobalHandlerのハンドラーを登録します。この動作を無効にしたい場合は、 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 ( ) ; 私たちは常にコミュニティからの貢献を探しています。これがあなたが助けることができる方法です: