Skip to content

WS-3156: Fix resolve experiment activation beacon trigger - #14333

Open
alex-magana wants to merge 5 commits into
latestfrom
FIX-resolve-experiment-activation-beacon-trigger
Open

WS-3156: Fix resolve experiment activation beacon trigger#14333
alex-magana wants to merge 5 commits into
latestfrom
FIX-resolve-experiment-activation-beacon-trigger

Conversation

@alex-magana

Copy link
Copy Markdown
Contributor

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

  • List key code changes that have been made.

Testing

  1. List the steps required to test this PR.

Useful Links

Copilot AI lite review requested due to automatic review settings August 20, 2026 12:03
@alex-magana alex-magana changed the title Fix resolve experiment activation beacon trigger WS-3156: Fix resolve experiment activation beacon trigger Aug 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants