-
Notifications
You must be signed in to change notification settings - Fork 590
feat: send additional Sift events on Android #8991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| diff --git a/node_modules/sift-react-native/lib/typescript/src/index.d.ts b/node_modules/sift-react-native/lib/typescript/src/index.d.ts | ||
| index e6bcb83..6582ec8 100644 | ||
| --- a/node_modules/sift-react-native/lib/typescript/src/index.d.ts | ||
| +++ b/node_modules/sift-react-native/lib/typescript/src/index.d.ts | ||
| @@ -1,6 +1,7 @@ | ||
| declare type SiftReactNativeType = { | ||
| setSiftConfig(accountId: string, beaconKey: string, disallowCollectingLocationData: boolean, serverUrlFormat: string): void; | ||
| setUserId(userId: string): void; | ||
| + setPageName(pageName: String): void; | ||
| unsetUserId(): void; | ||
| upload(): void; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,11 @@ import { Severity, addBreadcrumb } from "@sentry/react-native" | |
| import { AppModule, modules } from "app/AppRegistry" | ||
| import { __unsafe_mainModalStackRef } from "app/NativeModules/ARScreenPresenterModule" | ||
| import { GlobalStore } from "app/store/GlobalStore" | ||
| import { useFeatureFlag } from "app/utils/hooks/useFeatureFlag" | ||
| import { logNavigation } from "app/utils/loggers" | ||
| import { useEffect, useRef } from "react" | ||
| import { Platform } from "react-native" | ||
| import SiftReactNative from "sift-react-native" | ||
| import { NavStack } from "./NavStack" | ||
| import { useReloadedDevNavigationState } from "./useReloadedDevNavigationState" | ||
|
|
||
|
|
@@ -24,11 +27,28 @@ const Stack = createStackNavigator() | |
| export const ModalStack: React.FC = ({ children }) => { | ||
| const initialState = useReloadedDevNavigationState("main_modal_stack", __unsafe_mainModalStackRef) | ||
| const { setSessionState: setNavigationReady } = GlobalStore.actions | ||
|
|
||
| // Code for Sift tracking; needs to be manually fired on Android | ||
| // See https://github.com/SiftScience/sift-react-native/pull/23#issuecomment-1630984250 | ||
| const enableAdditionalSiftAndroidTracking = useFeatureFlag( | ||
| "AREnableAdditionalSiftAndroidTracking" | ||
| ) | ||
| const trackSiftAndroid = Platform.OS === "android" && enableAdditionalSiftAndroidTracking | ||
| const routeNameRef = useRef<string>() | ||
| useEffect(() => { | ||
| if (trackSiftAndroid) { | ||
| const initialRouteName = routeNameRef.current | ||
|
mdole marked this conversation as resolved.
Outdated
|
||
| SiftReactNative.setPageName(`screen_${initialRouteName}`) | ||
| SiftReactNative.upload() | ||
| } | ||
| }, []) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue(blocker): I think you need to trigger this only after the navigation is ready, otherwise it will be empty initially in case the navigation is not yet ready.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, even better, you might want to move this to be within
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, thank you! Updated in 3d08ba5 |
||
|
|
||
| return ( | ||
| <NavigationContainer | ||
| ref={__unsafe_mainModalStackRef} | ||
| initialState={initialState} | ||
| onReady={() => { | ||
| routeNameRef.current = __unsafe_mainModalStackRef.current?.getCurrentRoute()?.name | ||
| setNavigationReady({ isNavigationReady: true }) | ||
| }} | ||
| onStateChange={() => { | ||
|
|
@@ -51,6 +71,11 @@ export const ModalStack: React.FC = ({ children }) => { | |
| data: { ...params }, | ||
| level: Severity.Info, | ||
| }) | ||
|
|
||
| if (trackSiftAndroid) { | ||
| SiftReactNative.setPageName(`screen_${currentRoute.name}`) | ||
| SiftReactNative.upload() | ||
| } | ||
| } | ||
| }} | ||
| > | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.