Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
React config reads can misreport telemetry, and cached overrides can trigger unnecessary bootstrap rerenders.
2 open findings
What changed in this PR
Adds per-flag value-change events to the browser SDK and uses them to reduce unnecessary React updates.
Changes:
- Publish initial and changed flag values while preserving raw-data events.
- Subscribe React consumers by flag key and use current check metadata.
- Add documentation, runtime/type coverage, and release notes.
| File | Description |
|---|---|
| packages/vue-sdk/README.md | Document per-flag subscriptions. |
| packages/react-sdk/tsconfig.type-tests.json | Include new event type tests. |
| packages/react-sdk/test/flag-updated.test.tsx | Cover subscriptions, rendering, and telemetry. |
| packages/react-sdk/test/flag-updated-types.tsx | Validate event types. |
| packages/react-sdk/src/index.tsx | Add key-specific subscriptions and current telemetry reads. |
| packages/react-sdk/README.md | Explain event behavior. |
| packages/browser-sdk/test/flagUpdated.test.ts | Cover initialization, changes, and reentrant delivery. |
| packages/browser-sdk/src/index.ts | Export the event type. |
| packages/browser-sdk/src/hooksManager.ts | Register the new event. |
| packages/browser-sdk/src/flag/flagValueChanged.ts | Compare effective flag values. |
| packages/browser-sdk/src/flag/flags.ts | Publish and queue per-flag events. |
| packages/browser-sdk/src/client.ts | Forward events to client listeners. |
| packages/browser-sdk/README.md | Document value and raw-data subscriptions. |
| .changeset/quiet-flag-value-updates.md | Record browser and React minor releases. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if ( | ||
| current.client !== client || | ||
| current.key !== key || | ||
| current.flag !== flag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Add a per-flag value-change event and use it to avoid unnecessary React rerenders and check telemetry during metadata-only flag refreshes.
flagUpdatedwith{ key, flag }. Publish each initial flag duringinitialize(). Bootstrapped flags are published after applying cached overrides, without fetching or duplicate notifications. Subsequent events fire only when the effective enabled value (including local overrides), config key/payload, or flag presence changes.flagis undefined on removal.flagsUpdatedand its deprecated alias for raw-data and metadata subscribers. Lead the browser, React, and Vue event docs withflagUpdated, and retainflagsUpdatedfor metadata-only refreshes (identical raw results are still skipped).useFlag(key)subscribe only to changes for its own key. Keep config references stable and use current evaluation metadata when emitting check telemetry.getFlags()for initial state; no additional public getter API.Review feedback fixes
flagUpdatedbatches until the current batch finishes for all listeners. Cover override changes, multi-flag batches, bootstrap publication, and recovery from throwing listeners.Unrelated fixes are split into #771 (Management SDK README) and #772 (context update types).
Validation
test/sse.test.ts.git diff --checkpassed.Local testing limitation
The local installation uses Vitest 3.2.6, which has known constructor-mock incompatibilities in the existing SSE tests (seven failures). That file was excluded from the local browser test run; no SSE source/tests or repository test configuration were changed.