[Statsig] Send ref source (#3531)

* [Statsig] Send ref source

* Add is web check

* Fix types
zio/stable
dan 2024-04-13 12:09:49 +01:00 committed by GitHub
parent c3f75330ed
commit 1390b1dc9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 0 deletions

View File

@ -9,11 +9,20 @@ import {
} from 'statsig-react-native-expo' } from 'statsig-react-native-expo'
import {logger} from '#/logger' import {logger} from '#/logger'
import {isWeb} from '#/platform/detection'
import {IS_TESTFLIGHT} from 'lib/app-info' import {IS_TESTFLIGHT} from 'lib/app-info'
import {useSession} from '../../state/session' import {useSession} from '../../state/session'
import {LogEvents} from './events' import {LogEvents} from './events'
import {Gate} from './gates' 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} export type {LogEvents}
const statsigOptions = { const statsigOptions = {
@ -97,6 +106,8 @@ function toStatsigUser(did: string | undefined) {
userID, userID,
platform: Platform.OS, platform: Platform.OS,
custom: { custom: {
refSrc,
refUrl,
// Need to specify here too for gating. // Need to specify here too for gating.
platform: Platform.OS, platform: Platform.OS,
}, },