@nexly/web 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/session.d.ts CHANGED
@@ -4,6 +4,10 @@
4
4
  export declare function getVisitorId(): string;
5
5
  /**
6
6
  * Session ID with 30-minute inactivity timeout.
7
+ *
8
+ * Stored in `localStorage` (not `sessionStorage`) so the same session is shared
9
+ * across tabs and survives tab/window close. The 30-minute inactivity window is
10
+ * enforced via `SESSION_TS_KEY`, matching Plausible's visit definition.
7
11
  */
8
12
  export declare function getSessionId(): string;
9
13
  //# sourceMappingURL=session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAoBA;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAUrC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAkBrC"}
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAoBA;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAUrC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAkBrC"}
package/dist/session.js CHANGED
@@ -30,12 +30,16 @@ export function getVisitorId() {
30
30
  }
31
31
  /**
32
32
  * Session ID with 30-minute inactivity timeout.
33
+ *
34
+ * Stored in `localStorage` (not `sessionStorage`) so the same session is shared
35
+ * across tabs and survives tab/window close. The 30-minute inactivity window is
36
+ * enforced via `SESSION_TS_KEY`, matching Plausible's visit definition.
33
37
  */
34
38
  export function getSessionId() {
35
- if (typeof sessionStorage === 'undefined') {
39
+ if (typeof localStorage === 'undefined') {
36
40
  return generateId();
37
41
  }
38
- const existing = sessionStorage.getItem(SESSION_KEY);
42
+ const existing = localStorage.getItem(SESSION_KEY);
39
43
  const tsRaw = localStorage.getItem(SESSION_TS_KEY);
40
44
  const lastTs = tsRaw ? Number(tsRaw) : 0;
41
45
  const now = nowMs();
@@ -44,7 +48,7 @@ export function getSessionId() {
44
48
  return existing;
45
49
  }
46
50
  const id = generateId();
47
- sessionStorage.setItem(SESSION_KEY, id);
51
+ localStorage.setItem(SESSION_KEY, id);
48
52
  localStorage.setItem(SESSION_TS_KEY, String(now));
49
53
  return id;
50
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexly/web",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Nexly browser ingest SDK: sendBeacon transport, DOM metadata, engagement listeners on top of @nexly/core",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -38,7 +38,7 @@
38
38
  "node": ">=20"
39
39
  },
40
40
  "dependencies": {
41
- "@nexly/core": "0.15.0"
41
+ "@nexly/core": "0.15.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "typescript": "~6.0.2"