Skip to content

Commit 0910310

Browse files
authored
fix: track control impressions on targeted pages (#181)
1 parent ecebe6e commit 0910310

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/experiment-tag/src/experiment.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ export class DefaultWebExperimentClient implements WebExperimentClient {
358358
const isControlOrOffPayload =
359359
!variant.payload || (payloadIsArray && variant.payload.length === 0);
360360
if (shouldTrackExposure && isControlOrOffPayload) {
361-
this.exposureWithDedupe(key, variant);
361+
if (this.isActionActiveOnPage(key, undefined)) {
362+
this.exposureWithDedupe(key, variant);
363+
}
362364
// revert all applied mutations and injections
363365
this.revertVariants({ flagKeys: [key] });
364366
continue;

packages/experiment-tag/test/experiment.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ describe('initializeExperiment', () => {
189189
JSON.stringify([
190190
createRedirectFlag('test', 'control', 'http://test.com/2'),
191191
]),
192-
JSON.stringify({}),
192+
JSON.stringify(DEFAULT_PAGE_OBJECTS),
193193
).start();
194194
expect(mockGlobal.location.replace).toBeCalledTimes(0);
195195
expect(mockExposure).toHaveBeenCalledWith('test');

0 commit comments

Comments
 (0)