From 1390b1dc9e35aafda328877c46e90860c6268453 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 13 Apr 2024 12:09:49 +0100 Subject: [PATCH] [Statsig] Send ref source (#3531) * [Statsig] Send ref source * Add is web check * Fix types --- src/lib/statsig/statsig.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib/statsig/statsig.tsx b/src/lib/statsig/statsig.tsx index 7513b945..3d2dc130 100644 --- a/src/lib/statsig/statsig.tsx +++ b/src/lib/statsig/statsig.tsx @@ -9,11 +9,20 @@ import { } from 'statsig-react-native-expo' import {logger} from '#/logger' +import {isWeb} from '#/platform/detection' import {IS_TESTFLIGHT} from 'lib/app-info' import {useSession} from '../../state/session' import {LogEvents} from './events' import {Gate} from './gates' +let refSrc: string | undefined +let refUrl: string | undefined +if (isWeb && typeof window !== 'undefined') { + const params = new URLSearchParams(window.location.search) + refSrc = params.get('ref_src') ?? undefined + refUrl = params.get('ref_url') ?? undefined +} + export type {LogEvents} const statsigOptions = { @@ -97,6 +106,8 @@ function toStatsigUser(did: string | undefined) { userID, platform: Platform.OS, custom: { + refSrc, + refUrl, // Need to specify here too for gating. platform: Platform.OS, },