From a787b3fe8b4dd0781c656ac4a8600c4d86f70641 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 22 Jan 2026 16:33:48 -0600 Subject: [PATCH] Polyfill features cache --- src/analytics/features/index.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/analytics/features/index.ts b/src/analytics/features/index.ts index d438a2f8d7..81eb9eced0 100644 --- a/src/analytics/features/index.ts +++ b/src/analytics/features/index.ts @@ -1,3 +1,5 @@ +import {MMKV} from '@bsky.app/react-native-mmkv' +import {setPolyfills} from '@growthbook/growthbook' import {GrowthBook} from '@growthbook/growthbook-react' import {getNavigationMetadata, type Metadata} from '#/analytics/metadata' @@ -5,6 +7,20 @@ import * as env from '#/env' export {Features} from '#/analytics/features/types' +const CACHE = new MMKV({id: 'bsky_features_cache'}) + +setPolyfills({ + localStorage: { + getItem: key => { + const value = CACHE.getString(key) + return value != null ? JSON.parse(value) : null + }, + setItem: async (key, value) => { + CACHE.set(key, JSON.stringify(value)) + }, + }, +}) + /** * We vary the amount of time we wait for GrowthBook to fetch feature * gates based on the strategy specified.