Skip to content

Commit

Permalink
non-storage session
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkirtzel committed Jul 18, 2024
1 parent a2a0ad7 commit e3dd086
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 10 additions & 1 deletion packages/destinations/web/etag/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('Destination etag', () => {
expect(requestedUrl(mockSend, 1)).toContain('sid=1875854770'); // hash of 's3ss10n1ds3ss10n1d'
});

test('session start', () => {
test('session status', () => {
push(event, destination.config.custom, {
session: { isNew: true, isStart: true, count: 1 },
});
Expand All @@ -150,6 +150,15 @@ describe('Destination etag', () => {
expect(requestedUrl(mockSend, 1)).not.toContain('_ss=1');
expect(requestedUrl(mockSend, 1)).not.toContain('_nsi=1');
expect(requestedUrl(mockSend, 1)).not.toContain('_fv=1');

destination.config.custom!.sentSession = false;
push(event, destination.config.custom, {
session: { storage: false, isStart: true },
});
expect(requestedUrl(mockSend, 2)).toContain('_ss=1');
expect(requestedUrl(mockSend, 2)).toContain('_nsi=1');
expect(requestedUrl(mockSend, 2)).toContain('_fv=1');
expect(requestedUrl(mockSend, 2)).toContain('sct=1');
});

test('session engaged', () => {
Expand Down
8 changes: 3 additions & 5 deletions packages/destinations/web/etag/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,17 @@ function getSessionParams(
}

// Session status

// @TODO session.storage
if (!custom.sentSession && session) {
const { isStart, isNew, count } = session;
const { isStart, isNew, count, storage } = session;

if (isNew) {
if (isNew || !storage) {
params._nsi = 1; // new to site
params._fv = 1; // first visit
}

if (isStart) params._ss = 1; // session start

if (count) params.sct = count; // session count
params.sct = count || 1; // session count
}

custom.sentSession = true;
Expand Down

0 comments on commit e3dd086

Please sign in to comment.