@walkeros/core 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +17 -9
- package/dist/index.d.ts +17 -9
- 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 +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={},t={},n={},o={},r={},i={},s={},c={},a={},u={},l={},p={},d={},f={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function g(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}var m={merge:!0,shallow:!0,extend:!0};function y(e,t={},n={}){n={...m,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function h(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function b(e){return Array.isArray(e)}function w(e){return"boolean"==typeof e}function v(e){return"walker"===e}function x(e){return void 0!==e}function j(e){return e===document||e instanceof Element}function O(e){return"function"==typeof e}function k(e){return"number"==typeof e&&!Number.isNaN(e)}function S(e){return"object"==typeof e&&null!==e&&!b(e)&&"[object Object]"===Object.prototype.toString.call(e)}function E(e,t){return typeof e==typeof t}function A(e){return"string"==typeof e}function P(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=P(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(P(e,t))}),n}if("[object Date]"===n)return new Date(e.getTime());if("[object RegExp]"===n){const t=e;return new RegExp(t.source,t.flags)}return e}function $(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&b(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=$(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,!r)break}return x(r)?r:n}function M(e,t,n){if(!S(e))return e;const o=P(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}function N(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function T(e,t={},n={}){const o={...t,...n},r={};let i=void 0===e;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function I(e,t){const n={...e};return n.config=y(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=y(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=y(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function C(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",o=e.count||1,r=y({name:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{entity:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:`${t}-${n}-${o}`,trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,group:n,count:o,version:{source:"0.3.1",tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.name){const[t,n]=e.name.split(" ")??[];t&&n&&(r.entity=t,r.action=n)}return r}function _(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),o={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},r={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return C({...{"cart view":{data:{currency:"EUR",value:2*o.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...o.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:o.data.price+r.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...o,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...r,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"product",...r,context:{shopping:["complete",0]},nested:[]},{entity:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.elbwalker.com/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...o,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...o,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...o.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:n,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,name:e})}function D(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function K(e,t={}){const n="clickId",o={},r={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(y(r,t)).forEach(([t,r])=>{const i=e.searchParams.get(t);i&&(r===n&&(r=t,o[n]=t),o[r]=i)}),o}function L(e,t=1e3,n=!1){let o,r=null,i=!1;return(...s)=>new Promise(c=>{const a=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...s),c(o))},t),a&&(i=!0,o=e(...s),c(o))})}function R(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}function V(e){return w(e)||A(e)||k(e)||!x(e)||b(e)&&e.every(V)||S(e)&&Object.values(e).every(V)}function z(e){return w(e)||A(e)||k(e)?e:h(e)?z(Array.from(e)):b(e)?e.map(e=>z(e)).filter(e=>void 0!==e):S(e)?Object.entries(e).reduce((e,[t,n])=>{const o=z(n);return void 0!==o&&(e[t]=o),e},{}):void 0}function H(e){return V(e)?e:void 0}function U(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function W(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}async function q(e,t){const[n,o]=(e.name||"").split(" ");if(!t||!n||!o)return{};let r,i="",s=n,c=o;const a=t=>{if(t)return(t=b(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[s]||(s="*");const u=t[s];return u&&(u[c]||(c="*"),r=a(u[c])),r||(s="*",c="*",r=a(t[s]?.[c])),r&&(i=`${s} ${c}`),{eventMapping:r,mappingKey:i}}async function B(e,t={},n={}){if(!x(e))return;const o=S(e)&&e.consent||n.consent||n.collector?.consent,r=b(t)?t:[t];for(const t of r){const r=await W(F)(e,t,{...n,consent:o});if(x(r))return r}}async function F(e,t,n={}){const{collector:o,consent:r}=n;return(b(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const c=A(i)?{key:i}:i;if(!Object.keys(c).length)return;const{condition:a,consent:u,fn:l,key:p,loop:d,map:f,set:g,validate:m,value:y}=c;if(a&&!await W(a)(e,i,o))return;if(u&&!T(u,r))return y;let h=x(y)?y:e;if(l&&(h=await W(l)(e,i,n)),p&&(h=$(e,p,y)),d){const[t,o]=d,r="this"===t?[e]:await B(e,t,n);b(r)&&(h=(await Promise.all(r.map(e=>B(e,o,n)))).filter(x))}else f?h=await Object.entries(f).reduce(async(t,[o,r])=>{const i=await t,s=await B(e,r,n);return x(s)&&(i[o]=s),i},Promise.resolve({})):g&&(h=await Promise.all(g.map(t=>F(e,t,n))));m&&!await W(m)(h)&&(h=void 0);const w=H(h);return x(w)?w:H(y)},Promise.resolve(void 0))}async function X(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await B(e,o,{collector:n});e=M(e,t,r)}));const{eventMapping:o,mappingKey:r}=await q(e,t.mapping);o?.policy&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await B(e,o,{collector:n});e=M(e,t,r)}));let i=t.data&&await B(e,t.data,{collector:n});if(o){if(o.ignore)return{event:e,data:i,mapping:o,mappingKey:r,ignore:!0};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await B(e,o.data,{collector:n});i=S(i)&&S(t)?y(i,t):t}}return{event:e,data:i,mapping:o,mappingKey:r,ignore:!1}}function J(e,t){const n=(e,o=[])=>new Proxy(e,{get(e,r){const i=e[r],s=[...o,r];return"function"==typeof i?(...e)=>t(s,e,i):i&&"object"==typeof i?n(i,s):i}});return n(e)}function G(e,t){const n=(e,o=[])=>{if(!e||"object"!=typeof e)return e;const r=Array.isArray(e)?[]:{};for(const[i,s]of Object.entries(e)){const e=[...o,i];Array.isArray(r)?r[Number(i)]=t(s,e):r[i]=t(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(r)?r[Number(i)]=n(s,e):r[i]=n(s,e))}return r};return n(e)}function Q(e,t=!1){t&&console.dir(e,{depth:4})}function Y(e){const t=String(e),n=t.split("?")[1]||t;return U(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const o=n.split(/[[\]]+/).filter(Boolean);let r=t;o.forEach((t,n)=>{const i=n===o.length-1;if(b(r)){const s=parseInt(t,10);i?r[s]=N(e):(r[s]=r[s]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[s])}else S(r)&&(i?r[t]=N(e):(r[t]=r[t]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[t]))})}),t})()}function Z(e){if(!e)return"";const t=[],n=encodeURIComponent;function o(e,r){null!=r&&(b(r)?r.forEach((t,n)=>o(`${e}[${n}]`,t)):S(r)?Object.entries(r).forEach(([t,n])=>o(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(r))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>o(e,t)),t.join("&"))}function ee(e){return void 0===e||E(e,"")?e:JSON.stringify(e)}function te(e={}){return y({"Content-Type":"application/json; charset=utf-8"},e)}function ne(e){throw new Error(String(e))}function oe(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function re(e,t,n){return function(...o){let r;const i="post"+t,s=n["pre"+t],c=n[i];return r=s?s({fn:e},...o):e(...o),c&&(r=c({fn:e,result:r},...o)),r}}function ie(e){return e?{userAgent:e,browser:se(e),browserVersion:ce(e),os:ae(e),osVersion:ue(e),deviceType:le(e)}:{}}function se(e){const t=[{name:"Edge",substr:"Edg"},{name:"Chrome",substr:"Chrome"},{name:"Safari",substr:"Safari",exclude:"Chrome"},{name:"Firefox",substr:"Firefox"},{name:"IE",substr:"MSIE"},{name:"IE",substr:"Trident"}];for(const n of t)if(e.includes(n.substr)&&(!n.exclude||!e.includes(n.exclude)))return n.name}function ce(e){const t=[/Edg\/([0-9]+)/,/Chrome\/([0-9]+)/,/Version\/([0-9]+).*Safari/,/Firefox\/([0-9]+)/,/MSIE ([0-9]+)/,/rv:([0-9]+).*Trident/];for(const n of t){const t=e.match(n);if(t)return t[1]}}function ae(e){const t=[{name:"Windows",substr:"Windows NT"},{name:"macOS",substr:"Mac OS X"},{name:"Android",substr:"Android"},{name:"iOS",substr:"iPhone OS"},{name:"Linux",substr:"Linux"}];for(const n of t)if(e.includes(n.substr))return n.name}function ue(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function le(e){let t="Desktop";return/Tablet|iPad/i.test(e)?t="Tablet":/Mobi|Android|iPhone|iPod|BlackBerry|Opera Mini|IEMobile|WPDesktop/i.test(e)&&(t="Mobile"),t}function pe(e,t=[]){let n,o,r;E(e,{})||ne("Invalid object"),E(e.name,"")?(n=e.name,[o,r]=n.split(" "),o&&r||ne("Invalid event name")):E(e.entity,"")&&E(e.action,"")?(o=e.entity,r=e.action,n=`${o} ${r}`):ne("Missing or invalid name, entity, or action");const i={name:n,data:{},context:{},custom:{},globals:{},user:{},nested:[],consent:{},id:"",trigger:"",entity:o,action:r,timestamp:0,timing:0,group:"",count:0,version:{source:"",tagging:0},source:{type:"",id:"",previous_id:""}};return[{"*":{"*":{name:{maxLength:255},user:{allowedKeys:["id","device","session"]},consent:{allowedValues:[!0,!1]},timestamp:{min:0},timing:{min:0},count:{min:0},version:{allowedKeys:["source","tagging"]},source:{allowedKeys:["type","id","previous_id"]}}}}].concat(t).reduce((e,t)=>["*",o].reduce((e,n)=>["*",r].reduce((e,o)=>{const r=t[n]?.[o];return r?e.concat([r]):e},e),e),[]).reduce((t,n)=>{const o=Object.keys(n).filter(e=>{const t=n[e];return!0===t?.required});return[...Object.keys(e),...o].reduce((t,o)=>{const r=n[o];let i=e[o];return r&&(i=U(de,e=>{ne(String(e))})(t,o,i,r)),E(i,t[o])&&(t[o]=i),t},t)},i)}function de(e,t,n,o){if(o.validate&&(n=U(o.validate,e=>{ne(String(e))})(n,t,e)),o.required&&void 0===n&&ne("Missing required property"),E(n,""))o.maxLength&&n.length>o.maxLength&&(o.strict&&ne("Value exceeds maxLength"),n=n.substring(0,o.maxLength));else if(E(n,1))E(o.min,1)&&n<o.min?(o.strict&&ne("Value below min"),n=o.min):E(o.max,1)&&n>o.max&&(o.strict&&ne("Value exceeds max"),n=o.max);else if(E(n,{})){if(o.schema){const e=o.schema;Object.keys(e).reduce((t,n)=>{const o=e[n];let r=t[n];return o&&(o.type&&typeof r!==o.type&&ne(`Type doesn't match (${n})`),r=U(de,e=>{ne(String(e))})(t,n,r,o)),r},n)}for(const e of Object.keys(n))o.allowedKeys&&!o.allowedKeys.includes(e)&&(o.strict&&ne("Key not allowed"),delete n[e])}return n}export{e as Collector,f as Const,t as Data,n as Destination,o as Elb,r as Flow,i as Handler,s as Hooks,c as Mapping,a as On,u as Request,l as Schema,p as Source,d as WalkerOS,g as anonymizeIP,y as assign,H as castToProperty,N as castValue,P as clone,I as createDestination,C as createEvent,L as debounce,z as filterValues,se as getBrowser,ce as getBrowserVersion,$ as getByPath,le as getDeviceType,_ as getEvent,T as getGrantedConsent,te as getHeaders,D as getId,q as getMappingEvent,B as getMappingValue,K as getMarketingParameters,ae as getOS,ue as getOSVersion,h as isArguments,b as isArray,w as isBoolean,v as isCommand,x as isDefined,j as isElementOrDocument,O as isFunction,k as isNumber,S as isObject,V as isPropertyType,E as isSameType,A as isString,J as mockEnv,Q as onLog,ie as parseUserAgent,X as processEventMapping,Y as requestToData,Z as requestToParameter,M as setByPath,R as throttle,ne as throwError,ee as transformData,G as traverseEnv,oe as trim,U as tryCatch,W as tryCatchAsync,re as useHooks,pe as validateEvent,de as validateProperty};//# sourceMappingURL=index.mjs.map
|
|
1
|
+
var e={},t={},n={},o={},r={},i={},s={},c={},a={},u={},l={},p={},d={},f={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function g(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}var m={merge:!0,shallow:!0,extend:!0};function y(e,t={},n={}){n={...m,...n};const o=Object.entries(t).reduce((t,[o,r])=>{const i=e[o];return n.merge&&Array.isArray(i)&&Array.isArray(r)?t[o]=r.reduce((e,t)=>e.includes(t)?e:[...e,t],[...i]):(n.extend||o in e)&&(t[o]=r),t},{});return n.shallow?{...e,...o}:(Object.assign(e,o),e)}function h(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function b(e){return Array.isArray(e)}function w(e){return"boolean"==typeof e}function v(e){return"walker"===e}function x(e){return void 0!==e}function j(e){return e===document||e instanceof Element}function O(e){return"function"==typeof e}function k(e){return"number"==typeof e&&!Number.isNaN(e)}function S(e){return"object"==typeof e&&null!==e&&!b(e)&&"[object Object]"===Object.prototype.toString.call(e)}function E(e,t){return typeof e==typeof t}function A(e){return"string"==typeof e}function P(e,t=new WeakMap){if("object"!=typeof e||null===e)return e;if(t.has(e))return t.get(e);const n=Object.prototype.toString.call(e);if("[object Object]"===n){const n={};t.set(e,n);for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=P(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(P(e,t))}),n}if("[object Date]"===n)return new Date(e.getTime());if("[object RegExp]"===n){const t=e;return new RegExp(t.source,t.flags)}return e}function $(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&b(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=$(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,!r)break}return x(r)?r:n}function M(e,t,n){if(!S(e))return e;const o=P(e),r=t.split(".");let i=o;for(let e=0;e<r.length;e++){const t=r[e];e===r.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return o}function N(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function T(e,t={},n={}){const o={...t,...n},r={};let i=void 0===e;return Object.keys(o).forEach(t=>{o[t]&&(r[t]=!0,e&&e[t]&&(i=!0))}),!!i&&r}function I(e,t){const n={...e};return n.config=y(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=y(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=y(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function C(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",o=e.count||1,r=y({name:"entity action",data:{string:"foo",number:1,boolean:!0,array:[0,"text",!1],not:void 0},context:{dev:["test",1]},globals:{lang:"elb"},custom:{completely:"random"},user:{id:"us3r",device:"c00k13",session:"s3ss10n"},nested:[{entity:"child",data:{is:"subordinated"},nested:[],context:{element:["child",0]}}],consent:{functional:!0},id:`${t}-${n}-${o}`,trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,group:n,count:o,version:{source:"0.4.1",tagging:1},source:{type:"web",id:"https://localhost:80",previous_id:"http://remotehost:9001"}},e,{merge:!1});if(e.name){const[t,n]=e.name.split(" ")??[];t&&n&&(r.entity=t,r.action=n)}return r}function _(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),o={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},r={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return C({...{"cart view":{data:{currency:"EUR",value:2*o.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...o.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:o.data.price+r.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...o,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...r,context:{shopping:["checkout",0]},nested:[]}],trigger:"load"},"order complete":{data:{id:"0rd3r1d",currency:"EUR",shipping:5.22,taxes:73.76,total:555},context:{shopping:["complete",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...o,context:{shopping:["complete",0]},nested:[]},{entity:"product",...r,context:{shopping:["complete",0]},nested:[]},{entity:"gift",data:{name:"Surprise"},context:{shopping:["complete",0]},nested:[]}],trigger:"load"},"page view":{data:{domain:"www.example.com",title:"walkerOS documentation",referrer:"https://www.elbwalker.com/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...o,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...o,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...o.data,position:3,promo:!0},context:{shopping:["discover",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"promotion visible":{data:{name:"Setting up tracking easily",position:"hero"},context:{ab_test:["engagement",0]},globals:{pagegroup:"homepage"},trigger:"visible"},"session start":{data:{id:"s3ss10n",start:n,isNew:!0,count:1,runs:1,isStart:!0,storage:!0,referrer:"",device:"c00k13"},user:{id:"us3r",device:"c00k13",session:"s3ss10n",hash:"h4sh",address:"street number",email:"user@example.com",phone:"+49 123 456 789",userAgent:"Mozilla...",browser:"Chrome",browserVersion:"90",deviceType:"desktop",language:"de-DE",country:"DE",region:"HH",city:"Hamburg",zip:"20354",timezone:"Berlin",os:"walkerOS",osVersion:"1.0",screenSize:"1337x420",ip:"127.0.0.0",internal:!0,custom:"value"}}}[e],...t,name:e})}function D(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function K(e,t={}){const n="clickId",o={},r={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(y(r,t)).forEach(([t,r])=>{const i=e.searchParams.get(t);i&&(r===n&&(r=t,o[n]=t),o[r]=i)}),o}function L(e,t=1e3,n=!1){let o,r=null,i=!1;return(...s)=>new Promise(c=>{const a=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...s),c(o))},t),a&&(i=!0,o=e(...s),c(o))})}function R(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}function V(e){return w(e)||A(e)||k(e)||!x(e)||b(e)&&e.every(V)||S(e)&&Object.values(e).every(V)}function z(e){return w(e)||A(e)||k(e)?e:h(e)?z(Array.from(e)):b(e)?e.map(e=>z(e)).filter(e=>void 0!==e):S(e)?Object.entries(e).reduce((e,[t,n])=>{const o=z(n);return void 0!==o&&(e[t]=o),e},{}):void 0}function H(e){return V(e)?e:void 0}function U(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function W(e,t,n){return async function(...o){try{return await e(...o)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}async function q(e,t){const[n,o]=(e.name||"").split(" ");if(!t||!n||!o)return{};let r,i="",s=n,c=o;const a=t=>{if(t)return(t=b(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[s]||(s="*");const u=t[s];return u&&(u[c]||(c="*"),r=a(u[c])),r||(s="*",c="*",r=a(t[s]?.[c])),r&&(i=`${s} ${c}`),{eventMapping:r,mappingKey:i}}async function B(e,t={},n={}){if(!x(e))return;const o=S(e)&&e.consent||n.consent||n.collector?.consent,r=b(t)?t:[t];for(const t of r){const r=await W(F)(e,t,{...n,consent:o});if(x(r))return r}}async function F(e,t,n={}){const{collector:o,consent:r}=n;return(b(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const c=A(i)?{key:i}:i;if(!Object.keys(c).length)return;const{condition:a,consent:u,fn:l,key:p,loop:d,map:f,set:g,validate:m,value:y}=c;if(a&&!await W(a)(e,i,o))return;if(u&&!T(u,r))return y;let h=x(y)?y:e;if(l&&(h=await W(l)(e,i,n)),p&&(h=$(e,p,y)),d){const[t,o]=d,r="this"===t?[e]:await B(e,t,n);b(r)&&(h=(await Promise.all(r.map(e=>B(e,o,n)))).filter(x))}else f?h=await Object.entries(f).reduce(async(t,[o,r])=>{const i=await t,s=await B(e,r,n);return x(s)&&(i[o]=s),i},Promise.resolve({})):g&&(h=await Promise.all(g.map(t=>F(e,t,n))));m&&!await W(m)(h)&&(h=void 0);const w=H(h);return x(w)?w:H(y)},Promise.resolve(void 0))}async function X(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await B(e,o,{collector:n});e=M(e,t,r)}));const{eventMapping:o,mappingKey:r}=await q(e,t.mapping);o?.policy&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await B(e,o,{collector:n});e=M(e,t,r)}));let i=t.data&&await B(e,t.data,{collector:n});if(o){if(o.ignore)return{event:e,data:i,mapping:o,mappingKey:r,ignore:!0};if(o.name&&(e.name=o.name),o.data){const t=o.data&&await B(e,o.data,{collector:n});i=S(i)&&S(t)?y(i,t):t}}return{event:e,data:i,mapping:o,mappingKey:r,ignore:!1}}function J(e,t){const n=(e,o=[])=>new Proxy(e,{get(e,r){const i=e[r],s=[...o,r];return"function"==typeof i?(...e)=>t(s,e,i):i&&"object"==typeof i?n(i,s):i}});return n(e)}function G(e,t){const n=(e,o=[])=>{if(!e||"object"!=typeof e)return e;const r=Array.isArray(e)?[]:{};for(const[i,s]of Object.entries(e)){const e=[...o,i];Array.isArray(r)?r[Number(i)]=t(s,e):r[i]=t(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(r)?r[Number(i)]=n(s,e):r[i]=n(s,e))}return r};return n(e)}function Q(e,t=!1){t&&console.dir(e,{depth:4})}function Y(e){const t=String(e),n=t.split("?")[1]||t;return U(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const o=n.split(/[[\]]+/).filter(Boolean);let r=t;o.forEach((t,n)=>{const i=n===o.length-1;if(b(r)){const s=parseInt(t,10);i?r[s]=N(e):(r[s]=r[s]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[s])}else S(r)&&(i?r[t]=N(e):(r[t]=r[t]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[t]))})}),t})()}function Z(e){if(!e)return"";const t=[],n=encodeURIComponent;function o(e,r){null!=r&&(b(r)?r.forEach((t,n)=>o(`${e}[${n}]`,t)):S(r)?Object.entries(r).forEach(([t,n])=>o(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(r))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>o(e,t)),t.join("&"))}function ee(e){return void 0===e||E(e,"")?e:JSON.stringify(e)}function te(e={}){return y({"Content-Type":"application/json; charset=utf-8"},e)}function ne(e){throw new Error(String(e))}function oe(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function re(e,t,n){return function(...o){let r;const i="post"+t,s=n["pre"+t],c=n[i];return r=s?s({fn:e},...o):e(...o),c&&(r=c({fn:e,result:r},...o)),r}}function ie(e){return e?{userAgent:e,browser:se(e),browserVersion:ce(e),os:ae(e),osVersion:ue(e),deviceType:le(e)}:{}}function se(e){const t=[{name:"Edge",substr:"Edg"},{name:"Chrome",substr:"Chrome"},{name:"Safari",substr:"Safari",exclude:"Chrome"},{name:"Firefox",substr:"Firefox"},{name:"IE",substr:"MSIE"},{name:"IE",substr:"Trident"}];for(const n of t)if(e.includes(n.substr)&&(!n.exclude||!e.includes(n.exclude)))return n.name}function ce(e){const t=[/Edg\/([0-9]+)/,/Chrome\/([0-9]+)/,/Version\/([0-9]+).*Safari/,/Firefox\/([0-9]+)/,/MSIE ([0-9]+)/,/rv:([0-9]+).*Trident/];for(const n of t){const t=e.match(n);if(t)return t[1]}}function ae(e){const t=[{name:"Windows",substr:"Windows NT"},{name:"macOS",substr:"Mac OS X"},{name:"Android",substr:"Android"},{name:"iOS",substr:"iPhone OS"},{name:"Linux",substr:"Linux"}];for(const n of t)if(e.includes(n.substr))return n.name}function ue(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function le(e){let t="Desktop";return/Tablet|iPad/i.test(e)?t="Tablet":/Mobi|Android|iPhone|iPod|BlackBerry|Opera Mini|IEMobile|WPDesktop/i.test(e)&&(t="Mobile"),t}function pe(e,t=[]){let n,o,r;E(e,{})||ne("Invalid object"),E(e.name,"")?(n=e.name,[o,r]=n.split(" "),o&&r||ne("Invalid event name")):E(e.entity,"")&&E(e.action,"")?(o=e.entity,r=e.action,n=`${o} ${r}`):ne("Missing or invalid name, entity, or action");const i={name:n,data:{},context:{},custom:{},globals:{},user:{},nested:[],consent:{},id:"",trigger:"",entity:o,action:r,timestamp:0,timing:0,group:"",count:0,version:{source:"",tagging:0},source:{type:"",id:"",previous_id:""}};return[{"*":{"*":{name:{maxLength:255},user:{allowedKeys:["id","device","session"]},consent:{allowedValues:[!0,!1]},timestamp:{min:0},timing:{min:0},count:{min:0},version:{allowedKeys:["source","tagging"]},source:{allowedKeys:["type","id","previous_id"]}}}}].concat(t).reduce((e,t)=>["*",o].reduce((e,n)=>["*",r].reduce((e,o)=>{const r=t[n]?.[o];return r?e.concat([r]):e},e),e),[]).reduce((t,n)=>{const o=Object.keys(n).filter(e=>{const t=n[e];return!0===t?.required});return[...Object.keys(e),...o].reduce((t,o)=>{const r=n[o];let i=e[o];return r&&(i=U(de,e=>{ne(String(e))})(t,o,i,r)),E(i,t[o])&&(t[o]=i),t},t)},i)}function de(e,t,n,o){if(o.validate&&(n=U(o.validate,e=>{ne(String(e))})(n,t,e)),o.required&&void 0===n&&ne("Missing required property"),E(n,""))o.maxLength&&n.length>o.maxLength&&(o.strict&&ne("Value exceeds maxLength"),n=n.substring(0,o.maxLength));else if(E(n,1))E(o.min,1)&&n<o.min?(o.strict&&ne("Value below min"),n=o.min):E(o.max,1)&&n>o.max&&(o.strict&&ne("Value exceeds max"),n=o.max);else if(E(n,{})){if(o.schema){const e=o.schema;Object.keys(e).reduce((t,n)=>{const o=e[n];let r=t[n];return o&&(o.type&&typeof r!==o.type&&ne(`Type doesn't match (${n})`),r=U(de,e=>{ne(String(e))})(t,n,r,o)),r},n)}for(const e of Object.keys(n))o.allowedKeys&&!o.allowedKeys.includes(e)&&(o.strict&&ne("Key not allowed"),delete n[e])}return n}export{e as Collector,f as Const,t as Data,n as Destination,o as Elb,r as Flow,i as Handler,s as Hooks,c as Mapping,a as On,u as Request,l as Schema,p as Source,d as WalkerOS,g as anonymizeIP,y as assign,H as castToProperty,N as castValue,P as clone,I as createDestination,C as createEvent,L as debounce,z as filterValues,se as getBrowser,ce as getBrowserVersion,$ as getByPath,le as getDeviceType,_ as getEvent,T as getGrantedConsent,te as getHeaders,D as getId,q as getMappingEvent,B as getMappingValue,K as getMarketingParameters,ae as getOS,ue as getOSVersion,h as isArguments,b as isArray,w as isBoolean,v as isCommand,x as isDefined,j as isElementOrDocument,O as isFunction,k as isNumber,S as isObject,V as isPropertyType,E as isSameType,A as isString,J as mockEnv,Q as onLog,ie as parseUserAgent,X as processEventMapping,Y as requestToData,Z as requestToParameter,M as setByPath,R as throttle,ne as throwError,ee as transformData,G as traverseEnv,oe as trim,U as tryCatch,W as tryCatchAsync,re as useHooks,pe as validateEvent,de as validateProperty};//# sourceMappingURL=index.mjs.map
|