@walkeros/web-source-session 4.1.0-next-1778668930820 → 4.1.0
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/CHANGELOG.md +435 -0
- package/README.md +30 -196
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +2 -2
- package/package.json +6 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
# @walkeros/web-source-session
|
|
2
|
+
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fd6076e: Walker commands `destination`, `hook`, and `on` now take a single
|
|
8
|
+
Init object: `elb('walker destination', { code, config })`,
|
|
9
|
+
`elb('walker hook', { name, fn })`, `elb('walker on', { type, rules })`. The
|
|
10
|
+
previous positional forms and the `{ push }` shorthand are removed; the
|
|
11
|
+
`options` argument is gone from `collector.command`, `addDestination`, and
|
|
12
|
+
`commonHandleCommand`.
|
|
13
|
+
- Updated dependencies [e155ff8]
|
|
14
|
+
- Updated dependencies [e800974]
|
|
15
|
+
- Updated dependencies [e155ff8]
|
|
16
|
+
- Updated dependencies [1a8f2d7]
|
|
17
|
+
- Updated dependencies [1a8f2d7]
|
|
18
|
+
- Updated dependencies [b276173]
|
|
19
|
+
- Updated dependencies [dd9f5ad]
|
|
20
|
+
- Updated dependencies [c60ef35]
|
|
21
|
+
- Updated dependencies [adeebea]
|
|
22
|
+
- Updated dependencies [13aaeaa]
|
|
23
|
+
- Updated dependencies [e800974]
|
|
24
|
+
- Updated dependencies [adeebea]
|
|
25
|
+
- Updated dependencies [e800974]
|
|
26
|
+
- Updated dependencies [e800974]
|
|
27
|
+
- Updated dependencies [058f7ed]
|
|
28
|
+
- Updated dependencies [28a8ac2]
|
|
29
|
+
- Updated dependencies [fd6076e]
|
|
30
|
+
- @walkeros/core@4.1.0
|
|
31
|
+
- @walkeros/web-core@4.1.0
|
|
32
|
+
|
|
33
|
+
## 4.0.2
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [a6a0ea7]
|
|
38
|
+
- @walkeros/core@4.0.2
|
|
39
|
+
- @walkeros/web-core@4.0.2
|
|
40
|
+
|
|
41
|
+
## 4.0.1
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [381dfe7]
|
|
46
|
+
- Updated dependencies [1524275]
|
|
47
|
+
- Updated dependencies [03d7055]
|
|
48
|
+
- @walkeros/core@4.0.1
|
|
49
|
+
- @walkeros/web-core@4.0.1
|
|
50
|
+
|
|
51
|
+
## 4.0.0
|
|
52
|
+
|
|
53
|
+
### Major Changes
|
|
54
|
+
|
|
55
|
+
- 93ea9c4: Event model v4: breaking changes to the `Event`, `Source`, and
|
|
56
|
+
`Entity` shapes.
|
|
57
|
+
- `event.id` is now a W3C span_id (16 lowercase hex chars), generated by the
|
|
58
|
+
collector. Reference: W3C Trace Context (W3C Recommendation, January 2020).
|
|
59
|
+
- `event.version`, `event.group`, `event.count` are removed.
|
|
60
|
+
- `source.type` is now the source kind (e.g. `browser`, `gtag`, `mcp`, `cli`).
|
|
61
|
+
New `source.platform` holds the runtime (`web` | `server` | `app` | ...).
|
|
62
|
+
- `source.id` and `source.previous_id` are removed.
|
|
63
|
+
- Browser source now sets `source.url` and `source.referrer`.
|
|
64
|
+
- MCP source sets `source.tool` per emission. CLI source sets
|
|
65
|
+
`source.command`.
|
|
66
|
+
- `Entity.nested` and `Entity.context` are now optional. Root `event.nested`
|
|
67
|
+
and `event.context` remain required.
|
|
68
|
+
- Each source self-registers via TypeScript module augmentation of `SourceMap`
|
|
69
|
+
in `@walkeros/core`.
|
|
70
|
+
- App-side coordination (`/workspaces/developer/app`) is a follow-up plan, not
|
|
71
|
+
part of this release. Telemetry from v4 CLI/MCP will not validate against
|
|
72
|
+
the existing app schema until that follow-up ships.
|
|
73
|
+
- `Mapping.Rule.skip` is renamed to `Mapping.Rule.silent`. Customer flow.json
|
|
74
|
+
configs using `skip: true` in mapping rules must rename to `silent: true`.
|
|
75
|
+
Hard cut: no legacy alias, the field is gone.
|
|
76
|
+
|
|
77
|
+
- 1ef33d9: **BREAKING:** Unified callback signatures across mapping and on.\*
|
|
78
|
+
subscriptions.
|
|
79
|
+
|
|
80
|
+
Every callback in walkerOS now reads `(data, context) => result`. Sources,
|
|
81
|
+
transformers, destinations, and stores already conformed; mapping and on.\*
|
|
82
|
+
join the family in v4.1.
|
|
83
|
+
|
|
84
|
+
### Mapping callbacks
|
|
85
|
+
|
|
86
|
+
`fn`, `condition`, and `validate` now share a single shape:
|
|
87
|
+
|
|
88
|
+
`(value, context: Mapping.Context) => result`
|
|
89
|
+
|
|
90
|
+
`Mapping.Options` is removed. Replaced by `Mapping.Context`:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
interface Context {
|
|
94
|
+
event: WalkerOS.DeepPartialEvent;
|
|
95
|
+
mapping: Value | Rule;
|
|
96
|
+
collector: Collector.Instance; // required
|
|
97
|
+
logger: Logger.Instance; // required
|
|
98
|
+
consent?: WalkerOS.Consent; // resolved consent
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Rule-level `condition` is now `(event, context) => boolean`.
|
|
103
|
+
`Mapping.Options.props` is removed (no production callers).
|
|
104
|
+
|
|
105
|
+
#### Mapping upgrade
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
// before
|
|
109
|
+
const fn: Mapping.Fn = (value, mapping, options) => /* … */;
|
|
110
|
+
const cond: Mapping.Condition = (value, mapping, collector) => /* … */;
|
|
111
|
+
const val: Mapping.Validate = (value) => /* … */;
|
|
112
|
+
|
|
113
|
+
// after
|
|
114
|
+
const fn: Mapping.Fn = (value, context) => /* … */;
|
|
115
|
+
const cond: Mapping.Condition = (value, context) => /* … */;
|
|
116
|
+
const val: Mapping.Validate = (value, context) => /* … */;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
In `$code:` strings (flow.json):
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
// before
|
|
123
|
+
"fn": "$code:(value, mapping, options) => …"
|
|
124
|
+
"condition": "$code:(value, mapping, collector) => …"
|
|
125
|
+
|
|
126
|
+
// after
|
|
127
|
+
"fn": "$code:(value, context) => …"
|
|
128
|
+
"condition": "$code:(value, context) => …"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
`context.mapping` replaces the second positional arg; `context.collector`,
|
|
132
|
+
`context.logger`, and `context.consent` are all available.
|
|
133
|
+
|
|
134
|
+
One-arg callbacks like `(value) => value.toUpperCase()` continue to work
|
|
135
|
+
unchanged.
|
|
136
|
+
|
|
137
|
+
### On.\* subscription callbacks
|
|
138
|
+
|
|
139
|
+
`walker.on('consent', …)`, `walker.on('ready', …)`, etc. now receive
|
|
140
|
+
`(data, context: On.Context) => void | Promise<void>`. The legacy `Context`
|
|
141
|
+
interface, `*Config` aliases, and `Options` discriminated union are removed.
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
interface Context {
|
|
145
|
+
collector: Collector.Instance; // required
|
|
146
|
+
logger: Logger.Instance; // required
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
type Fn<TData = unknown> = (
|
|
150
|
+
data: TData,
|
|
151
|
+
context: Context,
|
|
152
|
+
) => void | Promise<void>;
|
|
153
|
+
|
|
154
|
+
type ConsentFn = Fn<WalkerOS.Consent>;
|
|
155
|
+
type SessionFn = Fn<Collector.SessionData | undefined>;
|
|
156
|
+
type UserFn = Fn<WalkerOS.User>;
|
|
157
|
+
type ReadyFn = Fn<void>;
|
|
158
|
+
type RunFn = Fn<void>;
|
|
159
|
+
type GenericFn = Fn<unknown>;
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The new `On.Subscription` alias is the registerable union for
|
|
163
|
+
`walker.on(action, X)`.
|
|
164
|
+
|
|
165
|
+
#### On.\* upgrade
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
// before
|
|
169
|
+
walker.on('consent', { marketing: (collector, consent) => /* … */ });
|
|
170
|
+
walker.on('ready', (collector) => /* … */);
|
|
171
|
+
walker.on('session', (collector, session) => /* … */);
|
|
172
|
+
|
|
173
|
+
// after
|
|
174
|
+
walker.on('consent', { marketing: (consent, ctx) => /* … */ });
|
|
175
|
+
walker.on('ready', (_, ctx) => /* … */);
|
|
176
|
+
walker.on('session', (session, ctx) => /* … */);
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
`ctx.collector` replaces the positional first arg; `ctx.logger` is also
|
|
180
|
+
available.
|
|
181
|
+
|
|
182
|
+
### Why both at once
|
|
183
|
+
|
|
184
|
+
Both refactors follow the same `(data, context)` pattern. Shipping them in one
|
|
185
|
+
release means consumers do one search-and-replace pass instead of two, and the
|
|
186
|
+
codebase reaches full callback-signature consistency in v4.1.
|
|
187
|
+
|
|
188
|
+
### Patch Changes
|
|
189
|
+
|
|
190
|
+
- Updated dependencies [93ea9c4]
|
|
191
|
+
- Updated dependencies [465775c]
|
|
192
|
+
- Updated dependencies [942a7fe]
|
|
193
|
+
- Updated dependencies [cfc7469]
|
|
194
|
+
- Updated dependencies [8e06b1f]
|
|
195
|
+
- Updated dependencies [3d50dd6]
|
|
196
|
+
- Updated dependencies [1ef33d9]
|
|
197
|
+
- @walkeros/core@4.0.0
|
|
198
|
+
- @walkeros/web-core@4.0.0
|
|
199
|
+
|
|
200
|
+
## 3.4.2
|
|
201
|
+
|
|
202
|
+
### Patch Changes
|
|
203
|
+
|
|
204
|
+
- @walkeros/core@3.4.2
|
|
205
|
+
- @walkeros/web-core@3.4.2
|
|
206
|
+
|
|
207
|
+
## 3.4.1
|
|
208
|
+
|
|
209
|
+
### Patch Changes
|
|
210
|
+
|
|
211
|
+
- Updated dependencies [12adf24]
|
|
212
|
+
- Updated dependencies [75aa26b]
|
|
213
|
+
- Updated dependencies [caea905]
|
|
214
|
+
- @walkeros/core@3.4.1
|
|
215
|
+
- @walkeros/web-core@3.4.1
|
|
216
|
+
|
|
217
|
+
## 3.4.0
|
|
218
|
+
|
|
219
|
+
### Minor Changes
|
|
220
|
+
|
|
221
|
+
- 724f97e: Migrate every step example in every walkerOS package to the
|
|
222
|
+
standardized `[callable, ...args][]` shape introduced in `@walkeros/core`.
|
|
223
|
+
Every step example's `out` is now an array of effect tuples whose first
|
|
224
|
+
element is the callable's public SDK name (`'gtag'`, `'analytics.track'`,
|
|
225
|
+
`'fbq'`, `'dataLayer.push'`, `'sendServer'`, `'fetch'`, `'trackClient.track'`,
|
|
226
|
+
`'amplitude.track'`, `'fs.writeFile'`, `'producer.send'`, `'client.xadd'`,
|
|
227
|
+
`'client.send'`, `'dataset.table.insert'`, etc.). Source examples use `'elb'`
|
|
228
|
+
as the callable; transformer examples use the reserved `'return'` keyword;
|
|
229
|
+
store examples use store-operation callables (`'get'`, `'set'`). Tests capture
|
|
230
|
+
real calls on each component's spy and assert against `example.out` directly —
|
|
231
|
+
the hardcoded `PACKAGE_CALLS` registry in the app is no longer consulted
|
|
232
|
+
(emptied; plan #3 removes it structurally).
|
|
233
|
+
|
|
234
|
+
### Patch Changes
|
|
235
|
+
|
|
236
|
+
- Updated dependencies [74940cc]
|
|
237
|
+
- Updated dependencies [525f5d9]
|
|
238
|
+
- @walkeros/core@3.4.0
|
|
239
|
+
- @walkeros/web-core@3.4.0
|
|
240
|
+
|
|
241
|
+
## 3.3.1
|
|
242
|
+
|
|
243
|
+
### Patch Changes
|
|
244
|
+
|
|
245
|
+
- @walkeros/core@3.3.1
|
|
246
|
+
- @walkeros/web-core@3.3.1
|
|
247
|
+
|
|
248
|
+
## 3.3.0
|
|
249
|
+
|
|
250
|
+
### Patch Changes
|
|
251
|
+
|
|
252
|
+
- 08c365a: Expand `getMarketingParameters` to recognise 25+ ad platform click
|
|
253
|
+
IDs (Pinterest, Reddit, Quora, Yandex, Outbrain, Taboola, Mailchimp, Klaviyo,
|
|
254
|
+
HubSpot, Adobe, Impact, CJ, Branch, plus Google's `wbraid`/`gbraid`). Add a
|
|
255
|
+
new `platform` field that resolves the click ID to a canonical platform
|
|
256
|
+
identifier (e.g. `gclid` → `google`, `fbclid` → `meta`). Multi-click-ID URLs
|
|
257
|
+
are resolved deterministically via a priority order.
|
|
258
|
+
|
|
259
|
+
Custom click-ID registries can be passed as the third argument to
|
|
260
|
+
`getMarketingParameters`, or via the new `clickIds` field in the session
|
|
261
|
+
source settings — so flow.json users can extend or override defaults without
|
|
262
|
+
touching code.
|
|
263
|
+
|
|
264
|
+
- Updated dependencies [2849acb]
|
|
265
|
+
- Updated dependencies [08c365a]
|
|
266
|
+
- Updated dependencies [08c365a]
|
|
267
|
+
- Updated dependencies [08c365a]
|
|
268
|
+
- Updated dependencies [08c365a]
|
|
269
|
+
- @walkeros/core@3.3.0
|
|
270
|
+
- @walkeros/web-core@3.3.0
|
|
271
|
+
|
|
272
|
+
## 3.2.0
|
|
273
|
+
|
|
274
|
+
### Patch Changes
|
|
275
|
+
|
|
276
|
+
- Updated dependencies [eb865e1]
|
|
277
|
+
- Updated dependencies [c0a53f9]
|
|
278
|
+
- Updated dependencies [f007c9f]
|
|
279
|
+
- Updated dependencies [bf2dc5b]
|
|
280
|
+
- Updated dependencies [da0b640]
|
|
281
|
+
- @walkeros/core@3.2.0
|
|
282
|
+
- @walkeros/web-core@3.2.0
|
|
283
|
+
|
|
284
|
+
## 3.1.1
|
|
285
|
+
|
|
286
|
+
### Patch Changes
|
|
287
|
+
|
|
288
|
+
- @walkeros/core@3.1.1
|
|
289
|
+
- @walkeros/web-core@3.1.1
|
|
290
|
+
|
|
291
|
+
## 3.1.0
|
|
292
|
+
|
|
293
|
+
### Minor Changes
|
|
294
|
+
|
|
295
|
+
- 956c337: Add createTrigger following unified Trigger.CreateFn interface. Step
|
|
296
|
+
examples updated with trigger metadata.
|
|
297
|
+
- ff58828: Add env.window and env.document to session source Env interface.
|
|
298
|
+
Session detection (window, storage, performance) now uses injected globals
|
|
299
|
+
when provided, enabling full simulation without a browser environment.
|
|
300
|
+
|
|
301
|
+
### Patch Changes
|
|
302
|
+
|
|
303
|
+
- Updated dependencies [ff58828]
|
|
304
|
+
- Updated dependencies [dfc6738]
|
|
305
|
+
- Updated dependencies [966342b]
|
|
306
|
+
- Updated dependencies [bee8ba7]
|
|
307
|
+
- Updated dependencies [966342b]
|
|
308
|
+
- Updated dependencies [df990d4]
|
|
309
|
+
- @walkeros/web-core@3.1.0
|
|
310
|
+
- @walkeros/core@3.1.0
|
|
311
|
+
|
|
312
|
+
## 3.0.2
|
|
313
|
+
|
|
314
|
+
### Patch Changes
|
|
315
|
+
|
|
316
|
+
- @walkeros/core@3.0.2
|
|
317
|
+
- @walkeros/web-core@3.0.2
|
|
318
|
+
|
|
319
|
+
## 3.0.1
|
|
320
|
+
|
|
321
|
+
### Patch Changes
|
|
322
|
+
|
|
323
|
+
- @walkeros/core@3.0.1
|
|
324
|
+
- @walkeros/web-core@3.0.1
|
|
325
|
+
|
|
326
|
+
## 3.0.0
|
|
327
|
+
|
|
328
|
+
### Patch Changes
|
|
329
|
+
|
|
330
|
+
- 499e27a: Add sideEffects declarations to all packages for bundler tree-shaking
|
|
331
|
+
support.
|
|
332
|
+
- Updated dependencies [2b259b6]
|
|
333
|
+
- Updated dependencies [2614014]
|
|
334
|
+
- Updated dependencies [6ae0ee3]
|
|
335
|
+
- Updated dependencies [37299a9]
|
|
336
|
+
- Updated dependencies [499e27a]
|
|
337
|
+
- Updated dependencies [0e5eede]
|
|
338
|
+
- Updated dependencies [d11f574]
|
|
339
|
+
- Updated dependencies [d11f574]
|
|
340
|
+
- Updated dependencies [1fe337a]
|
|
341
|
+
- Updated dependencies [5cb84c1]
|
|
342
|
+
- Updated dependencies [23f218a]
|
|
343
|
+
- Updated dependencies [499e27a]
|
|
344
|
+
- Updated dependencies [c83d909]
|
|
345
|
+
- Updated dependencies [b6c8fa8]
|
|
346
|
+
- @walkeros/core@3.0.0
|
|
347
|
+
- @walkeros/web-core@3.0.0
|
|
348
|
+
|
|
349
|
+
## 2.1.1
|
|
350
|
+
|
|
351
|
+
### Patch Changes
|
|
352
|
+
|
|
353
|
+
- Updated dependencies [fab477d]
|
|
354
|
+
- @walkeros/core@2.1.1
|
|
355
|
+
- @walkeros/web-core@2.1.1
|
|
356
|
+
|
|
357
|
+
## 2.1.0
|
|
358
|
+
|
|
359
|
+
### Minor Changes
|
|
360
|
+
|
|
361
|
+
- 97df0b2: Step examples: upgrade all packages to blueprint pattern with inline
|
|
362
|
+
mapping, no intermediate variables, no `all` export
|
|
363
|
+
|
|
364
|
+
### Patch Changes
|
|
365
|
+
|
|
366
|
+
- 60f0a1c: Add setup functions and renderer metadata for source simulation
|
|
367
|
+
- Updated dependencies [7fc4cee]
|
|
368
|
+
- Updated dependencies [7fc4cee]
|
|
369
|
+
- Updated dependencies [cb2da05]
|
|
370
|
+
- Updated dependencies [2bbe8c8]
|
|
371
|
+
- Updated dependencies [3eb6416]
|
|
372
|
+
- Updated dependencies [02a7958]
|
|
373
|
+
- Updated dependencies [97df0b2]
|
|
374
|
+
- Updated dependencies [97df0b2]
|
|
375
|
+
- Updated dependencies [026c412]
|
|
376
|
+
- Updated dependencies [7d38d9d]
|
|
377
|
+
- @walkeros/core@2.1.0
|
|
378
|
+
- @walkeros/web-core@2.1.0
|
|
379
|
+
|
|
380
|
+
## 2.0.1
|
|
381
|
+
|
|
382
|
+
## 1.1.4
|
|
383
|
+
|
|
384
|
+
### Patch Changes
|
|
385
|
+
|
|
386
|
+
- Updated dependencies [7b2d750]
|
|
387
|
+
- @walkeros/core@1.4.0
|
|
388
|
+
- @walkeros/web-core@2.0.0
|
|
389
|
+
|
|
390
|
+
## 1.1.3
|
|
391
|
+
|
|
392
|
+
### Patch Changes
|
|
393
|
+
|
|
394
|
+
- Updated dependencies [a4cc1ea]
|
|
395
|
+
- @walkeros/core@1.3.0
|
|
396
|
+
- @walkeros/web-core@1.0.5
|
|
397
|
+
|
|
398
|
+
## 1.1.2
|
|
399
|
+
|
|
400
|
+
### Patch Changes
|
|
401
|
+
|
|
402
|
+
- Updated dependencies [7ad6cfb]
|
|
403
|
+
- @walkeros/core@1.2.2
|
|
404
|
+
- @walkeros/web-core@1.0.4
|
|
405
|
+
|
|
406
|
+
## 1.1.1
|
|
407
|
+
|
|
408
|
+
### Patch Changes
|
|
409
|
+
|
|
410
|
+
- Updated dependencies [6256c12]
|
|
411
|
+
- @walkeros/core@1.2.1
|
|
412
|
+
- @walkeros/web-core@1.0.3
|
|
413
|
+
|
|
414
|
+
## 1.1.0
|
|
415
|
+
|
|
416
|
+
### Minor Changes
|
|
417
|
+
|
|
418
|
+
- a38d791: Session detection extracted to standalone sourceSession
|
|
419
|
+
- New `sourceSession` for composable session management
|
|
420
|
+
- Browser source no longer includes session by default
|
|
421
|
+
- To restore previous behavior, add sourceSession alongside browser source:
|
|
422
|
+
|
|
423
|
+
```typescript
|
|
424
|
+
sources: {
|
|
425
|
+
browser: sourceBrowser,
|
|
426
|
+
session: { code: sourceSession, config: { storage: true } }
|
|
427
|
+
}
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### Patch Changes
|
|
431
|
+
|
|
432
|
+
- Updated dependencies [f39d9fb]
|
|
433
|
+
- Updated dependencies [888bbdf]
|
|
434
|
+
- @walkeros/core@1.2.0
|
|
435
|
+
- @walkeros/web-core@1.0.2
|
package/README.md
CHANGED
|
@@ -1,41 +1,17 @@
|
|
|
1
|
+
<p align="left">
|
|
2
|
+
<a href="https://www.walkeros.io">
|
|
3
|
+
<img alt="walkerOS" title="walkerOS" src="https://www.walkeros.io/img/walkerOS_logo.svg" width="256px"/>
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
1
7
|
# @walkeros/web-source-session
|
|
2
8
|
|
|
3
|
-
Standalone session detection and management
|
|
9
|
+
Standalone session detection and management that can be composed with any
|
|
10
|
+
walkerOS source.
|
|
4
11
|
|
|
12
|
+
[Documentation](https://www.walkeros.io/docs/sources/web/session) •
|
|
13
|
+
[NPM Package](https://www.npmjs.com/package/@walkeros/web-source-session) •
|
|
5
14
|
[Source Code](https://github.com/elbwalker/walkerOS/tree/main/packages/web/sources/session)
|
|
6
|
-
| [NPM](https://www.npmjs.com/package/@walkeros/web-source-session) |
|
|
7
|
-
[Documentation](https://www.walkeros.io/docs/sources/web/session)
|
|
8
|
-
|
|
9
|
-
## Quick Start
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { startFlow } from '@walkeros/collector';
|
|
13
|
-
import { sourceBrowser } from '@walkeros/web-source-browser';
|
|
14
|
-
import { sourceSession } from '@walkeros/web-source-session';
|
|
15
|
-
|
|
16
|
-
const { collector, elb } = await startFlow({
|
|
17
|
-
sources: {
|
|
18
|
-
browser: sourceBrowser,
|
|
19
|
-
session: {
|
|
20
|
-
code: sourceSession,
|
|
21
|
-
config: {
|
|
22
|
-
settings: {
|
|
23
|
-
storage: true, // Enable persistent session storage
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Features
|
|
32
|
-
|
|
33
|
-
- **Session detection**: Automatic detection of new sessions based on
|
|
34
|
-
navigation, referrer, and marketing parameters
|
|
35
|
-
- **Device tracking**: Persistent device ID across sessions (with consent)
|
|
36
|
-
- **Consent-aware**: Switches between window-only and storage-based sessions
|
|
37
|
-
based on user consent
|
|
38
|
-
- **Composable**: Works alongside any source (browser, dataLayer, custom)
|
|
39
15
|
|
|
40
16
|
## Installation
|
|
41
17
|
|
|
@@ -43,176 +19,34 @@ const { collector, elb } = await startFlow({
|
|
|
43
19
|
npm install @walkeros/web-source-session
|
|
44
20
|
```
|
|
45
21
|
|
|
46
|
-
##
|
|
47
|
-
|
|
48
|
-
The session source was extracted from the browser source to enable:
|
|
49
|
-
|
|
50
|
-
1. **Composability**: Use session detection with any source, not just browser
|
|
51
|
-
2. **Single responsibility**: Browser source focuses on DOM events, session
|
|
52
|
-
source on identity
|
|
53
|
-
3. **Flexibility**: Configure session independently from event capture
|
|
54
|
-
4. **Server-side ready**: Session logic can work with server sources too
|
|
55
|
-
|
|
56
|
-
## Configuration Reference
|
|
57
|
-
|
|
58
|
-
| Name | Type | Description | Default |
|
|
59
|
-
| ---------------- | -------------------------- | ------------------------------------------------ | ---------------- |
|
|
60
|
-
| `storage` | `boolean` | Enable persistent storage for session/device IDs | `false` |
|
|
61
|
-
| `consent` | `string \| string[]` | Consent key(s) required to enable storage mode | - |
|
|
62
|
-
| `length` | `number` | Session timeout in minutes | `30` |
|
|
63
|
-
| `pulse` | `boolean` | Keep session alive on each event | `false` |
|
|
64
|
-
| `sessionKey` | `string` | Storage key for session ID | `'elbSessionId'` |
|
|
65
|
-
| `sessionStorage` | `'local' \| 'session'` | Storage type for session | `'local'` |
|
|
66
|
-
| `deviceKey` | `string` | Storage key for device ID | `'elbDeviceId'` |
|
|
67
|
-
| `deviceStorage` | `'local' \| 'session'` | Storage type for device | `'local'` |
|
|
68
|
-
| `cb` | `SessionCallback \| false` | Custom callback or disable default | - |
|
|
69
|
-
|
|
70
|
-
## Examples
|
|
71
|
-
|
|
72
|
-
### Basic (Window-only)
|
|
73
|
-
|
|
74
|
-
No persistent storage, session detected per page load:
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
const { elb } = await startFlow({
|
|
78
|
-
sources: {
|
|
79
|
-
browser: sourceBrowser,
|
|
80
|
-
session: sourceSession, // Defaults to window-only mode
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### With Persistent Storage
|
|
86
|
-
|
|
87
|
-
Store session and device IDs in localStorage:
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
const { elb } = await startFlow({
|
|
91
|
-
sources: {
|
|
92
|
-
browser: sourceBrowser,
|
|
93
|
-
session: {
|
|
94
|
-
code: sourceSession,
|
|
95
|
-
config: {
|
|
96
|
-
settings: {
|
|
97
|
-
storage: true,
|
|
98
|
-
length: 30, // 30-minute session timeout
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Consent-Aware
|
|
107
|
-
|
|
108
|
-
Switch to storage mode only when user grants consent:
|
|
109
|
-
|
|
110
|
-
```typescript
|
|
111
|
-
const { elb } = await startFlow({
|
|
112
|
-
sources: {
|
|
113
|
-
browser: sourceBrowser,
|
|
114
|
-
session: {
|
|
115
|
-
code: sourceSession,
|
|
116
|
-
config: {
|
|
117
|
-
settings: {
|
|
118
|
-
consent: 'analytics', // Wait for analytics consent
|
|
119
|
-
storage: true,
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// Later, when user grants consent:
|
|
127
|
-
elb('walker consent', { analytics: true });
|
|
128
|
-
// Session source automatically switches to storage mode
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Session Start Event
|
|
132
|
-
|
|
133
|
-
When a new session is detected, the source pushes a `session start` event:
|
|
22
|
+
## Quick start
|
|
134
23
|
|
|
135
|
-
```
|
|
24
|
+
```json
|
|
136
25
|
{
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
26
|
+
"version": 4,
|
|
27
|
+
"flows": {
|
|
28
|
+
"default": {
|
|
29
|
+
"config": { "platform": "web" },
|
|
30
|
+
"sources": {
|
|
31
|
+
"session": { "package": "@walkeros/web-source-session", "config": {} }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
144
34
|
}
|
|
145
35
|
}
|
|
146
36
|
```
|
|
147
37
|
|
|
148
|
-
|
|
149
|
-
canonical `platform` field on the session data (e.g. `google`, `meta`). Extend
|
|
150
|
-
or override the built-in registry via `settings.clickIds` — entries with a
|
|
151
|
-
`param` matching a default override the platform name in place, new params
|
|
152
|
-
append to the priority list.
|
|
153
|
-
|
|
154
|
-
## Migration from Browser Source
|
|
155
|
-
|
|
156
|
-
If you were using the browser source with session enabled:
|
|
157
|
-
|
|
158
|
-
```typescript
|
|
159
|
-
// Before (browser source with built-in session)
|
|
160
|
-
const { elb } = await startFlow({
|
|
161
|
-
sources: {
|
|
162
|
-
browser: {
|
|
163
|
-
code: sourceBrowser,
|
|
164
|
-
config: { settings: { session: true } },
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// After (separate session source)
|
|
170
|
-
const { elb } = await startFlow({
|
|
171
|
-
sources: {
|
|
172
|
-
browser: sourceBrowser,
|
|
173
|
-
session: {
|
|
174
|
-
code: sourceSession,
|
|
175
|
-
config: { settings: { storage: true } },
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
});
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
## Exported Functions
|
|
182
|
-
|
|
183
|
-
The session source exports session functions for direct usage:
|
|
184
|
-
|
|
185
|
-
```typescript
|
|
186
|
-
import {
|
|
187
|
-
// Session functions
|
|
188
|
-
sessionStart,
|
|
189
|
-
sessionWindow,
|
|
190
|
-
sessionStorage,
|
|
191
|
-
} from '@walkeros/web-source-session';
|
|
192
|
-
|
|
193
|
-
// Use sessionStart directly (advanced usage)
|
|
194
|
-
const session = sessionStart({
|
|
195
|
-
storage: true,
|
|
196
|
-
collector: collectorInstance,
|
|
197
|
-
});
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
Storage utilities are available from `@walkeros/web-core`:
|
|
38
|
+
## Documentation
|
|
201
39
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
storageWrite('key', 'value', 30); // 30-minute expiration
|
|
206
|
-
const value = storageRead('key');
|
|
207
|
-
storageDelete('key');
|
|
208
|
-
```
|
|
40
|
+
Full configuration, mapping, and examples live in the docs:
|
|
41
|
+
**https://www.walkeros.io/docs/sources/web/session**
|
|
209
42
|
|
|
210
|
-
##
|
|
43
|
+
## Contribute
|
|
211
44
|
|
|
212
|
-
|
|
45
|
+
Feel free to contribute by submitting an
|
|
46
|
+
[issue](https://github.com/elbwalker/walkerOS/issues), starting a
|
|
47
|
+
[discussion](https://github.com/elbwalker/walkerOS/discussions), or getting in
|
|
48
|
+
[contact](https://calendly.com/elb-alexander/30min).
|
|
213
49
|
|
|
214
|
-
##
|
|
50
|
+
## License
|
|
215
51
|
|
|
216
|
-
|
|
217
|
-
- [DataLayer Source](/docs/sources/web/dataLayer) - GTM/GA4 integration
|
|
218
|
-
- [Session Documentation](https://www.walkeros.io/docs/sources/web/session)
|
|
52
|
+
MIT
|