Skip to content

Commit

Permalink
Update screen-tracking.md (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
MoKhajavi75 committed Nov 30, 2020
1 parent b5aaf6e commit 3f191f8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions versioned_docs/version-4.x/screen-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ const AppContainer = createAppContainer(AppNavigator);

export default () => (
<AppContainer
onNavigationStateChange={(prevState, currentState, action) => {
onNavigationStateChange={async (prevState, currentState) => {
const currentRouteName = getActiveRouteName(currentState);
const previousRouteName = getActiveRouteName(prevState);

if (previousRouteName !== currentRouteName) {
// the line below uses the @react-native-firebase/analytics tracker
// change the tracker here to use other Mobile analytics SDK.
analytics().setCurrentScreen(currentRouteName, currentRouteName);
await analytics().logScreenView({
screen_name: currentRouteName,
screen_class: currentRouteName
});
}
}}
/>
Expand Down

0 comments on commit 3f191f8

Please sign in to comment.