Skip to content
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

feat: send additional Sift events on Android #8991

Merged
merged 5 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 13 additions & 0 deletions HACKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,16 @@ Once we have removed the `palette` directory from eigen.
#### Explanation/Context:

Look at the tech plan here: https://www.notion.so/artsy/palette-mobile-in-eigen-c5e3396302734f0a921aed3978f5dbeb

## Patch-package for sift-react-native

#### When can we remove this:

Just adds a type, so likely doesn't need to be removed. But if they officially add it
([see this issue](https://github.com/SiftScience/sift-react-native/issues/6)), we could drop this
patch.

#### Explanation/Context:

This package includes a `setPageName` method on `SiftReactNative`, but no corresponding type.
I patched it to add the type.
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;
};
mdole marked this conversation as resolved.
Show resolved Hide 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: {
mdole marked this conversation as resolved.
Show resolved Hide resolved
description: "Send additional events to Sift on Android",
readyForRelease: true,
showInDevMenu: true,
echoFlagKey: "AREnableAdditionalSiftAndroidTracking",
},
}

export interface DevToggleDescriptor {
Expand Down
21 changes: 21 additions & 0 deletions src/app/system/navigation/ModalStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ 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 { Platform } from "react-native"
import SiftReactNative from "sift-react-native"
import { NavStack } from "./NavStack"
import { useReloadedDevNavigationState } from "./useReloadedDevNavigationState"

Expand All @@ -24,12 +26,26 @@ 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

return (
<NavigationContainer
ref={__unsafe_mainModalStackRef}
initialState={initialState}
onReady={() => {
setNavigationReady({ isNavigationReady: true })

if (trackSiftAndroid) {
const initialRouteName = __unsafe_mainModalStackRef.current?.getCurrentRoute()?.name
SiftReactNative.setPageName(`screen_${initialRouteName}`)
SiftReactNative.upload()
}
}}
onStateChange={() => {
const currentRoute = __unsafe_mainModalStackRef.current?.getCurrentRoute()
Expand All @@ -51,6 +67,11 @@ export const ModalStack: React.FC = ({ children }) => {
data: { ...params },
level: Severity.Info,
})

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