@walkeros/web-source-browser 0.0.9 → 0.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/README.md +95 -58
- package/dist/index.browser.js +1 -1
- package/dist/index.d.mts +18 -3
- package/dist/index.d.ts +18 -3
- 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,s=Object.prototype.hasOwnProperty,i={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(i,{SourceBrowser:()=>Ae,createTagger:()=>$e,default:()=>Pe,getAllEvents:()=>M,getEvents:()=>T,getGlobals:()=>U,sourceBrowser:()=>Ie});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.0",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 s=e[r];return n.merge&&Array.isArray(s)&&Array.isArray(o)?t[r]=o.reduce((e,t)=>e.includes(t)?e:[...e,t],[...s]):(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 j=Object.getOwnPropertyNames,x=(y={"package.json"(e,t){t.exports={name:"@walkeros/collector",description:"Unified platform-agnostic collector for walkerOS",version:"0.1.0",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.0"},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,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 x.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 x.Commands.Ready:case x.Commands.Run:i=o,(s=e).allowed&&i.forEach(e=>{S(e)(s)});break;case x.Commands.Session:!function(e,t){e.session&&t.forEach(t=>{S(t)(e,e.session)})}(e,o)}var s,i}function E(e,t){return(e.getAttribute(t)||"").trim()}var A=function(){const e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)};function $(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(),s=o.height,i=o.y,c=i+s,a={x:o.x+e.offsetWidth/2,y:o.y+e.offsetHeight/2};if(s<=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(i<0&&c<e)return!1;if(c>r&&i>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 L(e={}){const{cb:t,consent:n,collector:r,storage:o}=e,s=(null==r?void 0:r.push)||A;if(!n)return I((o?W:N)(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 s=()=>N(e);if(e.consent){(function(e,t={},n={}){const r={...t,...n},o={};let s=void 0===e;return Object.keys(r).forEach(t=>{r[t]&&(o[t]=!0,e&&e[t]&&(s=!0))}),!!s&&o})((f(e.consent)?e.consent:[e.consent]).reduce((e,t)=>({...e,[t]:!0}),{}),o)&&(s=()=>W(e))}return I(s(),r,t)}}(e,t);s("walker on","consent",(f(n)?n:[n]).reduce((e,t)=>({...e,[t]:r}),{}))}}function I(e,t,n){return!1===n?e:(n||(n=P),n(e,t,P))}var P=(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({name:"session start",data:e}),e};function _(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,s;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:s=r(window.localStorage.getItem(e));break;case l.Storage.Session:s=r(window.sessionStorage.getItem(e))}return s&&(o=s.v,0!=s.e&&s.e<Date.now()&&(function(e,t=l.Storage.Session){switch(t){case l.Storage.Cookie:R(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 R(e,t,n=30,r=l.Storage.Session,o){const s={e:Date.now()+6e4*n,v:String(t)},i=JSON.stringify(s);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,i);break;case l.Storage.Session:window.sessionStorage.setItem(e,i)}return _(e,r)}function W(e={}){const t=Date.now(),{length:n=30,deviceKey:r="elbDeviceId",deviceStorage:o="local",deviceAge:s=30,sessionKey:i="elbSessionId",sessionStorage:c="local",pulse:a=!1}=e,l=N(e);let u=!1;const d=S((e,t,n)=>{let r=_(e,n);return r||(r=v(8),R(e,r,1440*t,n)),String(r)})(r,s,o),f=S((e,r)=>{const o=JSON.parse(String(_(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})(i,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 R(i,JSON.stringify(m),2*n,c),m}function N(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,s=o&&new URL(o).hostname,i=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 s=e.searchParams.get(t);s&&(o===n&&(o=t,r[n]=t),r[o]=s)}),r}(r,e.parameters);if(Object.keys(i).length&&(i.marketing||(i.marketing=!0),t=!0),!t){const n=e.domains||[];n.push(r.hostname),t=!n.includes(s)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:v(12),referrer:s},i,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(E(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=document.body,t=x.Commands.Prefix){let n=[];const r=x.Commands.Action,o=`[${D(t,r,!1)}]`,s=e=>{Object.keys(H(t,e,r,!1)).forEach(r=>{n=n.concat(T(e,r,t))})};return e!==document&&e.matches(o)&&s(e),K(e,o,s),n}function T(e,t,n=x.Commands.Prefix){const r=[],{actions:o,nearestOnly:s}=function(e,t,n){let r=t;for(;r;){const t=E(r,D(e,x.Commands.Actions,!1));if(t){const e=G(t);if(e[n])return{actions:e[n],nearestOnly:!1}}const o=E(r,D(e,x.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 i=V(o.actionParams||"",",").reduce((e,t)=>(e[O(t)]=!0,e),{}),c=J(n,e,i,s);if(!c.length){const t="page",r=`[${D(n,t)}]`,[o,s]=F(e,r,n,t);c.push({entity:t,data:o,nested:[],context:s})}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 U(e=x.Commands.Prefix,t=document){const n=D(e,x.Commands.Globals,!1);let r={};return K(t,`[${n}]`,t=>{r=d(r,H(e,t,x.Commands.Globals,!1))}),r}function G(e){const t={};return V(e).forEach(e=>{const[n,r]=Y(e),[o,s]=z(n);if(!o)return;let[i,c]=z(r||"");i=i||o,t[o]||(t[o]=[]),t[o].push({trigger:o,triggerParams:s,action:i,actionParams:c})}),t}function J(e,t,n,r=!1){const o=[];let s=t;for(n=0!==Object.keys(n||{}).length?n:void 0;s;){const i=B(e,s,t,n);if(i&&(o.push(i),r))break;s=q(e,s)}return o}function B(e,t,n,r){const o=E(t,D(e));if(!o||r&&!r[o])return null;const s=[t],i=`[${D(e,o)}],[${D(e,"")}]`,c=D(e,x.Commands.Link,!1);let a={};const l=[],[u,f]=F(n||t,i,e,o);K(t,`[${c}]`,t=>{const[n,r]=Y(E(t,c));"parent"===r&&K(document.body,`[${c}="${n}:child"]`,t=>{s.push(t);const n=B(e,t);n&&l.push(n)})});const g=[];s.forEach(e=>{e.matches(i)&&g.push(e),K(e,i,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),s.forEach(t=>{K(t,`[${D(e)}]`,t=>{const n=B(e,t);n&&l.push(n)})}),{entity:o,data:a,context:f,nested:l}}function q(e,t){const n=D(e,x.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 F(e,t,n,r){let o={};const s={};let i=e;const c=`[${D(n,x.Commands.Context,!1)}]`;let a=0;for(;i;)i.matches(t)&&(o=d(H(n,i,""),o),o=d(H(n,i,r),o)),i.matches(c)&&(Object.entries(H(n,i,x.Commands.Context,!1)).forEach(([e,t])=>{t&&!s[e]&&(s[e]=[t,a])}),++a),i=q(n,i);return[o,s]}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;function Z(e){const t=Date.now();let n=X.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:$(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,s=e._visibilityState;if(!s)return;const i=s.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=s.elementConfigs)?void 0:n.get(o);if((null==t?void 0:t.multiple)&&t.blocked)return;if(!i){const t=window.setTimeout(async()=>{var t,n;if(Z(o)){const r=null==(t=s.elementConfigs)?void 0:t.get(o);(null==r?void 0:r.context)&&await we(r.context,o,r.trigger);const i=null==(n=s.elementConfigs)?void 0:n.get(o);(null==i?void 0:i.multiple)?i.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)}},s.duration);s.timers.set(o,t)}return}}i&&(clearTimeout(i),s.timers.delete(o));const c=null==(r=s.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.collector._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,context:e,trigger:n.multiple?"visible":"impression"}),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,n,r,o,s,i){const{collector:c,settings:a}=e;if(h(t)&&t.startsWith("walker ")){return c.push(t,n)}if(p(t)){const e=t;return e.source||(e.source=se()),c.push(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=J(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);const b={name:String(t||""),data:d,context:f,nested:s,custom:i,trigger:h(r)?r:"",timing:Math.round((performance.now()-re)/10)/100,source:se()};return c.push(b)}function se(){return{type:"browser",id:window.location.href,previous_id:document.referrer}}var ie,ce=[],ae="click",le="hover",ue="load",de="pulse",fe="scroll",ge="submit",me="impression",pe="visible",he="wait";function be(e,t){!function(e,t){const n=t.scope,r={collector:e,settings:t};n.addEventListener("click",S(function(e){ve.call(this,r,e)})),n.addEventListener("submit",S(function(e){Se.call(this,r,e)}))}(e,t)}function ye(e,t){!function(e,t){const n=t.scope;ce=[],ne(e),function(e,t=1e3){e._visibilityState||(e._visibilityState={observer:ee(e),timers:new WeakMap,duration:t})}(e,1e3);const r=D(t.prefix,x.Commands.Action,!1),o=n||document;o!==document&&ke(e,o,r,t);o.querySelectorAll(`[${r}]`).forEach(n=>{ke(e,n,r,t)}),ce.length&&function(e,t,n){const r={collector:e,settings:n},o=(e,t)=>e.filter(([e,n])=>{const r=window.scrollY+window.innerHeight,o=e.offsetTop;if(r<o)return!0;const s=e.clientHeight;return!(100*(1-(o+s-r)/(s||1))>=n)||(we(t,e,fe),!1)});ie||(ie=function(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}(function(){ce=o.call(t,ce,r)}),t.addEventListener("scroll",ie))}(e,o,t)}(e,t)}async function we(e,t,n){const r=T(t,n,e.settings.prefix);return Promise.all(r.map(t=>oe(e,{name:`${t.entity} ${t.action}`,...t,trigger:n})))}function ke(e,t,n,r){const o=E(t,n);if(!o)return;const s={collector:e,settings:r};Object.values(G(o)).forEach(e=>e.forEach(e=>{switch(e.trigger){case le:!function(e,t){t.addEventListener("mouseenter",S(function(t){t.target instanceof Element&&we(e,t.target,le)}))}(s,t);break;case ue:!function(e,t){we(e,t,ue)}(s,t);break;case de:!function(e,t,n=""){setInterval(()=>{document.hidden||we(e,t,de)},parseInt(n||"")||15e3)}(s,t,e.triggerParams);break;case fe:!function(e,t=""){const n=parseInt(t||"")||50;if(n<0||n>100)return;ce.push([e,n])}(t,e.triggerParams);break;case me:te(s,t);break;case pe:te(s,t,{multiple:!0});break;case he:!function(e,t,n=""){setTimeout(()=>we(e,t,he),parseInt(n||"")||15e3)}(s,t,e.triggerParams)}}))}function ve(e,t){we(e,t.target,ae)}function Se(e,t){t.target&&we(e,t.target,ge)}function Oe(e,t={}){const n=t.name||"elbLayer";window[n]||(window[n]=[]);const r=window[n];r.push=function(...n){if(Ce(n[0])){const r=[...Array.from(n[0])],o=Array.prototype.push.apply(this,[r]);return xe(e,t.prefix,r),o}const r=Array.prototype.push.apply(this,n);return n.forEach(n=>{xe(e,t.prefix,n)}),r},Array.isArray(r)&&r.length>0&&function(e,t="data-elb",n){je(e,t,n,!0),je(e,t,n,!1),n.length=0}(e,t.prefix,r)}function je(e,t,n,r){const o=[];let s=!0;n.forEach(e=>{const t=Ce(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 i=t[0],c=!p(i)&&h(i)&&i.startsWith("walker ");if(p(i)){if("object"==typeof i&&0===Object.keys(i).length)return}else{const e=Array.from(t);if(!h(e[0])||""===e[0].trim())return;const n="walker run";s&&e[0]===n&&(s=!1)}(r&&c||!r&&!c)&&o.push(t)}),o.forEach(n=>{xe(e,t,n)})}function xe(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.push(r,o[0]);oe({collector: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.push(n)}},()=>{})()}function Ce(e){return null!=e&&"object"==typeof e&&"[object Arguments]"===Object.prototype.toString.call(e)}function Ee(e={}){return{prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:document,...e}}var Ae={};function $e(e={}){const t=e.prefix||"data-elb";return function(e){let n,r=e;const o={},s={},i={},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))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},actions(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},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(s).length>0&&(e[`${t}action`]=u(s)),Object.keys(i).length>0&&(e[`${t}actions`]=u(i)),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 Le,Ie=async(e,t)=>{try{const n={...t,settings:Ee(t.settings)},r={type:"browser",config:n,collector:e,destroy(){ne(e)}};if(!1!==n.settings.elbLayer&&Oe(e,{name:h(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,s,i;(o=L,s="SessionStart",i=e.hooks,function(...e){let t;const n="post"+s,r=i["pre"+s],c=i[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 s=n;return!1!==s.cb&&s.cb?o=s.cb(e,t,r):!1!==s.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)}(be,e,n.settings);const o=e=>{if(ye(e,n.settings),n.settings.pageview){const[t,r]=function(e,t){const n=window.location,r="page",o=t===document?document.body:t,[s,i]=F(o,`[${D(e,r)}]`,e,r);return s.domain=n.hostname,s.title=document.title,s.referrer=document.referrer,n.search&&(s.search=n.search),n.hash&&(s.hash=n.hash),[s,i]}(n.settings.prefix||"data-elb",n.settings.scope);oe({collector:e,settings:n.settings},"page view",t,ue,r)}};await e.push("walker on","run",o);const s=e._destroy;e._destroy=()=>{var e;null==(e=r.destroy)||e.call(r),s&&s()};const i=(...t)=>{const[r,o,s,i,c,a]=t;return oe({collector:e,settings:n.settings},r,o,s,i,c,a)};return h(n.settings.elb)&&(window[n.settings.elb]=i),{source:r,elb:i}}catch(e){throw e}},Pe=Ie;return Le=i,((e,t,i,c)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of o(t))s.call(e,a)||a===i||n(e,a,{get:()=>t[a],enumerable:!(c=r(t,a))||c.enumerable});return e})(n({},"__esModule",{value:!0}),Le)})();
|
package/dist/index.d.mts
CHANGED
|
@@ -28,9 +28,9 @@ type Layer = Elb.Layer | IArguments;
|
|
|
28
28
|
|
|
29
29
|
interface BrowserSourceConfig extends Source.Config {
|
|
30
30
|
type: 'browser';
|
|
31
|
-
settings:
|
|
31
|
+
settings: InitSettings;
|
|
32
32
|
}
|
|
33
|
-
interface
|
|
33
|
+
interface InitSettings extends Record<string, unknown> {
|
|
34
34
|
prefix?: string;
|
|
35
35
|
scope?: Element | Document;
|
|
36
36
|
pageview?: boolean;
|
|
@@ -38,6 +38,18 @@ interface Settings extends Record<string, unknown> {
|
|
|
38
38
|
elb?: string;
|
|
39
39
|
elbLayer?: boolean | string | Elb$1.Layer;
|
|
40
40
|
}
|
|
41
|
+
interface Settings extends Record<string, unknown> {
|
|
42
|
+
prefix: string;
|
|
43
|
+
scope: Element | Document;
|
|
44
|
+
pageview: boolean;
|
|
45
|
+
session: boolean | SessionConfig;
|
|
46
|
+
elb: string;
|
|
47
|
+
elbLayer: boolean | string | Elb$1.Layer;
|
|
48
|
+
}
|
|
49
|
+
interface Context {
|
|
50
|
+
collector: Collector.Instance;
|
|
51
|
+
settings: Settings;
|
|
52
|
+
}
|
|
41
53
|
|
|
42
54
|
type ELBLayer = Array<Elb$1.Layer | IArguments>;
|
|
43
55
|
interface ELBLayerConfig {
|
|
@@ -60,8 +72,10 @@ type index_BrowserSourceConfig = BrowserSourceConfig;
|
|
|
60
72
|
type index_CommandDestination<R = Promise<Elb.PushResult>> = CommandDestination<R>;
|
|
61
73
|
type index_CommandInit<R = Promise<Elb.PushResult>> = CommandInit<R>;
|
|
62
74
|
type index_CommandRun<R = Promise<Elb.PushResult>> = CommandRun<R>;
|
|
75
|
+
type index_Context = Context;
|
|
63
76
|
type index_ELBLayer = ELBLayer;
|
|
64
77
|
type index_ELBLayerConfig = ELBLayerConfig;
|
|
78
|
+
type index_InitSettings = InitSettings;
|
|
65
79
|
type index_Layer = Layer;
|
|
66
80
|
type index_PushResult = PushResult;
|
|
67
81
|
type index_Scope = Scope;
|
|
@@ -70,7 +84,7 @@ declare const index_SessionConfig: typeof SessionConfig;
|
|
|
70
84
|
type index_Settings = Settings;
|
|
71
85
|
type index_Trigger = Trigger;
|
|
72
86
|
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 };
|
|
87
|
+
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_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
88
|
}
|
|
75
89
|
|
|
76
90
|
declare function getAllEvents(scope?: Scope, prefix?: string): Walker.Events;
|
|
@@ -84,6 +98,7 @@ interface TaggerInstance {
|
|
|
84
98
|
entity: (name: string) => TaggerInstance;
|
|
85
99
|
data: ((key: string, value: WalkerOS.Property) => TaggerInstance) & ((data: WalkerOS.Properties) => TaggerInstance);
|
|
86
100
|
action: ((trigger: string, action?: string) => TaggerInstance) & ((actions: Record<string, string>) => TaggerInstance);
|
|
101
|
+
actions: ((trigger: string, action?: string) => TaggerInstance) & ((actions: Record<string, string>) => TaggerInstance);
|
|
87
102
|
context: ((key: string, value: WalkerOS.Property) => TaggerInstance) & ((context: WalkerOS.Properties) => TaggerInstance);
|
|
88
103
|
globals: ((key: string, value: WalkerOS.Property) => TaggerInstance) & ((globals: WalkerOS.Properties) => TaggerInstance);
|
|
89
104
|
link: ((id: string, type: string) => TaggerInstance) & ((links: Record<string, string>) => TaggerInstance);
|
package/dist/index.d.ts
CHANGED
|
@@ -28,9 +28,9 @@ type Layer = Elb.Layer | IArguments;
|
|
|
28
28
|
|
|
29
29
|
interface BrowserSourceConfig extends Source.Config {
|
|
30
30
|
type: 'browser';
|
|
31
|
-
settings:
|
|
31
|
+
settings: InitSettings;
|
|
32
32
|
}
|
|
33
|
-
interface
|
|
33
|
+
interface InitSettings extends Record<string, unknown> {
|
|
34
34
|
prefix?: string;
|
|
35
35
|
scope?: Element | Document;
|
|
36
36
|
pageview?: boolean;
|
|
@@ -38,6 +38,18 @@ interface Settings extends Record<string, unknown> {
|
|
|
38
38
|
elb?: string;
|
|
39
39
|
elbLayer?: boolean | string | Elb$1.Layer;
|
|
40
40
|
}
|
|
41
|
+
interface Settings extends Record<string, unknown> {
|
|
42
|
+
prefix: string;
|
|
43
|
+
scope: Element | Document;
|
|
44
|
+
pageview: boolean;
|
|
45
|
+
session: boolean | SessionConfig;
|
|
46
|
+
elb: string;
|
|
47
|
+
elbLayer: boolean | string | Elb$1.Layer;
|
|
48
|
+
}
|
|
49
|
+
interface Context {
|
|
50
|
+
collector: Collector.Instance;
|
|
51
|
+
settings: Settings;
|
|
52
|
+
}
|
|
41
53
|
|
|
42
54
|
type ELBLayer = Array<Elb$1.Layer | IArguments>;
|
|
43
55
|
interface ELBLayerConfig {
|
|
@@ -60,8 +72,10 @@ type index_BrowserSourceConfig = BrowserSourceConfig;
|
|
|
60
72
|
type index_CommandDestination<R = Promise<Elb.PushResult>> = CommandDestination<R>;
|
|
61
73
|
type index_CommandInit<R = Promise<Elb.PushResult>> = CommandInit<R>;
|
|
62
74
|
type index_CommandRun<R = Promise<Elb.PushResult>> = CommandRun<R>;
|
|
75
|
+
type index_Context = Context;
|
|
63
76
|
type index_ELBLayer = ELBLayer;
|
|
64
77
|
type index_ELBLayerConfig = ELBLayerConfig;
|
|
78
|
+
type index_InitSettings = InitSettings;
|
|
65
79
|
type index_Layer = Layer;
|
|
66
80
|
type index_PushResult = PushResult;
|
|
67
81
|
type index_Scope = Scope;
|
|
@@ -70,7 +84,7 @@ declare const index_SessionConfig: typeof SessionConfig;
|
|
|
70
84
|
type index_Settings = Settings;
|
|
71
85
|
type index_Trigger = Trigger;
|
|
72
86
|
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 };
|
|
87
|
+
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_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
88
|
}
|
|
75
89
|
|
|
76
90
|
declare function getAllEvents(scope?: Scope, prefix?: string): Walker.Events;
|
|
@@ -84,6 +98,7 @@ interface TaggerInstance {
|
|
|
84
98
|
entity: (name: string) => TaggerInstance;
|
|
85
99
|
data: ((key: string, value: WalkerOS.Property) => TaggerInstance) & ((data: WalkerOS.Properties) => TaggerInstance);
|
|
86
100
|
action: ((trigger: string, action?: string) => TaggerInstance) & ((actions: Record<string, string>) => TaggerInstance);
|
|
101
|
+
actions: ((trigger: string, action?: string) => TaggerInstance) & ((actions: Record<string, string>) => TaggerInstance);
|
|
87
102
|
context: ((key: string, value: WalkerOS.Property) => TaggerInstance) & ((context: WalkerOS.Properties) => TaggerInstance);
|
|
88
103
|
globals: ((key: string, value: WalkerOS.Property) => TaggerInstance) & ((globals: WalkerOS.Properties) => TaggerInstance);
|
|
89
104
|
link: ((id: string, type: string) => TaggerInstance) & ((links: Record<string, string>) => TaggerInstance);
|
package/dist/index.es5.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function _array_like_to_array(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function asyncGeneratorStep(e,t,r,n,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,o)}function _async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){asyncGeneratorStep(i,n,o,a,c,"next",e)}function c(e){asyncGeneratorStep(i,n,o,a,c,"throw",e)}a(void 0)})}}function _define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterable_to_array_limit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],a=!0,c=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(c)throw o}}return i}}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){_define_property(e,t,r[t])})}return e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function _sliced_to_array(e,t){return _array_with_holes(e)||_iterable_to_array_limit(e,t)||_unsupported_iterable_to_array(e,t)||_non_iterable_rest()}function _to_array(e){return _array_with_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,t){if(e){if("string"==typeof e)return _array_like_to_array(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_array_like_to_array(e,t):void 0}}function _ts_generator(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}var Source=function(){var e,t,r=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};r=_object_spread({},me,r);var n=Object.entries(t).reduce(function(t,n){var o=_sliced_to_array(n,2),i=o[0],a=o[1],c=e[i];return r.merge&&Array.isArray(c)&&Array.isArray(a)?t[i]=a.reduce(function(e,t){return e.includes(t)?e:_to_consumable_array(e).concat([t])},_to_consumable_array(c)):(r.extend||i in e)&&(t[i]=a),t},{});return r.shallow?_object_spread({},e,n):(Object.assign(e,n),e)},n=function(e){return Array.isArray(e)},o=function(e){return void 0!==e},i=function(e){return e===document||_instanceof(e,Element)},a=function(e){return"object"==(void 0===e?"undefined":_type_of(e))&&null!==e&&!n(e)&&"[object Object]"===Object.prototype.toString.call(e)},c=function(e){return"string"==typeof e},s=function(e){if("true"===e)return!0;if("false"===e)return!1;var t=Number(e);return e==t&&""!==e?t:String(e)},u=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6,t="";t.length<e;)t+=(36*Math.random()|0).toString(36);return t},l=function(e,t,r){return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];try{return e.apply(void 0,_to_consumable_array(o))}catch(e){if(!t)return;return t(e)}finally{null==r||r()}}},f=function(e){return e?e.trim().replace(/^'|'$/g,"").trim():""},d=function(e,t,r,n){var o,i,a,c=r||[];if(r||(c=e.on[t]||[],Object.values(e.destinations).forEach(function(e){var r,n=null===(r=e.config.on)||void 0===r?void 0:r[t];n&&(c=c.concat(n))})),c.length)switch(t){case ke.Commands.Consent:o=e,i=c,a=n||o.consent,i.forEach(function(e){Object.keys(a).filter(function(t){return t in e}).forEach(function(t){l(e[t])(o,a)})});break;case ke.Commands.Ready:case ke.Commands.Run:!function(e,t){e.allowed&&t.forEach(function(t){l(t)(e)})}(e,c);break;case ke.Commands.Session:!function(e,t){e.session&&t.forEach(function(t){l(t)(e,e.session)})}(e,c)}},p=function(e,t){return(e.getAttribute(t)||"").trim()},v=function(e){var t,r=getComputedStyle(e);if("none"===r.display)return!1;if("visible"!==r.visibility)return!1;if(r.opacity&&Number(r.opacity)<.1)return!1;var n=window.innerHeight,o=e.getBoundingClientRect(),i=o.height,a=o.y,c=a+i,s={x:o.x+e.offsetWidth/2,y:o.y+e.offsetHeight/2};if(i<=n){if(e.offsetWidth+o.width===0||e.offsetHeight+o.height===0)return!1;if(s.x<0)return!1;if(s.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(s.y<0)return!1;if(s.y>(document.documentElement.clientHeight||window.innerHeight))return!1;t=document.elementFromPoint(s.x,s.y)}else{var u=n/2;if(a<0&&c<u)return!1;if(c>n&&a>u)return!1;t=document.elementFromPoint(s.x,n/2)}if(t)do{if(t===e)return!0}while(t=t.parentElement);return!1},g=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.cb,r=e.consent,i=e.collector,a=e.storage,c=(null==i?void 0:i.push)||Se;if(!r)return y((a?h:m)(e),i,t);var s,u,l,f=(s=e,u=t,function(e,t){if(!o(l)||l!==(null==e?void 0:e.group)){l=null==e?void 0:e.group;var r=function(){return m(s)};return s.consent&&function(e){var t=_object_spread({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),r={},n=void 0===e;return Object.keys(t).forEach(function(o){t[o]&&(r[o]=!0,e&&e[o]&&(n=!0))}),!!n&&r}((n(s.consent)?s.consent:[s.consent]).reduce(function(e,t){return _object_spread_props(_object_spread({},e),_define_property({},t,!0))},{}),t)&&(r=function(){return h(s)}),y(r(),e,u)}});c("walker on","consent",(n(r)?r:[r]).reduce(function(e,t){return _object_spread_props(_object_spread({},e),_define_property({},t,f))},{}))},y=function(e,t,r){return!1===r?e:(r||(r=je),r(e,t,je))},_=function(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:he.Utils.Storage.Session;function o(e){try{return JSON.parse(e||"")}catch(n){var t=1,r="";return e&&(t=0,r=e),{e:t,v:r}}}switch(n){case he.Utils.Storage.Cookie:var i;t=decodeURIComponent((null===(i=document.cookie.split("; ").find(function(t){return t.startsWith(e+"=")}))||void 0===i?void 0:i.split("=")[1])||"");break;case he.Utils.Storage.Local:r=o(window.localStorage.getItem(e));break;case he.Utils.Storage.Session:r=o(window.sessionStorage.getItem(e))}return r&&(t=r.v,0!=r.e&&r.e<Date.now()&&(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:he.Utils.Storage.Session;switch(t){case he.Utils.Storage.Cookie:b(e,"",0,t);break;case he.Utils.Storage.Local:window.localStorage.removeItem(e);break;case he.Utils.Storage.Session:window.sessionStorage.removeItem(e)}}(e,n),t="")),s(t||"")},b=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:he.Utils.Storage.Session,o=arguments.length>4?arguments[4]:void 0,i={e:Date.now()+6e4*r,v:String(t)},a=JSON.stringify(i);switch(n){case he.Utils.Storage.Cookie:t="object"==(void 0===t?"undefined":_type_of(t))?JSON.stringify(t):t;var c="".concat(e,"=").concat(encodeURIComponent(t),"; max-age=").concat(60*r,"; path=/; SameSite=Lax; secure");o&&(c+="; domain="+o),document.cookie=c;break;case he.Utils.Storage.Local:window.localStorage.setItem(e,a);break;case he.Utils.Storage.Session:window.sessionStorage.setItem(e,a)}return _(e,n)},h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Date.now(),r=e.length,n=void 0===r?30:r,o=e.deviceKey,i=void 0===o?"elbDeviceId":o,a=e.deviceStorage,c=void 0===a?"local":a,s=e.deviceAge,f=void 0===s?30:s,d=e.sessionKey,p=void 0===d?"elbSessionId":d,v=e.sessionStorage,g=void 0===v?"local":v,y=e.pulse,h=void 0!==y&&y,w=m(e),k=!1,S=l(function(e,t,r){var n=_(e,r);return n||(n=u(8),b(e,n,1440*t,r)),String(n)})(i,f,c),j=l(function(e,r){var o=JSON.parse(String(_(e,r)));return h||(o.isNew=!1,w.marketing&&(Object.assign(o,w),k=!0),k||o.updated+6e4*n<t?(delete o.id,delete o.referrer,o.start=t,o.count++,o.runs=1,k=!0):o.runs++),o},function(){k=!0})(p,g)||{},O={id:u(12),start:t,isNew:!0,count:1,runs:1},x=Object.assign(O,w,j,{device:S},{isStart:k,storage:!0,updated:t},e.data);return b(p,JSON.stringify(x),2*n,g),x},m=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isStart||!1,n={isStart:t,storage:!1};if(!1===e.isStart)return n;if(!t&&"navigate"!==_sliced_to_array(performance.getEntriesByType("navigation"),1)[0].type)return n;var o=new URL(e.url||window.location.href),i=e.referrer||document.referrer,a=i&&new URL(i).hostname,c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="clickId",o={},i={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(r(i,t)).forEach(function(t){var r=_sliced_to_array(t,2),i=r[0],a=r[1],c=e.searchParams.get(i);c&&(a===n&&(a=i,o[n]=i),o[a]=c)}),o}(o,e.parameters);if(Object.keys(c).length&&(c.marketing||(c.marketing=!0),t=!0),!t){var s=e.domains||[];s.push(o.hostname),t=!s.includes(a)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:u(12),referrer:a},c,e.data):n},w=function(e,t){return e+(t=null!=t?(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?"-":"")+t:"")},k=function(e,t,r){var o=p(t,w(e,r,!(arguments.length>3&&void 0!==arguments[3])||arguments[3]))||"";return I(o).reduce(function(e,r){var o=_sliced_to_array(U(r),2),i=o[0],a=o[1];if(!i)return e;if(a||(i.endsWith(":")&&(i=i.slice(0,-1)),a=""),a.startsWith("#")){a=a.slice(1);try{var c=t[a];c||"selected"!==a||(c=t.options[t.selectedIndex].text),a=String(c)}catch(e){a=""}}return i.endsWith("[]")?(i=i.slice(0,-2),n(e[i])||(e[i]=[]),e[i].push(s(a))):e[i]=s(a),e},{})},S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ke.Commands.Prefix,r=[],n=ke.Commands.Action,o="[".concat(w(t,n,!1),"]"),i=function(e){Object.keys(k(t,e,n,!1)).forEach(function(n){r=r.concat(j(e,n,t))})};return e!==document&&e.matches(o)&&i(e),P(e,o,i),r},j=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ke.Commands.Prefix,n=[],o=L(r,e,t);return o?(o.forEach(function(o){var i=I(o.actionParams||"",",").reduce(function(e,t){return e[f(t)]=!0,e},{}),a=C(r,e,i);if(!a.length){var c="page",s="[".concat(w(r,c),"]"),u=_sliced_to_array(E(e,s,r,c),2),l=u[0],d=u[1];a.push({type:c,data:l,nested:[],context:d})}a.forEach(function(e){n.push({entity:e.type,action:o.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),n):n},O=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ke.Commands.Prefix,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document,n=w(e,ke.Commands.Globals,!1),o="[".concat(n,"]"),i={};return P(t,o,function(t){i=r(i,k(e,t,ke.Commands.Globals,!1))}),i},x=function(e){var t={};return I(e).forEach(function(e){var r=_sliced_to_array(U(e),2),n=r[0],o=r[1],i=_sliced_to_array(W(n),2),a=i[0],c=i[1];if(a){var s=_sliced_to_array(W(o||""),2),u=s[0],l=s[1];u=u||a,t[a]||(t[a]=[]),t[a].push({trigger:a,triggerParams:c,action:u,actionParams:l})}}),t},C=function(e,t,r){var n=[],o=t;for(r=0!==Object.keys(r||{}).length?r:void 0;o;){var i=Oe(e,o,t,r);i&&n.push(i),o=A(e,o)}return n},A=function(e,t){var r=w(e,ke.Commands.Link,!1);if(t.matches("[".concat(r,"]"))){var n=_sliced_to_array(U(p(t,r)),2),o=n[0];if("child"===n[1])return document.querySelector("[".concat(r,'="').concat(o,':parent"]'))}return!t.parentElement&&t.getRootNode&&_instanceof(t.getRootNode(),ShadowRoot)?t.getRootNode().host:t.parentElement},E=function(e,t,n,o){for(var i={},a={},c=e,s="[".concat(w(n,ke.Commands.Context,!1),"]"),u=0;c;)c.matches(t)&&(i=r(k(n,c,""),i),i=r(k(n,c,o),i)),c.matches(s)&&(Object.entries(k(n,c,ke.Commands.Context,!1)).forEach(function(e){var t=_sliced_to_array(e,2),r=t[0],n=t[1];n&&!a[r]&&(a[r]=[n,u])}),++u),c=A(n,c);return[i,a]},P=function(e,t,r){e.querySelectorAll(t).forEach(r)},L=function(e,t,r){for(var n=t;n;){var o=p(n,w(e,ke.Commands.Action,!1)),i=x(o);if(i[r]||"click"!==r)return i[r];n=A(e,n)}return[]},I=function(e){if(!e)return[];var t=new RegExp("(?:[^".concat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:";","']+|'[^']*')+"),"ig");return e.match(t)||[]},U=function(e){var t=_sliced_to_array(e.split(/:(.+)/,2),2),r=t[0],n=t[1];return[f(r),f(n)]},W=function(e){var t=_sliced_to_array(e.split("(",2),2),r=t[0],n=t[1];return[r,n?n.slice(0,-1):""]},D=function(e){var t=Date.now(),r=Ee.get(e);return(!r||t-r.lastChecked>500)&&(r={isVisible:v(e),lastChecked:t},Ee.set(e,r)),r.isVisible},R=function(e){if(window.IntersectionObserver)return l(function(){return new window.IntersectionObserver(function(t){t.forEach(function(t){H(e,t)})},{rootMargin:"0px",threshold:[0,.5]})},function(){})()},H=function(e,t){var r,n=t.target,o=e._visibilityState;if(o){var i=o.timers.get(n);if(t.intersectionRatio>0){var a=Date.now(),c=Ae.get(n);if((!c||a-c.lastChecked>1e3)&&(c={isLarge:n.offsetHeight>window.innerHeight,lastChecked:a},Ae.set(n,c)),t.intersectionRatio>=.5||c.isLarge&&D(n)){var s,u=null===(s=o.elementConfigs)||void 0===s?void 0:s.get(n);if((null==u?void 0:u.multiple)&&u.blocked)return;if(!i){var l=window.setTimeout(function(){return _async_to_generator(function(){var t,r,i,a,c;return _ts_generator(this,function(s){switch(s.label){case 0:return D(n)?(i=null===(t=o.elementConfigs)||void 0===t?void 0:t.get(n),a=(null==i?void 0:i.prefix)||"data-elb",[4,q(e,a,n,Ie.Visible)]):[3,2];case 1:s.sent(),(null==(c=null===(r=o.elementConfigs)||void 0===r?void 0:r.get(n))?void 0:c.multiple)?c.blocked=!0:function(e,t){var r=e._visibilityState;if(r){r.observer&&r.observer.unobserve(t);var n=r.timers.get(t);n&&(clearTimeout(n),r.timers.delete(t)),Ae.delete(t),Ee.delete(t)}}(e,n),s.label=2;case 2:return[2]}})})()},o.duration);o.timers.set(n,l)}return}}i&&(clearTimeout(i),o.timers.delete(n));var f=null===(r=o.elementConfigs)||void 0===r?void 0:r.get(n);(null==f?void 0:f.multiple)&&(f.blocked=!1)}},N=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{multiple:!1},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)&&void 0!==r&&r,blocked:!1,prefix:n.prefix||"data-elb"}),o.observer.observe(t))},T=function(e){var t=e._visibilityState;t&&(t.observer&&t.observer.disconnect(),delete e._visibilityState)},M=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"data-elb",r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0,s=arguments.length>5?arguments[5]:void 0,u=arguments.length>6?arguments[6]:void 0,l=arguments.length>7?arguments[7]:void 0;if(c(r)&&r.startsWith("walker "))return e.push(r,n);if(a(r)){var f=r;return f.source||(f.source=G()),e.push(f)}var d,p=_sliced_to_array(String(a(r)?r.event:r).split(" "),1)[0],v=a(n)?n:{},g={},y=!1;if(i(n)&&(d=n,y=!0),i(s)?d=s:a(s)&&Object.keys(s).length&&(g=s),d){var _=C(t,d).find(function(e){return e.type===p});_&&(y&&(v=_.data),g=_.context)}"page"===p&&(v.id=v.id||window.location.pathname);var b={event:String(r||""),data:v,context:g,nested:u,custom:l,trigger:c(o)?o:"",timing:Math.round((performance.now()-Pe)/10)/100,source:G()};return e.push(b)},G=function(){return{type:"browser",id:window.location.href,previous_id:document.referrer}},V=function(e,t,r){return _async_to_generator(function(){var n;return _ts_generator(this,function(o){return n=function(){if(e(t,r),null==t?void 0:t.on)try{d(t,"ready")}catch(e){}},"loading"!==document.readyState?n():document.addEventListener("DOMContentLoaded",n),[2]})})()},J=function(e,t){var r=t.scope,n=t.prefix;B(e,r,n)},B=function(e,t,r){t.addEventListener("click",l(function(t){$.call(this,e,t,r)})),t.addEventListener("submit",l(function(t){Z.call(this,e,t,r)}))},K=function(e,t,r){Le=[],T(e),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;e._visibilityState||(e._visibilityState={observer:R(e),timers:new WeakMap,duration:t})}(e,1e3);var n=w(t,ke.Commands.Action,!1),o=r||document;o!==document&&F(e,o,n,t),o.querySelectorAll("[".concat(n,"]")).forEach(function(r){F(e,r,n,t)}),Le.length&&te(e,o,t)},q=function(e,t,r,n){return _async_to_generator(function(){var o;return _ts_generator(this,function(i){return o=j(r,n,t),[2,Promise.all(o.map(function(r){return M(e,t,_object_spread_props(_object_spread({event:"".concat(r.entity," ").concat(r.action)},r),{trigger:n}))}))]})})()},F=function(e,t,r,n){var o=p(t,r);o&&Object.values(x(o)).forEach(function(r){return r.forEach(function(r){switch(r.trigger){case Ie.Hover:Y(e,t,n);break;case Ie.Load:z(e,t,n);break;case Ie.Pulse:Q(e,t,r.triggerParams,n);break;case Ie.Scroll:X(t,r.triggerParams);break;case Ie.Visible:N(e,t,{prefix:n});break;case Ie.Visibles:N(e,t,{multiple:!0,prefix:n});break;case Ie.Wait:ee(e,t,r.triggerParams,n)}})})},$=function(e,t,r){q(e,r,t.target,Ie.Click)},Y=function(e,t,r){t.addEventListener("mouseenter",l(function(t){_instanceof(t.target,Element)&&q(e,r,t.target,Ie.Hover)}))},z=function(e,t,r){q(e,r,t,Ie.Load)},Q=function(e,t){var r=arguments.length>3?arguments[3]:void 0;setInterval(function(){document.hidden||q(e,r,t,Ie.Pulse)},parseInt((arguments.length>2&&void 0!==arguments[2]?arguments[2]:"")||"")||15e3)},X=function(e){var t=parseInt((arguments.length>1&&void 0!==arguments[1]?arguments[1]:"")||"")||50;t<0||t>100||Le.push([e,t])},Z=function(e,t,r){t.target&&q(e,r,t.target,Ie.Submit)},ee=function(e,t){var r=arguments.length>3?arguments[3]:void 0;setTimeout(function(){return q(e,r,t,Ie.Wait)},parseInt((arguments.length>2&&void 0!==arguments[2]?arguments[2]:"")||"")||15e3)},te=function(e,t,r){var n=function(e,t,r){return e.filter(function(e){var n=_sliced_to_array(e,2),o=n[0],i=n[1],a=window.scrollY+window.innerHeight,c=o.offsetTop;if(a<c)return!0;var s=o.clientHeight;return!(100*(1-(c+s-a)/(s||1))>=i)||(q(t,r,o,Ie.Scroll),!1)})};xe||(xe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,r=null;return function(){for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];if(null===r)return r=setTimeout(function(){r=null},t),e.apply(void 0,_to_consumable_array(o))}}(function(){Le=n.call(t,Le,e,r)}),t.addEventListener("scroll",xe))},re=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"data-elb",r=arguments.length>2?arguments[2]:void 0;ne(e,t,r,!0),ne(e,t,r,!1),r.length=0},ne=function(e,t,r,n){var o=[],i=!0;r.forEach(function(e){var t=ie(e)?_to_consumable_array(Array.from(e)):ae(e)?Array.from(e):[e];if((!Array.isArray(t)||0!==t.length)&&(!Array.isArray(t)||1!==t.length||t[0])){var r=t[0],s=!a(r)&&c(r)&&r.startsWith("walker ");if(a(r)){if("object"===(void 0===r?"undefined":_type_of(r))&&0===Object.keys(r).length)return}else{var u=Array.from(t);if(!c(u[0])||""===u[0].trim())return;i&&"walker run"===u[0]&&(i=!1)}(n&&s||!n&&!s)&&o.push(t)}}),o.forEach(function(r){oe(e,t,r)})},oe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"data-elb",r=arguments.length>2?arguments[2]:void 0;l(function(){if(Array.isArray(r)){var n=_to_array(r),o=n[0],i=n.slice(1);if(!o||c(o)&&""===o.trim())return;if(c(o)&&o.startsWith("walker "))return void e.push(o,i[0]);M.apply(void 0,[e,t,o].concat(_to_consumable_array(i)))}else if(r&&"object"===(void 0===r?"undefined":_type_of(r))){if(0===Object.keys(r).length)return;e.push(r)}},function(){})()},ie=function(e){return null!=e&&"object"===(void 0===e?"undefined":_type_of(e))&&"[object Arguments]"===Object.prototype.toString.call(e)},ae=function(e){return null!=e&&"object"===(void 0===e?"undefined":_type_of(e))&&"length"in e&&"number"==typeof e.length},ce=function(e){var t,n,o,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=i.config||{},c=r(e.config.sessionStatic||{},i.data||{}),s=(t=g,n="SessionStart",o=e.hooks,function(){for(var e=arguments.length,r=new Array(e),i=0;i<e;i++)r[i]=arguments[i];var a,c="post"+n,s=o["pre"+n],u=o[c];return a=s?s.apply(void 0,[{fn:t}].concat(_to_consumable_array(r))):t.apply(void 0,_to_consumable_array(r)),u&&(a=u.apply(void 0,[{fn:t,result:a}].concat(_to_consumable_array(r)))),a})(_object_spread_props(_object_spread({},a),{cb:function(e,t,r){var n,o=a;return!1!==o.cb&&o.cb?n=o.cb(e,t,r):!1!==o.cb&&(n=r(e,t,r)),t&&(t.session=e,d(t,"session")),n},data:c,collector:e}));return s},se=function(){return _object_spread({prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:document},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})},ue=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).prefix||"data-elb";return function(t){var r=void 0,n=t,i={},a={},s={},u={},l={};function f(e){return Object.entries(e).map(function(e){var t=_sliced_to_array(e,2),r=t[0],n=t[1];return"".concat(r,":").concat(function(e){if(!o(e)||null===e)return"undefined";var t=String(e);return(t=(t=(t=t.replace(/\\/g,"\\\\")).replace(/;/g,"\\;")).replace(/:/g,"\\:")).replace(/'/g,"\\'")}(n))}).join(";")}var d={entity:function(e){return r=e,n=e,d},data:function(e,t){var r=null!=n?n:"";return i[r]||(i[r]={}),c(e)?i[r][e]=t:Object.assign(i[r],e),d},action:function(e,t){if(c(e))if(o(t))a[e]=t;else if(e.includes(":")){var r=_sliced_to_array(e.split(":",2),2),n=r[0],i=r[1];a[n]=i}else a[e]=e;else Object.assign(a,e);return d},context:function(e,t){return c(e)?s[e]=t:Object.assign(s,e),d},globals:function(e,t){return c(e)?u[e]=t:Object.assign(u,e),d},link:function(e,t){return c(e)?l[e]=t:Object.assign(l,e),d},get:function(){var t={};return r&&(t[e]=r),Object.entries(i).forEach(function(r){var n=_sliced_to_array(r,2),o=n[0],i=n[1];if(Object.keys(i).length>0){var a=o?"".concat(e,"-").concat(o):"".concat(e,"-");t[a]=f(i)}}),Object.keys(a).length>0&&(t["".concat(e,"action")]=f(a)),Object.keys(s).length>0&&(t["".concat(e,"context")]=f(s)),Object.keys(u).length>0&&(t["".concat(e,"globals")]=f(u)),Object.keys(l).length>0&&(t["".concat(e,"link")]=f(l)),t}};return d}},le=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,de=Object.getOwnPropertyNames,pe=Object.prototype.hasOwnProperty,ve={};!function(e,t){for(var r in t)le(e,r,{get:t[r],enumerable:!0})}(ve,{SourceBrowser:function(){return Ue},createTagger:function(){return ue},default:function(){return De},getAllEvents:function(){return S},getEvents:function(){return j},getGlobals:function(){return O},sourceBrowser:function(){return We}});var ge,ye,_e=Object.getOwnPropertyNames,be=(e={"package.json":function(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[_e(e)[0]])((t={exports:{}}).exports,t),t.exports}),he={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}},me={merge:!0,shallow:!0,extend:!0},we=(be().version,Object.getOwnPropertyNames),ke=(ge={"package.json":function(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"}}}),Se=function(){var e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)},je=function(e,t){var r=(null==t?void 0:t.push)||Se,n={};return e.id&&(n.session=e.id),e.storage&&e.device&&(n.device=e.device),r("walker user",n),e.isStart&&r({event:"session start",data:e}),e};function Oe(e,t,n,o){var i=p(t,w(e));if(!i||o&&!o[i])return null;var a=[t],c="[".concat(w(e,i),"],[").concat(w(e,""),"]"),s=w(e,ke.Commands.Link,!1),u={},l=[],f=_sliced_to_array(E(n||t,c,e,i),2),d=f[0],v=f[1];P(t,"[".concat(s,"]"),function(t){var r=_sliced_to_array(U(p(t,s)),2),n=r[0];"parent"===r[1]&&P(document.body,"[".concat(s,'="').concat(n,':child"]'),function(t){a.push(t);var r=Oe(e,t);r&&l.push(r)})});var g=[];a.forEach(function(e){e.matches(c)&&g.push(e),P(e,c,function(e){return g.push(e)})});var y={};return g.forEach(function(t){y=r(y,k(e,t,"")),u=r(u,k(e,t,i))}),u=r(r(y,u),d),a.forEach(function(t){P(t,"[".concat(w(e),"]"),function(t){var r=Oe(e,t);r&&l.push(r)})}),{type:i,data:u,context:v,nested:l}}var xe,Ce,Ae=new WeakMap,Ee=new WeakMap,Pe=performance.now(),Le=[],Ie={Click:"click",Custom:"custom",Hover:"hover",Load:"load",Pulse:"pulse",Scroll:"scroll",Submit:"submit",Visible:"visible",Visibles:"visibles",Wait:"wait"},Ue={},We=function(e,t){return _async_to_generator(function(){var r,n,o,i,a,s;return _ts_generator(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),r=_object_spread_props(_object_spread({},t),{settings:se(t.settings)}),n={type:"browser",config:r,collector:e,destroy:function(){T(e)}},!1!==r.settings.elbLayer&&function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.name||"elbLayer";window[r]||(window[r]=[]);var n=window[r];n.push=function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];if(ie(n[0])){var i=_to_consumable_array(Array.from(n[0])),a=Array.prototype.push.apply(this,[i]);return oe(e,t.prefix,i),a}var c=Array.prototype.push.apply(this,n);return n.forEach(function(r){oe(e,t.prefix,r)}),c},Array.isArray(n)&&n.length>0&&re(e,t.prefix,n)}(e,{name:c(r.settings.elbLayer)?r.settings.elbLayer:"elbLayer",prefix:r.settings.prefix}),r.settings.session&&(o="boolean"==typeof r.settings.session?{}:r.settings.session,ce(e,{config:o})),[4,V(J,e,r.settings)];case 1:return u.sent(),i=function(e){if(function(e,t){var r=t.prefix,n=t.scope;K(e,r,n)}(e,r.settings),r.settings.pageview){var t=_sliced_to_array(function(e,t){var r=window.location,n="page",o=t===document?document.body:t,i=_sliced_to_array(E(o,"[".concat(w(e,n),"]"),e,n),2),a=i[0],c=i[1];return a.domain=r.hostname,a.title=document.title,a.referrer=document.referrer,r.search&&(a.search=r.search),r.hash&&(a.hash=r.hash),[a,c]}(r.settings.prefix||"data-elb",r.settings.scope),2),n=t[0],o=t[1];M(e,"page view",n,Ie.Load,o)}},[4,e.push("walker on","run",i)];case 2:return u.sent(),a=e._destroy,e._destroy=function(){var e;null===(e=n.destroy)||void 0===e||e.call(n),a&&a()},s=function(){for(var t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];var i=_sliced_to_array(n,6),a=i[0],c=i[1],s=i[2],u=i[3],l=i[4],f=i[5];return M(e,r.settings.prefix,a,c,s,u,l,f)},c(r.settings.elb)&&(window[r.settings.elb]=s),[2,{source:n,elb:s}];case 3:throw u.sent();case 4:return[2]}})})()},De=We;return Ce=ve,function(e,t,r,n){if(t&&"object"===(void 0===t?"undefined":_type_of(t))||"function"==typeof t){var o=!0,i=!1,a=void 0;try{for(var c,s=function(){var o=c.value;pe.call(e,o)||o===r||le(e,o,{get:function(){return t[o]},enumerable:!(n=fe(t,o))||n.enumerable})},u=de(t)[Symbol.iterator]();!(o=(c=u.next()).done);o=!0)s()}catch(e){i=!0,a=e}finally{try{o||null==u.return||u.return()}finally{if(i)throw a}}}return e}(le({},"__esModule",{value:!0}),Ce)}();
|
|
1
|
+
"use strict";function _array_like_to_array(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function _array_with_holes(e){if(Array.isArray(e))return e}function _array_without_holes(e){if(Array.isArray(e))return _array_like_to_array(e)}function asyncGeneratorStep(e,t,n,r,o,i,a){try{var c=e[i](a),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,o)}function _async_to_generator(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){asyncGeneratorStep(i,r,o,a,c,"next",e)}function c(e){asyncGeneratorStep(i,r,o,a,c,"throw",e)}a(void 0)})}}function _define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function _iterable_to_array(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _iterable_to_array_limit(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i=[],a=!0,c=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(c)throw o}}return i}}function _non_iterable_rest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _non_iterable_spread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _object_spread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){_define_property(e,t,n[t])})}return e}function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function _sliced_to_array(e,t){return _array_with_holes(e)||_iterable_to_array_limit(e,t)||_unsupported_iterable_to_array(e,t)||_non_iterable_rest()}function _to_array(e){return _array_with_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_rest()}function _to_consumable_array(e){return _array_without_holes(e)||_iterable_to_array(e)||_unsupported_iterable_to_array(e)||_non_iterable_spread()}function _type_of(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function _unsupported_iterable_to_array(e,t){if(e){if("string"==typeof e)return _array_like_to_array(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_array_like_to_array(e,t):void 0}}function _ts_generator(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=t.call(e,i)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}var Source=function(){var e,t,n=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n=_object_spread({},he,n);var r=Object.entries(t).reduce(function(t,r){var o=_sliced_to_array(r,2),i=o[0],a=o[1],c=e[i];return n.merge&&Array.isArray(c)&&Array.isArray(a)?t[i]=a.reduce(function(e,t){return e.includes(t)?e:_to_consumable_array(e).concat([t])},_to_consumable_array(c)):(n.extend||i in e)&&(t[i]=a),t},{});return n.shallow?_object_spread({},e,r):(Object.assign(e,r),e)},r=function(e){return Array.isArray(e)},o=function(e){return void 0!==e},i=function(e){return e===document||_instanceof(e,Element)},a=function(e){return"object"==(void 0===e?"undefined":_type_of(e))&&null!==e&&!r(e)&&"[object Object]"===Object.prototype.toString.call(e)},c=function(e){return"string"==typeof e},s=function(e){if("true"===e)return!0;if("false"===e)return!1;var t=Number(e);return e==t&&""!==e?t:String(e)},l=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6,t="";t.length<e;)t+=(36*Math.random()|0).toString(36);return t},u=function(e,t,n){return function(){for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];try{return e.apply(void 0,_to_consumable_array(o))}catch(e){if(!t)return;return t(e)}finally{null==n||n()}}},f=function(e){return e?e.trim().replace(/^'|'$/g,"").trim():""},d=function(e,t,n,r){var o,i,a,c=n||[];if(n||(c=e.on[t]||[],Object.values(e.destinations).forEach(function(e){var n,r=null===(n=e.config.on)||void 0===n?void 0:n[t];r&&(c=c.concat(r))})),c.length)switch(t){case ke.Commands.Consent:o=e,i=c,a=r||o.consent,i.forEach(function(e){Object.keys(a).filter(function(t){return t in e}).forEach(function(t){u(e[t])(o,a)})});break;case ke.Commands.Ready:case ke.Commands.Run:!function(e,t){e.allowed&&t.forEach(function(t){u(t)(e)})}(e,c);break;case ke.Commands.Session:!function(e,t){e.session&&t.forEach(function(t){u(t)(e,e.session)})}(e,c)}},p=function(e,t){return(e.getAttribute(t)||"").trim()},g=function(e){var t,n=getComputedStyle(e);if("none"===n.display)return!1;if("visible"!==n.visibility)return!1;if(n.opacity&&Number(n.opacity)<.1)return!1;var r=window.innerHeight,o=e.getBoundingClientRect(),i=o.height,a=o.y,c=a+i,s={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(s.x<0)return!1;if(s.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(s.y<0)return!1;if(s.y>(document.documentElement.clientHeight||window.innerHeight))return!1;t=document.elementFromPoint(s.x,s.y)}else{var l=r/2;if(a<0&&c<l)return!1;if(c>r&&a>l)return!1;t=document.elementFromPoint(s.x,r/2)}if(t)do{if(t===e)return!0}while(t=t.parentElement);return!1},v=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.cb,n=e.consent,i=e.collector,a=e.storage,c=(null==i?void 0:i.push)||Se;if(!n)return y((a?m:h)(e),i,t);var s,l,u,f=(s=e,l=t,function(e,t){if(!o(u)||u!==(null==e?void 0:e.group)){u=null==e?void 0:e.group;var n=function(){return h(s)};return s.consent&&function(e){var t=_object_spread({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}),n={},r=void 0===e;return Object.keys(t).forEach(function(o){t[o]&&(n[o]=!0,e&&e[o]&&(r=!0))}),!!r&&n}((r(s.consent)?s.consent:[s.consent]).reduce(function(e,t){return _object_spread_props(_object_spread({},e),_define_property({},t,!0))},{}),t)&&(n=function(){return m(s)}),y(n(),e,l)}});c("walker on","consent",(r(n)?n:[n]).reduce(function(e,t){return _object_spread_props(_object_spread({},e),_define_property({},t,f))},{}))},y=function(e,t,n){return!1===n?e:(n||(n=je),n(e,t,je))},_=function(e){var t,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:me.Utils.Storage.Session;function o(e){try{return JSON.parse(e||"")}catch(r){var t=1,n="";return e&&(t=0,n=e),{e:t,v:n}}}switch(r){case me.Utils.Storage.Cookie:var i;t=decodeURIComponent((null===(i=document.cookie.split("; ").find(function(t){return t.startsWith(e+"=")}))||void 0===i?void 0:i.split("=")[1])||"");break;case me.Utils.Storage.Local:n=o(window.localStorage.getItem(e));break;case me.Utils.Storage.Session:n=o(window.sessionStorage.getItem(e))}return n&&(t=n.v,0!=n.e&&n.e<Date.now()&&(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:me.Utils.Storage.Session;switch(t){case me.Utils.Storage.Cookie:b(e,"",0,t);break;case me.Utils.Storage.Local:window.localStorage.removeItem(e);break;case me.Utils.Storage.Session:window.sessionStorage.removeItem(e)}}(e,r),t="")),s(t||"")},b=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:me.Utils.Storage.Session,o=arguments.length>4?arguments[4]:void 0,i={e:Date.now()+6e4*n,v:String(t)},a=JSON.stringify(i);switch(r){case me.Utils.Storage.Cookie:t="object"==(void 0===t?"undefined":_type_of(t))?JSON.stringify(t):t;var c="".concat(e,"=").concat(encodeURIComponent(t),"; max-age=").concat(60*n,"; path=/; SameSite=Lax; secure");o&&(c+="; domain="+o),document.cookie=c;break;case me.Utils.Storage.Local:window.localStorage.setItem(e,a);break;case me.Utils.Storage.Session:window.sessionStorage.setItem(e,a)}return _(e,r)},m=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Date.now(),n=e.length,r=void 0===n?30:n,o=e.deviceKey,i=void 0===o?"elbDeviceId":o,a=e.deviceStorage,c=void 0===a?"local":a,s=e.deviceAge,f=void 0===s?30:s,d=e.sessionKey,p=void 0===d?"elbSessionId":d,g=e.sessionStorage,v=void 0===g?"local":g,y=e.pulse,m=void 0!==y&&y,w=h(e),k=!1,S=u(function(e,t,n){var r=_(e,n);return r||(r=l(8),b(e,r,1440*t,n)),String(r)})(i,f,c),j=u(function(e,n){var o=JSON.parse(String(_(e,n)));return m||(o.isNew=!1,w.marketing&&(Object.assign(o,w),k=!0),k||o.updated+6e4*r<t?(delete o.id,delete o.referrer,o.start=t,o.count++,o.runs=1,k=!0):o.runs++),o},function(){k=!0})(p,v)||{},O={id:l(12),start:t,isNew:!0,count:1,runs:1},x=Object.assign(O,w,j,{device:S},{isStart:k,storage:!0,updated:t},e.data);return b(p,JSON.stringify(x),2*r,v),x},h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.isStart||!1,r={isStart:t,storage:!1};if(!1===e.isStart)return r;if(!t&&"navigate"!==_sliced_to_array(performance.getEntriesByType("navigation"),1)[0].type)return r;var o=new URL(e.url||window.location.href),i=e.referrer||document.referrer,a=i&&new URL(i).hostname,c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="clickId",o={},i={utm_campaign:"campaign",utm_content:"content",utm_medium:"medium",utm_source:"source",utm_term:"term",dclid:r,fbclid:r,gclid:r,msclkid:r,ttclid:r,twclid:r,igshid:r,sclid:r};return Object.entries(n(i,t)).forEach(function(t){var n=_sliced_to_array(t,2),i=n[0],a=n[1],c=e.searchParams.get(i);c&&(a===r&&(a=i,o[r]=i),o[a]=c)}),o}(o,e.parameters);if(Object.keys(c).length&&(c.marketing||(c.marketing=!0),t=!0),!t){var s=e.domains||[];s.push(o.hostname),t=!s.includes(a)}return t?Object.assign({isStart:t,storage:!1,start:Date.now(),id:l(12),referrer:a},c,e.data):r},w=function(e,t){return e+(t=null!=t?(!(arguments.length>2&&void 0!==arguments[2])||arguments[2]?"-":"")+t:"")},k=function(e,t,n){var o=p(t,w(e,n,!(arguments.length>3&&void 0!==arguments[3])||arguments[3]))||"";return I(o).reduce(function(e,n){var o=_sliced_to_array(U(n),2),i=o[0],a=o[1];if(!i)return e;if(a||(i.endsWith(":")&&(i=i.slice(0,-1)),a=""),a.startsWith("#")){a=a.slice(1);try{var c=t[a];c||"selected"!==a||(c=t.options[t.selectedIndex].text),a=String(c)}catch(e){a=""}}return i.endsWith("[]")?(i=i.slice(0,-2),r(e[i])||(e[i]=[]),e[i].push(s(a))):e[i]=s(a),e},{})},S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ke.Commands.Prefix,n=[],r=ke.Commands.Action,o="[".concat(w(t,r,!1),"]"),i=function(e){Object.keys(k(t,e,r,!1)).forEach(function(r){n=n.concat(j(e,r,t))})};return e!==document&&e.matches(o)&&i(e),P(e,o,i),n},j=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:ke.Commands.Prefix,r=[],o=L(n,e,t),i=o.actions,a=o.nearestOnly;return i.length?(i.forEach(function(o){var i=I(o.actionParams||"",",").reduce(function(e,t){return e[f(t)]=!0,e},{}),c=C(n,e,i,a);if(!c.length){var s="page",l="[".concat(w(n,s),"]"),u=_sliced_to_array(E(e,l,n,s),2),d=u[0],p=u[1];c.push({entity:s,data:d,nested:[],context:p})}c.forEach(function(e){r.push({entity:e.entity,action:o.action,data:e.data,trigger:t,context:e.context,nested:e.nested})})}),r):r},O=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ke.Commands.Prefix,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document,r=w(e,ke.Commands.Globals,!1),o="[".concat(r,"]"),i={};return P(t,o,function(t){i=n(i,k(e,t,ke.Commands.Globals,!1))}),i},x=function(e){var t={};return I(e).forEach(function(e){var n=_sliced_to_array(U(e),2),r=n[0],o=n[1],i=_sliced_to_array(W(r),2),a=i[0],c=i[1];if(a){var s=_sliced_to_array(W(o||""),2),l=s[0],u=s[1];l=l||a,t[a]||(t[a]=[]),t[a].push({trigger:a,triggerParams:c,action:l,actionParams:u})}}),t},C=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=[],i=t;for(n=0!==Object.keys(n||{}).length?n:void 0;i;){var a=Oe(e,i,t,n);if(a&&(o.push(a),r))break;i=A(e,i)}return o},A=function(e,t){var n=w(e,ke.Commands.Link,!1);if(t.matches("[".concat(n,"]"))){var r=_sliced_to_array(U(p(t,n)),2),o=r[0];if("child"===r[1])return document.querySelector("[".concat(n,'="').concat(o,':parent"]'))}return!t.parentElement&&t.getRootNode&&_instanceof(t.getRootNode(),ShadowRoot)?t.getRootNode().host:t.parentElement},E=function(e,t,r,o){for(var i={},a={},c=e,s="[".concat(w(r,ke.Commands.Context,!1),"]"),l=0;c;)c.matches(t)&&(i=n(k(r,c,""),i),i=n(k(r,c,o),i)),c.matches(s)&&(Object.entries(k(r,c,ke.Commands.Context,!1)).forEach(function(e){var t=_sliced_to_array(e,2),n=t[0],r=t[1];r&&!a[n]&&(a[n]=[r,l])}),++l),c=A(r,c);return[i,a]},P=function(e,t,n){e.querySelectorAll(t).forEach(n)},L=function(e,t,n){for(var r=t;r;){var o=p(r,w(e,ke.Commands.Actions,!1));if(o){var i=x(o);if(i[n])return{actions:i[n],nearestOnly:!1}}var a=p(r,w(e,ke.Commands.Action,!1));if(a){var c=x(a);if(c[n]||"click"!==n)return{actions:c[n]||[],nearestOnly:!0}}r=A(e,r)}return{actions:[],nearestOnly:!1}},I=function(e){if(!e)return[];var t=new RegExp("(?:[^".concat(arguments.length>1&&void 0!==arguments[1]?arguments[1]:";","']+|'[^']*')+"),"ig");return e.match(t)||[]},U=function(e){var t=_sliced_to_array(e.split(/:(.+)/,2),2),n=t[0],r=t[1];return[f(n),f(r)]},W=function(e){var t=_sliced_to_array(e.split("(",2),2),n=t[0],r=t[1];return[n,r?r.slice(0,-1):""]},D=function(e){var t=Date.now(),n=Ee.get(e);return(!n||t-n.lastChecked>500)&&(n={isVisible:g(e),lastChecked:t},Ee.set(e,n)),n.isVisible},R=function(e){if(window.IntersectionObserver)return u(function(){return new window.IntersectionObserver(function(t){t.forEach(function(t){H(e,t)})},{rootMargin:"0px",threshold:[0,.5]})},function(){})()},H=function(e,t){var n,r=t.target,o=e._visibilityState;if(o){var i=o.timers.get(r);if(t.intersectionRatio>0){var a=Date.now(),c=Ae.get(r);if((!c||a-c.lastChecked>1e3)&&(c={isLarge:r.offsetHeight>window.innerHeight,lastChecked:a},Ae.set(r,c)),t.intersectionRatio>=.5||c.isLarge&&D(r)){var s,l=null===(s=o.elementConfigs)||void 0===s?void 0:s.get(r);if((null==l?void 0:l.multiple)&&l.blocked)return;if(!i){var u=window.setTimeout(function(){return _async_to_generator(function(){var t,n,i,a;return _ts_generator(this,function(c){switch(c.label){case 0:return D(r)?(null==(i=null===(t=o.elementConfigs)||void 0===t?void 0:t.get(r))?void 0:i.context)?[4,q(i.context,r,i.trigger)]:[3,2]:[3,3];case 1:c.sent(),c.label=2;case 2:(null==(a=null===(n=o.elementConfigs)||void 0===n?void 0:n.get(r))?void 0:a.multiple)?a.blocked=!0:function(e,t){var n=e._visibilityState;if(n){n.observer&&n.observer.unobserve(t);var r=n.timers.get(t);r&&(clearTimeout(r),n.timers.delete(t)),Ae.delete(t),Ee.delete(t)}}(e,r),c.label=3;case 3:return[2]}})})()},o.duration);o.timers.set(r,u)}return}}i&&(clearTimeout(i),o.timers.delete(r));var f=null===(n=o.elementConfigs)||void 0===n?void 0:n.get(r);(null==f?void 0:f.multiple)&&(f.blocked=!1)}},N=function(e,t){var n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{multiple:!1},o=e.collector._visibilityState;(null==o?void 0:o.observer)&&t&&(o.elementConfigs||(o.elementConfigs=new WeakMap),o.elementConfigs.set(t,{multiple:null!==(n=r.multiple)&&void 0!==n&&n,blocked:!1,context:e,trigger:r.multiple?"visible":"impression"}),o.observer.observe(t))},T=function(e){var t=e._visibilityState;t&&(t.observer&&t.observer.disconnect(),delete e._visibilityState)},M=function(e,t,n,r,o,s,l){var u=e.collector,f=e.settings;if(c(t)&&t.startsWith("walker "))return u.push(t,n);if(a(t)){var d=t;return d.source||(d.source=G()),u.push(d)}var p,g=_sliced_to_array(String(a(t)?t.name:t).split(" "),1)[0],v=a(n)?n:{},y={},_=!1;if(i(n)&&(p=n,_=!0),i(o)?p=o:a(o)&&Object.keys(o).length&&(y=o),p){var b=C(f.prefix||"data-elb",p).find(function(e){return e.entity===g});b&&(_&&(v=b.data),y=b.context)}"page"===g&&(v.id=v.id||window.location.pathname);var m={name:String(t||""),data:v,context:y,nested:s,custom:l,trigger:c(r)?r:"",timing:Math.round((performance.now()-Pe)/10)/100,source:G()};return u.push(m)},G=function(){return{type:"browser",id:window.location.href,previous_id:document.referrer}},J=function(e,t,n){return _async_to_generator(function(){var r;return _ts_generator(this,function(o){return r=function(){if(e(t,n),null==t?void 0:t.on)try{d(t,"ready")}catch(e){}},"loading"!==document.readyState?r():document.addEventListener("DOMContentLoaded",r),[2]})})()},B=function(e,t){K(e,t)},K=function(e,t){var n=t.scope,r={collector:e,settings:t};n.addEventListener("click",u(function(e){$.call(this,r,e)})),n.addEventListener("submit",u(function(e){Z.call(this,r,e)}))},V=function(e,t){var n=t.scope;Le=[],T(e),function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;e._visibilityState||(e._visibilityState={observer:R(e),timers:new WeakMap,duration:t})}(e,1e3);var r=w(t.prefix,ke.Commands.Action,!1),o=n||document;o!==document&&F(e,o,r,t),o.querySelectorAll("[".concat(r,"]")).forEach(function(n){F(e,n,r,t)}),Le.length&&te(e,o,t)},q=function(e,t,n){return _async_to_generator(function(){var r;return _ts_generator(this,function(o){return r=j(t,n,e.settings.prefix),[2,Promise.all(r.map(function(t){return M(e,_object_spread_props(_object_spread({name:"".concat(t.entity," ").concat(t.action)},t),{trigger:n}))}))]})})()},F=function(e,t,n,r){var o=p(t,n);if(o){var i={collector:e,settings:r};Object.values(x(o)).forEach(function(e){return e.forEach(function(e){switch(e.trigger){case Ie.Hover:Y(i,t);break;case Ie.Load:z(i,t);break;case Ie.Pulse:Q(i,t,e.triggerParams);break;case Ie.Scroll:X(t,e.triggerParams);break;case Ie.Impression:N(i,t);break;case Ie.Visible:N(i,t,{multiple:!0});break;case Ie.Wait:ee(i,t,e.triggerParams)}})})}},$=function(e,t){q(e,t.target,Ie.Click)},Y=function(e,t){t.addEventListener("mouseenter",u(function(t){_instanceof(t.target,Element)&&q(e,t.target,Ie.Hover)}))},z=function(e,t){q(e,t,Ie.Load)},Q=function(e,t){setInterval(function(){document.hidden||q(e,t,Ie.Pulse)},parseInt((arguments.length>2&&void 0!==arguments[2]?arguments[2]:"")||"")||15e3)},X=function(e){var t=parseInt((arguments.length>1&&void 0!==arguments[1]?arguments[1]:"")||"")||50;t<0||t>100||Le.push([e,t])},Z=function(e,t){t.target&&q(e,t.target,Ie.Submit)},ee=function(e,t){setTimeout(function(){return q(e,t,Ie.Wait)},parseInt((arguments.length>2&&void 0!==arguments[2]?arguments[2]:"")||"")||15e3)},te=function(e,t,n){var r={collector:e,settings:n},o=function(e,t){return e.filter(function(e){var n=_sliced_to_array(e,2),r=n[0],o=n[1],i=window.scrollY+window.innerHeight,a=r.offsetTop;if(i<a)return!0;var c=r.clientHeight;return!(100*(1-(a+c-i)/(c||1))>=o)||(q(t,r,Ie.Scroll),!1)})};xe||(xe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,n=null;return function(){for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];if(null===n)return n=setTimeout(function(){n=null},t),e.apply(void 0,_to_consumable_array(o))}}(function(){Le=o.call(t,Le,r)}),t.addEventListener("scroll",xe))},ne=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"data-elb",n=arguments.length>2?arguments[2]:void 0;re(e,t,n,!0),re(e,t,n,!1),n.length=0},re=function(e,t,n,r){var o=[],i=!0;n.forEach(function(e){var t=ie(e)?_to_consumable_array(Array.from(e)):ae(e)?Array.from(e):[e];if((!Array.isArray(t)||0!==t.length)&&(!Array.isArray(t)||1!==t.length||t[0])){var n=t[0],s=!a(n)&&c(n)&&n.startsWith("walker ");if(a(n)){if("object"===(void 0===n?"undefined":_type_of(n))&&0===Object.keys(n).length)return}else{var l=Array.from(t);if(!c(l[0])||""===l[0].trim())return;i&&"walker run"===l[0]&&(i=!1)}(r&&s||!r&&!s)&&o.push(t)}}),o.forEach(function(n){oe(e,t,n)})},oe=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"data-elb",n=arguments.length>2?arguments[2]:void 0;u(function(){if(Array.isArray(n)){var r=_to_array(n),o=r[0],i=r.slice(1);if(!o||c(o)&&""===o.trim())return;if(c(o)&&o.startsWith("walker "))return void e.push(o,i[0]);M.apply(void 0,[{collector:e,settings:{prefix:t,scope:document,pageview:!1,session:!1,elb:"",elbLayer:!1}},o].concat(_to_consumable_array(i)))}else if(n&&"object"===(void 0===n?"undefined":_type_of(n))){if(0===Object.keys(n).length)return;e.push(n)}},function(){})()},ie=function(e){return null!=e&&"object"===(void 0===e?"undefined":_type_of(e))&&"[object Arguments]"===Object.prototype.toString.call(e)},ae=function(e){return null!=e&&"object"===(void 0===e?"undefined":_type_of(e))&&"length"in e&&"number"==typeof e.length},ce=function(e){var t,r,o,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=i.config||{},c=n(e.config.sessionStatic||{},i.data||{}),s=(t=v,r="SessionStart",o=e.hooks,function(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];var a,c="post"+r,s=o["pre"+r],l=o[c];return a=s?s.apply(void 0,[{fn:t}].concat(_to_consumable_array(n))):t.apply(void 0,_to_consumable_array(n)),l&&(a=l.apply(void 0,[{fn:t,result:a}].concat(_to_consumable_array(n)))),a})(_object_spread_props(_object_spread({},a),{cb:function(e,t,n){var r,o=a;return!1!==o.cb&&o.cb?r=o.cb(e,t,n):!1!==o.cb&&(r=n(e,t,n)),t&&(t.session=e,d(t,"session")),r},data:c,collector:e}));return s},se=function(){return _object_spread({prefix:"data-elb",pageview:!0,session:!0,elb:"elb",elbLayer:"elbLayer",scope:document},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})},le=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).prefix||"data-elb";return function(t){var n=void 0,r=t,i={},a={},s={},l={},u={},f={};function d(e){return Object.entries(e).map(function(e){var t=_sliced_to_array(e,2),n=t[0],r=t[1];return"".concat(n,":").concat(function(e){if(!o(e)||null===e)return"undefined";var t=String(e);return(t=(t=(t=t.replace(/\\/g,"\\\\")).replace(/;/g,"\\;")).replace(/:/g,"\\:")).replace(/'/g,"\\'")}(r))}).join(";")}var p={entity:function(e){return n=e,r=e,p},data:function(e,t){var n=null!=r?r:"";return i[n]||(i[n]={}),c(e)?i[n][e]=t:Object.assign(i[n],e),p},action:function(e,t){if(c(e))if(o(t))a[e]=t;else if(e.includes(":")){var n=_sliced_to_array(e.split(":",2),2),r=n[0],i=n[1];a[r]=i}else a[e]=e;else Object.assign(a,e);return p},actions:function(e,t){if(c(e))if(o(t))s[e]=t;else if(e.includes(":")){var n=_sliced_to_array(e.split(":",2),2),r=n[0],i=n[1];s[r]=i}else s[e]=e;else Object.assign(s,e);return p},context:function(e,t){return c(e)?l[e]=t:Object.assign(l,e),p},globals:function(e,t){return c(e)?u[e]=t:Object.assign(u,e),p},link:function(e,t){return c(e)?f[e]=t:Object.assign(f,e),p},get:function(){var t={};return n&&(t[e]=n),Object.entries(i).forEach(function(n){var r=_sliced_to_array(n,2),o=r[0],i=r[1];if(Object.keys(i).length>0){var a=o?"".concat(e,"-").concat(o):"".concat(e,"-");t[a]=d(i)}}),Object.keys(a).length>0&&(t["".concat(e,"action")]=d(a)),Object.keys(s).length>0&&(t["".concat(e,"actions")]=d(s)),Object.keys(l).length>0&&(t["".concat(e,"context")]=d(l)),Object.keys(u).length>0&&(t["".concat(e,"globals")]=d(u)),Object.keys(f).length>0&&(t["".concat(e,"link")]=d(f)),t}};return p}},ue=Object.defineProperty,fe=Object.getOwnPropertyDescriptor,de=Object.getOwnPropertyNames,pe=Object.prototype.hasOwnProperty,ge={};!function(e,t){for(var n in t)ue(e,n,{get:t[n],enumerable:!0})}(ge,{SourceBrowser:function(){return Ue},createTagger:function(){return le},default:function(){return De},getAllEvents:function(){return S},getEvents:function(){return j},getGlobals:function(){return O},sourceBrowser:function(){return We}});var ve,ye,_e=Object.getOwnPropertyNames,be=(e={"package.json":function(e,t){t.exports={name:"@walkeros/core",description:"Core types and platform-agnostic utilities for walkerOS",version:"0.1.0",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[_e(e)[0]])((t={exports:{}}).exports,t),t.exports}),me={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}},he={merge:!0,shallow:!0,extend:!0},we=(be().version,Object.getOwnPropertyNames),ke=(ve={"package.json":function(e,t){t.exports={name:"@walkeros/collector",description:"Unified platform-agnostic collector for walkerOS",version:"0.1.0",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.0"},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"}}}),Se=function(){var e=window;(e.elbLayer=e.elbLayer||[]).push(arguments)},je=function(e,t){var n=(null==t?void 0:t.push)||Se,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 Oe(e,t,r,o){var i=p(t,w(e));if(!i||o&&!o[i])return null;var a=[t],c="[".concat(w(e,i),"],[").concat(w(e,""),"]"),s=w(e,ke.Commands.Link,!1),l={},u=[],f=_sliced_to_array(E(r||t,c,e,i),2),d=f[0],g=f[1];P(t,"[".concat(s,"]"),function(t){var n=_sliced_to_array(U(p(t,s)),2),r=n[0];"parent"===n[1]&&P(document.body,"[".concat(s,'="').concat(r,':child"]'),function(t){a.push(t);var n=Oe(e,t);n&&u.push(n)})});var v=[];a.forEach(function(e){e.matches(c)&&v.push(e),P(e,c,function(e){return v.push(e)})});var y={};return v.forEach(function(t){y=n(y,k(e,t,"")),l=n(l,k(e,t,i))}),l=n(n(y,l),d),a.forEach(function(t){P(t,"[".concat(w(e),"]"),function(t){var n=Oe(e,t);n&&u.push(n)})}),{entity:i,data:l,context:g,nested:u}}var xe,Ce,Ae=new WeakMap,Ee=new WeakMap,Pe=performance.now(),Le=[],Ie={Click:"click",Custom:"custom",Hover:"hover",Load:"load",Pulse:"pulse",Scroll:"scroll",Submit:"submit",Impression:"impression",Visible:"visible",Wait:"wait"},Ue={},We=function(e,t){return _async_to_generator(function(){var n,r,o,i,a,s;return _ts_generator(this,function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),n=_object_spread_props(_object_spread({},t),{settings:se(t.settings)}),r={type:"browser",config:n,collector:e,destroy:function(){T(e)}},!1!==n.settings.elbLayer&&function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.name||"elbLayer";window[n]||(window[n]=[]);var r=window[n];r.push=function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];if(ie(r[0])){var i=_to_consumable_array(Array.from(r[0])),a=Array.prototype.push.apply(this,[i]);return oe(e,t.prefix,i),a}var c=Array.prototype.push.apply(this,r);return r.forEach(function(n){oe(e,t.prefix,n)}),c},Array.isArray(r)&&r.length>0&&ne(e,t.prefix,r)}(e,{name:c(n.settings.elbLayer)?n.settings.elbLayer:"elbLayer",prefix:n.settings.prefix}),n.settings.session&&(o="boolean"==typeof n.settings.session?{}:n.settings.session,ce(e,{config:o})),[4,J(B,e,n.settings)];case 1:return l.sent(),i=function(e){if(function(e,t){V(e,t)}(e,n.settings),n.settings.pageview){var t=_sliced_to_array(function(e,t){var n=window.location,r="page",o=t===document?document.body:t,i=_sliced_to_array(E(o,"[".concat(w(e,r),"]"),e,r),2),a=i[0],c=i[1];return a.domain=n.hostname,a.title=document.title,a.referrer=document.referrer,n.search&&(a.search=n.search),n.hash&&(a.hash=n.hash),[a,c]}(n.settings.prefix||"data-elb",n.settings.scope),2),r=t[0],o=t[1];M({collector:e,settings:n.settings},"page view",r,Ie.Load,o)}},[4,e.push("walker on","run",i)];case 2:return l.sent(),a=e._destroy,e._destroy=function(){var e;null===(e=r.destroy)||void 0===e||e.call(r),a&&a()},s=function(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];var i=_sliced_to_array(r,6),a=i[0],c=i[1],s=i[2],l=i[3],u=i[4],f=i[5];return M({collector:e,settings:n.settings},a,c,s,l,u,f)},c(n.settings.elb)&&(window[n.settings.elb]=s),[2,{source:r,elb:s}];case 3:throw l.sent();case 4:return[2]}})})()},De=We;return Ce=ge,function(e,t,n,r){if(t&&"object"===(void 0===t?"undefined":_type_of(t))||"function"==typeof t){var o=!0,i=!1,a=void 0;try{for(var c,s=function(){var o=c.value;pe.call(e,o)||o===n||ue(e,o,{get:function(){return t[o]},enumerable:!(r=fe(t,o))||r.enumerable})},l=de(t)[Symbol.iterator]();!(o=(c=l.next()).done);o=!0)s()}catch(e){i=!0,a=e}finally{try{o||null==l.return||l.return()}finally{if(i)throw a}}}return e}(ue({},"__esModule",{value:!0}),Ce)}();
|