WS-2284 - Fix lost view events in Optimizely#13858
Merged
louisearchibald merged 43 commits intolatestfrom Apr 21, 2026
Merged
Conversation
pvaliani
reviewed
Mar 31, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses lost Optimizely page-view events by ensuring tracking in OptimizelyPageMetrics only renders after the user is confirmed to be bucketed into a relevant experiment, including handling late experiment assignment via an Optimizely decision notification listener.
Changes:
- Adds
@optimizely/optimizely-sdkto access Optimizely enums for notification types. - Adds an initial
decideAll-based membership check before rendering tracking components. - Attaches and cleans up a decision notification listener to detect post-load bucketing into relevant experiments.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/app/components/OptimizelyPageMetrics/index.tsx |
Adds initial bucketing check and a decision notification listener to gate tracking rendering until experiment membership is confirmed. |
package.json |
Adds a direct dependency on @optimizely/optimizely-sdk for notification enums. |
yarn.lock |
Updates lockfile to reflect the added Optimizely SDK dependency/version resolution. |
andrewscfc
reviewed
Apr 8, 2026
…fix-lost-view-events-in-optimizely-alt
…//github.com/bbc/simorgh into WS-2284-fix-lost-view-events-in-optimizely-alt
…fix-lost-view-events-in-optimizely-alt
…//github.com/bbc/simorgh into WS-2284-fix-lost-view-events-in-optimizely-alt
…fix-lost-view-events-in-optimizely-alt
…//github.com/bbc/simorgh into WS-2284-fix-lost-view-events-in-optimizely-alt
This reverts commit fe65d79.
…timizely-alt [copilot] refactor OptimizelyPageMetrics notification listener to use…
HarveyPeachey
previously approved these changes
Apr 21, 2026
pvaliani
approved these changes
Apr 21, 2026
ACtually just noticed something with the bundle size
HarveyPeachey
approved these changes
Apr 21, 2026
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.
Resolves JIRA: WS-2284
Summary
Attempts to solve a known bug with page-views firing incorrectly before experiments activate.
Code changes
useSyncExternalStoreso React components will re-render when new flags are activated.useActivatedExperimentshook.Setinstances when updating snapshots so React reliably detects state changes.resetDecisionStoreto clear state and reset snapshots.DECISIONnotification listener to react to experiment activations.notifyDecision(flagKey)to record activated experiments and notify subscribers.Testing