WS-3156: Fix resolve experiment activation beacon trigger - #14333
Open
alex-magana wants to merge 5 commits into
Open
WS-3156: Fix resolve experiment activation beacon trigger#14333alex-magana wants to merge 5 commits into
alex-magana wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR moves Optimizely experiment “activation” tracking from a per-page React effect to the global Optimizely DECISION notification listener, aiming to ensure the activation beacon is fired at the correct time and only once per decision.
Changes:
- Removed ArticlePage-specific activation tracking logic for the Search OJ experiment (no longer sending activation beacons from
ArticlePage.tsx). - Added a global activation-context bridge so the Optimizely DECISION listener (outside React) can access ATI/tracking fields when sending a beacon.
- Updated the Optimizely decision store to return whether a decision is new, enabling one-time activation beacon dispatch.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/app/pages/ArticlePage/ArticlePage.tsx | Removes Search OJ activation beacon dispatch from the page-level effect. |
| src/app/lib/optimizelyDecisionStore.ts | Makes notifyDecision return a boolean to indicate first-time activation. |
| src/app/lib/activationContext/index.ts | Introduces a singleton activation context used by the Optimizely listener. |
| src/app/legacy/containers/PageHandlers/withOptimizelyProvider/index.tsx | Sends a Piano/ATI activation beacon from the Optimizely DECISION listener, gated by new-decision detection. |
| src/app/contexts/EventTrackingContext/index.tsx | Populates the activation context from ATI tracking props for use by the listener. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+15
to
+29
| const NO_ACTIVATION_CONTEXT: ActivationContext = { trackingIsEnabled: false }; | ||
|
|
||
| let activationContext: ActivationContext = NO_ACTIVATION_CONTEXT; | ||
|
|
||
| // Bridges the current page's ATI/tracking context (React state) into the | ||
| // Optimizely DECISION notification listener, which runs outside the React tree. | ||
| export const setActivationContext = (context: ActivationContext) => { | ||
| activationContext = context; | ||
| }; | ||
|
|
||
| export const getActivationContext = (): ActivationContext => activationContext; | ||
|
|
||
| export const resetActivationContext = () => { | ||
| activationContext = NO_ACTIVATION_CONTEXT; | ||
| }; |
Comment on lines
124
to
+156
| @@ -139,6 +142,18 @@ export const EventTrackingContextProvider = ({ | |||
| trackingProps.statsDestination, | |||
| ].every(Boolean); | |||
|
|
|||
| setActivationContext({ | |||
| trackingIsEnabled: Boolean(hasRequiredProps), | |||
| pageIdentifier: trackingProps?.pageIdentifier, | |||
| producerId: trackingProps?.producerId, | |||
| platform: trackingProps?.platform, | |||
| statsDestination: trackingProps?.statsDestination, | |||
| campaignID: trackingProps?.campaignID, | |||
| producerName: trackingProps?.producerName, | |||
| isSignedIn: trackingProps?.isSignedIn, | |||
| hashedId: trackingProps?.hashedId, | |||
| }); | |||
|
|
|||
Comment on lines
160
to
+169
| if (decisionKey && variationKey && variationKey !== 'off') { | ||
| const isNewDecision = notifyDecision(decisionKey); | ||
|
|
||
| if (impressionDispatched) { | ||
| if (isNewDecision) { | ||
| dispatchExperimentActivationBeaconToPiano({ | ||
| decisionKey, | ||
| variationKey, | ||
| }); | ||
| } |
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:
Summary
A very high-level summary of easily-reproducible changes that can be understood by non-devs, and why these changes where made.
Code changes
Testing
Useful Links