Para começar com o núcleo, crie uma conta no núcleo e pegue o ID do aplicativo e use o SDK para começar a rastrear eventos.
Este pacote possui @react-native-async-storage/async-storage e @react-native-community/netinfo como dependências de pares. Instale -os primeiro se você não os tiver
yarn add @react-native-async-storage/async-storage @react-native-community/netinfo Em seguida, prossiga para instalar nucleus-rn como pacote NPM (recomendado)
# with yarn
yarn add nucleus-rn import Nucleus from 'nucleus-rn' ;
Nucleus . init ( 'YOUR_APP_ID' ) ; Substitua 'YOUR_APP_ID' pelo ID exclusivo do seu aplicativo. Você pode obtê -lo aqui.
Você pode verificar exemplos com estruturas diferentes aqui.
O núcleo suporta a aprovação das seguintes opções como segundo argumento para o método 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
} )Rastreie eventos com dados personalizados opcionais
Nucleus . track ( "click" , { foo : 'bar' } ) ;Acompanhe erros com um nome e o objeto de erro.
Nucleus . trackError ( name , error ) ; Por padrão, o Nucleus registra um manipulador de ErrorUtils.setGlobalHandler que envia erros 'GlobalError' para a API. Se você deseja desativar esse comportamento, pode configurar disableErrorReports como true :
Nucleus . init ( 'APP_ID' , { disableErrorReports : true } ) e capturar erros usando manualmente Nucleus.trackError('an error', errObject) .
Identifique um usuário por um ID exclusivo e opcionalmente defina propriedades personalizadas.
Nucleus . identify ( '04f8846d-ecca-4a81-8740-f6428ceb7f7b' , { firstName : 'Jordan' , lastName : 'Walke' } ) ;Rastrear as visualizações da tela com o nome da tela e os parâmetros opcionais.
Nucleus . page ( '/about' , { foo : 'baz' } ) ;Para desativar o rastreamento
Nucleus . disableTracking ( ) ;Para ativar o rastreamento
Nucleus . enableTracking ( ) ; Estamos sempre procurando contribuições da comunidade. Veja como você pode ajudar: