Skip to content

Commit e86f36b

Browse files
committed
Allow events to be tracked on the onSessionUpdate callback (close #1213)
* Allow events to be tracked on the onSessionUpdate callback (close #1213) * Increased the bundlemon browser-tracker-core size at a reasonable value * Add onSessionUpdate integration test #1214
1 parent 01f89a0 commit e86f36b

File tree

12 files changed

+347
-163
lines changed

12 files changed

+347
-163
lines changed

.bundlemonrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
{
2424
"path": "./libraries/browser-tracker-core/dist/index.module.js",
25-
"maxSize": "25kb",
25+
"maxSize": "26kb",
2626
"maxPercentIncrease": 10
2727
},
2828
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@snowplow/browser-tracker-core",
5+
"comment": "Allow events to be tracked on the onSessionUpdate callback",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@snowplow/browser-tracker-core"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@snowplow/javascript-tracker",
5+
"comment": "Added onSessionUpdate callback integration test",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@snowplow/javascript-tracker"
10+
}

common/config/rush/pnpm-lock.yaml

Lines changed: 20 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/config/rush/repo-state.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// DO NOT MODIFY THIS FILE MANUALLY BUT DO COMMIT IT. It is generated and used by Rush.
22
{
3-
"pnpmShrinkwrapHash": "1a9deb48a8d2843fb67d9c93ff618d8373ca31c8",
3+
"pnpmShrinkwrapHash": "b3670fdd35939880fb5506b045e5826aeab84996",
44
"preferredVersionsHash": "bf21a9e8fbc5a3846fb05b4fa0859e0917b2202f"
55
}

libraries/browser-tracker-core/src/tracker/id_cookie.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,7 @@ export function initializeDomainUserId(idCookie: ParsedIdCookie, configAnonymous
171171
}
172172

173173
type NewSessionOptions = {
174-
memorizedVisitCount?: number;
175-
onSessionUpdateCallback?: (sessionState: ClientSession) => void;
176-
configStateStorageStrategy: string;
177-
configAnonymousTracking: boolean;
174+
memorizedVisitCount: number;
178175
};
179176

180177
/**
@@ -189,11 +186,11 @@ type NewSessionOptions = {
189186
* @param options.onSessionUpdateCallback Session callback triggered on every session update
190187
* @returns New session ID
191188
*/
192-
export function startNewIdCookieSession(idCookie: ParsedIdCookie, options: NewSessionOptions) {
193-
const { memorizedVisitCount, configStateStorageStrategy, configAnonymousTracking, onSessionUpdateCallback } = {
194-
memorizedVisitCount: 1,
195-
...options,
196-
};
189+
export function startNewIdCookieSession(
190+
idCookie: ParsedIdCookie,
191+
options: NewSessionOptions = { memorizedVisitCount: 1 }
192+
) {
193+
const { memorizedVisitCount } = options;
197194

198195
// If cookies are enabled, base visit count and session ID on the cookies
199196
if (cookiesEnabledInIdCookie(idCookie)) {
@@ -216,10 +213,6 @@ export function startNewIdCookieSession(idCookie: ParsedIdCookie, options: NewSe
216213
idCookie[firstEventIdIndex] = '';
217214
idCookie[firstEventTsInMsIndex] = undefined;
218215

219-
if (onSessionUpdateCallback) {
220-
onSessionUpdateCallback(clientSessionFromIdCookie(idCookie, configStateStorageStrategy, configAnonymousTracking));
221-
}
222-
223216
return sessionId;
224217
}
225218

0 commit comments

Comments
 (0)