Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions patches/sift-react-native+0.1.8.patch
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;
};
Comment thread
mdole marked this conversation as resolved.
6 changes: 6 additions & 0 deletions src/app/store/config/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ export const features: { [key: string]: FeatureDescriptor } = {
readyForRelease: false,
showInDevMenu: true,
},
AREnableAdditionalSiftAndroidTracking: {
Comment thread
mdole marked this conversation as resolved.
description: "Send additional events to Sift on Android",
readyForRelease: true,
showInDevMenu: true,
echoFlagKey: "AREnableAdditionalSiftAndroidTracking",
},
}

export interface DevToggleDescriptor {
Expand Down
25 changes: 25 additions & 0 deletions src/app/system/navigation/ModalStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Comment thread
mdole marked this conversation as resolved.
Outdated
SiftReactNative.setPageName(`screen_${initialRouteName}`)
SiftReactNative.upload()
}
}, [])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, even better, you might want to move this to be within onReady prop in the NavigationContainer to avoid watching the onReady global state

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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={() => {
Expand All @@ -51,6 +71,11 @@ export const ModalStack: React.FC = ({ children }) => {
data: { ...params },
level: Severity.Info,
})

if (trackSiftAndroid) {
SiftReactNative.setPageName(`screen_${currentRoute.name}`)
SiftReactNative.upload()
}
}
}}
>
Expand Down