Skip to content

Instantly share code, notes, and snippets.

@ronal2do
Last active July 24, 2019 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronal2do/e947c44201292e6c4c4b436fd71f83e7 to your computer and use it in GitHub Desktop.
Save ronal2do/e947c44201292e6c4c4b436fd71f83e7 to your computer and use it in GitHub Desktop.
// Identify
const trackingOpts = { id, usernameOrEmail: email };
Analytics.identify(id, TrackingOpts);
// Simple event
Analytics.track(Analytics.events.BOOTSTRAP);
// Event with paramenters
Analytics.track(Analytics.events.USER_CREATED_ACCOUNT, trackingOpts);
// Errors handling
try {
// do something
} catch(error) {
Analytics.track(Analytics.events.ERROR, { error });
...
}
// PageView with react-navigation
<AppNavigator
uriPrefix={...}
onNavigationStateChange={(prevState, currentState, action) => {
const currentScreen = getActiveRouteName(currentState);
const prevScreen = getActiveRouteName(prevState);
if (prevScreen !== currentScreen) {
Analytics.track(Analytics.events.USER_PAGE_VIEW, { view: currentScreen });
}
}}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment