@walkeros/web-source-browser 0.0.9 → 0.1.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/README.md +95 -58
- package/dist/index.browser.js +1 -1
- package/dist/index.d.mts +33 -13
- package/dist/index.d.ts +33 -13
- package/dist/index.es5.js +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/package.json +4 -4
package/README.md
CHANGED
|
@@ -6,81 +6,118 @@
|
|
|
6
6
|
|
|
7
7
|
# Browser DOM Source for walkerOS
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
attributes. It serves as the primary source for capturing user behavior, page
|
|
12
|
-
views, and element interactions directly from the DOM without requiring manual
|
|
13
|
-
event instrumentation.
|
|
9
|
+
[Source Code](https://github.com/elbwalker/walkerOS/tree/main/packages/web/sources/browser)
|
|
10
|
+
• [NPM Package](https://www.npmjs.com/package/@walkeros/web-source-browser)
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
The Browser Source is walkerOS's primary web tracking solution that you can use
|
|
13
|
+
to capture user interactions directly from the browsers DOM.
|
|
16
14
|
|
|
17
|
-
|
|
15
|
+
## What It Does
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
- **Collector**: Processes, validates, and routes events with consent awareness
|
|
22
|
-
- **Destinations**: Send processed events to analytics platforms (GA4, Meta,
|
|
23
|
-
custom APIs)
|
|
17
|
+
The Browser Source transforms your website into a comprehensive tracking
|
|
18
|
+
environment by:
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
destinations.
|
|
20
|
+
- **Data attribute reading**: Extracts custom tracking data from HTML `data-elb`
|
|
21
|
+
attributes
|
|
22
|
+
- **Session management**: Detects and handles user sessions automatically
|
|
29
23
|
|
|
30
24
|
## Installation
|
|
31
25
|
|
|
32
|
-
|
|
33
|
-
npm install @walkeros/web-source-browser
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Usage
|
|
37
|
-
|
|
38
|
-
Here's a basic example of how to use the Browser DOM source:
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
import { elb } from '@walkeros/collector';
|
|
42
|
-
import { sourceBrowser, createTagger } from '@walkeros/web-source-browser';
|
|
43
|
-
|
|
44
|
-
// Initialize the browser source
|
|
45
|
-
sourceBrowser({ elb });
|
|
26
|
+
### With npm
|
|
46
27
|
|
|
47
|
-
|
|
48
|
-
const tagger = createTagger();
|
|
49
|
-
const attrs = tagger('product').data('id', '123').action('load', 'view').get();
|
|
50
|
-
// Result: { 'data-elb': 'product', 'data-elb-product': 'id:123', 'data-elbaction': 'load:view' }
|
|
28
|
+
Install the source via npm:
|
|
51
29
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// - Click events
|
|
55
|
-
// - Form submissions
|
|
56
|
-
// - Element visibility changes
|
|
57
|
-
// - Custom data attributes
|
|
30
|
+
```bash
|
|
31
|
+
npm install @walkeros/web-source-browser
|
|
58
32
|
```
|
|
59
33
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
34
|
+
Setup in your project:
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
import { createCollector } from '@walkeros/collector';
|
|
38
|
+
import { createSource } from '@walkeros/core';
|
|
39
|
+
import { sourceBrowser } from '@walkeros/web-source-browser';
|
|
40
|
+
|
|
41
|
+
const { collector } = await createCollector({
|
|
42
|
+
sources: {
|
|
43
|
+
browser: createSource(sourceBrowser, {
|
|
44
|
+
settings: {
|
|
45
|
+
pageview: true,
|
|
46
|
+
session: true,
|
|
47
|
+
elb: 'elb', // Browser source will set window.elb automatically
|
|
48
|
+
},
|
|
49
|
+
}),
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
```
|
|
69
53
|
|
|
70
|
-
|
|
54
|
+
### With a script tag
|
|
71
55
|
|
|
72
|
-
|
|
56
|
+
Load the source via dynamic import:
|
|
73
57
|
|
|
74
58
|
```html
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
59
|
+
<script>
|
|
60
|
+
// Load the collector, core utilities, and source
|
|
61
|
+
const { createCollector } = await import(
|
|
62
|
+
'https://cdn.jsdelivr.net/npm/@walkeros/collector/dist/index.mjs'
|
|
63
|
+
);
|
|
64
|
+
const { createSource } = await import(
|
|
65
|
+
'https://cdn.jsdelivr.net/npm/@walkeros/core/dist/index.mjs'
|
|
66
|
+
);
|
|
67
|
+
const { sourceBrowser } = await import(
|
|
68
|
+
'https://cdn.jsdelivr.net/npm/@walkeros/web-source-browser/dist/index.mjs'
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const { collector, elb } = await createCollector({
|
|
72
|
+
sources: {
|
|
73
|
+
browser: createSource(sourceBrowser, {
|
|
74
|
+
settings: {
|
|
75
|
+
prefix: 'data-elb',
|
|
76
|
+
pageview: true,
|
|
77
|
+
session: true,
|
|
78
|
+
},
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
</script>
|
|
82
83
|
```
|
|
83
84
|
|
|
85
|
+
## Configuration reference
|
|
86
|
+
|
|
87
|
+
| Name | Type | Description | Required | Example |
|
|
88
|
+
| ---------- | -------------------------------- | ------------------------------------------------ | -------- | -------------------------------- |
|
|
89
|
+
| `prefix` | `string` | Prefix for data attributes used in DOM tracking | No | `'data-elb'` |
|
|
90
|
+
| `scope` | `Element \| Document` | DOM scope for event tracking (default: document) | No | `document.querySelector("#app")` |
|
|
91
|
+
| `pageview` | `boolean` | Enable automatic pageview tracking | No | `true` |
|
|
92
|
+
| `session` | `boolean` | Enable session tracking and management | No | `true` |
|
|
93
|
+
| `elb` | `string` | Custom name for the global elb function | No | `'elb'` |
|
|
94
|
+
| `name` | `string` | Custom name for the browser source instance | No | `'mySource'` |
|
|
95
|
+
| `elbLayer` | `boolean \| string \| Elb.Layer` | Enable elbLayer for async command queuing | No | `true` |
|
|
96
|
+
|
|
97
|
+
### elb
|
|
98
|
+
|
|
99
|
+
> **Two Different elb Functions**
|
|
100
|
+
>
|
|
101
|
+
> The collector provides **two different elb functions**:
|
|
102
|
+
>
|
|
103
|
+
> 1. **Collector elb** (`elb` from `createCollector`): Basic event tracking
|
|
104
|
+
> that works with all sources and destinations
|
|
105
|
+
> 2. **Browser Source elb** (`collector.sources.browser.elb` or direct from
|
|
106
|
+
> `createSource`): Enhanced function with browser-specific features
|
|
107
|
+
>
|
|
108
|
+
> **Browser Source elb adds:**
|
|
109
|
+
>
|
|
110
|
+
> - **DOM Commands**: `walker init` for asynchronous loading of DOM elements
|
|
111
|
+
> - **Flexible Arguments**: Support for multiple argument patterns
|
|
112
|
+
> - **elbLayer Integration**: Automatic processing of queued commands
|
|
113
|
+
> - **Element parameters**: Support for element parameters in DOM commands
|
|
114
|
+
>
|
|
115
|
+
> Use **separate source creation** for direct access to the enhanced elb
|
|
116
|
+
> function, or access it via `collector.sources.browser.elb` in the unified API.
|
|
117
|
+
>
|
|
118
|
+
> See [Commands](https://www.elbwalker.com/docs/sources/web/browser/commands)
|
|
119
|
+
> for full browser source API documentation.
|
|
120
|
+
|
|
84
121
|
## Contribute
|
|
85
122
|
|
|
86
123
|
Feel free to contribute by submitting an
|
package/dist/index.browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Source=(()=>{var e,t,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(s,{SourceBrowser:()=>ve,createTagger:()=>ke,default:()=>xe,getAllEvents:()=>M,getEvents:()=>T,getGlobals:()=>U,sourceBrowser:()=>Oe});var c=Object.getOwnPropertyNames,a=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.0.8",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[c(e)[0]])((t={exports:{}}).exports,t),t.exports}),l={Storage:{Local:"local",Session:"session",Cookie:"cookie"}},u={merge:!0,shallow:!0,extend:!0};function d(e,t={},n={}){n={...u,...n};const r=Object.entries(t).reduce((t,[r,o])=>{const i=e[r];return n.merge&&Array.isArray(i)&&Array.isArray(o)?t[r]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||r in e)&&(t[r]=o),t},{});return n.shallow?{...e,...r}:(Object.assign(e,r),e)}function f(e){return Array.isArray(e)}function g(e){return void 0!==e}function m(e){return e===document||e instanceof Element}function p(e){return"object"==typeof e&&null!==e&&!f(e)&&"[object Object]"===Object.prototype.toString.call(e)}function b(e){return"string"==typeof e}function h(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}var y,w,{version:v}=a();function k(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function S(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function O(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}var x=Object.getOwnPropertyNames,j=(y={"package.json"(e,t){t.exports={name:"@walkeros/collector",description:"Unified platform-agnostic collector for walkerOS",version:"0.0.8",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{"@walkeros/core":"0.0.8"},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/collector"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","collector","event processing"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},{Commands:{Action:"action",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",User:"user",Walker:"walker"},Utils:{Storage:{Cookie:"cookie",Local:"local",Session:"session"}}});function C(e,t,n,r){let o=n||[];if(n||(o=e.on[t]||[],Object.values(e.destinations).forEach(e=>{var n;const r=null==(n=e.config.on)?void 0:n[t];r&&(o=o.concat(r))})),o.length)switch(t){case j.Commands.Consent:!function(e,t,n){const r=n||e.consent;t.forEach(t=>{Object.keys(r).filter(e=>e in t).forEach(n=>{S(t[n])(e,r)})})}(e,o,r);break;case j.Commands.Ready:case j.Commands.Run:s=o,(i=e).allowed&&s.forEach(e=>{S(e)(i)});break;case j.Commands.Session:!function(e,t){e.session&&t.forEach(t=>{S(t)(e,e.session)})}(e,o)}var i,s}function E(e,t){return(e.getAttribute(t)||"").trim()}var A=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function L(e){const t=getComputedStyle(e);if("none"===t.display)return!1;if("visible"!==t.visibility)return!1;if(t.opacity&&Number(t.opacity)<.1)return!1;let n;const r=window.innerHeight,o=e.getBoundingClientRect(),i=o.height,s=o.y,c=s+i,a={x:o.x+e.offsetWidth/2,y:o.y+e.offsetHeight/2};if(i<=r){if(e.offsetWidth+o.width===0||e.offsetHeight+o.height===0)return!1;if(a.x<0)return!1;if(a.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(a.y<0)return!1;if(a.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(a.x,a.y)}else{const e=r/2;if(s<0&&c<e)return!1;if(c>r&&s>e)return!1;n=document.elementFromPoint(a.x,r/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}function $(e={}){const{cb:t,consent:n,collector:r,storage:o}=e,i=(null==r?void 0:r.push)||A;if(!n)return P((o?R:H)(e),r,t);{const r=function(e,t){let n;return(r,o)=>{if(g(n)&&n===(null==r?void 0:r.group))return;n=null==r?void 0:r.group;let i=()=>H(e);if(e.consent){(function(e,t={},n={}){const r={...t,...n},o={};let i=void 0===e;return Object.keys(r).forEach(t=>{r[t]&&(o[t]=!0,e&&e[t]&&(i=!0))}),!!i&&o})((f(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),o)&&(i=()=>R(e))}return P(i(),r,t)}}(e,t);i("walker on","consent",(f(n)?n:[n]).reduce((e,t)=>({...e,[t]:r}),{}))}}function P(e,t,n){return!1===n?e:(n||(n=I),n(e,t,I))}var I=(e,t)=>{const n=(null==t?void 0:t.push)||A,r={};return e.id&&(r.session=e.id),e.storage&&e.device&&(r.device=e.device),n("walker user",r),e.isStart&&n({event:"session start",data:e}),e};function W(e,t=l.Storage.Session){var n;function r(e){try{return JSON.parse(e||"")}catch(t){let n=1,r="";return e&&(n=0,r=e),{e:n,v:r}}}let o,i;switch(t){case l.Storage.Cookie:o=decodeURIComponent((null==(n=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:n.split("=")[1])||"");break;case l.Storage.Local:i=r(window.localStorage.getItem(e));break;case l.Storage.Session:i=r(window.sessionStorage.getItem(e))}return i&&(o=i.v,0!=i.e&&i.e<Date.now()&&(function(e,t=l.Storage.Session){switch(t){case l.Storage.Cookie:_(e,"",0,t);break;case l.Storage.Local:window.localStorage.removeItem(e);break;case l.Storage.Session:window.sessionStorage.removeItem(e)}}(e,t),o="")),h(o||"")}function _(e,t,n=30,r=l.Storage.Session,o){const i={e:Date.now()+6e4*n,v:String(t)},s=JSON.stringify(i);switch(r){case l.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let r=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;o&&(r+="; domain="+o),document.cookie=r;break}case l.Storage.Local:window.localStorage.setItem(e,s);break;case l.Storage.Session:window.sessionStorage.setItem(e,s)}return W(e,r)}function R(e={}){const t=Date.now(),{length:n=30,deviceKey:r="elbDeviceId",deviceStorage:o="local",deviceAge:i=30,sessionKey:s="elbSessionId",sessionStorage:c="local",pulse:a=!1}=e,l=H(e);let u=!1;const d=S((e,t,n)=>{let r=W(e,n);return r||(r=k(8),_(e,r,1440*t,n)),String(r)})(r,i,o),f=S((e,r)=>{const o=JSON.parse(String(W(e,r)));return a||(o.isNew=!1,l.marketing&&(Object.assign(o,l),u=!0),u||o.updated+6e4*n<t?(delete o.id,delete o.referrer,o.start=t,o.count++,o.runs=1,u=!0):o.runs++),o},()=>{u=!0})(s,c)||{},g={id:k(12),start:t,isNew:!0,count:1,runs:1},m=Object.assign(g,l,f,{device:d},{isStart:u,storage:!0,updated:t},e.data);return _(s,JSON.stringify(m),2*n,c),m}function H(e={}){let t=e.isStart||!1;const n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t){const[e]=performance.getEntriesByType("navigation");if("navigate"!==e.type)return n}const r=new URL(e.url||window.location.href),o=e.referrer||document.referrer,i=o&&new URL(o).hostname,s=function(e,t={}){const n="clickId",r={},o={utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term",dclid:n,fbclid:n,gclid:n,msclkid:n,ttclid:n,twclid:n,igshid:n,sclid:n};return Object.entries(d(o,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}(r,e.parameters);if(Object.keys(s).length&&(s.marketing||(s.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(r.hostname),t=!n.includes(i)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:k(12),referrer:i},s,e.data):n}function N(e,t,n=!0){return e+(t=null!=t?(n?"-":"")+t:"")}function D(e,t,n,r=!0){return K(E(t,N(e,n,r))||"").reduce((e,n)=>{let[r,o]=Y(n);if(!r)return e;if(o||(r.endsWith(":")&&(r=r.slice(0,-1)),o=""),o.startsWith("#")){o=o.slice(1);try{let e=t[o];e||"selected"!==o||(e=t.options[t.selectedIndex].text),o=String(e)}catch(e){o=""}}return r.endsWith("[]")?(r=r.slice(0,-2),f(e[r])||(e[r]=[]),e[r].push(h(o))):e[r]=h(o),e},{})}function M(e=document.body,t=j.Commands.Prefix){let n=[];const r=j.Commands.Action,o=`[${N(t,r,!1)}]`,i=e=>{Object.keys(D(t,e,r,!1)).forEach(r=>{n=n.concat(T(e,r,t))})};return e!==document&&e.matches(o)&&i(e),F(e,o,i),n}function T(e,t,n=j.Commands.Prefix){const r=[],o=function(e,t,n){let r=t;for(;r;){const t=V(E(r,N(e,j.Commands.Action,!1)));if(t[n]||"click"!==n)return t[n];r=B(e,r)}return[]}(n,e,t);return o?(o.forEach(o=>{const i=K(o.actionParams||"",",").reduce((e,t)=>(e[O(t)]=!0,e),{}),s=G(n,e,i);if(!s.length){const t="page",r=`[${N(n,t)}]`,[o,i]=q(e,r,n,t);s.push({type:t,data:o,nested:[],context:i})}s.forEach(e=>{r.push({entity:e.type,action:o.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),r):r}function U(e=j.Commands.Prefix,t=document){const n=N(e,j.Commands.Globals,!1);let r={};return F(t,`[${n}]`,t=>{r=d(r,D(e,t,j.Commands.Globals,!1))}),r}function V(e){const t={};return K(e).forEach(e=>{const[n,r]=Y(e),[o,i]=z(n);if(!o)return;let[s,c]=z(r||"");s=s||o,t[o]||(t[o]=[]),t[o].push({trigger:o,triggerParams:i,action:s,actionParams:c})}),t}function G(e,t,n){const r=[];let o=t;for(n=0!==Object.keys(n||{}).length?n:void 0;o;){const i=J(e,o,t,n);i&&r.push(i),o=B(e,o)}return r}function J(e,t,n,r){const o=E(t,N(e));if(!o||r&&!r[o])return null;const i=[t],s=`[${N(e,o)}],[${N(e,"")}]`,c=N(e,j.Commands.Link,!1);let a={};const l=[],[u,f]=q(n||t,s,e,o);F(t,`[${c}]`,t=>{const[n,r]=Y(E(t,c));"parent"===r&&F(document.body,`[${c}="${n}:child"]`,t=>{i.push(t);const n=J(e,t);n&&l.push(n)})});const g=[];i.forEach(e=>{e.matches(s)&&g.push(e),F(e,s,e=>g.push(e))});let m={};return g.forEach(t=>{m=d(m,D(e,t,"")),a=d(a,D(e,t,o))}),a=d(d(m,a),u),i.forEach(t=>{F(t,`[${N(e)}]`,t=>{const n=J(e,t);n&&l.push(n)})}),{type:o,data:a,context:f,nested:l}}function B(e,t){const n=N(e,j.Commands.Link,!1);if(t.matches(`[${n}]`)){const[e,r]=Y(E(t,n));if("child"===r)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function q(e,t,n,r){let o={};const i={};let s=e;const c=`[${N(n,j.Commands.Context,!1)}]`;let a=0;for(;s;)s.matches(t)&&(o=d(D(n,s,""),o),o=d(D(n,s,r),o)),s.matches(c)&&(Object.entries(D(n,s,j.Commands.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,a])}),++a),s=B(n,s);return[o,i]}function F(e,t,n){e.querySelectorAll(t).forEach(n)}function K(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function Y(e){const[t,n]=e.split(/:(.+)/,2);return[O(t),O(n)]}function z(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var Q=new WeakMap,X=new WeakMap;function Z(e){const t=Date.now();let n=X.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:L(e),lastChecked:t},X.set(e,n)),n.isVisible}function ee(e){if(window.IntersectionObserver)return S(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,r;const o=t.target,i=e._visibilityState;if(!i)return;const s=i.timers.get(o);if(t.intersectionRatio>0){const r=Date.now();let c=Q.get(o);(!c||r-c.lastChecked>1e3)&&(c={isLarge:o.offsetHeight>window.innerHeight,lastChecked:r},Q.set(o,c));if(t.intersectionRatio>=.5||c.isLarge&&Z(o)){const t=null==(n=i.elementConfigs)?void 0:n.get(o);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!s){const t=window.setTimeout(async()=>{var t,n;if(Z(o)){const r=null==(t=i.elementConfigs)?void 0:t.get(o),s=(null==r?void 0:r.prefix)||"data-elb";await de(e,s,o,ae.Visible);const c=null==(n=i.elementConfigs)?void 0:n.get(o);(null==c?void 0:c.multiple)?c.blocked=!0:function(e,t){const n=e._visibilityState;if(!n)return;n.observer&&n.observer.unobserve(t);const r=n.timers.get(t);r&&(clearTimeout(r),n.timers.delete(t)),Q.delete(t),X.delete(t)}(e,o)}},i.duration);i.timers.set(o,t)}return}}s&&(clearTimeout(s),i.timers.delete(o));const c=null==(r=i.elementConfigs)?void 0:r.get(o);(null==c?void 0:c.multiple)&&(c.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function te(e,t,n={multiple:!1}){var r;const o=e._visibilityState;(null==o?void 0:o.observer)&&t&&(o.elementConfigs||(o.elementConfigs=new WeakMap),o.elementConfigs.set(t,{multiple:null!=(r=n.multiple)&&r,blocked:!1,prefix:n.prefix||"data-elb"}),o.observer.observe(t))}function ne(e){const t=e._visibilityState;t&&(t.observer&&t.observer.disconnect(),delete e._visibilityState)}var re=performance.now();function oe(e,t="data-elb",n,r,o,i,s,c){if(b(n)&&n.startsWith("walker ")){return e.push(n,r)}if(p(n)){const t=n;return t.source||(t.source=ie()),e.push(t)}const[a]=String(p(n)?n.event:n).split(" ");let l,u=p(r)?r:{},d={},f=!1;if(m(r)&&(l=r,f=!0),m(i)?l=i:p(i)&&Object.keys(i).length&&(d=i),l){const e=G(t,l).find(e=>e.type===a);e&&(f&&(u=e.data),d=e.context)}"page"===a&&(u.id=u.id||window.location.pathname);const g={event:String(n||""),data:u,context:d,nested:s,custom:c,trigger:b(o)?o:"",timing:Math.round((performance.now()-re)/10)/100,source:ie()};return e.push(g)}function ie(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var se,ce=[],ae={Click:"click",Custom:"custom",Hover:"hover",Load:"load",Pulse:"pulse",Scroll:"scroll",Submit:"submit",Visible:"visible",Visibles:"visibles",Wait:"wait"};function le(e,t){const{scope:n,prefix:r}=t;!function(e,t,n){t.addEventListener("click",S(function(t){ge.call(this,e,t,n)})),t.addEventListener("submit",S(function(t){me.call(this,e,t,n)}))}(e,n,r)}function ue(e,t){const{prefix:n,scope:r}=t;!function(e,t,n){ce=[],ne(e),function(e,t=1e3){e._visibilityState||(e._visibilityState={observer:ee(e),timers:new WeakMap,duration:t})}(e,1e3);const r=N(t,j.Commands.Action,!1),o=n||document;o!==document&&fe(e,o,r,t);const i=o.querySelectorAll(`[${r}]`);i.forEach(n=>{fe(e,n,r,t)}),ce.length&&function(e,t,n){const r=(e,t,n)=>e.filter(([e,r])=>{const o=window.scrollY+window.innerHeight,i=e.offsetTop;if(o<i)return!0;const s=e.clientHeight;return!(100*(1-(i+s-o)/(s||1))>=r)||(de(t,n,e,ae.Scroll),!1)});se||(se=function(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}(function(){ce=r.call(t,ce,e,n)}),t.addEventListener("scroll",se))}(e,o,t)}(e,n,r)}async function de(e,t,n,r){const o=T(n,r,t);return Promise.all(o.map(n=>oe(e,t,{event:`${n.entity} ${n.action}`,...n,trigger:r})))}function fe(e,t,n,r){const o=E(t,n);o&&Object.values(V(o)).forEach(n=>n.forEach(n=>{switch(n.trigger){case ae.Hover:!function(e,t,n){t.addEventListener("mouseenter",S(function(t){t.target instanceof Element&&de(e,n,t.target,ae.Hover)}))}(e,t,r);break;case ae.Load:!function(e,t,n){de(e,n,t,ae.Load)}(e,t,r);break;case ae.Pulse:!function(e,t,n="",r){setInterval(()=>{document.hidden||de(e,r,t,ae.Pulse)},parseInt(n||"")||15e3)}(e,t,n.triggerParams,r);break;case ae.Scroll:!function(e,t=""){const n=parseInt(t||"")||50;if(n<0||n>100)return;ce.push([e,n])}(t,n.triggerParams);break;case ae.Visible:te(e,t,{prefix:r});break;case ae.Visibles:te(e,t,{multiple:!0,prefix:r});break;case ae.Wait:!function(e,t,n="",r){setTimeout(()=>de(e,r,t,ae.Wait),parseInt(n||"")||15e3)}(e,t,n.triggerParams,r)}}))}function ge(e,t,n){de(e,n,t.target,ae.Click)}function me(e,t,n){t.target&&de(e,n,t.target,ae.Submit)}function pe(e,t={}){const n=t.name||"elbLayer";window[n]||(window[n]=[]);const r=window[n];r.push=function(...n){if(ye(n[0])){const r=[...Array.from(n[0])],o=Array.prototype.push.apply(this,[r]);return he(e,t.prefix,r),o}const r=Array.prototype.push.apply(this,n);return n.forEach(n=>{he(e,t.prefix,n)}),r},Array.isArray(r)&&r.length>0&&function(e,t="data-elb",n){be(e,t,n,!0),be(e,t,n,!1),n.length=0}(e,t.prefix,r)}function be(e,t,n,r){const o=[];let i=!0;n.forEach(e=>{const t=ye(e)?[...Array.from(e)]:null!=(n=e)&&"object"==typeof n&&"length"in n&&"number"==typeof n.length?Array.from(e):[e];var n;if(Array.isArray(t)&&0===t.length)return;if(Array.isArray(t)&&1===t.length&&!t[0])return;const s=t[0],c=!p(s)&&b(s)&&s.startsWith("walker ");if(p(s)){if("object"==typeof s&&0===Object.keys(s).length)return}else{const e=Array.from(t);if(!b(e[0])||""===e[0].trim())return;const n="walker run";i&&e[0]===n&&(i=!1)}(r&&c||!r&&!c)&&o.push(t)}),o.forEach(n=>{he(e,t,n)})}function he(e,t="data-elb",n){S(()=>{if(Array.isArray(n)){const[r,...o]=n;if(!r||b(r)&&""===r.trim())return;if(b(r)&&r.startsWith("walker "))return void e.push(r,o[0]);oe(e,t,r,...o)}else if(n&&"object"==typeof n){if(0===Object.keys(n).length)return;e.push(n)}},()=>{})()}function ye(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}function we(e={}){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:document,...e}}var ve={};function ke(e={}){const t=e.prefix||"data-elb";return function(e){let n,r=e;const o={},i={},s={},c={},a={};function l(e){return Object.entries(e).map(([e,t])=>`${e}:${function(e){if(!g(e)||null===e)return"undefined";let t=String(e);return t=t.replace(/\\/g,"\\\\"),t=t.replace(/;/g,"\\;"),t=t.replace(/:/g,"\\:"),t=t.replace(/'/g,"\\'"),t}(t)}`).join(";")}const u={entity:e=>(n=e,r=e,u),data(e,t){const n=null!=r?r:"";return o[n]||(o[n]={}),b(e)?o[n][e]=t:Object.assign(o[n],e),u},action(e,t){if(b(e))if(g(t))i[e]=t;else if(e.includes(":")){const[t,n]=e.split(":",2);i[t]=n}else i[e]=e;else Object.assign(i,e);return u},context:(e,t)=>(b(e)?s[e]=t:Object.assign(s,e),u),globals:(e,t)=>(b(e)?c[e]=t:Object.assign(c,e),u),link:(e,t)=>(b(e)?a[e]=t:Object.assign(a,e),u),get(){const e={};return n&&(e[t]=n),Object.entries(o).forEach(([n,r])=>{if(Object.keys(r).length>0){e[n?`${t}-${n}`:`${t}-`]=l(r)}}),Object.keys(i).length>0&&(e[`${t}action`]=l(i)),Object.keys(s).length>0&&(e[`${t}context`]=l(s)),Object.keys(c).length>0&&(e[`${t}globals`]=l(c)),Object.keys(a).length>0&&(e[`${t}link`]=l(a)),e}};return u}}var Se,Oe=async(e,t)=>{try{const n={...t,settings:we(t.settings)},r={type:"browser",config:n,collector:e,destroy(){ne(e)}};if(!1!==n.settings.elbLayer&&pe(e,{name:b(n.settings.elbLayer)?n.settings.elbLayer:"elbLayer",prefix:n.settings.prefix}),n.settings.session){const t="boolean"==typeof n.settings.session?{}:n.settings.session;!function(e,t={}){const n=t.config||{},r=d(e.config.sessionStatic||{},t.data||{});var o,i,s;(o=$,i="SessionStart",s=e.hooks,function(...e){let t;const n="post"+i,r=s["pre"+i],c=s[n];return t=r?r({fn:o},...e):o(...e),c&&(t=c({fn:o,result:t},...e)),t})({...n,cb:(e,t,r)=>{let o;const i=n;return!1!==i.cb&&i.cb?o=i.cb(e,t,r):!1!==i.cb&&(o=r(e,t,r)),t&&(t.session=e,C(t,"session")),o},data:r,collector:e})}(e,{config:t})}await async function(e,t,n){const r=()=>{if(e(t,n),null==t?void 0:t.on)try{C(t,"ready")}catch(e){}};"loading"!==document.readyState?r():document.addEventListener("DOMContentLoaded",r)}(le,e,n.settings);const o=e=>{if(ue(e,n.settings),n.settings.pageview){const[t,r]=function(e,t){const n=window.location,r="page",o=t===document?document.body:t,[i,s]=q(o,`[${N(e,r)}]`,e,r);return i.domain=n.hostname,i.title=document.title,i.referrer=document.referrer,n.search&&(i.search=n.search),n.hash&&(i.hash=n.hash),[i,s]}(n.settings.prefix||"data-elb",n.settings.scope);oe(e,"page view",t,ae.Load,r)}};await e.push("walker on","run",o);const i=e._destroy;e._destroy=()=>{var e;null==(e=r.destroy)||e.call(r),i&&i()};const s=(...t)=>{const[r,o,i,s,c,a]=t;return oe(e,n.settings.prefix,r,o,i,s,c,a)};return b(n.settings.elb)&&(window[n.settings.elb]=s),{source:r,elb:s}}catch(e){throw e}},xe=Oe;return Se=s,((e,t,s,c)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of o(t))i.call(e,a)||a===s||n(e,a,{get:()=>t[a],enumerable:!(c=r(t,a))||c.enumerable});return e})(n({},"__esModule",{value:!0}),Se)})();
|
|
1
|
+
"use strict";var Source=(()=>{var e,t,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(s,{SourceBrowser:()=>$e,createTagger:()=>Le,default:()=>We,getAllEvents:()=>M,getEvents:()=>T,getGlobals:()=>_,sourceBrowser:()=>Pe});var c=Object.getOwnPropertyNames,a=(e={"package.json"(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.1.1",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/core"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","web analytics","product analytics","core","types","utils"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[c(e)[0]])((t={exports:{}}).exports,t),t.exports}),l={Storage:{Local:"local",Session:"session",Cookie:"cookie"}},u={merge:!0,shallow:!0,extend:!0};function d(e,t={},n={}){n={...u,...n};const r=Object.entries(t).reduce((t,[r,o])=>{const i=e[r];return n.merge&&Array.isArray(i)&&Array.isArray(o)?t[r]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||r in e)&&(t[r]=o),t},{});return n.shallow?{...e,...r}:(Object.assign(e,r),e)}function f(e){return Array.isArray(e)}function g(e){return void 0!==e}function m(e){return e===document||e instanceof Element}function p(e){return"object"==typeof e&&null!==e&&!f(e)&&"[object Object]"===Object.prototype.toString.call(e)}function h(e){return"string"==typeof e}function b(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}var y,w,{version:k}=a();function v(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function S(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}}function O(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}var x=Object.getOwnPropertyNames,j=(y={"package.json"(e,t){t.exports={name:"@walkeros/collector",description:"Unified platform-agnostic collector for walkerOS",version:"0.1.1",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{"@walkeros/core":"0.1.1"},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/collector"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","collector","event processing"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},{Commands:{Action:"action",Actions:"actions",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",User:"user",Walker:"walker"},Utils:{Storage:{Cookie:"cookie",Local:"local",Session:"session"}}});function C(e,t){return(e.getAttribute(t)||"").trim()}var E=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function A(e){const t=getComputedStyle(e);if("none"===t.display)return!1;if("visible"!==t.visibility)return!1;if(t.opacity&&Number(t.opacity)<.1)return!1;let n;const r=window.innerHeight,o=e.getBoundingClientRect(),i=o.height,s=o.y,c=s+i,a={x:o.x+e.offsetWidth/2,y:o.y+e.offsetHeight/2};if(i<=r){if(e.offsetWidth+o.width===0||e.offsetHeight+o.height===0)return!1;if(a.x<0)return!1;if(a.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(a.y<0)return!1;if(a.y>(document.documentElement.clientHeight||window.innerHeight))return!1;n=document.elementFromPoint(a.x,a.y)}else{const e=r/2;if(s<0&&c<e)return!1;if(c>r&&s>e)return!1;n=document.elementFromPoint(a.x,r/2)}if(n)do{if(n===e)return!0}while(n=n.parentElement);return!1}function $(e={}){const{cb:t,consent:n,collector:r,storage:o}=e,i=(null==r?void 0:r.push)||E;if(!n)return L((o?N:R)(e),r,t);{const r=function(e,t){let n;return(r,o)=>{if(g(n)&&n===(null==r?void 0:r.group))return;n=null==r?void 0:r.group;let i=()=>R(e);if(e.consent){(function(e,t={},n={}){const r={...t,...n},o={};let i=void 0===e;return Object.keys(r).forEach(t=>{r[t]&&(o[t]=!0,e&&e[t]&&(i=!0))}),!!i&&o})((f(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),o)&&(i=()=>N(e))}return L(i(),r,t)}}(e,t);i("walker on","consent",(f(n)?n:[n]).reduce((e,t)=>({...e,[t]:r}),{}))}}function L(e,t,n){return!1===n?e:(n||(n=I),n(e,t,I))}var I=(e,t)=>{const n=(null==t?void 0:t.push)||E,r={};return e.id&&(r.session=e.id),e.storage&&e.device&&(r.device=e.device),n("walker user",r),e.isStart&&n({name:"session start",data:e}),e};function P(e,t=l.Storage.Session){var n;function r(e){try{return JSON.parse(e||"")}catch(t){let n=1,r="";return e&&(n=0,r=e),{e:n,v:r}}}let o,i;switch(t){case l.Storage.Cookie:o=decodeURIComponent((null==(n=document.cookie.split("; ").find(t=>t.startsWith(e+"=")))?void 0:n.split("=")[1])||"");break;case l.Storage.Local:i=r(window.localStorage.getItem(e));break;case l.Storage.Session:i=r(window.sessionStorage.getItem(e))}return i&&(o=i.v,0!=i.e&&i.e<Date.now()&&(function(e,t=l.Storage.Session){switch(t){case l.Storage.Cookie:W(e,"",0,t);break;case l.Storage.Local:window.localStorage.removeItem(e);break;case l.Storage.Session:window.sessionStorage.removeItem(e)}}(e,t),o="")),b(o||"")}function W(e,t,n=30,r=l.Storage.Session,o){const i={e:Date.now()+6e4*n,v:String(t)},s=JSON.stringify(i);switch(r){case l.Storage.Cookie:{t="object"==typeof t?JSON.stringify(t):t;let r=`${e}=${encodeURIComponent(t)}; max-age=${60*n}; path=/; SameSite=Lax; secure`;o&&(r+="; domain="+o),document.cookie=r;break}case l.Storage.Local:window.localStorage.setItem(e,s);break;case l.Storage.Session:window.sessionStorage.setItem(e,s)}return P(e,r)}function N(e={}){const t=Date.now(),{length:n=30,deviceKey:r="elbDeviceId",deviceStorage:o="local",deviceAge:i=30,sessionKey:s="elbSessionId",sessionStorage:c="local",pulse:a=!1}=e,l=R(e);let u=!1;const d=S((e,t,n)=>{let r=P(e,n);return r||(r=v(8),W(e,r,1440*t,n)),String(r)})(r,i,o),f=S((e,r)=>{const o=JSON.parse(String(P(e,r)));return a||(o.isNew=!1,l.marketing&&(Object.assign(o,l),u=!0),u||o.updated+6e4*n<t?(delete o.id,delete o.referrer,o.start=t,o.count++,o.runs=1,u=!0):o.runs++),o},()=>{u=!0})(s,c)||{},g={id:v(12),start:t,isNew:!0,count:1,runs:1},m=Object.assign(g,l,f,{device:d},{isStart:u,storage:!0,updated:t},e.data);return W(s,JSON.stringify(m),2*n,c),m}function R(e={}){let t=e.isStart||!1;const n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t){const[e]=performance.getEntriesByType("navigation");if("navigate"!==e.type)return n}const r=new URL(e.url||window.location.href),o=e.referrer||document.referrer,i=o&&new URL(o).hostname,s=function(e,t={}){const n="clickId",r={},o={utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term",dclid:n,fbclid:n,gclid:n,msclkid:n,ttclid:n,twclid:n,igshid:n,sclid:n};return Object.entries(d(o,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}(r,e.parameters);if(Object.keys(s).length&&(s.marketing||(s.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(r.hostname),t=!n.includes(i)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:v(12),referrer:i},s,e.data):n}function D(e,t,n=!0){return e+(t=null!=t?(n?"-":"")+t:"")}function H(e,t,n,r=!0){return V(C(t,D(e,n,r))||"").reduce((e,n)=>{let[r,o]=Y(n);if(!r)return e;if(o||(r.endsWith(":")&&(r=r.slice(0,-1)),o=""),o.startsWith("#")){o=o.slice(1);try{let e=t[o];e||"selected"!==o||(e=t.options[t.selectedIndex].text),o=String(e)}catch(e){o=""}}return r.endsWith("[]")?(r=r.slice(0,-2),f(e[r])||(e[r]=[]),e[r].push(b(o))):e[r]=b(o),e},{})}function M(e,t=j.Commands.Prefix){var n;const r=e||("undefined"!=typeof document?document.body:void 0);if(!r)return[];let o=[];const i=j.Commands.Action,s=`[${D(t,i,!1)}]`,c=e=>{Object.keys(H(t,e,i,!1)).forEach(n=>{o=o.concat(T(e,n,t))})};return r!==("undefined"!=typeof document?document:null)&&(null==(n=r.matches)?void 0:n.call(r,s))&&c(r),K(r,s,c),o}function T(e,t,n=j.Commands.Prefix){const r=[],{actions:o,nearestOnly:i}=function(e,t,n){let r=t;for(;r;){const t=C(r,D(e,j.Commands.Actions,!1));if(t){const e=G(t);if(e[n])return{actions:e[n],nearestOnly:!1}}const o=C(r,D(e,j.Commands.Action,!1));if(o){const e=G(o);if(e[n]||"click"!==n)return{actions:e[n]||[],nearestOnly:!0}}r=q(e,r)}return{actions:[],nearestOnly:!1}}(n,e,t);return o.length?(o.forEach(o=>{const s=V(o.actionParams||"",",").reduce((e,t)=>(e[O(t)]=!0,e),{}),c=B(n,e,s,i);if(!c.length){const t="page",r=`[${D(n,t)}]`,[o,i]=F(e,r,n,t);c.push({entity:t,data:o,nested:[],context:i})}c.forEach(e=>{r.push({entity:e.entity,action:o.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),r):r}function _(e=j.Commands.Prefix,t=document){const n=D(e,j.Commands.Globals,!1);let r={};return K(t,`[${n}]`,t=>{r=d(r,H(e,t,j.Commands.Globals,!1))}),r}function U(e,t){const n=window.location,r="page",o=t===document?document.body:t,[i,s]=F(o,`[${D(e,r)}]`,e,r);return i.domain=n.hostname,i.title=document.title,i.referrer=document.referrer,n.search&&(i.search=n.search),n.hash&&(i.hash=n.hash),[i,s]}function G(e){const t={};return V(e).forEach(e=>{const[n,r]=Y(e),[o,i]=z(n);if(!o)return;let[s,c]=z(r||"");s=s||o,t[o]||(t[o]=[]),t[o].push({trigger:o,triggerParams:i,action:s,actionParams:c})}),t}function B(e,t,n,r=!1){const o=[];let i=t;for(n=0!==Object.keys(n||{}).length?n:void 0;i;){const s=J(e,i,t,n);if(s&&(o.push(s),r))break;i=q(e,i)}return o}function J(e,t,n,r){const o=C(t,D(e));if(!o||r&&!r[o])return null;const i=[t],s=`[${D(e,o)}],[${D(e,"")}]`,c=D(e,j.Commands.Link,!1);let a={};const l=[],[u,f]=F(n||t,s,e,o);K(t,`[${c}]`,t=>{const[n,r]=Y(C(t,c));"parent"===r&&K(document.body,`[${c}="${n}:child"]`,t=>{i.push(t);const n=J(e,t);n&&l.push(n)})});const g=[];i.forEach(e=>{e.matches(s)&&g.push(e),K(e,s,e=>g.push(e))});let m={};return g.forEach(t=>{m=d(m,H(e,t,"")),a=d(a,H(e,t,o))}),a=d(d(m,a),u),i.forEach(t=>{K(t,`[${D(e)}]`,t=>{const n=J(e,t);n&&l.push(n)})}),{entity:o,data:a,context:f,nested:l}}function q(e,t){const n=D(e,j.Commands.Link,!1);if(t.matches(`[${n}]`)){const[e,r]=Y(C(t,n));if("child"===r)return document.querySelector(`[${n}="${e}:parent"]`)}return!t.parentElement&&t.getRootNode&&t.getRootNode()instanceof ShadowRoot?t.getRootNode().host:t.parentElement}function F(e,t,n,r){let o={};const i={};let s=e;const c=`[${D(n,j.Commands.Context,!1)}]`;let a=0;for(;s;)s.matches(t)&&(o=d(H(n,s,""),o),o=d(H(n,s,r),o)),s.matches(c)&&(Object.entries(H(n,s,j.Commands.Context,!1)).forEach(([e,t])=>{t&&!i[e]&&(i[e]=[t,a])}),++a),s=q(n,s);return[o,i]}function K(e,t,n){e.querySelectorAll(t).forEach(n)}function V(e,t=";"){if(!e)return[];const n=new RegExp(`(?:[^${t}']+|'[^']*')+`,"ig");return e.match(n)||[]}function Y(e){const[t,n]=e.split(/:(.+)/,2);return[O(t),O(n)]}function z(e){const[t,n]=e.split("(",2);return[t,n?n.slice(0,-1):""]}var Q=new WeakMap,X=new WeakMap,Z=new WeakMap;function ee(e){const t=Date.now();let n=X.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:A(e),lastChecked:t},X.set(e,n)),n.isVisible}function te(e){if(window.IntersectionObserver)return S(()=>new window.IntersectionObserver(t=>{t.forEach(t=>{!function(e,t){var n,r;const o=t.target,i=Z.get(e);if(!i)return;const s=i.timers.get(o);if(t.intersectionRatio>0){const r=Date.now();let c=Q.get(o);(!c||r-c.lastChecked>1e3)&&(c={isLarge:o.offsetHeight>window.innerHeight,lastChecked:r},Q.set(o,c));if(t.intersectionRatio>=.5||c.isLarge&&ee(o)){const t=null==(n=i.elementConfigs)?void 0:n.get(o);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!s){const t=window.setTimeout(async()=>{var t,n;if(ee(o)){const r=null==(t=i.elementConfigs)?void 0:t.get(o);(null==r?void 0:r.context)&&await ke(r.context,o,r.trigger);const s=null==(n=i.elementConfigs)?void 0:n.get(o);(null==s?void 0:s.multiple)?s.blocked=!0:function(e,t){const n=Z.get(e);if(!n)return;n.observer&&n.observer.unobserve(t);const r=n.timers.get(t);r&&(clearTimeout(r),n.timers.delete(t)),Q.delete(t),X.delete(t)}(e,o)}},i.duration);i.timers.set(o,t)}return}}s&&(clearTimeout(s),i.timers.delete(o));const c=null==(r=i.elementConfigs)?void 0:r.get(o);(null==c?void 0:c.multiple)&&(c.blocked=!1)}(e,t)})},{rootMargin:"0px",threshold:[0,.5]}),()=>{})()}function ne(e,t,n={multiple:!1}){var r;const o=e.settings.scope||document,i=Z.get(o);(null==i?void 0:i.observer)&&t&&(i.elementConfigs||(i.elementConfigs=new WeakMap),i.elementConfigs.set(t,{multiple:null!=(r=n.multiple)&&r,blocked:!1,context:e,trigger:n.multiple?"visible":"impression"}),i.observer.observe(t))}function re(e){if(!e)return;const t=Z.get(e);t&&(t.observer&&t.observer.disconnect(),Z.delete(e))}var oe=performance.now();function ie(e,t,n,r,o,i,s){const{elb:c,settings:a}=e;if(h(t)&&t.startsWith("walker ")){return c(t,n)}if(p(t)){const e=t;return e.source||(e.source=se()),c(e)}const[l]=String(p(t)?t.name:t).split(" ");let u,d=p(n)?n:{},f={},g=!1;if(m(n)&&(u=n,g=!0),m(o)?u=o:p(o)&&Object.keys(o).length&&(f=o),u){const e=B(a.prefix||"data-elb",u).find(e=>e.entity===l);e&&(g&&(d=e.data),f=e.context)}"page"===l&&(d.id=d.id||window.location.pathname);return c({name:String(t||""),data:d,context:f,nested:i,custom:s,trigger:h(r)?r:"",timing:Math.round((performance.now()-oe)/10)/100,source:se()})}function se(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var ce,ae=[],le="click",ue="hover",de="load",fe="pulse",ge="scroll",me="submit",pe="impression",he="visible",be="wait";function ye(e,t){if(!t.scope)return;!function(e,t){const n=t.scope;if(!n)return;n.addEventListener("click",S(function(t){Se.call(this,e,t)})),n.addEventListener("submit",S(function(t){Oe.call(this,e,t)}))}(e,t)}function we(e,t){if(!t.scope)return;!function(e,t){const n=t.scope;ae=[];const r=n||document;re(r),function(e,t=1e3){Z.has(e)||Z.set(e,{observer:te(e),timers:new WeakMap,duration:t})}(r,1e3);const o=D(t.prefix,j.Commands.Action,!1);r!==document&&ve(e,r,o,t);r.querySelectorAll(`[${o}]`).forEach(n=>{ve(e,n,o,t)}),ae.length&&function(e,t){const n=(e,t)=>e.filter(([e,n])=>{const r=window.scrollY+window.innerHeight,o=e.offsetTop;if(r<o)return!0;const i=e.clientHeight;return!(100*(1-(o+i-r)/(i||1))>=n)||(ke(t,e,ge),!1)});ce||(ce=function(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}(function(){ae=n.call(t,ae,e)}),t.addEventListener("scroll",ce))}(e,r)}(e,t)}async function ke(e,t,n){const r=T(t,n,e.settings.prefix);return Promise.all(r.map(t=>ie(e,{name:`${t.entity} ${t.action}`,...t,trigger:n})))}function ve(e,t,n,r){const o=C(t,n);o&&Object.values(G(o)).forEach(n=>n.forEach(n=>{switch(n.trigger){case ue:!function(e,t){t.addEventListener("mouseenter",S(function(t){t.target instanceof Element&&ke(e,t.target,ue)}))}(e,t);break;case de:!function(e,t){ke(e,t,de)}(e,t);break;case fe:!function(e,t,n=""){setInterval(()=>{document.hidden||ke(e,t,fe)},parseInt(n||"")||15e3)}(e,t,n.triggerParams);break;case ge:!function(e,t=""){const n=parseInt(t||"")||50;if(n<0||n>100)return;ae.push([e,n])}(t,n.triggerParams);break;case pe:ne(e,t);break;case he:ne(e,t,{multiple:!0});break;case be:!function(e,t,n=""){setTimeout(()=>ke(e,t,be),parseInt(n||"")||15e3)}(e,t,n.triggerParams)}}))}function Se(e,t){ke(e,t.target,le)}function Oe(e,t){t.target&&ke(e,t.target,me)}function xe(e,t={}){const n=t.name||"elbLayer",r=t.window||("undefined"!=typeof window?window:void 0);if(!r)return;const o=r;o[n]||(o[n]=[]);const i=o[n];i.push=function(...n){if(Ee(n[0])){const r=[...Array.from(n[0])],o=Array.prototype.push.apply(this,[r]);return Ce(e,t.prefix,r),o}const r=Array.prototype.push.apply(this,n);return n.forEach(n=>{Ce(e,t.prefix,n)}),r},Array.isArray(i)&&i.length>0&&function(e,t="data-elb",n){je(e,t,n,!0),je(e,t,n,!1),n.length=0}(e,t.prefix,i)}function je(e,t,n,r){const o=[];let i=!0;n.forEach(e=>{const t=Ee(e)?[...Array.from(e)]:null!=(n=e)&&"object"==typeof n&&"length"in n&&"number"==typeof n.length?Array.from(e):[e];var n;if(Array.isArray(t)&&0===t.length)return;if(Array.isArray(t)&&1===t.length&&!t[0])return;const s=t[0],c=!p(s)&&h(s)&&s.startsWith("walker ");if(p(s)){if("object"==typeof s&&0===Object.keys(s).length)return}else{const e=Array.from(t);if(!h(e[0])||""===e[0].trim())return;const n="walker run";i&&e[0]===n&&(i=!1)}(r&&c||!r&&!c)&&o.push(t)}),o.forEach(n=>{Ce(e,t,n)})}function Ce(e,t="data-elb",n){S(()=>{if(Array.isArray(n)){const[r,...o]=n;if(!r||h(r)&&""===r.trim())return;if(h(r)&&r.startsWith("walker "))return void e(r,o[0]);ie({elb:e,settings:{prefix:t,scope:document,pageview:!1,session:!1,elb:"",elbLayer:!1}},r,...o)}else if(n&&"object"==typeof n){if(0===Object.keys(n).length)return;e(n)}},()=>{})()}function Ee(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}function Ae(e,t={}){return $({...t,collector:{push:e,group:void 0}})}var $e={};function Le(e={}){const t=e.prefix||"data-elb";return function(e){let n,r=e;const o={},i={},s={},c={},a={},l={};function u(e){return Object.entries(e).map(([e,t])=>`${e}:${function(e){if(!g(e)||null===e)return"undefined";let t=String(e);return t=t.replace(/\\/g,"\\\\"),t=t.replace(/;/g,"\\;"),t=t.replace(/:/g,"\\:"),t=t.replace(/'/g,"\\'"),t}(t)}`).join(";")}const d={entity:e=>(n=e,r=e,d),data(e,t){const n=null!=r?r:"";return o[n]||(o[n]={}),h(e)?o[n][e]=t:Object.assign(o[n],e),d},action(e,t){if(h(e))if(g(t))i[e]=t;else if(e.includes(":")){const[t,n]=e.split(":",2);i[t]=n}else i[e]=e;else Object.assign(i,e);return d},actions(e,t){if(h(e))if(g(t))s[e]=t;else if(e.includes(":")){const[t,n]=e.split(":",2);s[t]=n}else s[e]=e;else Object.assign(s,e);return d},context:(e,t)=>(h(e)?c[e]=t:Object.assign(c,e),d),globals:(e,t)=>(h(e)?a[e]=t:Object.assign(a,e),d),link:(e,t)=>(h(e)?l[e]=t:Object.assign(l,e),d),get(){const e={};return n&&(e[t]=n),Object.entries(o).forEach(([n,r])=>{if(Object.keys(r).length>0){e[n?`${t}-${n}`:`${t}-`]=u(r)}}),Object.keys(i).length>0&&(e[`${t}action`]=u(i)),Object.keys(s).length>0&&(e[`${t}actions`]=u(s)),Object.keys(c).length>0&&(e[`${t}context`]=u(c)),Object.keys(a).length>0&&(e[`${t}globals`]=u(a)),Object.keys(l).length>0&&(e[`${t}link`]=u(l)),e}};return d}}var Ie,Pe=async(e,t)=>{try{const n=t||{},{elb:r,window:o,document:i}=n;if(!r)throw new Error("Browser source requires elb function in environment");const s=function(e={},t){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:t||void 0,...e}}((null==e?void 0:e.settings)||{},i),c={settings:s},a={elb:r,settings:s};if(i&&o){if(!1!==s.elbLayer&&xe(r,{name:h(s.elbLayer)?s.elbLayer:"elbLayer",prefix:s.prefix,window:o}),s.session){const e="boolean"==typeof s.session?{}:s.session;Ae(r,e)}await async function(e,t,n){const r=()=>{e(t,n)};"loading"!==document.readyState?r():document.addEventListener("DOMContentLoaded",r)}(ye,a,s);(()=>{if(we(a,s),s.pageview){const[e,t]=U(s.prefix||"data-elb",s.scope);ie(a,"page view",e,"load",t)}})(),h(s.elb)&&s.elb&&(o[s.elb]=(...e)=>{const[t,n,r,o,i,s]=e;return ie(a,t,n,r,o,i,s)})}return{type:"browser",config:c,push:(...e)=>{const[t,n,r,o,i,s]=e;return ie(a,t,n,r,o,i,s)},destroy:async()=>{i&&re(s.scope||i)},on:async(e,t)=>{switch(e){case"consent":if(s.session&&t){const e="boolean"==typeof s.session?{}:s.session;Ae(r,e)}break;case"session":case"ready":default:break;case"run":if(i&&o&&(we(a,s),s.pageview)){const[e,t]=U(s.prefix||"data-elb",s.scope);ie(a,"page view",e,"load",t)}}}}}catch(e){throw e}},We=Pe;return Ie=s,((e,t,s,c)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of o(t))i.call(e,a)||a===s||n(e,a,{get:()=>t[a],enumerable:!(c=r(t,a))||c.enumerable});return e})(n({},"__esModule",{value:!0}),Ie)})();
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _walkeros_core from '@walkeros/core';
|
|
2
2
|
import { Elb, WalkerOS, Collector, Source } from '@walkeros/core';
|
|
3
|
-
import { DestinationWeb,
|
|
3
|
+
import { DestinationWeb, SessionConfig, SessionCallback, Walker } from '@walkeros/web-core';
|
|
4
4
|
|
|
5
5
|
type Scope$1 = Element | Document;
|
|
6
6
|
type Trigger = string;
|
|
@@ -27,27 +27,37 @@ type PushResult = Elb.PushResult;
|
|
|
27
27
|
type Layer = Elb.Layer | IArguments;
|
|
28
28
|
|
|
29
29
|
interface BrowserSourceConfig extends Source.Config {
|
|
30
|
-
|
|
31
|
-
settings: Settings;
|
|
30
|
+
settings: InitSettings;
|
|
32
31
|
}
|
|
33
|
-
interface
|
|
32
|
+
interface InitSettings extends Record<string, unknown> {
|
|
34
33
|
prefix?: string;
|
|
35
34
|
scope?: Element | Document;
|
|
36
35
|
pageview?: boolean;
|
|
37
36
|
session?: boolean | SessionConfig;
|
|
38
37
|
elb?: string;
|
|
39
|
-
elbLayer?: boolean | string | Elb
|
|
38
|
+
elbLayer?: boolean | string | Elb.Layer;
|
|
39
|
+
}
|
|
40
|
+
interface Settings extends Record<string, unknown> {
|
|
41
|
+
prefix: string;
|
|
42
|
+
scope?: Element | Document;
|
|
43
|
+
pageview: boolean;
|
|
44
|
+
session: boolean | SessionConfig;
|
|
45
|
+
elb: string;
|
|
46
|
+
elbLayer: boolean | string | Elb.Layer;
|
|
47
|
+
}
|
|
48
|
+
interface Environment extends Source.Environment {
|
|
49
|
+
window?: typeof window;
|
|
50
|
+
document?: typeof document;
|
|
51
|
+
}
|
|
52
|
+
interface Context {
|
|
53
|
+
elb: Elb.Fn;
|
|
54
|
+
settings: Settings;
|
|
40
55
|
}
|
|
41
56
|
|
|
42
|
-
type ELBLayer = Array<Elb
|
|
57
|
+
type ELBLayer = Array<Elb.Layer | IArguments>;
|
|
43
58
|
interface ELBLayerConfig {
|
|
44
59
|
name?: string;
|
|
45
60
|
}
|
|
46
|
-
declare global {
|
|
47
|
-
interface Window {
|
|
48
|
-
[key: string]: Elb$1.Layer | unknown;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
61
|
type Scope = Document | Element;
|
|
52
62
|
|
|
53
63
|
type index_BrowserArguments<R = Promise<Elb.PushResult>> = BrowserArguments<R>;
|
|
@@ -60,8 +70,11 @@ type index_BrowserSourceConfig = BrowserSourceConfig;
|
|
|
60
70
|
type index_CommandDestination<R = Promise<Elb.PushResult>> = CommandDestination<R>;
|
|
61
71
|
type index_CommandInit<R = Promise<Elb.PushResult>> = CommandInit<R>;
|
|
62
72
|
type index_CommandRun<R = Promise<Elb.PushResult>> = CommandRun<R>;
|
|
73
|
+
type index_Context = Context;
|
|
63
74
|
type index_ELBLayer = ELBLayer;
|
|
64
75
|
type index_ELBLayerConfig = ELBLayerConfig;
|
|
76
|
+
type index_Environment = Environment;
|
|
77
|
+
type index_InitSettings = InitSettings;
|
|
65
78
|
type index_Layer = Layer;
|
|
66
79
|
type index_PushResult = PushResult;
|
|
67
80
|
type index_Scope = Scope;
|
|
@@ -70,7 +83,7 @@ declare const index_SessionConfig: typeof SessionConfig;
|
|
|
70
83
|
type index_Settings = Settings;
|
|
71
84
|
type index_Trigger = Trigger;
|
|
72
85
|
declare namespace index {
|
|
73
|
-
export { type index_BrowserArguments as BrowserArguments, type index_BrowserCommands as BrowserCommands, type index_BrowserPush as BrowserPush, type index_BrowserPushContext as BrowserPushContext, type index_BrowserPushData as BrowserPushData, type index_BrowserPushOptions as BrowserPushOptions, type index_BrowserSourceConfig as BrowserSourceConfig, type index_CommandDestination as CommandDestination, type index_CommandInit as CommandInit, type index_CommandRun as CommandRun, type index_ELBLayer as ELBLayer, type index_ELBLayerConfig as ELBLayerConfig, type index_Layer as Layer, type index_PushResult as PushResult, type index_Scope as Scope, index_SessionCallback as SessionCallback, index_SessionConfig as SessionConfig, type index_Settings as Settings, type index_Trigger as Trigger };
|
|
86
|
+
export { type index_BrowserArguments as BrowserArguments, type index_BrowserCommands as BrowserCommands, type index_BrowserPush as BrowserPush, type index_BrowserPushContext as BrowserPushContext, type index_BrowserPushData as BrowserPushData, type index_BrowserPushOptions as BrowserPushOptions, type index_BrowserSourceConfig as BrowserSourceConfig, type index_CommandDestination as CommandDestination, type index_CommandInit as CommandInit, type index_CommandRun as CommandRun, type index_Context as Context, type index_ELBLayer as ELBLayer, type index_ELBLayerConfig as ELBLayerConfig, type index_Environment as Environment, type index_InitSettings as InitSettings, type index_Layer as Layer, type index_PushResult as PushResult, type index_Scope as Scope, index_SessionCallback as SessionCallback, index_SessionConfig as SessionConfig, type index_Settings as Settings, type index_Trigger as Trigger };
|
|
74
87
|
}
|
|
75
88
|
|
|
76
89
|
declare function getAllEvents(scope?: Scope, prefix?: string): Walker.Events;
|
|
@@ -84,6 +97,7 @@ interface TaggerInstance {
|
|
|
84
97
|
entity: (name: string) => TaggerInstance;
|
|
85
98
|
data: ((key: string, value: WalkerOS.Property) => TaggerInstance) & ((data: WalkerOS.Properties) => TaggerInstance);
|
|
86
99
|
action: ((trigger: string, action?: string) => TaggerInstance) & ((actions: Record<string, string>) => TaggerInstance);
|
|
100
|
+
actions: ((trigger: string, action?: string) => TaggerInstance) & ((actions: Record<string, string>) => TaggerInstance);
|
|
87
101
|
context: ((key: string, value: WalkerOS.Property) => TaggerInstance) & ((context: WalkerOS.Properties) => TaggerInstance);
|
|
88
102
|
globals: ((key: string, value: WalkerOS.Property) => TaggerInstance) & ((globals: WalkerOS.Properties) => TaggerInstance);
|
|
89
103
|
link: ((id: string, type: string) => TaggerInstance) & ((links: Record<string, string>) => TaggerInstance);
|
|
@@ -97,6 +111,12 @@ interface TaggerInstance {
|
|
|
97
111
|
*/
|
|
98
112
|
declare function createTagger(config?: TaggerConfig): (entity?: string) => TaggerInstance;
|
|
99
113
|
|
|
100
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Browser source implementation using environment injection.
|
|
116
|
+
*
|
|
117
|
+
* This source captures DOM events, manages sessions, handles pageviews,
|
|
118
|
+
* and processes the elbLayer for browser environments.
|
|
119
|
+
*/
|
|
120
|
+
declare const sourceBrowser: Source.Init<BrowserSourceConfig>;
|
|
101
121
|
|
|
102
122
|
export { index as SourceBrowser, type TaggerConfig, type TaggerInstance, createTagger, sourceBrowser as default, getAllEvents, getEvents, getGlobals, sourceBrowser };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _walkeros_core from '@walkeros/core';
|
|
2
2
|
import { Elb, WalkerOS, Collector, Source } from '@walkeros/core';
|
|
3
|
-
import { DestinationWeb,
|
|
3
|
+
import { DestinationWeb, SessionConfig, SessionCallback, Walker } from '@walkeros/web-core';
|
|
4
4
|
|
|
5
5
|
type Scope$1 = Element | Document;
|
|
6
6
|
type Trigger = string;
|
|
@@ -27,27 +27,37 @@ type PushResult = Elb.PushResult;
|
|
|
27
27
|
type Layer = Elb.Layer | IArguments;
|
|
28
28
|
|
|
29
29
|
interface BrowserSourceConfig extends Source.Config {
|
|
30
|
-
|
|
31
|
-
settings: Settings;
|
|
30
|
+
settings: InitSettings;
|
|
32
31
|
}
|
|
33
|
-
interface
|
|
32
|
+
interface InitSettings extends Record<string, unknown> {
|
|
34
33
|
prefix?: string;
|
|
35
34
|
scope?: Element | Document;
|
|
36
35
|
pageview?: boolean;
|
|
37
36
|
session?: boolean | SessionConfig;
|
|
38
37
|
elb?: string;
|
|
39
|
-
elbLayer?: boolean | string | Elb
|
|
38
|
+
elbLayer?: boolean | string | Elb.Layer;
|
|
39
|
+
}
|
|
40
|
+
interface Settings extends Record<string, unknown> {
|
|
41
|
+
prefix: string;
|
|
42
|
+
scope?: Element | Document;
|
|
43
|
+
pageview: boolean;
|
|
44
|
+
session: boolean | SessionConfig;
|
|
45
|
+
elb: string;
|
|
46
|
+
elbLayer: boolean | string | Elb.Layer;
|
|
47
|
+
}
|
|
48
|
+
interface Environment extends Source.Environment {
|
|
49
|
+
window?: typeof window;
|
|
50
|
+
document?: typeof document;
|
|
51
|
+
}
|
|
52
|
+
interface Context {
|
|
53
|
+
elb: Elb.Fn;
|
|
54
|
+
settings: Settings;
|
|
40
55
|
}
|
|
41
56
|
|
|
42
|
-
type ELBLayer = Array<Elb
|
|
57
|
+
type ELBLayer = Array<Elb.Layer | IArguments>;
|
|
43
58
|
interface ELBLayerConfig {
|
|
44
59
|
name?: string;
|
|
45
60
|
}
|
|
46
|
-
declare global {
|
|
47
|
-
interface Window {
|
|
48
|
-
[key: string]: Elb$1.Layer | unknown;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
61
|
type Scope = Document | Element;
|
|
52
62
|
|
|
53
63
|
type index_BrowserArguments<R = Promise<Elb.PushResult>> = BrowserArguments<R>;
|
|
@@ -60,8 +70,11 @@ type index_BrowserSourceConfig = BrowserSourceConfig;
|
|
|
60
70
|
type index_CommandDestination<R = Promise<Elb.PushResult>> = CommandDestination<R>;
|
|
61
71
|
type index_CommandInit<R = Promise<Elb.PushResult>> = CommandInit<R>;
|
|
62
72
|
type index_CommandRun<R = Promise<Elb.PushResult>> = CommandRun<R>;
|
|
73
|
+
type index_Context = Context;
|
|
63
74
|
type index_ELBLayer = ELBLayer;
|
|
64
75
|
type index_ELBLayerConfig = ELBLayerConfig;
|
|
76
|
+
type index_Environment = Environment;
|
|
77
|
+
type index_InitSettings = InitSettings;
|
|
65
78
|
type index_Layer = Layer;
|
|
66
79
|
type index_PushResult = PushResult;
|
|
67
80
|
type index_Scope = Scope;
|
|
@@ -70,7 +83,7 @@ declare const index_SessionConfig: typeof SessionConfig;
|
|
|
70
83
|
type index_Settings = Settings;
|
|
71
84
|
type index_Trigger = Trigger;
|
|
72
85
|
declare namespace index {
|
|
73
|
-
export { type index_BrowserArguments as BrowserArguments, type index_BrowserCommands as BrowserCommands, type index_BrowserPush as BrowserPush, type index_BrowserPushContext as BrowserPushContext, type index_BrowserPushData as BrowserPushData, type index_BrowserPushOptions as BrowserPushOptions, type index_BrowserSourceConfig as BrowserSourceConfig, type index_CommandDestination as CommandDestination, type index_CommandInit as CommandInit, type index_CommandRun as CommandRun, type index_ELBLayer as ELBLayer, type index_ELBLayerConfig as ELBLayerConfig, type index_Layer as Layer, type index_PushResult as PushResult, type index_Scope as Scope, index_SessionCallback as SessionCallback, index_SessionConfig as SessionConfig, type index_Settings as Settings, type index_Trigger as Trigger };
|
|
86
|
+
export { type index_BrowserArguments as BrowserArguments, type index_BrowserCommands as BrowserCommands, type index_BrowserPush as BrowserPush, type index_BrowserPushContext as BrowserPushContext, type index_BrowserPushData as BrowserPushData, type index_BrowserPushOptions as BrowserPushOptions, type index_BrowserSourceConfig as BrowserSourceConfig, type index_CommandDestination as CommandDestination, type index_CommandInit as CommandInit, type index_CommandRun as CommandRun, type index_Context as Context, type index_ELBLayer as ELBLayer, type index_ELBLayerConfig as ELBLayerConfig, type index_Environment as Environment, type index_InitSettings as InitSettings, type index_Layer as Layer, type index_PushResult as PushResult, type index_Scope as Scope, index_SessionCallback as SessionCallback, index_SessionConfig as SessionConfig, type index_Settings as Settings, type index_Trigger as Trigger };
|
|
74
87
|
}
|
|
75
88
|
|
|
76
89
|
declare function getAllEvents(scope?: Scope, prefix?: string): Walker.Events;
|
|
@@ -84,6 +97,7 @@ interface TaggerInstance {
|
|
|
84
97
|
entity: (name: string) => TaggerInstance;
|
|
85
98
|
data: ((key: string, value: WalkerOS.Property) => TaggerInstance) & ((data: WalkerOS.Properties) => TaggerInstance);
|
|
86
99
|
action: ((trigger: string, action?: string) => TaggerInstance) & ((actions: Record<string, string>) => TaggerInstance);
|
|
100
|
+
actions: ((trigger: string, action?: string) => TaggerInstance) & ((actions: Record<string, string>) => TaggerInstance);
|
|
87
101
|
context: ((key: string, value: WalkerOS.Property) => TaggerInstance) & ((context: WalkerOS.Properties) => TaggerInstance);
|
|
88
102
|
globals: ((key: string, value: WalkerOS.Property) => TaggerInstance) & ((globals: WalkerOS.Properties) => TaggerInstance);
|
|
89
103
|
link: ((id: string, type: string) => TaggerInstance) & ((links: Record<string, string>) => TaggerInstance);
|
|
@@ -97,6 +111,12 @@ interface TaggerInstance {
|
|
|
97
111
|
*/
|
|
98
112
|
declare function createTagger(config?: TaggerConfig): (entity?: string) => TaggerInstance;
|
|
99
113
|
|
|
100
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Browser source implementation using environment injection.
|
|
116
|
+
*
|
|
117
|
+
* This source captures DOM events, manages sessions, handles pageviews,
|
|
118
|
+
* and processes the elbLayer for browser environments.
|
|
119
|
+
*/
|
|
120
|
+
declare const sourceBrowser: Source.Init<BrowserSourceConfig>;
|
|
101
121
|
|
|
102
122
|
export { index as SourceBrowser, type TaggerConfig, type TaggerInstance, createTagger, sourceBrowser as default, getAllEvents, getEvents, getGlobals, sourceBrowser };
|