parent
48bd98f9ef
commit
71c427cea8
|
@ -15,8 +15,21 @@ import {useSession} from '../../state/session'
|
||||||
import {LogEvents} from './events'
|
import {LogEvents} from './events'
|
||||||
import {Gate} from './gates'
|
import {Gate} from './gates'
|
||||||
|
|
||||||
let refSrc: string
|
type StatsigUser = {
|
||||||
let refUrl: string
|
userID: string | undefined
|
||||||
|
// TODO: Remove when enough users have custom.platform:
|
||||||
|
platform: 'ios' | 'android' | 'web'
|
||||||
|
custom: {
|
||||||
|
// This is the place where we can add our own stuff.
|
||||||
|
// Fields here have to be non-optional to be visible in the UI.
|
||||||
|
platform: 'ios' | 'android' | 'web'
|
||||||
|
refSrc: string
|
||||||
|
refUrl: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let refSrc = ''
|
||||||
|
let refUrl = ''
|
||||||
if (isWeb && typeof window !== 'undefined') {
|
if (isWeb && typeof window !== 'undefined') {
|
||||||
const params = new URLSearchParams(window.location.search)
|
const params = new URLSearchParams(window.location.search)
|
||||||
refSrc = params.get('ref_src') ?? ''
|
refSrc = params.get('ref_src') ?? ''
|
||||||
|
@ -97,19 +110,18 @@ export function useGate(gateName: Gate): boolean {
|
||||||
return initialValue
|
return initialValue
|
||||||
}
|
}
|
||||||
|
|
||||||
function toStatsigUser(did: string | undefined) {
|
function toStatsigUser(did: string | undefined): StatsigUser {
|
||||||
let userID: string | undefined
|
let userID: string | undefined
|
||||||
if (did) {
|
if (did) {
|
||||||
userID = sha256(did)
|
userID = sha256(did)
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
userID,
|
userID,
|
||||||
platform: Platform.OS,
|
platform: Platform.OS as 'ios' | 'android' | 'web',
|
||||||
custom: {
|
custom: {
|
||||||
refSrc,
|
refSrc,
|
||||||
refUrl,
|
refUrl,
|
||||||
// Need to specify here too for gating.
|
platform: Platform.OS as 'ios' | 'android' | 'web',
|
||||||
platform: Platform.OS,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue