Skip to content

Commit f285b5d

Browse files
committed
fix: dont cache web exposures
1 parent cc5016f commit f285b5d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

packages/experiment-browser/src/integration/manager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ export class SessionDedupeCache {
114114
}
115115

116116
shouldTrack(exposure: Exposure): boolean {
117+
// Always track web impressions.
118+
if (exposure.metadata['deliveryMethod'] === 'web') {
119+
return true;
120+
}
117121
this.loadCache();
118122
const value = this.inMemoryCache[exposure.flag_key];
119123
let shouldTrack = false;

packages/experiment-browser/test/integration/manager.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,21 @@ describe('SessionDedupeCache', () => {
246246
expect(storedCache).toEqual(expected);
247247
expect(cache['inMemoryCache']).toEqual(expected);
248248
});
249+
test('should track with web delivery method exposure, always true', () => {
250+
const instanceName = '$default_instance';
251+
const cache = new SessionDedupeCache(instanceName);
252+
const exposure = {
253+
flag_key: 'flag-key',
254+
variant: 'on',
255+
metadata: {
256+
deliveryMethod: 'web',
257+
},
258+
};
259+
expect(cache.shouldTrack(exposure)).toEqual(true);
260+
expect(safeGlobal.sessionStorage.getItem(cache['storageKey'])).toBeNull();
261+
expect(cache.shouldTrack(exposure)).toEqual(true);
262+
expect(safeGlobal.sessionStorage.getItem(cache['storageKey'])).toBeNull();
263+
});
249264
});
250265

251266
describe('PersistentTrackingQueue', () => {

0 commit comments

Comments
 (0)