Enable gating and experimentation on native, send init event (#3149)

* Add the mobile fork

* Add init event
This commit is contained in:
dan 2024-03-08 04:33:42 +00:00 committed by GitHub
parent 31826633cb
commit dd86d0964d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 74 additions and 6 deletions

View file

@ -1,5 +1,9 @@
import React from 'react'
import {StatsigProvider, useGate as useStatsigGate} from 'statsig-react'
import {
Statsig,
StatsigProvider,
useGate as useStatsigGate,
} from 'statsig-react'
import {useSession} from '../../state/session'
import {sha256} from 'js-sha256'
@ -13,6 +17,14 @@ const statsigOptions = {
initTimeoutMs: 1,
}
export function logEvent(
eventName: string,
value?: string | number | null,
metadata?: Record<string, string> | null,
) {
Statsig.logEvent(eventName, value, metadata)
}
export function useGate(gateName: string) {
const {isLoading, value} = useStatsigGate(gateName)
if (isLoading) {