Skip to content

Commit 15e8ecf

Browse files
multiple consent states
1 parent 4a3482d commit 15e8ecf

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

.changeset/weak-lobsters-grab.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@elbwalker/walker.js': patch
3+
'@elbwalker/utils': patch
4+
---
5+
6+
Support multiple consent states for session detection [#497](https://github.com/elbwalker/walkerOS/issues/497)

packages/sources/walkerjs/src/__tests__/session.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ describe('Session', () => {
7979
expect(mockFn).toHaveBeenCalledTimes(2);
8080
});
8181

82+
test('different consent keys', () => {
83+
walkerjs = Walkerjs({
84+
default: true,
85+
session: { consent: ['marketing', 'analytics'], storage: true },
86+
pageview: false,
87+
});
88+
89+
expect(mockDataLayer).toHaveBeenCalledTimes(0);
90+
elb('walker consent', { marketing: false, analytics: true });
91+
92+
expect(mockDataLayer).toHaveBeenCalledTimes(1);
93+
expect(mockDataLayer).toHaveBeenCalledWith(
94+
expect.objectContaining({
95+
event: 'session start',
96+
data: expect.objectContaining({
97+
storage: true, // Prefer granted consent
98+
}),
99+
}),
100+
);
101+
});
102+
82103
test('multiple consent updates', () => {
83104
const originalLocation = window.location;
84105
Object.defineProperty(window, 'location', {

0 commit comments

Comments
 (0)