@walkeros/core 0.4.2 → 0.5.1-next.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 +45 -8
- package/dist/dev.d.mts +92 -45
- package/dist/dev.d.ts +92 -45
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/index.d.mts +24 -6
- package/dist/index.d.ts +24 -6
- 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 +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -211,6 +211,7 @@ interface Instance$2<T extends TypesGeneric$1 = Types$2> {
|
|
|
211
211
|
config: Config$5<T>;
|
|
212
212
|
queue?: Events;
|
|
213
213
|
dlq?: DLQ;
|
|
214
|
+
batches?: BatchRegistry<Mapping$1<T>>;
|
|
214
215
|
type?: string;
|
|
215
216
|
env?: Env$1<T>;
|
|
216
217
|
init?: InitFn<T>;
|
|
@@ -235,8 +236,9 @@ type PartialConfig$1<T extends TypesGeneric$1 = Types$2> = Config$5<Types$2<Part
|
|
|
235
236
|
interface Policy$1 {
|
|
236
237
|
[key: string]: Value;
|
|
237
238
|
}
|
|
239
|
+
type Code<T extends TypesGeneric$1 = Types$2> = Instance$2<T> | true;
|
|
238
240
|
type Init$1<T extends TypesGeneric$1 = Types$2> = {
|
|
239
|
-
code:
|
|
241
|
+
code: Code<T>;
|
|
240
242
|
config?: Partial<Config$5<T>>;
|
|
241
243
|
env?: Partial<Env$1<T>>;
|
|
242
244
|
};
|
|
@@ -280,6 +282,12 @@ interface Batch<Mapping> {
|
|
|
280
282
|
data: Array<Data$1>;
|
|
281
283
|
mapping?: Rule<Mapping>;
|
|
282
284
|
}
|
|
285
|
+
interface BatchRegistry<Mapping> {
|
|
286
|
+
[mappingKey: string]: {
|
|
287
|
+
batched: Batch<Mapping>;
|
|
288
|
+
batchFn: () => void;
|
|
289
|
+
};
|
|
290
|
+
}
|
|
283
291
|
type Data$1 = Property | undefined | Array<Property | undefined>;
|
|
284
292
|
type Ref = {
|
|
285
293
|
id: string;
|
|
@@ -297,6 +305,8 @@ type Result$1 = {
|
|
|
297
305
|
};
|
|
298
306
|
|
|
299
307
|
type destination_Batch<Mapping> = Batch<Mapping>;
|
|
308
|
+
type destination_BatchRegistry<Mapping> = BatchRegistry<Mapping>;
|
|
309
|
+
type destination_Code<T extends TypesGeneric$1 = Types$2> = Code<T>;
|
|
300
310
|
type destination_DLQ = DLQ;
|
|
301
311
|
type destination_Destinations = Destinations;
|
|
302
312
|
type destination_InitContext<T extends TypesGeneric$1 = Types$2> = InitContext<T>;
|
|
@@ -310,7 +320,7 @@ type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
|
|
|
310
320
|
type destination_PushFn<T extends TypesGeneric$1 = Types$2> = PushFn<T>;
|
|
311
321
|
type destination_Ref = Ref;
|
|
312
322
|
declare namespace destination {
|
|
313
|
-
export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, Config$5 as Config, Context$2 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, Env$1 as Env, Init$1 as Init, destination_InitContext as InitContext, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, InitSettings$1 as InitSettings, Instance$2 as Instance, Mapping$1 as Mapping, PartialConfig$1 as PartialConfig, Policy$1 as Policy, Push$1 as Push, destination_PushBatchContext as PushBatchContext, destination_PushBatchFn as PushBatchFn, destination_PushContext as PushContext, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, destination_Ref as Ref, Result$1 as Result, Settings$1 as Settings, Types$2 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
|
|
323
|
+
export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, destination_BatchRegistry as BatchRegistry, destination_Code as Code, Config$5 as Config, Context$2 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, Env$1 as Env, Init$1 as Init, destination_InitContext as InitContext, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, InitSettings$1 as InitSettings, Instance$2 as Instance, Mapping$1 as Mapping, PartialConfig$1 as PartialConfig, Policy$1 as Policy, Push$1 as Push, destination_PushBatchContext as PushBatchContext, destination_PushBatchFn as PushBatchFn, destination_PushContext as PushContext, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, destination_Ref as Ref, Result$1 as Result, Settings$1 as Settings, Types$2 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
|
|
314
324
|
}
|
|
315
325
|
|
|
316
326
|
interface EventFn<R = Promise<PushResult>> {
|
|
@@ -1036,8 +1046,8 @@ interface OnConfig {
|
|
|
1036
1046
|
session?: SessionConfig[];
|
|
1037
1047
|
[key: string]: ConsentConfig[] | ReadyConfig[] | RunConfig[] | SessionConfig[] | undefined;
|
|
1038
1048
|
}
|
|
1039
|
-
type OnFn
|
|
1040
|
-
type OnFnRuntime = (
|
|
1049
|
+
type OnFn<T extends TypesGeneric$1 = Types$2> = (type: Types$1, context: Context$2<T>) => PromiseOrValue<void>;
|
|
1050
|
+
type OnFnRuntime = (type: Types$1, context: Context$2) => PromiseOrValue<void>;
|
|
1041
1051
|
|
|
1042
1052
|
type on_AnyEventContext = AnyEventContext;
|
|
1043
1053
|
type on_ConsentConfig = ConsentConfig;
|
|
@@ -1045,7 +1055,7 @@ type on_ConsentFn = ConsentFn;
|
|
|
1045
1055
|
type on_EventContext<T extends Types$1> = EventContext<T>;
|
|
1046
1056
|
type on_EventContextMap = EventContextMap;
|
|
1047
1057
|
type on_OnConfig = OnConfig;
|
|
1048
|
-
type on_OnFn = OnFn
|
|
1058
|
+
type on_OnFn<T extends TypesGeneric$1 = Types$2> = OnFn<T>;
|
|
1049
1059
|
type on_OnFnRuntime = OnFnRuntime;
|
|
1050
1060
|
type on_Options = Options;
|
|
1051
1061
|
type on_ReadyConfig = ReadyConfig;
|
|
@@ -1359,6 +1369,14 @@ declare function anonymizeIP(ip: string): string;
|
|
|
1359
1369
|
* @packageDocumentation
|
|
1360
1370
|
*/
|
|
1361
1371
|
|
|
1372
|
+
/**
|
|
1373
|
+
* Convert package name to valid JavaScript variable name.
|
|
1374
|
+
* Used for deterministic default import naming.
|
|
1375
|
+
* @example
|
|
1376
|
+
* packageNameToVariable('@walkeros/server-destination-api')
|
|
1377
|
+
* // → '_walkerosServerDestinationApi'
|
|
1378
|
+
*/
|
|
1379
|
+
declare function packageNameToVariable(packageName: string): string;
|
|
1362
1380
|
/**
|
|
1363
1381
|
* Get resolved flow configuration for a named flow.
|
|
1364
1382
|
*
|
|
@@ -2050,4 +2068,4 @@ declare function wrapFn(code: string): Fn;
|
|
|
2050
2068
|
*/
|
|
2051
2069
|
declare function wrapValidate(code: string): Validate;
|
|
2052
2070
|
|
|
2053
|
-
export { collector as Collector, Const, data as Data, destination as Destination, elb as Elb, flow as Flow, hooks as Hooks, Level, logger as Logger, mapping as Mapping, type MarketingParameters, type MockLogger, on as On, request as Request, schema as Schema, type SendDataValue, type SendHeaders, type SendResponse, source as Source, type StorageType, walkeros as WalkerOS, anonymizeIP, assign, castToProperty, castValue, clone, createDestination, createEvent, createLogger, createMockLogger, debounce, filterValues, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowConfig, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isSameType, isString, mockEnv, parseUserAgent, processEventMapping, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty, wrapCondition, wrapFn, wrapValidate };
|
|
2071
|
+
export { collector as Collector, Const, data as Data, destination as Destination, elb as Elb, flow as Flow, hooks as Hooks, Level, logger as Logger, mapping as Mapping, type MarketingParameters, type MockLogger, on as On, request as Request, schema as Schema, type SendDataValue, type SendHeaders, type SendResponse, source as Source, type StorageType, walkeros as WalkerOS, anonymizeIP, assign, castToProperty, castValue, clone, createDestination, createEvent, createLogger, createMockLogger, debounce, filterValues, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowConfig, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isSameType, isString, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty, wrapCondition, wrapFn, wrapValidate };
|
package/dist/index.d.ts
CHANGED
|
@@ -211,6 +211,7 @@ interface Instance$2<T extends TypesGeneric$1 = Types$2> {
|
|
|
211
211
|
config: Config$5<T>;
|
|
212
212
|
queue?: Events;
|
|
213
213
|
dlq?: DLQ;
|
|
214
|
+
batches?: BatchRegistry<Mapping$1<T>>;
|
|
214
215
|
type?: string;
|
|
215
216
|
env?: Env$1<T>;
|
|
216
217
|
init?: InitFn<T>;
|
|
@@ -235,8 +236,9 @@ type PartialConfig$1<T extends TypesGeneric$1 = Types$2> = Config$5<Types$2<Part
|
|
|
235
236
|
interface Policy$1 {
|
|
236
237
|
[key: string]: Value;
|
|
237
238
|
}
|
|
239
|
+
type Code<T extends TypesGeneric$1 = Types$2> = Instance$2<T> | true;
|
|
238
240
|
type Init$1<T extends TypesGeneric$1 = Types$2> = {
|
|
239
|
-
code:
|
|
241
|
+
code: Code<T>;
|
|
240
242
|
config?: Partial<Config$5<T>>;
|
|
241
243
|
env?: Partial<Env$1<T>>;
|
|
242
244
|
};
|
|
@@ -280,6 +282,12 @@ interface Batch<Mapping> {
|
|
|
280
282
|
data: Array<Data$1>;
|
|
281
283
|
mapping?: Rule<Mapping>;
|
|
282
284
|
}
|
|
285
|
+
interface BatchRegistry<Mapping> {
|
|
286
|
+
[mappingKey: string]: {
|
|
287
|
+
batched: Batch<Mapping>;
|
|
288
|
+
batchFn: () => void;
|
|
289
|
+
};
|
|
290
|
+
}
|
|
283
291
|
type Data$1 = Property | undefined | Array<Property | undefined>;
|
|
284
292
|
type Ref = {
|
|
285
293
|
id: string;
|
|
@@ -297,6 +305,8 @@ type Result$1 = {
|
|
|
297
305
|
};
|
|
298
306
|
|
|
299
307
|
type destination_Batch<Mapping> = Batch<Mapping>;
|
|
308
|
+
type destination_BatchRegistry<Mapping> = BatchRegistry<Mapping>;
|
|
309
|
+
type destination_Code<T extends TypesGeneric$1 = Types$2> = Code<T>;
|
|
300
310
|
type destination_DLQ = DLQ;
|
|
301
311
|
type destination_Destinations = Destinations;
|
|
302
312
|
type destination_InitContext<T extends TypesGeneric$1 = Types$2> = InitContext<T>;
|
|
@@ -310,7 +320,7 @@ type destination_PushEvents<Mapping = unknown> = PushEvents<Mapping>;
|
|
|
310
320
|
type destination_PushFn<T extends TypesGeneric$1 = Types$2> = PushFn<T>;
|
|
311
321
|
type destination_Ref = Ref;
|
|
312
322
|
declare namespace destination {
|
|
313
|
-
export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, Config$5 as Config, Context$2 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, Env$1 as Env, Init$1 as Init, destination_InitContext as InitContext, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, InitSettings$1 as InitSettings, Instance$2 as Instance, Mapping$1 as Mapping, PartialConfig$1 as PartialConfig, Policy$1 as Policy, Push$1 as Push, destination_PushBatchContext as PushBatchContext, destination_PushBatchFn as PushBatchFn, destination_PushContext as PushContext, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, destination_Ref as Ref, Result$1 as Result, Settings$1 as Settings, Types$2 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
|
|
323
|
+
export type { BaseEnv$1 as BaseEnv, destination_Batch as Batch, destination_BatchRegistry as BatchRegistry, destination_Code as Code, Config$5 as Config, Context$2 as Context, destination_DLQ as DLQ, Data$1 as Data, destination_Destinations as Destinations, Env$1 as Env, Init$1 as Init, destination_InitContext as InitContext, destination_InitDestinations as InitDestinations, destination_InitFn as InitFn, InitSettings$1 as InitSettings, Instance$2 as Instance, Mapping$1 as Mapping, PartialConfig$1 as PartialConfig, Policy$1 as Policy, Push$1 as Push, destination_PushBatchContext as PushBatchContext, destination_PushBatchFn as PushBatchFn, destination_PushContext as PushContext, destination_PushEvent as PushEvent, destination_PushEvents as PushEvents, destination_PushFn as PushFn, destination_Ref as Ref, Result$1 as Result, Settings$1 as Settings, Types$2 as Types, TypesGeneric$1 as TypesGeneric, TypesOf$1 as TypesOf };
|
|
314
324
|
}
|
|
315
325
|
|
|
316
326
|
interface EventFn<R = Promise<PushResult>> {
|
|
@@ -1036,8 +1046,8 @@ interface OnConfig {
|
|
|
1036
1046
|
session?: SessionConfig[];
|
|
1037
1047
|
[key: string]: ConsentConfig[] | ReadyConfig[] | RunConfig[] | SessionConfig[] | undefined;
|
|
1038
1048
|
}
|
|
1039
|
-
type OnFn
|
|
1040
|
-
type OnFnRuntime = (
|
|
1049
|
+
type OnFn<T extends TypesGeneric$1 = Types$2> = (type: Types$1, context: Context$2<T>) => PromiseOrValue<void>;
|
|
1050
|
+
type OnFnRuntime = (type: Types$1, context: Context$2) => PromiseOrValue<void>;
|
|
1041
1051
|
|
|
1042
1052
|
type on_AnyEventContext = AnyEventContext;
|
|
1043
1053
|
type on_ConsentConfig = ConsentConfig;
|
|
@@ -1045,7 +1055,7 @@ type on_ConsentFn = ConsentFn;
|
|
|
1045
1055
|
type on_EventContext<T extends Types$1> = EventContext<T>;
|
|
1046
1056
|
type on_EventContextMap = EventContextMap;
|
|
1047
1057
|
type on_OnConfig = OnConfig;
|
|
1048
|
-
type on_OnFn = OnFn
|
|
1058
|
+
type on_OnFn<T extends TypesGeneric$1 = Types$2> = OnFn<T>;
|
|
1049
1059
|
type on_OnFnRuntime = OnFnRuntime;
|
|
1050
1060
|
type on_Options = Options;
|
|
1051
1061
|
type on_ReadyConfig = ReadyConfig;
|
|
@@ -1359,6 +1369,14 @@ declare function anonymizeIP(ip: string): string;
|
|
|
1359
1369
|
* @packageDocumentation
|
|
1360
1370
|
*/
|
|
1361
1371
|
|
|
1372
|
+
/**
|
|
1373
|
+
* Convert package name to valid JavaScript variable name.
|
|
1374
|
+
* Used for deterministic default import naming.
|
|
1375
|
+
* @example
|
|
1376
|
+
* packageNameToVariable('@walkeros/server-destination-api')
|
|
1377
|
+
* // → '_walkerosServerDestinationApi'
|
|
1378
|
+
*/
|
|
1379
|
+
declare function packageNameToVariable(packageName: string): string;
|
|
1362
1380
|
/**
|
|
1363
1381
|
* Get resolved flow configuration for a named flow.
|
|
1364
1382
|
*
|
|
@@ -2050,4 +2068,4 @@ declare function wrapFn(code: string): Fn;
|
|
|
2050
2068
|
*/
|
|
2051
2069
|
declare function wrapValidate(code: string): Validate;
|
|
2052
2070
|
|
|
2053
|
-
export { collector as Collector, Const, data as Data, destination as Destination, elb as Elb, flow as Flow, hooks as Hooks, Level, logger as Logger, mapping as Mapping, type MarketingParameters, type MockLogger, on as On, request as Request, schema as Schema, type SendDataValue, type SendHeaders, type SendResponse, source as Source, type StorageType, walkeros as WalkerOS, anonymizeIP, assign, castToProperty, castValue, clone, createDestination, createEvent, createLogger, createMockLogger, debounce, filterValues, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowConfig, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isSameType, isString, mockEnv, parseUserAgent, processEventMapping, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty, wrapCondition, wrapFn, wrapValidate };
|
|
2071
|
+
export { collector as Collector, Const, data as Data, destination as Destination, elb as Elb, flow as Flow, hooks as Hooks, Level, logger as Logger, mapping as Mapping, type MarketingParameters, type MockLogger, on as On, request as Request, schema as Schema, type SendDataValue, type SendHeaders, type SendResponse, source as Source, type StorageType, walkeros as WalkerOS, anonymizeIP, assign, castToProperty, castValue, clone, createDestination, createEvent, createLogger, createMockLogger, debounce, filterValues, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowConfig, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getOS, getOSVersion, getPlatform, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isFunction, isNumber, isObject, isPropertyType, isSameType, isString, mockEnv, packageNameToVariable, parseUserAgent, processEventMapping, requestToData, requestToParameter, setByPath, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateEvent, validateProperty, wrapCondition, wrapFn, wrapValidate };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,i=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},s={};i(s,{Collector:()=>c,Const:()=>j,Data:()=>a,Destination:()=>u,Elb:()=>l,Flow:()=>f,Hooks:()=>p,Level:()=>g,Logger:()=>d,Mapping:()=>m,On:()=>y,Request:()=>b,Schema:()=>h,Source:()=>v,WalkerOS:()=>w,anonymizeIP:()=>O,assign:()=>D,castToProperty:()=>ae,castValue:()=>q,clone:()=>U,createDestination:()=>G,createEvent:()=>J,createLogger:()=>oe,createMockLogger:()=>be,debounce:()=>Z,filterValues:()=>ce,getBrowser:()=>Se,getBrowserVersion:()=>$e,getByPath:()=>z,getDeviceType:()=>Me,getEvent:()=>X,getFlowConfig:()=>P,getGrantedConsent:()=>W,getHeaders:()=>je,getId:()=>Q,getMappingEvent:()=>fe,getMappingValue:()=>pe,getMarketingParameters:()=>Y,getOS:()=>Pe,getOSVersion:()=>Ae,getPlatform:()=>A,isArguments:()=>N,isArray:()=>T,isBoolean:()=>C,isCommand:()=>I,isDefined:()=>V,isElementOrDocument:()=>L,isFunction:()=>R,isNumber:()=>F,isObject:()=>_,isPropertyType:()=>se,isSameType:()=>B,isString:()=>K,mockEnv:()=>me,parseUserAgent:()=>ke,processEventMapping:()=>ge,requestToData:()=>he,requestToParameter:()=>ve,setByPath:()=>H,throttle:()=>ee,throwError:()=>Oe,transformData:()=>we,traverseEnv:()=>ye,trim:()=>xe,tryCatch:()=>ue,tryCatchAsync:()=>le,useHooks:()=>Ee,validateEvent:()=>De,validateProperty:()=>Ne,wrapCondition:()=>Ce,wrapFn:()=>Ie,wrapValidate:()=>Ve}),module.exports=(e=s,((e,i,s,c)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let a of r(i))o.call(e,a)||a===s||t(e,a,{get:()=>i[a],enumerable:!(c=n(i,a))||c.enumerable});return e})(t({},"__esModule",{value:!0}),e));var c={},a={},u={},l={},f={},p={},d={};i(d,{Level:()=>g});var g=(e=>(e[e.ERROR=0]="ERROR",e[e.INFO=1]="INFO",e[e.DEBUG=2]="DEBUG",e))(g||{}),m={},y={},b={},h={},v={},w={},j={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function O(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function x(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function E(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function k(e,t){if("string"==typeof e)return e.replace(/\$\{([^}:]+)(?::([^}]*))?\}/g,(e,n,r)=>{if("undefined"!=typeof process&&void 0!==process.env?.[n])return process.env[n];if(void 0!==t[n])return String(t[n]);if(void 0!==r)return r;throw new Error(`Variable "${n}" not found and no default provided`)});if(Array.isArray(e))return e.map(e=>k(e,t));if(null!==e&&"object"==typeof e){const n={};for(const[r,o]of Object.entries(e))n[r]=k(o,t);return n}return e}function S(e,t,n){if(t)return t;if(!e||!n)return;const r=n[e];return r?.imports?.[0]?r.imports[0]:void 0}function $(e,t){if(null!==e&&"object"==typeof e){if("$ref"in e&&"string"==typeof e.$ref){const n=e.$ref,r=n.match(/^#\/definitions\/(.+)$/);if(r){const e=r[1];if(void 0===t[e])throw new Error(`Definition "${e}" not found`);return $(t[e],t)}throw new Error(`Invalid $ref format: ${n}`)}if(Array.isArray(e))return e.map(e=>$(e,t));const n={};for(const[r,o]of Object.entries(e))n[r]=$(o,t);return n}return e}function P(e,t){const n=Object.keys(e.flows);if(!t){if(1!==n.length)throw new Error(`Multiple flows found (${n.join(", ")}). Please specify a flow.`);t=n[0]}const r=e.flows[t];if(!r)throw new Error(`Flow "${t}" not found. Available: ${n.join(", ")}`);const o=JSON.parse(JSON.stringify(r));if(o.sources)for(const[t,n]of Object.entries(o.sources)){const i=x(e.variables,r.variables,n.variables),s=E(e.definitions,r.definitions,n.definitions);let c=$(n.config,s);c=k(c,i);const a=S(n.package,n.code,o.packages);o.sources[t]={...n,config:c,...a&&{code:a}}}if(o.destinations)for(const[t,n]of Object.entries(o.destinations)){const i=x(e.variables,r.variables,n.variables),s=E(e.definitions,r.definitions,n.definitions);let c=$(n.config,s);c=k(c,i);const a=S(n.package,n.code,o.packages);o.destinations[t]={...n,config:c,...a&&{code:a}}}if(o.collector){const t=x(e.variables,r.variables),n=E(e.definitions,r.definitions);let i=$(o.collector,n);i=k(i,t),o.collector=i}return o}function A(e){if(void 0!==e.web)return"web";if(void 0!==e.server)return"server";throw new Error("Config must have web or server key")}var M={merge:!0,shallow:!0,extend:!0};function D(e,t={},n={}){n={...M,...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 N(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function T(e){return Array.isArray(e)}function C(e){return"boolean"==typeof e}function I(e){return"walker"===e}function V(e){return void 0!==e}function L(e){return e===document||e instanceof Element}function R(e){return"function"==typeof e}function F(e){return"number"==typeof e&&!Number.isNaN(e)}function _(e){return"object"==typeof e&&null!==e&&!T(e)&&"[object Object]"===Object.prototype.toString.call(e)}function B(e,t){return typeof e==typeof t}function K(e){return"string"==typeof e}function U(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 r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=U(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(U(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 z(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&T(o)){const t=r.slice(e+1).join("."),i=[];for(const e of o){const r=z(e,t,n);i.push(r)}return i}if(o=o instanceof Object?o[t]:void 0,!o)break}return V(o)?o:n}function H(e,t,n){if(!_(e))return e;const r=U(e),o=t.split(".");let i=r;for(let e=0;e<o.length;e++){const t=o[e];e===o.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return r}function q(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function W(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}function G(e,t){const n={...e};return n.config=D(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=D(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=D(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function J(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",r=e.count||1,o=D({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}-${r}`,trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,group:n,count:r,version:{source:"0.4.2",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&&(o.entity=t,o.action=n)}return o}function X(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),r={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},o={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return J({...{"cart view":{data:{currency:"EUR",value:2*r.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...r.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:r.data.price+o.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...r,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...o,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",...r,context:{shopping:["complete",0]},nested:[]},{entity:"product",...o,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":{...r,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...r,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...r.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 Q(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function Y(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}function Z(e,t=1e3,n=!1){let r,o=null,i=!1;return(...s)=>new Promise(c=>{const a=n&&!i;o&&clearTimeout(o),o=setTimeout(()=>{o=null,n&&!i||(r=e(...s),c(r))},t),a&&(i=!0,r=e(...s),c(r))})}function ee(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}function te(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function ne(e,t){let n,r={};return e instanceof Error?(n=e.message,r.error=te(e)):n=e,void 0!==t&&(t instanceof Error?r.error=te(t):"object"==typeof t&&null!==t?(r={...r,...t},"error"in r&&r.error instanceof Error&&(r.error=te(r.error))):r.value=t),{message:n,context:r}}var re=(e,t,n,r)=>{const o=`${g[e]}${r.length>0?` [${r.join(":")}]`:""}`,i=Object.keys(n).length>0;0===e?i?console.error(o,t,n):console.error(o,t):i?console.log(o,t,n):console.log(o,t)};function oe(e={}){return ie({level:void 0!==e.level?function(e){return"string"==typeof e?g[e]:e}(e.level):0,handler:e.handler,scope:[]})}function ie(e){const{level:t,handler:n,scope:r}=e,o=(e,o,i)=>{if(e<=t){const t=ne(o,i);n?n(e,t.message,t.context,r,re):re(e,t.message,t.context,r)}};return{error:(e,t)=>o(0,e,t),info:(e,t)=>o(1,e,t),debug:(e,t)=>o(2,e,t),throw:(e,t)=>{const o=ne(e,t);throw n?n(0,o.message,o.context,r,re):re(0,o.message,o.context,r),new Error(o.message)},scope:e=>ie({level:t,handler:n,scope:[...r,e]})}}function se(e){return C(e)||K(e)||F(e)||!V(e)||T(e)&&e.every(se)||_(e)&&Object.values(e).every(se)}function ce(e){return C(e)||K(e)||F(e)?e:N(e)?ce(Array.from(e)):T(e)?e.map(e=>ce(e)).filter(e=>void 0!==e):_(e)?Object.entries(e).reduce((e,[t,n])=>{const r=ce(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function ae(e){return se(e)?e:void 0}function ue(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function le(e,t,n){return async function(...r){try{return await e(...r)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}async function fe(e,t){const[n,r]=(e.name||"").split(" ");if(!t||!n||!r)return{};let o,i="",s=n,c=r;const a=t=>{if(t)return(t=T(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[s]||(s="*");const u=t[s];return u&&(u[c]||(c="*"),o=a(u[c])),o||(s="*",c="*",o=a(t[s]?.[c])),o&&(i=`${s} ${c}`),{eventMapping:o,mappingKey:i}}async function pe(e,t={},n={}){if(!V(e))return;const r=_(e)&&e.consent||n.consent||n.collector?.consent,o=T(t)?t:[t];for(const t of o){const o=await le(de)(e,t,{...n,consent:r});if(V(o))return o}}async function de(e,t,n={}){const{collector:r,consent:o}=n;return(T(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const c=K(i)?{key:i}:i;if(!Object.keys(c).length)return;const{condition:a,consent:u,fn:l,key:f,loop:p,map:d,set:g,validate:m,value:y}=c;if(a&&!await le(a)(e,i,r))return;if(u&&!W(u,o))return y;let b=V(y)?y:e;if(l&&(b=await le(l)(e,i,n)),f&&(b=z(e,f,y)),p){const[t,r]=p,o="this"===t?[e]:await pe(e,t,n);T(o)&&(b=(await Promise.all(o.map(e=>pe(e,r,n)))).filter(V))}else d?b=await Object.entries(d).reduce(async(t,[r,o])=>{const i=await t,s=await pe(e,o,n);return V(s)&&(i[r]=s),i},Promise.resolve({})):g&&(b=await Promise.all(g.map(t=>de(e,t,n))));m&&!await le(m)(b)&&(b=void 0);const h=ae(b);return V(h)?h:ae(y)},Promise.resolve(void 0))}async function ge(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,r])=>{const o=await pe(e,r,{collector:n});e=H(e,t,o)}));const{eventMapping:r,mappingKey:o}=await fe(e,t.mapping);r?.policy&&await Promise.all(Object.entries(r.policy).map(async([t,r])=>{const o=await pe(e,r,{collector:n});e=H(e,t,o)}));let i=t.data&&await pe(e,t.data,{collector:n});if(r){if(r.ignore)return{event:e,data:i,mapping:r,mappingKey:o,ignore:!0};if(r.name&&(e.name=r.name),r.data){const t=r.data&&await pe(e,r.data,{collector:n});i=_(i)&&_(t)?D(i,t):t}}return{event:e,data:i,mapping:r,mappingKey:o,ignore:!1}}function me(e,t){const n=(e,r=[])=>new Proxy(e,{get(e,o){const i=e[o],s=[...r,o];return"function"==typeof i?(...e)=>t(s,e,i):i&&"object"==typeof i?n(i,s):i}});return n(e)}function ye(e,t){const n=(e,r=[])=>{if(!e||"object"!=typeof e)return e;const o=Array.isArray(e)?[]:{};for(const[i,s]of Object.entries(e)){const e=[...r,i];Array.isArray(o)?o[Number(i)]=t(s,e):o[i]=t(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(o)?o[Number(i)]=n(s,e):o[i]=n(s,e))}return o};return n(e)}function be(){const e=[],t=jest.fn(e=>{const t=e instanceof Error?e.message:e;throw new Error(t)}),n=jest.fn(t=>{const n=be();return e.push(n),n});return{error:jest.fn(),info:jest.fn(),debug:jest.fn(),throw:t,scope:n,scopedLoggers:e}}function he(e){const t=String(e),n=t.split("?")[1]||t;return ue(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const r=n.split(/[[\]]+/).filter(Boolean);let o=t;r.forEach((t,n)=>{const i=n===r.length-1;if(T(o)){const s=parseInt(t,10);i?o[s]=q(e):(o[s]=o[s]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[s])}else _(o)&&(i?o[t]=q(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function ve(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(T(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):_(o)?Object.entries(o).forEach(([t,n])=>r(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(o))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>r(e,t)),t.join("&"))}function we(e){return void 0===e||B(e,"")?e:JSON.stringify(e)}function je(e={}){return D({"Content-Type":"application/json; charset=utf-8"},e)}function Oe(e){throw new Error(String(e))}function xe(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function Ee(e,t,n){return function(...r){let o;const i="post"+t,s=n["pre"+t],c=n[i];return o=s?s({fn:e},...r):e(...r),c&&(o=c({fn:e,result:o},...r)),o}}function ke(e){return e?{userAgent:e,browser:Se(e),browserVersion:$e(e),os:Pe(e),osVersion:Ae(e),deviceType:Me(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 $e(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 Pe(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 Ae(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function Me(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 De(e,t=[]){let n,r,o;B(e,{})||Oe("Invalid object"),B(e.name,"")?(n=e.name,[r,o]=n.split(" "),r&&o||Oe("Invalid event name")):B(e.entity,"")&&B(e.action,"")?(r=e.entity,o=e.action,n=`${r} ${o}`):Oe("Missing or invalid name, entity, or action");const i={name:n,data:{},context:{},custom:{},globals:{},user:{},nested:[],consent:{},id:"",trigger:"",entity:r,action:o,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)=>["*",r].reduce((e,n)=>["*",o].reduce((e,r)=>{const o=t[n]?.[r];return o?e.concat([o]):e},e),e),[]).reduce((t,n)=>{const r=Object.keys(n).filter(e=>{const t=n[e];return!0===t?.required});return[...Object.keys(e),...r].reduce((t,r)=>{const o=n[r];let i=e[r];return o&&(i=ue(Ne,e=>{Oe(String(e))})(t,r,i,o)),B(i,t[r])&&(t[r]=i),t},t)},i)}function Ne(e,t,n,r){if(r.validate&&(n=ue(r.validate,e=>{Oe(String(e))})(n,t,e)),r.required&&void 0===n&&Oe("Missing required property"),B(n,""))r.maxLength&&n.length>r.maxLength&&(r.strict&&Oe("Value exceeds maxLength"),n=n.substring(0,r.maxLength));else if(B(n,1))B(r.min,1)&&n<r.min?(r.strict&&Oe("Value below min"),n=r.min):B(r.max,1)&&n>r.max&&(r.strict&&Oe("Value exceeds max"),n=r.max);else if(B(n,{})){if(r.schema){const e=r.schema;Object.keys(e).reduce((t,n)=>{const r=e[n];let o=t[n];return r&&(r.type&&typeof o!==r.type&&Oe(`Type doesn't match (${n})`),o=ue(Ne,e=>{Oe(String(e))})(t,n,o,r)),o},n)}for(const e of Object.keys(n))r.allowedKeys&&!r.allowedKeys.includes(e)&&(r.strict&&Oe("Key not allowed"),delete n[e])}return n}function Te(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function Ce(e){const t=Te(e);return new Function("value","mapping","collector",t)}function Ie(e){const t=Te(e);return new Function("value","mapping","options",t)}function Ve(e){const t=Te(e);return new Function("value",t)}//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,i=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},s={};i(s,{Collector:()=>c,Const:()=>j,Data:()=>a,Destination:()=>u,Elb:()=>l,Flow:()=>f,Hooks:()=>p,Level:()=>g,Logger:()=>d,Mapping:()=>m,On:()=>y,Request:()=>b,Schema:()=>h,Source:()=>v,WalkerOS:()=>w,anonymizeIP:()=>O,assign:()=>T,castToProperty:()=>ue,castValue:()=>W,clone:()=>z,createDestination:()=>J,createEvent:()=>X,createLogger:()=>ie,createMockLogger:()=>he,debounce:()=>ee,filterValues:()=>ae,getBrowser:()=>$e,getBrowserVersion:()=>Ae,getByPath:()=>H,getDeviceType:()=>Ne,getEvent:()=>Q,getFlowConfig:()=>P,getGrantedConsent:()=>G,getHeaders:()=>Oe,getId:()=>Y,getMappingEvent:()=>pe,getMappingValue:()=>de,getMarketingParameters:()=>Z,getOS:()=>Pe,getOSVersion:()=>Me,getPlatform:()=>M,isArguments:()=>C,isArray:()=>D,isBoolean:()=>I,isCommand:()=>V,isDefined:()=>_,isElementOrDocument:()=>L,isFunction:()=>R,isNumber:()=>F,isObject:()=>B,isPropertyType:()=>ce,isSameType:()=>K,isString:()=>U,mockEnv:()=>ye,packageNameToVariable:()=>S,parseUserAgent:()=>Se,processEventMapping:()=>me,requestToData:()=>ve,requestToParameter:()=>we,setByPath:()=>q,throttle:()=>te,throwError:()=>xe,transformData:()=>je,traverseEnv:()=>be,trim:()=>Ee,tryCatch:()=>le,tryCatchAsync:()=>fe,useHooks:()=>ke,validateEvent:()=>Te,validateProperty:()=>Ce,wrapCondition:()=>Ie,wrapFn:()=>Ve,wrapValidate:()=>_e}),module.exports=(e=s,((e,i,s,c)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let a of r(i))o.call(e,a)||a===s||t(e,a,{get:()=>i[a],enumerable:!(c=n(i,a))||c.enumerable});return e})(t({},"__esModule",{value:!0}),e));var c={},a={},u={},l={},f={},p={},d={};i(d,{Level:()=>g});var g=(e=>(e[e.ERROR=0]="ERROR",e[e.INFO=1]="INFO",e[e.DEBUG=2]="DEBUG",e))(g||{}),m={},y={},b={},h={},v={},w={},j={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function O(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function x(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function E(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function k(e,t){if("string"==typeof e)return e.replace(/\$\{([^}:]+)(?::([^}]*))?\}/g,(e,n,r)=>{if("undefined"!=typeof process&&void 0!==process.env?.[n])return process.env[n];if(void 0!==t[n])return String(t[n]);if(void 0!==r)return r;throw new Error(`Variable "${n}" not found and no default provided`)});if(Array.isArray(e))return e.map(e=>k(e,t));if(null!==e&&"object"==typeof e){const n={};for(const[r,o]of Object.entries(e))n[r]=k(o,t);return n}return e}function S(e){const t=e.startsWith("@"),n=e.replace("@","").replace(/[/-]/g,"_").split("_").filter(e=>e.length>0).map((e,t)=>0===t?e:e.charAt(0).toUpperCase()+e.slice(1)).join("");return t?"_"+n:n}function $(e,t,n){if(t)return t;if(!e||!n)return;return n[e]?S(e):void 0}function A(e,t){if(null!==e&&"object"==typeof e){if("$ref"in e&&"string"==typeof e.$ref){const n=e.$ref,r=n.match(/^#\/definitions\/(.+)$/);if(r){const e=r[1];if(void 0===t[e])throw new Error(`Definition "${e}" not found`);return A(t[e],t)}throw new Error(`Invalid $ref format: ${n}`)}if(Array.isArray(e))return e.map(e=>A(e,t));const n={};for(const[r,o]of Object.entries(e))n[r]=A(o,t);return n}return e}function P(e,t){const n=Object.keys(e.flows);if(!t){if(1!==n.length)throw new Error(`Multiple flows found (${n.join(", ")}). Please specify a flow.`);t=n[0]}const r=e.flows[t];if(!r)throw new Error(`Flow "${t}" not found. Available: ${n.join(", ")}`);const o=JSON.parse(JSON.stringify(r));if(o.sources)for(const[t,n]of Object.entries(o.sources)){const i=x(e.variables,r.variables,n.variables),s=E(e.definitions,r.definitions,n.definitions);let c=A(n.config,s);c=k(c,i);const a=$(n.package,n.code,o.packages);o.sources[t]={...n,config:c,...a&&{code:a}}}if(o.destinations)for(const[t,n]of Object.entries(o.destinations)){const i=x(e.variables,r.variables,n.variables),s=E(e.definitions,r.definitions,n.definitions);let c=A(n.config,s);c=k(c,i);const a=$(n.package,n.code,o.packages);o.destinations[t]={...n,config:c,...a&&{code:a}}}if(o.collector){const t=x(e.variables,r.variables),n=E(e.definitions,r.definitions);let i=A(o.collector,n);i=k(i,t),o.collector=i}return o}function M(e){if(void 0!==e.web)return"web";if(void 0!==e.server)return"server";throw new Error("Config must have web or server key")}var N={merge:!0,shallow:!0,extend:!0};function T(e,t={},n={}){n={...N,...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 C(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function D(e){return Array.isArray(e)}function I(e){return"boolean"==typeof e}function V(e){return"walker"===e}function _(e){return void 0!==e}function L(e){return e===document||e instanceof Element}function R(e){return"function"==typeof e}function F(e){return"number"==typeof e&&!Number.isNaN(e)}function B(e){return"object"==typeof e&&null!==e&&!D(e)&&"[object Object]"===Object.prototype.toString.call(e)}function K(e,t){return typeof e==typeof t}function U(e){return"string"==typeof e}function z(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 r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=z(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(z(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 H(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&D(o)){const t=r.slice(e+1).join("."),i=[];for(const e of o){const r=H(e,t,n);i.push(r)}return i}if(o=o instanceof Object?o[t]:void 0,!o)break}return _(o)?o:n}function q(e,t,n){if(!B(e))return e;const r=z(e),o=t.split(".");let i=r;for(let e=0;e<o.length;e++){const t=o[e];e===o.length-1?i[t]=n:(t in i&&"object"==typeof i[t]&&null!==i[t]||(i[t]={}),i=i[t])}return r}function W(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function G(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}function J(e,t){const n={...e};return n.config=T(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=T(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=T(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function X(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",r=e.count||1,o=T({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}-${r}`,trigger:"test",entity:"entity",action:"action",timestamp:t,timing:3.14,group:n,count:r,version:{source:"0.5.0",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&&(o.entity=t,o.action=n)}return o}function Q(e="entity action",t={}){const n=t.timestamp||(new Date).setHours(0,13,37,0),r={data:{id:"ers",name:"Everyday Ruck Snack",color:"black",size:"l",price:420}},o={data:{id:"cc",name:"Cool Cap",size:"one size",price:42}};return X({...{"cart view":{data:{currency:"EUR",value:2*r.data.price},context:{shopping:["cart",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",data:{...r.data,quantity:2},context:{shopping:["cart",0]},nested:[]}],trigger:"load"},"checkout view":{data:{step:"payment",currency:"EUR",value:r.data.price+o.data.price},context:{shopping:["checkout",0]},globals:{pagegroup:"shop"},nested:[{entity:"product",...r,context:{shopping:["checkout",0]},nested:[]},{entity:"product",...o,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",...r,context:{shopping:["complete",0]},nested:[]},{entity:"product",...o,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.walkeros.io/",search:"?foo=bar",hash:"#hash",id:"/docs/"},globals:{pagegroup:"docs"},trigger:"load"},"product add":{...r,context:{shopping:["intent",0]},globals:{pagegroup:"shop"},nested:[],trigger:"click"},"product view":{...r,context:{shopping:["detail",0]},globals:{pagegroup:"shop"},nested:[],trigger:"load"},"product visible":{data:{...r.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 Y(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function Z(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(T(o,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}function ee(e,t=1e3,n=!1){let r,o=null,i=!1;return(...s)=>new Promise(c=>{const a=n&&!i;o&&clearTimeout(o),o=setTimeout(()=>{o=null,n&&!i||(r=e(...s),c(r))},t),a&&(i=!0,r=e(...s),c(r))})}function te(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}function ne(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function re(e,t){let n,r={};return e instanceof Error?(n=e.message,r.error=ne(e)):n=e,void 0!==t&&(t instanceof Error?r.error=ne(t):"object"==typeof t&&null!==t?(r={...r,...t},"error"in r&&r.error instanceof Error&&(r.error=ne(r.error))):r.value=t),{message:n,context:r}}var oe=(e,t,n,r)=>{const o=`${g[e]}${r.length>0?` [${r.join(":")}]`:""}`,i=Object.keys(n).length>0;0===e?i?console.error(o,t,n):console.error(o,t):i?console.log(o,t,n):console.log(o,t)};function ie(e={}){return se({level:void 0!==e.level?function(e){return"string"==typeof e?g[e]:e}(e.level):0,handler:e.handler,scope:[]})}function se(e){const{level:t,handler:n,scope:r}=e,o=(e,o,i)=>{if(e<=t){const t=re(o,i);n?n(e,t.message,t.context,r,oe):oe(e,t.message,t.context,r)}};return{error:(e,t)=>o(0,e,t),info:(e,t)=>o(1,e,t),debug:(e,t)=>o(2,e,t),throw:(e,t)=>{const o=re(e,t);throw n?n(0,o.message,o.context,r,oe):oe(0,o.message,o.context,r),new Error(o.message)},scope:e=>se({level:t,handler:n,scope:[...r,e]})}}function ce(e){return I(e)||U(e)||F(e)||!_(e)||D(e)&&e.every(ce)||B(e)&&Object.values(e).every(ce)}function ae(e){return I(e)||U(e)||F(e)?e:C(e)?ae(Array.from(e)):D(e)?e.map(e=>ae(e)).filter(e=>void 0!==e):B(e)?Object.entries(e).reduce((e,[t,n])=>{const r=ae(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function ue(e){return ce(e)?e:void 0}function le(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function fe(e,t,n){return async function(...r){try{return await e(...r)}catch(e){if(!t)return;return await t(e)}finally{await(n?.())}}}async function pe(e,t){const[n,r]=(e.name||"").split(" ");if(!t||!n||!r)return{};let o,i="",s=n,c=r;const a=t=>{if(t)return(t=D(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[s]||(s="*");const u=t[s];return u&&(u[c]||(c="*"),o=a(u[c])),o||(s="*",c="*",o=a(t[s]?.[c])),o&&(i=`${s} ${c}`),{eventMapping:o,mappingKey:i}}async function de(e,t={},n={}){if(!_(e))return;const r=B(e)&&e.consent||n.consent||n.collector?.consent,o=D(t)?t:[t];for(const t of o){const o=await fe(ge)(e,t,{...n,consent:r});if(_(o))return o}}async function ge(e,t,n={}){const{collector:r,consent:o}=n;return(D(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const c=U(i)?{key:i}:i;if(!Object.keys(c).length)return;const{condition:a,consent:u,fn:l,key:f,loop:p,map:d,set:g,validate:m,value:y}=c;if(a&&!await fe(a)(e,i,r))return;if(u&&!G(u,o))return y;let b=_(y)?y:e;if(l&&(b=await fe(l)(e,i,n)),f&&(b=H(e,f,y)),p){const[t,r]=p,o="this"===t?[e]:await de(e,t,n);D(o)&&(b=(await Promise.all(o.map(e=>de(e,r,n)))).filter(_))}else d?b=await Object.entries(d).reduce(async(t,[r,o])=>{const i=await t,s=await de(e,o,n);return _(s)&&(i[r]=s),i},Promise.resolve({})):g&&(b=await Promise.all(g.map(t=>ge(e,t,n))));m&&!await fe(m)(b)&&(b=void 0);const h=ue(b);return _(h)?h:ue(y)},Promise.resolve(void 0))}async function me(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,r])=>{const o=await de(e,r,{collector:n});e=q(e,t,o)}));const{eventMapping:r,mappingKey:o}=await pe(e,t.mapping);r?.policy&&await Promise.all(Object.entries(r.policy).map(async([t,r])=>{const o=await de(e,r,{collector:n});e=q(e,t,o)}));let i=t.data&&await de(e,t.data,{collector:n});if(r){if(r.ignore)return{event:e,data:i,mapping:r,mappingKey:o,ignore:!0};if(r.name&&(e.name=r.name),r.data){const t=r.data&&await de(e,r.data,{collector:n});i=B(i)&&B(t)?T(i,t):t}}return{event:e,data:i,mapping:r,mappingKey:o,ignore:!1}}function ye(e,t){const n=(e,r=[])=>new Proxy(e,{get(e,o){const i=e[o],s=[...r,o];return"function"==typeof i?(...e)=>t(s,e,i):i&&"object"==typeof i?n(i,s):i}});return n(e)}function be(e,t){const n=(e,r=[])=>{if(!e||"object"!=typeof e)return e;const o=Array.isArray(e)?[]:{};for(const[i,s]of Object.entries(e)){const e=[...r,i];Array.isArray(o)?o[Number(i)]=t(s,e):o[i]=t(s,e),s&&"object"==typeof s&&"function"!=typeof s&&(Array.isArray(o)?o[Number(i)]=n(s,e):o[i]=n(s,e))}return o};return n(e)}function he(){const e=[],t=jest.fn(e=>{const t=e instanceof Error?e.message:e;throw new Error(t)}),n=jest.fn(t=>{const n=he();return e.push(n),n});return{error:jest.fn(),info:jest.fn(),debug:jest.fn(),throw:t,scope:n,scopedLoggers:e}}function ve(e){const t=String(e),n=t.split("?")[1]||t;return le(()=>{const e=new URLSearchParams(n),t={};return e.forEach((e,n)=>{const r=n.split(/[[\]]+/).filter(Boolean);let o=t;r.forEach((t,n)=>{const i=n===r.length-1;if(D(o)){const s=parseInt(t,10);i?o[s]=W(e):(o[s]=o[s]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[s])}else B(o)&&(i?o[t]=W(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function we(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(D(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):B(o)?Object.entries(o).forEach(([t,n])=>r(`${e}[${t}]`,n)):t.push(`${n(e)}=${n(String(o))}`))}return"object"!=typeof e?n(e):(Object.entries(e).forEach(([e,t])=>r(e,t)),t.join("&"))}function je(e){return void 0===e||K(e,"")?e:JSON.stringify(e)}function Oe(e={}){return T({"Content-Type":"application/json; charset=utf-8"},e)}function xe(e){throw new Error(String(e))}function Ee(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function ke(e,t,n){return function(...r){let o;const i="post"+t,s=n["pre"+t],c=n[i];return o=s?s({fn:e},...r):e(...r),c&&(o=c({fn:e,result:o},...r)),o}}function Se(e){return e?{userAgent:e,browser:$e(e),browserVersion:Ae(e),os:Pe(e),osVersion:Me(e),deviceType:Ne(e)}:{}}function $e(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 Ae(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 Pe(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 Me(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function Ne(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 Te(e,t=[]){let n,r,o;K(e,{})||xe("Invalid object"),K(e.name,"")?(n=e.name,[r,o]=n.split(" "),r&&o||xe("Invalid event name")):K(e.entity,"")&&K(e.action,"")?(r=e.entity,o=e.action,n=`${r} ${o}`):xe("Missing or invalid name, entity, or action");const i={name:n,data:{},context:{},custom:{},globals:{},user:{},nested:[],consent:{},id:"",trigger:"",entity:r,action:o,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)=>["*",r].reduce((e,n)=>["*",o].reduce((e,r)=>{const o=t[n]?.[r];return o?e.concat([o]):e},e),e),[]).reduce((t,n)=>{const r=Object.keys(n).filter(e=>{const t=n[e];return!0===t?.required});return[...Object.keys(e),...r].reduce((t,r)=>{const o=n[r];let i=e[r];return o&&(i=le(Ce,e=>{xe(String(e))})(t,r,i,o)),K(i,t[r])&&(t[r]=i),t},t)},i)}function Ce(e,t,n,r){if(r.validate&&(n=le(r.validate,e=>{xe(String(e))})(n,t,e)),r.required&&void 0===n&&xe("Missing required property"),K(n,""))r.maxLength&&n.length>r.maxLength&&(r.strict&&xe("Value exceeds maxLength"),n=n.substring(0,r.maxLength));else if(K(n,1))K(r.min,1)&&n<r.min?(r.strict&&xe("Value below min"),n=r.min):K(r.max,1)&&n>r.max&&(r.strict&&xe("Value exceeds max"),n=r.max);else if(K(n,{})){if(r.schema){const e=r.schema;Object.keys(e).reduce((t,n)=>{const r=e[n];let o=t[n];return r&&(r.type&&typeof o!==r.type&&xe(`Type doesn't match (${n})`),o=le(Ce,e=>{xe(String(e))})(t,n,o,r)),o},n)}for(const e of Object.keys(n))r.allowedKeys&&!r.allowedKeys.includes(e)&&(r.strict&&xe("Key not allowed"),delete n[e])}return n}function De(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function Ie(e){const t=De(e);return new Function("value","mapping","collector",t)}function Ve(e){const t=De(e);return new Function("value","mapping","options",t)}function _e(e){const t=De(e);return new Function("value",t)}//# sourceMappingURL=index.js.map
|