feat(web): upgrade feature-flag-client to SSE streaming + getValue()

This commit is contained in:
saravanakumardb1 2026-03-21 17:40:43 -07:00
parent 8c90d863a8
commit 09310b7eb8

View File

@ -14,7 +14,12 @@ const client = createFeatureFlagClient({
baseUrl: `${getBaseUrl()}/api`,
productId: PRODUCT_ID,
platform: 'web',
useStreaming: true,
pollIntervalMs: 5 * 60 * 1000,
getAccessToken: () =>
typeof window !== 'undefined'
? localStorage.getItem('access_token')
: null,
});
/**
@ -35,6 +40,14 @@ export function getAllFlags(): Readonly<Record<string, boolean>> {
return client.getAllFlags();
}
/** Get a multi-variate flag value. Returns defaultValue if not found. */
export function getFeatureValue<T = boolean | string | number | Record<string, unknown>>(
key: string,
defaultValue: T,
): T {
return client.getValue(key, defaultValue);
}
/** Stop polling and reset state. Useful for tests. */
export function resetFeatureFlags(): void {
client.stop();