[Statsig] Fix exposure logging for reduced onboarding (#4131)
* Add dangerouslyDisableExposureLogging option * Rename onboarding gate to v2 * Disable exposure logging for onboarding in PostFeed queryzio/stable
parent
516eb69637
commit
4fa92d7a49
|
@ -4,7 +4,7 @@ export type Gate =
|
||||||
| 'disable_min_shell_on_foregrounding_v3'
|
| 'disable_min_shell_on_foregrounding_v3'
|
||||||
| 'disable_poll_on_discover_v2'
|
| 'disable_poll_on_discover_v2'
|
||||||
| 'dms'
|
| 'dms'
|
||||||
| 'reduced_onboarding_and_home_algo'
|
| 'reduced_onboarding_and_home_algo_v2'
|
||||||
| 'request_notifications_permission_after_onboarding'
|
| 'request_notifications_permission_after_onboarding'
|
||||||
| 'show_follow_back_label_v2'
|
| 'show_follow_back_label_v2'
|
||||||
| 'start_session_with_following_v2'
|
| 'start_session_with_following_v2'
|
||||||
|
|
|
@ -108,20 +108,29 @@ export function logEvent<E extends keyof LogEvents>(
|
||||||
// Our own cache ensures consistent evaluation within a single session.
|
// Our own cache ensures consistent evaluation within a single session.
|
||||||
const GateCache = React.createContext<Map<string, boolean> | null>(null)
|
const GateCache = React.createContext<Map<string, boolean> | null>(null)
|
||||||
|
|
||||||
export function useGate(): (gateName: Gate) => boolean {
|
type GateOptions = {
|
||||||
|
dangerouslyDisableExposureLogging?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useGate(): (gateName: Gate, options?: GateOptions) => boolean {
|
||||||
const cache = React.useContext(GateCache)
|
const cache = React.useContext(GateCache)
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
throw Error('useGate() cannot be called outside StatsigProvider.')
|
throw Error('useGate() cannot be called outside StatsigProvider.')
|
||||||
}
|
}
|
||||||
const gate = React.useCallback(
|
const gate = React.useCallback(
|
||||||
(gateName: Gate): boolean => {
|
(gateName: Gate, options: GateOptions = {}): boolean => {
|
||||||
const cachedValue = cache.get(gateName)
|
const cachedValue = cache.get(gateName)
|
||||||
if (cachedValue !== undefined) {
|
if (cachedValue !== undefined) {
|
||||||
return cachedValue
|
return cachedValue
|
||||||
}
|
}
|
||||||
const value = Statsig.initializeCalled()
|
let value = false
|
||||||
? Statsig.checkGate(gateName)
|
if (Statsig.initializeCalled()) {
|
||||||
: false
|
if (options.dangerouslyDisableExposureLogging) {
|
||||||
|
value = Statsig.checkGateWithExposureLoggingDisabled(gateName)
|
||||||
|
} else {
|
||||||
|
value = Statsig.checkGate(gateName)
|
||||||
|
}
|
||||||
|
}
|
||||||
cache.set(gateName, value)
|
cache.set(gateName, value)
|
||||||
return value
|
return value
|
||||||
},
|
},
|
||||||
|
|
|
@ -83,7 +83,7 @@ export function StepFinished() {
|
||||||
* selected in onboarding and therefore we don't need to run this
|
* selected in onboarding and therefore we don't need to run this
|
||||||
* code (which would overwrite the other feeds already set).
|
* code (which would overwrite the other feeds already set).
|
||||||
*/
|
*/
|
||||||
if (!gate('reduced_onboarding_and_home_algo')) {
|
if (!gate('reduced_onboarding_and_home_algo_v2')) {
|
||||||
const otherFeeds = selectedFeeds.length
|
const otherFeeds = selectedFeeds.length
|
||||||
? selectedFeeds.map(f => ({
|
? selectedFeeds.map(f => ({
|
||||||
type: 'feed',
|
type: 'feed',
|
||||||
|
@ -120,7 +120,7 @@ export function StepFinished() {
|
||||||
})(),
|
})(),
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
if (!gate('reduced_onboarding_and_home_algo')) return
|
if (!gate('reduced_onboarding_and_home_algo_v2')) return
|
||||||
|
|
||||||
const {imageUri, imageMime} = profileStepResults
|
const {imageUri, imageMime} = profileStepResults
|
||||||
if (imageUri && imageMime) {
|
if (imageUri && imageMime) {
|
||||||
|
|
|
@ -134,7 +134,7 @@ export function StepInterests() {
|
||||||
}, [track])
|
}, [track])
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!gate('reduced_onboarding_and_home_algo')) {
|
if (!gate('reduced_onboarding_and_home_algo_v2')) {
|
||||||
requestNotificationsPermission('StartOnboarding')
|
requestNotificationsPermission('StartOnboarding')
|
||||||
}
|
}
|
||||||
}, [gate, requestNotificationsPermission])
|
}, [gate, requestNotificationsPermission])
|
||||||
|
|
|
@ -94,7 +94,7 @@ export function StepProfile() {
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
// We have an experiment running for redueced onboarding, where this screen shows up as the first in onboarding.
|
// We have an experiment running for redueced onboarding, where this screen shows up as the first in onboarding.
|
||||||
// We only want to request permissions when that gate is actually active to prevent pollution
|
// We only want to request permissions when that gate is actually active to prevent pollution
|
||||||
if (gate('reduced_onboarding_and_home_algo')) {
|
if (gate('reduced_onboarding_and_home_algo_v2')) {
|
||||||
requestNotificationsPermission('StartOnboarding')
|
requestNotificationsPermission('StartOnboarding')
|
||||||
}
|
}
|
||||||
}, [gate, requestNotificationsPermission])
|
}, [gate, requestNotificationsPermission])
|
||||||
|
|
|
@ -24,7 +24,7 @@ import {Portal} from '#/components/Portal'
|
||||||
export function Onboarding() {
|
export function Onboarding() {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const gate = useGate()
|
const gate = useGate()
|
||||||
const isReducedOnboardingEnabled = gate('reduced_onboarding_and_home_algo')
|
const isReducedOnboardingEnabled = gate('reduced_onboarding_and_home_algo_v2')
|
||||||
const [state, dispatch] = React.useReducer(
|
const [state, dispatch] = React.useReducer(
|
||||||
isReducedOnboardingEnabled ? reducerReduced : reducer,
|
isReducedOnboardingEnabled ? reducerReduced : reducer,
|
||||||
isReducedOnboardingEnabled ? {...initialStateReduced} : {...initialState},
|
isReducedOnboardingEnabled ? {...initialStateReduced} : {...initialState},
|
||||||
|
|
|
@ -152,7 +152,13 @@ export function usePostFeedQuery(
|
||||||
feedTuners,
|
feedTuners,
|
||||||
userInterests, // Not in the query key because they don't change.
|
userInterests, // Not in the query key because they don't change.
|
||||||
getAgent,
|
getAgent,
|
||||||
useBaseFollowingFeed: gate('reduced_onboarding_and_home_algo'),
|
useBaseFollowingFeed: gate(
|
||||||
|
'reduced_onboarding_and_home_algo_v2',
|
||||||
|
{
|
||||||
|
// If you're not already in this experiment, we don't want to expose you to it now.
|
||||||
|
dangerouslyDisableExposureLogging: true,
|
||||||
|
},
|
||||||
|
),
|
||||||
}),
|
}),
|
||||||
cursor: undefined,
|
cursor: undefined,
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ export function TestCtrls() {
|
||||||
testID="e2eStartOnboarding"
|
testID="e2eStartOnboarding"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
// TODO remove when experiment is over
|
// TODO remove when experiment is over
|
||||||
setGate('reduced_onboarding_and_home_algo', true)
|
setGate('reduced_onboarding_and_home_algo_v2', true)
|
||||||
onboardingDispatch({type: 'start'})
|
onboardingDispatch({type: 'start'})
|
||||||
}}
|
}}
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
|
@ -123,7 +123,7 @@ export function TestCtrls() {
|
||||||
testID="e2eStartLongboarding"
|
testID="e2eStartLongboarding"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
// TODO remove when experiment is over
|
// TODO remove when experiment is over
|
||||||
setGate('reduced_onboarding_and_home_algo', false)
|
setGate('reduced_onboarding_and_home_algo_v2', false)
|
||||||
onboardingDispatch({type: 'start'})
|
onboardingDispatch({type: 'start'})
|
||||||
}}
|
}}
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
|
|
Loading…
Reference in New Issue