Disable analytics, GrowthBook, and telemetry egress
This commit is contained in:
@@ -21,7 +21,6 @@ import {
|
||||
getUserForGrowthBook,
|
||||
} from '../../utils/user.js'
|
||||
import {
|
||||
is1PEventLoggingEnabled,
|
||||
logGrowthBookExperimentTo1P,
|
||||
} from './firstPartyEventLogger.js'
|
||||
|
||||
@@ -219,6 +218,19 @@ function getConfigOverrides(): Record<string, unknown> | undefined {
|
||||
}
|
||||
}
|
||||
|
||||
function getCachedGrowthBookFeature<T>(feature: string): T | undefined {
|
||||
if (remoteEvalFeatureValues.has(feature)) {
|
||||
return remoteEvalFeatureValues.get(feature) as T
|
||||
}
|
||||
|
||||
try {
|
||||
const cached = getGlobalConfig().cachedGrowthBookFeatures?.[feature]
|
||||
return cached !== undefined ? (cached as T) : undefined
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enumerate all known GrowthBook features and their current resolved values
|
||||
* (not including overrides). In-memory payload first, disk cache fallback —
|
||||
@@ -420,8 +432,9 @@ function syncRemoteEvalToDisk(): void {
|
||||
* Check if GrowthBook operations should be enabled
|
||||
*/
|
||||
function isGrowthBookEnabled(): boolean {
|
||||
// GrowthBook depends on 1P event logging.
|
||||
return is1PEventLoggingEnabled()
|
||||
// Network-backed GrowthBook egress is disabled in this build. Callers still
|
||||
// read local cache and explicit overrides through the helpers below.
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -682,6 +695,11 @@ async function getFeatureValueInternal<T>(
|
||||
return configOverrides[feature] as T
|
||||
}
|
||||
|
||||
const cached = getCachedGrowthBookFeature<T>(feature)
|
||||
if (cached !== undefined) {
|
||||
return cached
|
||||
}
|
||||
|
||||
if (!isGrowthBookEnabled()) {
|
||||
return defaultValue
|
||||
}
|
||||
@@ -745,6 +763,11 @@ export function getFeatureValue_CACHED_MAY_BE_STALE<T>(
|
||||
return configOverrides[feature] as T
|
||||
}
|
||||
|
||||
const cached = getCachedGrowthBookFeature<T>(feature)
|
||||
if (cached !== undefined) {
|
||||
return cached
|
||||
}
|
||||
|
||||
if (!isGrowthBookEnabled()) {
|
||||
return defaultValue
|
||||
}
|
||||
@@ -814,6 +837,16 @@ export function checkStatsigFeatureGate_CACHED_MAY_BE_STALE(
|
||||
return Boolean(configOverrides[gate])
|
||||
}
|
||||
|
||||
const cached = getCachedGrowthBookFeature<boolean>(gate)
|
||||
if (cached !== undefined) {
|
||||
return Boolean(cached)
|
||||
}
|
||||
|
||||
const statsigCached = getGlobalConfig().cachedStatsigGates?.[gate]
|
||||
if (statsigCached !== undefined) {
|
||||
return Boolean(statsigCached)
|
||||
}
|
||||
|
||||
if (!isGrowthBookEnabled()) {
|
||||
return false
|
||||
}
|
||||
@@ -861,6 +894,16 @@ export async function checkSecurityRestrictionGate(
|
||||
return Boolean(configOverrides[gate])
|
||||
}
|
||||
|
||||
const cached = getCachedGrowthBookFeature<boolean>(gate)
|
||||
if (cached !== undefined) {
|
||||
return Boolean(cached)
|
||||
}
|
||||
|
||||
const statsigCached = getGlobalConfig().cachedStatsigGates?.[gate]
|
||||
if (statsigCached !== undefined) {
|
||||
return Boolean(statsigCached)
|
||||
}
|
||||
|
||||
if (!isGrowthBookEnabled()) {
|
||||
return false
|
||||
}
|
||||
@@ -871,19 +914,6 @@ export async function checkSecurityRestrictionGate(
|
||||
await reinitializingPromise
|
||||
}
|
||||
|
||||
// Check Statsig cache first - it may have correct value from previous logged-in session
|
||||
const config = getGlobalConfig()
|
||||
const statsigCached = config.cachedStatsigGates?.[gate]
|
||||
if (statsigCached !== undefined) {
|
||||
return Boolean(statsigCached)
|
||||
}
|
||||
|
||||
// Then check GrowthBook cache
|
||||
const gbCached = config.cachedGrowthBookFeatures?.[gate]
|
||||
if (gbCached !== undefined) {
|
||||
return Boolean(gbCached)
|
||||
}
|
||||
|
||||
// No cache - return false (don't block on init for uncached gates)
|
||||
return false
|
||||
}
|
||||
@@ -914,13 +944,23 @@ export async function checkGate_CACHED_OR_BLOCKING(
|
||||
return Boolean(configOverrides[gate])
|
||||
}
|
||||
|
||||
const cached = getCachedGrowthBookFeature<boolean>(gate)
|
||||
if (cached !== undefined) {
|
||||
return Boolean(cached)
|
||||
}
|
||||
|
||||
const statsigCached = getGlobalConfig().cachedStatsigGates?.[gate]
|
||||
if (statsigCached !== undefined) {
|
||||
return Boolean(statsigCached)
|
||||
}
|
||||
|
||||
if (!isGrowthBookEnabled()) {
|
||||
return false
|
||||
}
|
||||
|
||||
// Fast path: disk cache already says true — trust it
|
||||
const cached = getGlobalConfig().cachedGrowthBookFeatures?.[gate]
|
||||
if (cached === true) {
|
||||
const diskCached = getGlobalConfig().cachedGrowthBookFeatures?.[gate]
|
||||
if (diskCached === true) {
|
||||
// Log experiment exposure if data is available, otherwise defer
|
||||
if (experimentDataByFeature.has(gate)) {
|
||||
logExposureForFeature(gate)
|
||||
|
||||
Reference in New Issue
Block a user