@hanzo/event 0.3.41 → 0.3.43
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/core.d.ts +8 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/events.d.ts +1 -1
- package/dist/index.cjs +133 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +130 -6
- package/dist/index.mjs.map +1 -1
- package/dist/link.d.ts +28 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/react.cjs +129 -5
- package/dist/react.cjs.map +1 -1
- package/dist/react.mjs +129 -5
- package/dist/react.mjs.map +1 -1
- package/dist/scrub.d.ts +5 -0
- package/dist/scrub.d.ts.map +1 -1
- package/dist/storage.d.ts +6 -0
- package/dist/storage.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/anon.d.ts +3 -0
- package/src/anon.js +19 -1
- package/src/core.test.ts +19 -0
- package/src/core.ts +52 -7
- package/src/events.ts +1 -1
- package/src/index.ts +2 -0
- package/src/link.test.ts +222 -0
- package/src/link.ts +103 -0
- package/src/scrub.test.ts +34 -1
- package/src/scrub.ts +20 -0
- package/src/storage.ts +14 -1
package/src/storage.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// the one value the OTHER two distributions must agree with, so its chain lives in
|
|
7
7
|
// ./anon.js and this file only calls it. Everything else here stays origin-local.
|
|
8
8
|
|
|
9
|
-
import { hzAnonId } from './anon.js'
|
|
9
|
+
import { hzAnonAdopt, hzAnonId } from './anon.js'
|
|
10
10
|
import type { Attribution, Cohort } from './types'
|
|
11
11
|
import { uuidv7 } from './uid'
|
|
12
12
|
|
|
@@ -75,6 +75,19 @@ export function sessionId(now = Date.now()): string | undefined {
|
|
|
75
75
|
return state.id
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/** Make `id` the current session, as if it had begun now. The session a link
|
|
79
|
+
* carries is the one the visitor is already in, so the journey stays one session
|
|
80
|
+
* across the hop instead of splitting at the host boundary. */
|
|
81
|
+
export function adoptSession(id: string, now = Date.now()): void {
|
|
82
|
+
const s = ls()
|
|
83
|
+
if (s) s.setItem(KEY.session, JSON.stringify({ id, last: now }))
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Make `id` the browser's anonymous id, replacing the one it held. */
|
|
87
|
+
export function adoptAnonId(id: string): void {
|
|
88
|
+
hzAnonAdopt(id)
|
|
89
|
+
}
|
|
90
|
+
|
|
78
91
|
/** Read the persisted first-touch attribution. */
|
|
79
92
|
export function getFirstTouch(): Attribution | undefined {
|
|
80
93
|
const s = ls()
|