Skip to content

Commit 521cf4b

Browse files
committed
feat: adopt v2 flag values in browser and framework SDKs
1 parent 2448fca commit 521cf4b

51 files changed

Lines changed: 2999 additions & 8614 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
"@reflag/browser-sdk": major
3+
"@reflag/react-sdk": major
4+
"@reflag/vue-sdk": major
5+
---
6+
7+
Adopt protocol-v2 evaluated flags and direct JSON values across Browser, React and Vue.
8+
9+
Bare singular reads return Boolean with an implicit false default. Positional JSON defaults infer widened direct-value types without generated declarations, enforce top-level categories, preserve accepted falsy values, and return independent copies. Null explicitly accepts arbitrary JSON; nested schema validation remains the application's responsibility.
10+
11+
Browser `getFlag()` and `getFlags()` register root checks immediately with genuine selected-key/source/snapshot identity. Delivery stays buffered and identity-aware rate-limited. Diagnostic access and bootstrap serialization do not register checks; defaults, mismatches, overrides and static fallback values do not invent selections. V2 cache/override storage is isolated from v1, and complete evaluated snapshots are validated before acceptance. This requires compatible `/flags/evaluated` and canonical-check ingestion on the server.
12+
13+
React `useFlag()` returns a direct value without suspending. Use the separate `useFlagSuspense()` hook to wait for initialization; missing flags then use the default. Vue `useFlag()` returns a ref to the direct value. Loading, application usage tracking and feedback remain separate hooks/composables. The existing opt-in Suspense controls remain specific to `useOptInFlags`.
14+
15+
Upgrade bootstrap producers/consumers together: only protocol-v2 envelopes from Node SDK v2 are supported; legacy bootstrap wrappers and the Browser `bootstrappedFlags` option are rejected. Move wrapper `.track()`/`.requestFeedback()` calls to ordinary client/framework methods. Undefined clears a value override; null is a JSON override.
16+
17+
Opt-in metadata arrives with ordinary v2 evaluated responses. Bootstrapped clients fetch missing metadata on demand from the same v2 endpoint without replacing server-derived values. Mutations confirm versioned evaluation and membership in one refresh. The unchanged OpenFeature Browser provider and React Native wrapper remain pinned to published v1 SDK dependencies. CLI direct-value generation remains a separate migration.

‎packages/browser-sdk/README.md‎

Lines changed: 91 additions & 525 deletions
Large diffs are not rendered by default.

‎packages/browser-sdk/example/typescript/app.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ReflagClient, RawFlags } from "../../src";
1+
import { ReflagClient } from "../../src";
22

33
const urlParams = new URLSearchParams(window?.location?.search);
44
const publishableKey = urlParams.get("publishableKey");
@@ -34,8 +34,8 @@ reflag.initialize().then(() => {
3434
if (loadingElem) loadingElem.style.display = "none";
3535
});
3636

37-
reflag.on("flagsUpdated", (flags: RawFlags) => {
38-
const { isEnabled } = flags[flagKey];
37+
reflag.on("flagsUpdated", () => {
38+
const isEnabled = reflag.getFlag(flagKey);
3939

4040
const startHuddleElem = document.getElementById("start-huddle");
4141
if (isEnabled) {

‎packages/browser-sdk/package.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@reflag/browser-sdk",
3-
"version": "1.7.0",
3+
"version": "2.0.0-next.0",
44
"license": "MIT",
55
"repository": {
66
"type": "git",
@@ -26,7 +26,8 @@
2626
"scripts": {
2727
"dev": "vite",
2828
"build": "tsc --project tsconfig.native.json && tsc --project tsconfig.build.json && vite build",
29-
"test": "vitest run",
29+
"test": "yarn test:types && vitest run",
30+
"test:types": "tsc --project tsconfig.type-tests.json",
3031
"test:watch": "vitest",
3132
"test:e2e": "yarn build && playwright test",
3233
"test:ci": "yarn test --reporter=default --reporter=junit --outputFile=junit.xml && yarn test:e2e",

‎packages/browser-sdk/src/bulkQueue.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ export type BulkEvent =
3232
}
3333
| {
3434
type: "feature-flag-event";
35-
action: "check-is-enabled" | "check-config";
35+
action: "check";
3636
key: string;
37-
targetingVersion?: number;
38-
evalResult?: boolean | { key: string; payload: any };
37+
sourceVersionId?: string;
38+
flagStateVersion?: number;
39+
evalResult?: string;
40+
evalErrors?: import("./flag/flags").EvaluationError[];
3941
evalContext?: Record<string, any>;
4042
evalRuleResults?: boolean[];
4143
evalMissingFields?: string[];

0 commit comments

Comments
 (0)