Skip to content

Commit 2b08845

Browse files
authored
fix: previewVariants should fire impression events (#235)
1 parent 5459229 commit 2b08845

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/experiment-tag/src/experiment.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ export class DefaultWebExperimentClient implements WebExperimentClient {
135135
Object.keys(variants).forEach((variantKey) => {
136136
this.flagVariantMap[key][variantKey] =
137137
convertEvaluationVariantToVariant(variants[variantKey]);
138+
this.flagVariantMap[key][variantKey].metadata = {
139+
deliveryMethod: 'web',
140+
};
138141
});
139142

140143
if (metadata.evaluationMode !== 'local') {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,14 @@ describe('initializeExperiment', () => {
330330
'http://test.com/',
331331
);
332332
expect(mockExposureInternal).toHaveBeenCalledWith('test', {
333-
variant: { key: 'control', value: 'control' },
333+
variant: {
334+
key: 'control',
335+
value: 'control',
336+
metadata: {
337+
deliveryMethod: 'web',
338+
url: 'http://localhost/',
339+
},
340+
},
334341
source: 'local-evaluation',
335342
hasDefaultVariant: false,
336343
});

0 commit comments

Comments
 (0)