@walkeros/core 1.1.0 → 1.2.0-next-1769691037535
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 +69 -20
- package/dist/index.d.ts +69 -20
- 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.d.mts
CHANGED
|
@@ -278,7 +278,7 @@ type PartialConfig$1<T extends TypesGeneric$2 = Types$3> = Config$6<Types$3<Part
|
|
|
278
278
|
interface Policy$1 {
|
|
279
279
|
[key: string]: Value;
|
|
280
280
|
}
|
|
281
|
-
type Code<T extends TypesGeneric$2 = Types$3> = Instance$3<T
|
|
281
|
+
type Code<T extends TypesGeneric$2 = Types$3> = Instance$3<T>;
|
|
282
282
|
type Init$2<T extends TypesGeneric$2 = Types$3> = {
|
|
283
283
|
code: Code<T>;
|
|
284
284
|
config?: Partial<Config$6<T>>;
|
|
@@ -424,6 +424,15 @@ type Variables = Record<string, Primitive>;
|
|
|
424
424
|
* Used at Setup, Config, Source, and Destination levels.
|
|
425
425
|
*/
|
|
426
426
|
type Definitions = Record<string, unknown>;
|
|
427
|
+
/**
|
|
428
|
+
* Inline code definition for sources/destinations/transformers.
|
|
429
|
+
* Used instead of package when defining inline functions.
|
|
430
|
+
*/
|
|
431
|
+
interface InlineCode {
|
|
432
|
+
push: string;
|
|
433
|
+
type?: string;
|
|
434
|
+
init?: string;
|
|
435
|
+
}
|
|
427
436
|
/**
|
|
428
437
|
* Packages configuration for build.
|
|
429
438
|
*/
|
|
@@ -691,6 +700,7 @@ interface Config$5 {
|
|
|
691
700
|
* @remarks
|
|
692
701
|
* References a source package and provides configuration.
|
|
693
702
|
* The package is automatically downloaded and imported during build.
|
|
703
|
+
* Alternatively, use `code: true` for inline code execution.
|
|
694
704
|
*/
|
|
695
705
|
interface SourceReference {
|
|
696
706
|
/**
|
|
@@ -708,18 +718,30 @@ interface SourceReference {
|
|
|
708
718
|
* 3. Auto-detect default or named export
|
|
709
719
|
* 4. Generate import statement
|
|
710
720
|
*
|
|
721
|
+
* Optional when `code: true` is used for inline code execution.
|
|
722
|
+
*
|
|
711
723
|
* @example
|
|
712
724
|
* "package": "@walkeros/web-source-browser@latest"
|
|
713
725
|
*/
|
|
714
|
-
package
|
|
726
|
+
package?: string;
|
|
715
727
|
/**
|
|
716
|
-
* Resolved import variable name.
|
|
728
|
+
* Resolved import variable name or built-in code source.
|
|
717
729
|
*
|
|
718
730
|
* @remarks
|
|
719
|
-
* Auto-resolved from packages[package].imports[0] during getFlowConfig()
|
|
720
|
-
*
|
|
731
|
+
* - String: Auto-resolved from packages[package].imports[0] during getFlowConfig(),
|
|
732
|
+
* or provided explicitly for advanced use cases.
|
|
733
|
+
* - InlineCode: Object with type, push, and optional init for inline code definition.
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* // Using inline code object
|
|
737
|
+
* {
|
|
738
|
+
* "code": {
|
|
739
|
+
* "type": "logger",
|
|
740
|
+
* "push": "$code:(event) => console.log(event)"
|
|
741
|
+
* }
|
|
742
|
+
* }
|
|
721
743
|
*/
|
|
722
|
-
code?: string;
|
|
744
|
+
code?: string | InlineCode;
|
|
723
745
|
/**
|
|
724
746
|
* Source-specific configuration.
|
|
725
747
|
*
|
|
@@ -776,8 +798,9 @@ interface SourceReference {
|
|
|
776
798
|
* @remarks
|
|
777
799
|
* Name of the transformer to execute after this source captures an event.
|
|
778
800
|
* If omitted, events route directly to the collector.
|
|
801
|
+
* Can be an array for explicit chain control (bypasses transformer.next resolution).
|
|
779
802
|
*/
|
|
780
|
-
next?: string;
|
|
803
|
+
next?: string | string[];
|
|
781
804
|
}
|
|
782
805
|
/**
|
|
783
806
|
* Transformer reference with inline package syntax.
|
|
@@ -785,6 +808,7 @@ interface SourceReference {
|
|
|
785
808
|
* @remarks
|
|
786
809
|
* References a transformer package and provides configuration.
|
|
787
810
|
* Transformers transform events in the pipeline between sources and destinations.
|
|
811
|
+
* Alternatively, use `code: true` for inline code execution.
|
|
788
812
|
*/
|
|
789
813
|
interface TransformerReference {
|
|
790
814
|
/**
|
|
@@ -792,19 +816,30 @@ interface TransformerReference {
|
|
|
792
816
|
*
|
|
793
817
|
* @remarks
|
|
794
818
|
* Same format as SourceReference.package
|
|
819
|
+
* Optional when `code: true` is used for inline code execution.
|
|
795
820
|
*
|
|
796
821
|
* @example
|
|
797
822
|
* "package": "@walkeros/transformer-enricher@1.0.0"
|
|
798
823
|
*/
|
|
799
|
-
package
|
|
824
|
+
package?: string;
|
|
800
825
|
/**
|
|
801
|
-
* Resolved import variable name.
|
|
826
|
+
* Resolved import variable name or built-in code transformer.
|
|
802
827
|
*
|
|
803
828
|
* @remarks
|
|
804
|
-
* Auto-resolved from packages[package].imports[0] during getFlowConfig()
|
|
805
|
-
*
|
|
829
|
+
* - String: Auto-resolved from packages[package].imports[0] during getFlowConfig(),
|
|
830
|
+
* or provided explicitly for advanced use cases.
|
|
831
|
+
* - InlineCode: Object with type, push, and optional init for inline code definition.
|
|
832
|
+
*
|
|
833
|
+
* @example
|
|
834
|
+
* // Using inline code object
|
|
835
|
+
* {
|
|
836
|
+
* "code": {
|
|
837
|
+
* "type": "enricher",
|
|
838
|
+
* "push": "$code:(event) => ({ ...event, data: { enriched: true } })"
|
|
839
|
+
* }
|
|
840
|
+
* }
|
|
806
841
|
*/
|
|
807
|
-
code?: string;
|
|
842
|
+
code?: string | InlineCode;
|
|
808
843
|
/**
|
|
809
844
|
* Transformer-specific configuration.
|
|
810
845
|
*
|
|
@@ -829,8 +864,9 @@ interface TransformerReference {
|
|
|
829
864
|
* If omitted:
|
|
830
865
|
* - Pre-collector: routes to collector
|
|
831
866
|
* - Post-collector: routes to destination
|
|
867
|
+
* Can be an array for explicit chain control (terminates chain walking).
|
|
832
868
|
*/
|
|
833
|
-
next?: string;
|
|
869
|
+
next?: string | string[];
|
|
834
870
|
/**
|
|
835
871
|
* Transformer-level variables (highest priority in cascade).
|
|
836
872
|
* Overrides flow and setup variables.
|
|
@@ -855,19 +891,30 @@ interface DestinationReference {
|
|
|
855
891
|
*
|
|
856
892
|
* @remarks
|
|
857
893
|
* Same format as SourceReference.package
|
|
894
|
+
* Optional when `code: true` is used for inline code execution.
|
|
858
895
|
*
|
|
859
896
|
* @example
|
|
860
897
|
* "package": "@walkeros/web-destination-gtag@2.0.0"
|
|
861
898
|
*/
|
|
862
|
-
package
|
|
899
|
+
package?: string;
|
|
863
900
|
/**
|
|
864
|
-
* Resolved import variable name.
|
|
901
|
+
* Resolved import variable name or built-in code destination.
|
|
865
902
|
*
|
|
866
903
|
* @remarks
|
|
867
|
-
* Auto-resolved from packages[package].imports[0] during getFlowConfig()
|
|
868
|
-
*
|
|
904
|
+
* - String: Auto-resolved from packages[package].imports[0] during getFlowConfig(),
|
|
905
|
+
* or provided explicitly for advanced use cases.
|
|
906
|
+
* - InlineCode: Object with type, push, and optional init for inline code definition.
|
|
907
|
+
*
|
|
908
|
+
* @example
|
|
909
|
+
* // Using inline code object
|
|
910
|
+
* {
|
|
911
|
+
* "code": {
|
|
912
|
+
* "type": "logger",
|
|
913
|
+
* "push": "$code:(event) => console.log('Event:', event.name)"
|
|
914
|
+
* }
|
|
915
|
+
* }
|
|
869
916
|
*/
|
|
870
|
-
code?: string;
|
|
917
|
+
code?: string | InlineCode;
|
|
871
918
|
/**
|
|
872
919
|
* Destination-specific configuration.
|
|
873
920
|
*
|
|
@@ -925,12 +972,14 @@ interface DestinationReference {
|
|
|
925
972
|
* @remarks
|
|
926
973
|
* Name of the transformer to execute before sending events to this destination.
|
|
927
974
|
* If omitted, events are sent directly from the collector.
|
|
975
|
+
* Can be an array for explicit chain control (bypasses transformer.next resolution).
|
|
928
976
|
*/
|
|
929
|
-
before?: string;
|
|
977
|
+
before?: string | string[];
|
|
930
978
|
}
|
|
931
979
|
|
|
932
980
|
type flow_Definitions = Definitions;
|
|
933
981
|
type flow_DestinationReference = DestinationReference;
|
|
982
|
+
type flow_InlineCode = InlineCode;
|
|
934
983
|
type flow_Packages = Packages;
|
|
935
984
|
type flow_Primitive = Primitive;
|
|
936
985
|
type flow_Server = Server;
|
|
@@ -940,7 +989,7 @@ type flow_TransformerReference = TransformerReference;
|
|
|
940
989
|
type flow_Variables = Variables;
|
|
941
990
|
type flow_Web = Web;
|
|
942
991
|
declare namespace flow {
|
|
943
|
-
export type { Config$5 as Config, flow_Definitions as Definitions, flow_DestinationReference as DestinationReference, flow_Packages as Packages, flow_Primitive as Primitive, flow_Server as Server, flow_Setup as Setup, flow_SourceReference as SourceReference, flow_TransformerReference as TransformerReference, flow_Variables as Variables, flow_Web as Web };
|
|
992
|
+
export type { Config$5 as Config, flow_Definitions as Definitions, flow_DestinationReference as DestinationReference, flow_InlineCode as InlineCode, flow_Packages as Packages, flow_Primitive as Primitive, flow_Server as Server, flow_Setup as Setup, flow_SourceReference as SourceReference, flow_TransformerReference as TransformerReference, flow_Variables as Variables, flow_Web as Web };
|
|
944
993
|
}
|
|
945
994
|
|
|
946
995
|
type AnyFunction$1<P extends unknown[] = never[], R = unknown> = (...args: P) => R;
|
package/dist/index.d.ts
CHANGED
|
@@ -278,7 +278,7 @@ type PartialConfig$1<T extends TypesGeneric$2 = Types$3> = Config$6<Types$3<Part
|
|
|
278
278
|
interface Policy$1 {
|
|
279
279
|
[key: string]: Value;
|
|
280
280
|
}
|
|
281
|
-
type Code<T extends TypesGeneric$2 = Types$3> = Instance$3<T
|
|
281
|
+
type Code<T extends TypesGeneric$2 = Types$3> = Instance$3<T>;
|
|
282
282
|
type Init$2<T extends TypesGeneric$2 = Types$3> = {
|
|
283
283
|
code: Code<T>;
|
|
284
284
|
config?: Partial<Config$6<T>>;
|
|
@@ -424,6 +424,15 @@ type Variables = Record<string, Primitive>;
|
|
|
424
424
|
* Used at Setup, Config, Source, and Destination levels.
|
|
425
425
|
*/
|
|
426
426
|
type Definitions = Record<string, unknown>;
|
|
427
|
+
/**
|
|
428
|
+
* Inline code definition for sources/destinations/transformers.
|
|
429
|
+
* Used instead of package when defining inline functions.
|
|
430
|
+
*/
|
|
431
|
+
interface InlineCode {
|
|
432
|
+
push: string;
|
|
433
|
+
type?: string;
|
|
434
|
+
init?: string;
|
|
435
|
+
}
|
|
427
436
|
/**
|
|
428
437
|
* Packages configuration for build.
|
|
429
438
|
*/
|
|
@@ -691,6 +700,7 @@ interface Config$5 {
|
|
|
691
700
|
* @remarks
|
|
692
701
|
* References a source package and provides configuration.
|
|
693
702
|
* The package is automatically downloaded and imported during build.
|
|
703
|
+
* Alternatively, use `code: true` for inline code execution.
|
|
694
704
|
*/
|
|
695
705
|
interface SourceReference {
|
|
696
706
|
/**
|
|
@@ -708,18 +718,30 @@ interface SourceReference {
|
|
|
708
718
|
* 3. Auto-detect default or named export
|
|
709
719
|
* 4. Generate import statement
|
|
710
720
|
*
|
|
721
|
+
* Optional when `code: true` is used for inline code execution.
|
|
722
|
+
*
|
|
711
723
|
* @example
|
|
712
724
|
* "package": "@walkeros/web-source-browser@latest"
|
|
713
725
|
*/
|
|
714
|
-
package
|
|
726
|
+
package?: string;
|
|
715
727
|
/**
|
|
716
|
-
* Resolved import variable name.
|
|
728
|
+
* Resolved import variable name or built-in code source.
|
|
717
729
|
*
|
|
718
730
|
* @remarks
|
|
719
|
-
* Auto-resolved from packages[package].imports[0] during getFlowConfig()
|
|
720
|
-
*
|
|
731
|
+
* - String: Auto-resolved from packages[package].imports[0] during getFlowConfig(),
|
|
732
|
+
* or provided explicitly for advanced use cases.
|
|
733
|
+
* - InlineCode: Object with type, push, and optional init for inline code definition.
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* // Using inline code object
|
|
737
|
+
* {
|
|
738
|
+
* "code": {
|
|
739
|
+
* "type": "logger",
|
|
740
|
+
* "push": "$code:(event) => console.log(event)"
|
|
741
|
+
* }
|
|
742
|
+
* }
|
|
721
743
|
*/
|
|
722
|
-
code?: string;
|
|
744
|
+
code?: string | InlineCode;
|
|
723
745
|
/**
|
|
724
746
|
* Source-specific configuration.
|
|
725
747
|
*
|
|
@@ -776,8 +798,9 @@ interface SourceReference {
|
|
|
776
798
|
* @remarks
|
|
777
799
|
* Name of the transformer to execute after this source captures an event.
|
|
778
800
|
* If omitted, events route directly to the collector.
|
|
801
|
+
* Can be an array for explicit chain control (bypasses transformer.next resolution).
|
|
779
802
|
*/
|
|
780
|
-
next?: string;
|
|
803
|
+
next?: string | string[];
|
|
781
804
|
}
|
|
782
805
|
/**
|
|
783
806
|
* Transformer reference with inline package syntax.
|
|
@@ -785,6 +808,7 @@ interface SourceReference {
|
|
|
785
808
|
* @remarks
|
|
786
809
|
* References a transformer package and provides configuration.
|
|
787
810
|
* Transformers transform events in the pipeline between sources and destinations.
|
|
811
|
+
* Alternatively, use `code: true` for inline code execution.
|
|
788
812
|
*/
|
|
789
813
|
interface TransformerReference {
|
|
790
814
|
/**
|
|
@@ -792,19 +816,30 @@ interface TransformerReference {
|
|
|
792
816
|
*
|
|
793
817
|
* @remarks
|
|
794
818
|
* Same format as SourceReference.package
|
|
819
|
+
* Optional when `code: true` is used for inline code execution.
|
|
795
820
|
*
|
|
796
821
|
* @example
|
|
797
822
|
* "package": "@walkeros/transformer-enricher@1.0.0"
|
|
798
823
|
*/
|
|
799
|
-
package
|
|
824
|
+
package?: string;
|
|
800
825
|
/**
|
|
801
|
-
* Resolved import variable name.
|
|
826
|
+
* Resolved import variable name or built-in code transformer.
|
|
802
827
|
*
|
|
803
828
|
* @remarks
|
|
804
|
-
* Auto-resolved from packages[package].imports[0] during getFlowConfig()
|
|
805
|
-
*
|
|
829
|
+
* - String: Auto-resolved from packages[package].imports[0] during getFlowConfig(),
|
|
830
|
+
* or provided explicitly for advanced use cases.
|
|
831
|
+
* - InlineCode: Object with type, push, and optional init for inline code definition.
|
|
832
|
+
*
|
|
833
|
+
* @example
|
|
834
|
+
* // Using inline code object
|
|
835
|
+
* {
|
|
836
|
+
* "code": {
|
|
837
|
+
* "type": "enricher",
|
|
838
|
+
* "push": "$code:(event) => ({ ...event, data: { enriched: true } })"
|
|
839
|
+
* }
|
|
840
|
+
* }
|
|
806
841
|
*/
|
|
807
|
-
code?: string;
|
|
842
|
+
code?: string | InlineCode;
|
|
808
843
|
/**
|
|
809
844
|
* Transformer-specific configuration.
|
|
810
845
|
*
|
|
@@ -829,8 +864,9 @@ interface TransformerReference {
|
|
|
829
864
|
* If omitted:
|
|
830
865
|
* - Pre-collector: routes to collector
|
|
831
866
|
* - Post-collector: routes to destination
|
|
867
|
+
* Can be an array for explicit chain control (terminates chain walking).
|
|
832
868
|
*/
|
|
833
|
-
next?: string;
|
|
869
|
+
next?: string | string[];
|
|
834
870
|
/**
|
|
835
871
|
* Transformer-level variables (highest priority in cascade).
|
|
836
872
|
* Overrides flow and setup variables.
|
|
@@ -855,19 +891,30 @@ interface DestinationReference {
|
|
|
855
891
|
*
|
|
856
892
|
* @remarks
|
|
857
893
|
* Same format as SourceReference.package
|
|
894
|
+
* Optional when `code: true` is used for inline code execution.
|
|
858
895
|
*
|
|
859
896
|
* @example
|
|
860
897
|
* "package": "@walkeros/web-destination-gtag@2.0.0"
|
|
861
898
|
*/
|
|
862
|
-
package
|
|
899
|
+
package?: string;
|
|
863
900
|
/**
|
|
864
|
-
* Resolved import variable name.
|
|
901
|
+
* Resolved import variable name or built-in code destination.
|
|
865
902
|
*
|
|
866
903
|
* @remarks
|
|
867
|
-
* Auto-resolved from packages[package].imports[0] during getFlowConfig()
|
|
868
|
-
*
|
|
904
|
+
* - String: Auto-resolved from packages[package].imports[0] during getFlowConfig(),
|
|
905
|
+
* or provided explicitly for advanced use cases.
|
|
906
|
+
* - InlineCode: Object with type, push, and optional init for inline code definition.
|
|
907
|
+
*
|
|
908
|
+
* @example
|
|
909
|
+
* // Using inline code object
|
|
910
|
+
* {
|
|
911
|
+
* "code": {
|
|
912
|
+
* "type": "logger",
|
|
913
|
+
* "push": "$code:(event) => console.log('Event:', event.name)"
|
|
914
|
+
* }
|
|
915
|
+
* }
|
|
869
916
|
*/
|
|
870
|
-
code?: string;
|
|
917
|
+
code?: string | InlineCode;
|
|
871
918
|
/**
|
|
872
919
|
* Destination-specific configuration.
|
|
873
920
|
*
|
|
@@ -925,12 +972,14 @@ interface DestinationReference {
|
|
|
925
972
|
* @remarks
|
|
926
973
|
* Name of the transformer to execute before sending events to this destination.
|
|
927
974
|
* If omitted, events are sent directly from the collector.
|
|
975
|
+
* Can be an array for explicit chain control (bypasses transformer.next resolution).
|
|
928
976
|
*/
|
|
929
|
-
before?: string;
|
|
977
|
+
before?: string | string[];
|
|
930
978
|
}
|
|
931
979
|
|
|
932
980
|
type flow_Definitions = Definitions;
|
|
933
981
|
type flow_DestinationReference = DestinationReference;
|
|
982
|
+
type flow_InlineCode = InlineCode;
|
|
934
983
|
type flow_Packages = Packages;
|
|
935
984
|
type flow_Primitive = Primitive;
|
|
936
985
|
type flow_Server = Server;
|
|
@@ -940,7 +989,7 @@ type flow_TransformerReference = TransformerReference;
|
|
|
940
989
|
type flow_Variables = Variables;
|
|
941
990
|
type flow_Web = Web;
|
|
942
991
|
declare namespace flow {
|
|
943
|
-
export type { Config$5 as Config, flow_Definitions as Definitions, flow_DestinationReference as DestinationReference, flow_Packages as Packages, flow_Primitive as Primitive, flow_Server as Server, flow_Setup as Setup, flow_SourceReference as SourceReference, flow_TransformerReference as TransformerReference, flow_Variables as Variables, flow_Web as Web };
|
|
992
|
+
export type { Config$5 as Config, flow_Definitions as Definitions, flow_DestinationReference as DestinationReference, flow_InlineCode as InlineCode, flow_Packages as Packages, flow_Primitive as Primitive, flow_Server as Server, flow_Setup as Setup, flow_SourceReference as SourceReference, flow_TransformerReference as TransformerReference, flow_Variables as Variables, flow_Web as Web };
|
|
944
993
|
}
|
|
945
994
|
|
|
946
995
|
type AnyFunction$1<P extends unknown[] = never[], R = unknown> = (...args: P) => R;
|
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:()=>x,Context:()=>a,Data:()=>u,Destination:()=>l,Elb:()=>f,Flow:()=>p,Hooks:()=>d,Level:()=>m,Logger:()=>g,Mapping:()=>y,On:()=>b,Request:()=>v,Schema:()=>w,Source:()=>j,Transformer:()=>h,WalkerOS:()=>O,anonymizeIP:()=>k,assign:()=>N,castToProperty:()=>fe,castValue:()=>G,clone:()=>q,createDestination:()=>X,createEvent:()=>Q,createLogger:()=>ce,createMockLogger:()=>we,debounce:()=>ne,filterValues:()=>le,getBrowser:()=>Pe,getBrowserVersion:()=>$e,getByPath:()=>W,getDeviceType:()=>_e,getEvent:()=>Y,getFlowConfig:()=>T,getGrantedConsent:()=>J,getHeaders:()=>ke,getId:()=>ee,getMappingEvent:()=>ge,getMappingValue:()=>me,getMarketingParameters:()=>te,getOS:()=>Me,getOSVersion:()=>Te,getPlatform:()=>_,isArguments:()=>D,isArray:()=>V,isBoolean:()=>I,isCommand:()=>L,isDefined:()=>R,isElementOrDocument:()=>z,isFunction:()=>F,isNumber:()=>B,isObject:()=>K,isPropertyType:()=>ue,isSameType:()=>U,isString:()=>H,mockEnv:()=>he,packageNameToVariable:()=>$,parseUserAgent:()=>Ae,processEventMapping:()=>be,requestToData:()=>je,requestToParameter:()=>Oe,setByPath:()=>Z,throttle:()=>re,throwError:()=>E,transformData:()=>xe,traverseEnv:()=>ve,trim:()=>Ee,tryCatch:()=>pe,tryCatchAsync:()=>de,useHooks:()=>Se,validateEvent:()=>Ce,validateProperty:()=>Ne,wrapCondition:()=>Ve,wrapFn:()=>Ie,wrapValidate:()=>Le}),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={},g={};i(g,{Level:()=>m});var m=(e=>(e[e.ERROR=0]="ERROR",e[e.INFO=1]="INFO",e[e.DEBUG=2]="DEBUG",e))(m||{}),y={},b={},h={},v={},w={},j={},O={},x={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function k(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function E(e){throw new Error(String(e))}function S(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function A(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function P(e,t,n){if("string"==typeof e){const r=e.match(/^\$def\.([a-zA-Z_][a-zA-Z0-9_]*)$/);if(r){const e=r[1];return void 0===n[e]&&E(`Definition "${e}" not found`),P(n[e],t,n)}let o=e.replace(/\$var\.([a-zA-Z_][a-zA-Z0-9_]*)/g,(e,n)=>{if(void 0!==t[n])return String(t[n]);E(`Variable "${n}" not found`)});return o=o.replace(/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g,(e,t,n)=>"undefined"!=typeof process&&void 0!==process.env?.[t]?process.env[t]:void 0!==n?n:void E(`Environment variable "${t}" not found and no default provided`)),o}if(Array.isArray(e))return e.map(e=>P(e,t,n));if(null!==e&&"object"==typeof e){const r={};for(const[o,i]of Object.entries(e))r[o]=P(i,t,n);return r}return e}function $(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 M(e,t,n){if(t)return t;if(!e||!n)return;return n[e]?$(e):void 0}function T(e,t){const n=Object.keys(e.flows);t||(1===n.length?t=n[0]:E(`Multiple flows found (${n.join(", ")}). Please specify a flow.`));const r=e.flows[t];r||E(`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=S(e.variables,r.variables,n.variables),s=A(e.definitions,r.definitions,n.definitions),c=P(n.config,i,s),a=M(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=S(e.variables,r.variables,n.variables),s=A(e.definitions,r.definitions,n.definitions),c=P(n.config,i,s),a=M(n.package,n.code,o.packages);o.destinations[t]={...n,config:c,...a&&{code:a}}}if(o.collector){const t=S(e.variables,r.variables),n=A(e.definitions,r.definitions),i=P(o.collector,t,n);o.collector=i}return o}function _(e){return void 0!==e.web?"web":void 0!==e.server?"server":void E("Config must have web or server key")}var C={merge:!0,shallow:!0,extend:!0};function N(e,t={},n={}){n={...C,...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 D(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function V(e){return Array.isArray(e)}function I(e){return"boolean"==typeof e}function L(e){return"walker"===e}function R(e){return void 0!==e}function z(e){return e===document||e instanceof Element}function F(e){return"function"==typeof e}function B(e){return"number"==typeof e&&!Number.isNaN(e)}function K(e){return"object"==typeof e&&null!==e&&!V(e)&&"[object Object]"===Object.prototype.toString.call(e)}function U(e,t){return typeof e==typeof t}function H(e){return"string"==typeof e}function q(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]=q(e[r],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(q(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 W(e,t="",n){const r=t.split(".");let o=e;for(let e=0;e<r.length;e++){const t=r[e];if("*"===t&&V(o)){const t=r.slice(e+1).join("."),i=[];for(const e of o){const r=W(e,t,n);i.push(r)}return i}if(o=o instanceof Object?o[t]:void 0,!o)break}return R(o)?o:n}function Z(e,t,n){if(!K(e))return e;const r=q(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 G(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function J(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 X(e,t){const n={...e};return n.config=N(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=N(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=N(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function Q(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",r=e.count||1,o=N({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:"1.0.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 Y(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 Q({...{"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 ee(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function te(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(N(o,t)).forEach(([t,o])=>{const i=e.searchParams.get(t);i&&(o===n&&(o=t,r[n]=t),r[o]=i)}),r}function ne(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 re(e,t=1e3){let n=null;return function(...r){if(null===n)return n=setTimeout(()=>{n=null},t),e(...r)}}function oe(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function ie(e,t){let n,r={};return e instanceof Error?(n=e.message,r.error=oe(e)):n=e,void 0!==t&&(t instanceof Error?r.error=oe(t):"object"==typeof t&&null!==t?(r={...r,...t},"error"in r&&r.error instanceof Error&&(r.error=oe(r.error))):r.value=t),{message:n,context:r}}var se=(e,t,n,r)=>{const o=`${m[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 ce(e={}){return ae({level:void 0!==e.level?function(e){return"string"==typeof e?m[e]:e}(e.level):0,handler:e.handler,scope:[]})}function ae(e){const{level:t,handler:n,scope:r}=e,o=(e,o,i)=>{if(e<=t){const t=ie(o,i);n?n(e,t.message,t.context,r,se):se(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=ie(e,t);throw n?n(0,o.message,o.context,r,se):se(0,o.message,o.context,r),new Error(o.message)},scope:e=>ae({level:t,handler:n,scope:[...r,e]})}}function ue(e){return I(e)||H(e)||B(e)||!R(e)||V(e)&&e.every(ue)||K(e)&&Object.values(e).every(ue)}function le(e){return I(e)||H(e)||B(e)?e:D(e)?le(Array.from(e)):V(e)?e.map(e=>le(e)).filter(e=>void 0!==e):K(e)?Object.entries(e).reduce((e,[t,n])=>{const r=le(n);return void 0!==r&&(e[t]=r),e},{}):void 0}function fe(e){return ue(e)?e:void 0}function pe(e,t,n){return function(...r){try{return e(...r)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function de(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 ge(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=V(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 me(e,t={},n={}){if(!R(e))return;const r=K(e)&&e.consent||n.consent||n.collector?.consent,o=V(t)?t:[t];for(const t of o){const o=await de(ye)(e,t,{...n,consent:r});if(R(o))return o}}async function ye(e,t,n={}){const{collector:r,consent:o}=n;return(V(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const c=H(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 de(a)(e,i,r))return;if(u&&!J(u,o))return y;let b=R(y)?y:e;if(l&&(b=await de(l)(e,i,n)),f&&(b=W(e,f,y)),p){const[t,r]=p,o="this"===t?[e]:await me(e,t,n);V(o)&&(b=(await Promise.all(o.map(e=>me(e,r,n)))).filter(R))}else d?b=await Object.entries(d).reduce(async(t,[r,o])=>{const i=await t,s=await me(e,o,n);return R(s)&&(i[r]=s),i},Promise.resolve({})):g&&(b=await Promise.all(g.map(t=>ye(e,t,n))));m&&!await de(m)(b)&&(b=void 0);const h=fe(b);return R(h)?h:fe(y)},Promise.resolve(void 0))}async function be(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,r])=>{const o=await me(e,r,{collector:n});e=Z(e,t,o)}));const{eventMapping:r,mappingKey:o}=await ge(e,t.mapping);r?.policy&&await Promise.all(Object.entries(r.policy).map(async([t,r])=>{const o=await me(e,r,{collector:n});e=Z(e,t,o)}));let i=t.data&&await me(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 me(e,r.data,{collector:n});i=K(i)&&K(t)?N(i,t):t}}return{event:e,data:i,mapping:r,mappingKey:o,ignore:!1}}function he(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 ve(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 we(){const e=[],t=jest.fn(e=>{const t=e instanceof Error?e.message:e;throw new Error(t)}),n=jest.fn(t=>{const n=we();return e.push(n),n});return{error:jest.fn(),info:jest.fn(),debug:jest.fn(),throw:t,scope:n,scopedLoggers:e}}function je(e){const t=String(e),n=t.split("?")[1]||t;return pe(()=>{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(V(o)){const s=parseInt(t,10);i?o[s]=G(e):(o[s]=o[s]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[s])}else K(o)&&(i?o[t]=G(e):(o[t]=o[t]||(isNaN(parseInt(r[n+1],10))?{}:[]),o=o[t]))})}),t})()}function Oe(e){if(!e)return"";const t=[],n=encodeURIComponent;function r(e,o){null!=o&&(V(o)?o.forEach((t,n)=>r(`${e}[${n}]`,t)):K(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 xe(e){return void 0===e||U(e,"")?e:JSON.stringify(e)}function ke(e={}){return N({"Content-Type":"application/json; charset=utf-8"},e)}function Ee(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function Se(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 Ae(e){return e?{userAgent:e,browser:Pe(e),browserVersion:$e(e),os:Me(e),osVersion:Te(e),deviceType:_e(e)}:{}}function Pe(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 Me(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 Te(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function _e(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 Ce(e,t=[]){let n,r,o;U(e,{})||E("Invalid object"),U(e.name,"")?(n=e.name,[r,o]=n.split(" "),r&&o||E("Invalid event name")):U(e.entity,"")&&U(e.action,"")?(r=e.entity,o=e.action,n=`${r} ${o}`):E("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=pe(Ne,e=>{E(String(e))})(t,r,i,o)),U(i,t[r])&&(t[r]=i),t},t)},i)}function Ne(e,t,n,r){if(r.validate&&(n=pe(r.validate,e=>{E(String(e))})(n,t,e)),r.required&&void 0===n&&E("Missing required property"),U(n,""))r.maxLength&&n.length>r.maxLength&&(r.strict&&E("Value exceeds maxLength"),n=n.substring(0,r.maxLength));else if(U(n,1))U(r.min,1)&&n<r.min?(r.strict&&E("Value below min"),n=r.min):U(r.max,1)&&n>r.max&&(r.strict&&E("Value exceeds max"),n=r.max);else if(U(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&&E(`Type doesn't match (${n})`),o=pe(Ne,e=>{E(String(e))})(t,n,o,r)),o},n)}for(const e of Object.keys(n))r.allowedKeys&&!r.allowedKeys.includes(e)&&(r.strict&&E("Key not allowed"),delete n[e])}return n}function De(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function Ve(e){const t=De(e);return new Function("value","mapping","collector",t)}function Ie(e){const t=De(e);return new Function("value","mapping","options",t)}function Le(e){const t=De(e);return new Function("value",t)}//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})},s={};i(s,{Collector:()=>a,Const:()=>x,Context:()=>c,Data:()=>u,Destination:()=>l,Elb:()=>f,Flow:()=>p,Hooks:()=>d,Level:()=>m,Logger:()=>g,Mapping:()=>y,On:()=>b,Request:()=>h,Schema:()=>w,Source:()=>j,Transformer:()=>v,WalkerOS:()=>O,anonymizeIP:()=>k,assign:()=>N,castToProperty:()=>fe,castValue:()=>G,clone:()=>q,createDestination:()=>X,createEvent:()=>Q,createLogger:()=>ae,createMockLogger:()=>we,debounce:()=>ne,filterValues:()=>le,getBrowser:()=>Pe,getBrowserVersion:()=>$e,getByPath:()=>W,getDeviceType:()=>_e,getEvent:()=>Y,getFlowConfig:()=>T,getGrantedConsent:()=>J,getHeaders:()=>ke,getId:()=>ee,getMappingEvent:()=>ge,getMappingValue:()=>me,getMarketingParameters:()=>te,getOS:()=>Me,getOSVersion:()=>Te,getPlatform:()=>_,isArguments:()=>D,isArray:()=>V,isBoolean:()=>I,isCommand:()=>L,isDefined:()=>R,isElementOrDocument:()=>z,isFunction:()=>F,isNumber:()=>B,isObject:()=>K,isPropertyType:()=>ue,isSameType:()=>U,isString:()=>H,mockEnv:()=>ve,packageNameToVariable:()=>$,parseUserAgent:()=>Ae,processEventMapping:()=>be,requestToData:()=>je,requestToParameter:()=>Oe,setByPath:()=>Z,throttle:()=>oe,throwError:()=>E,transformData:()=>xe,traverseEnv:()=>he,trim:()=>Ee,tryCatch:()=>pe,tryCatchAsync:()=>de,useHooks:()=>Se,validateEvent:()=>Ce,validateProperty:()=>Ne,wrapCondition:()=>Ve,wrapFn:()=>Ie,wrapValidate:()=>Le}),module.exports=(e=s,((e,i,s,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of o(i))r.call(e,c)||c===s||t(e,c,{get:()=>i[c],enumerable:!(a=n(i,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={},c={},u={},l={},f={},p={},d={},g={};i(g,{Level:()=>m});var m=(e=>(e[e.ERROR=0]="ERROR",e[e.INFO=1]="INFO",e[e.DEBUG=2]="DEBUG",e))(m||{}),y={},b={},v={},h={},w={},j={},O={},x={Utils:{Storage:{Local:"local",Session:"session",Cookie:"cookie"}}};function k(e){return/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)?e.replace(/\.\d+$/,".0"):""}function E(e){throw new Error(String(e))}function S(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function A(...e){const t={};for(const n of e)n&&Object.assign(t,n);return t}function P(e,t,n){if("string"==typeof e){const o=e.match(/^\$def\.([a-zA-Z_][a-zA-Z0-9_]*)$/);if(o){const e=o[1];return void 0===n[e]&&E(`Definition "${e}" not found`),P(n[e],t,n)}let r=e.replace(/\$var\.([a-zA-Z_][a-zA-Z0-9_]*)/g,(e,n)=>{if(void 0!==t[n])return String(t[n]);E(`Variable "${n}" not found`)});return r=r.replace(/\$env\.([a-zA-Z_][a-zA-Z0-9_]*)(?::([^"}\s]*))?/g,(e,t,n)=>"undefined"!=typeof process&&void 0!==process.env?.[t]?process.env[t]:void 0!==n?n:void E(`Environment variable "${t}" not found and no default provided`)),r}if(Array.isArray(e))return e.map(e=>P(e,t,n));if(null!==e&&"object"==typeof e){const o={};for(const[r,i]of Object.entries(e))o[r]=P(i,t,n);return o}return e}function $(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 M(e,t,n){if(t)return t;if(!e||!n)return;return n[e]?$(e):void 0}function T(e,t){const n=Object.keys(e.flows);t||(1===n.length?t=n[0]:E(`Multiple flows found (${n.join(", ")}). Please specify a flow.`));const o=e.flows[t];o||E(`Flow "${t}" not found. Available: ${n.join(", ")}`);const r=JSON.parse(JSON.stringify(o));if(r.sources)for(const[t,n]of Object.entries(r.sources)){const i=S(e.variables,o.variables,n.variables),s=A(e.definitions,o.definitions,n.definitions),a=P(n.config,i,s),c=M(n.package,n.code,r.packages),u="string"==typeof n.code||"object"==typeof n.code?n.code:void 0,l=c||u;r.sources[t]={package:n.package,config:a,env:n.env,primary:n.primary,variables:n.variables,definitions:n.definitions,next:n.next,code:l}}if(r.destinations)for(const[t,n]of Object.entries(r.destinations)){const i=S(e.variables,o.variables,n.variables),s=A(e.definitions,o.definitions,n.definitions),a=P(n.config,i,s),c=M(n.package,n.code,r.packages),u="string"==typeof n.code||"object"==typeof n.code?n.code:void 0,l=c||u;r.destinations[t]={package:n.package,config:a,env:n.env,variables:n.variables,definitions:n.definitions,before:n.before,code:l}}if(r.collector){const t=S(e.variables,o.variables),n=A(e.definitions,o.definitions),i=P(r.collector,t,n);r.collector=i}return r}function _(e){return void 0!==e.web?"web":void 0!==e.server?"server":void E("Config must have web or server key")}var C={merge:!0,shallow:!0,extend:!0};function N(e,t={},n={}){n={...C,...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 D(e){return"[object Arguments]"===Object.prototype.toString.call(e)}function V(e){return Array.isArray(e)}function I(e){return"boolean"==typeof e}function L(e){return"walker"===e}function R(e){return void 0!==e}function z(e){return e===document||e instanceof Element}function F(e){return"function"==typeof e}function B(e){return"number"==typeof e&&!Number.isNaN(e)}function K(e){return"object"==typeof e&&null!==e&&!V(e)&&"[object Object]"===Object.prototype.toString.call(e)}function U(e,t){return typeof e==typeof t}function H(e){return"string"==typeof e}function q(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]=q(e[o],t));return n}if("[object Array]"===n){const n=[];return t.set(e,n),e.forEach(e=>{n.push(q(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 W(e,t="",n){const o=t.split(".");let r=e;for(let e=0;e<o.length;e++){const t=o[e];if("*"===t&&V(r)){const t=o.slice(e+1).join("."),i=[];for(const e of r){const o=W(e,t,n);i.push(o)}return i}if(r=r instanceof Object?r[t]:void 0,!r)break}return R(r)?r:n}function Z(e,t,n){if(!K(e))return e;const o=q(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 G(e){if("true"===e)return!0;if("false"===e)return!1;const t=Number(e);return e==t&&""!==e?t:String(e)}function J(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 X(e,t){const n={...e};return n.config=N(e.config,t,{shallow:!0,merge:!0,extend:!0}),e.config.settings&&t.settings&&(n.config.settings=N(e.config.settings,t.settings,{shallow:!0,merge:!0,extend:!0})),e.config.mapping&&t.mapping&&(n.config.mapping=N(e.config.mapping,t.mapping,{shallow:!0,merge:!0,extend:!0})),n}function Q(e={}){const t=e.timestamp||(new Date).setHours(0,13,37,0),n=e.group||"gr0up",o=e.count||1,r=N({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:"1.1.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&&(r.entity=t,r.action=n)}return r}function Y(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 Q({...{"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.walkeros.io/",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 ee(e=6){let t="";for(let n=36;t.length<e;)t+=(Math.random()*n|0).toString(n);return t}function te(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(N(r,t)).forEach(([t,r])=>{const i=e.searchParams.get(t);i&&(r===n&&(r=t,o[n]=t),o[r]=i)}),o}function ne(e,t=1e3,n=!1){let o,r=null,i=!1;return(...s)=>new Promise(a=>{const c=n&&!i;r&&clearTimeout(r),r=setTimeout(()=>{r=null,n&&!i||(o=e(...s),a(o))},t),c&&(i=!0,o=e(...s),a(o))})}function oe(e,t=1e3){let n=null;return function(...o){if(null===n)return n=setTimeout(()=>{n=null},t),e(...o)}}function re(e){return{message:e.message,name:e.name,stack:e.stack,cause:e.cause}}function ie(e,t){let n,o={};return e instanceof Error?(n=e.message,o.error=re(e)):n=e,void 0!==t&&(t instanceof Error?o.error=re(t):"object"==typeof t&&null!==t?(o={...o,...t},"error"in o&&o.error instanceof Error&&(o.error=re(o.error))):o.value=t),{message:n,context:o}}var se=(e,t,n,o)=>{const r=`${m[e]}${o.length>0?` [${o.join(":")}]`:""}`,i=Object.keys(n).length>0;0===e?i?console.error(r,t,n):console.error(r,t):i?console.log(r,t,n):console.log(r,t)};function ae(e={}){return ce({level:void 0!==e.level?function(e){return"string"==typeof e?m[e]:e}(e.level):0,handler:e.handler,scope:[]})}function ce(e){const{level:t,handler:n,scope:o}=e,r=(e,r,i)=>{if(e<=t){const t=ie(r,i);n?n(e,t.message,t.context,o,se):se(e,t.message,t.context,o)}};return{error:(e,t)=>r(0,e,t),info:(e,t)=>r(1,e,t),debug:(e,t)=>r(2,e,t),throw:(e,t)=>{const r=ie(e,t);throw n?n(0,r.message,r.context,o,se):se(0,r.message,r.context,o),new Error(r.message)},scope:e=>ce({level:t,handler:n,scope:[...o,e]})}}function ue(e){return I(e)||H(e)||B(e)||!R(e)||V(e)&&e.every(ue)||K(e)&&Object.values(e).every(ue)}function le(e){return I(e)||H(e)||B(e)?e:D(e)?le(Array.from(e)):V(e)?e.map(e=>le(e)).filter(e=>void 0!==e):K(e)?Object.entries(e).reduce((e,[t,n])=>{const o=le(n);return void 0!==o&&(e[t]=o),e},{}):void 0}function fe(e){return ue(e)?e:void 0}function pe(e,t,n){return function(...o){try{return e(...o)}catch(e){if(!t)return;return t(e)}finally{n?.()}}}function de(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 ge(e,t){const[n,o]=(e.name||"").split(" ");if(!t||!n||!o)return{};let r,i="",s=n,a=o;const c=t=>{if(t)return(t=V(t)?t:[t]).find(t=>!t.condition||t.condition(e))};t[s]||(s="*");const u=t[s];return u&&(u[a]||(a="*"),r=c(u[a])),r||(s="*",a="*",r=c(t[s]?.[a])),r&&(i=`${s} ${a}`),{eventMapping:r,mappingKey:i}}async function me(e,t={},n={}){if(!R(e))return;const o=K(e)&&e.consent||n.consent||n.collector?.consent,r=V(t)?t:[t];for(const t of r){const r=await de(ye)(e,t,{...n,consent:o});if(R(r))return r}}async function ye(e,t,n={}){const{collector:o,consent:r}=n;return(V(t)?t:[t]).reduce(async(t,i)=>{const s=await t;if(s)return s;const a=H(i)?{key:i}:i;if(!Object.keys(a).length)return;const{condition:c,consent:u,fn:l,key:f,loop:p,map:d,set:g,validate:m,value:y}=a;if(c&&!await de(c)(e,i,o))return;if(u&&!J(u,r))return y;let b=R(y)?y:e;if(l&&(b=await de(l)(e,i,n)),f&&(b=W(e,f,y)),p){const[t,o]=p,r="this"===t?[e]:await me(e,t,n);V(r)&&(b=(await Promise.all(r.map(e=>me(e,o,n)))).filter(R))}else d?b=await Object.entries(d).reduce(async(t,[o,r])=>{const i=await t,s=await me(e,r,n);return R(s)&&(i[o]=s),i},Promise.resolve({})):g&&(b=await Promise.all(g.map(t=>ye(e,t,n))));m&&!await de(m)(b)&&(b=void 0);const v=fe(b);return R(v)?v:fe(y)},Promise.resolve(void 0))}async function be(e,t,n){t.policy&&await Promise.all(Object.entries(t.policy).map(async([t,o])=>{const r=await me(e,o,{collector:n});e=Z(e,t,r)}));const{eventMapping:o,mappingKey:r}=await ge(e,t.mapping);o?.policy&&await Promise.all(Object.entries(o.policy).map(async([t,o])=>{const r=await me(e,o,{collector:n});e=Z(e,t,r)}));let i=t.data&&await me(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 me(e,o.data,{collector:n});i=K(i)&&K(t)?N(i,t):t}}return{event:e,data:i,mapping:o,mappingKey:r,ignore:!1}}function ve(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 he(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 we(){const e=[],t=jest.fn(e=>{const t=e instanceof Error?e.message:e;throw new Error(t)}),n=jest.fn(t=>{const n=we();return e.push(n),n});return{error:jest.fn(),info:jest.fn(),debug:jest.fn(),throw:t,scope:n,scopedLoggers:e}}function je(e){const t=String(e),n=t.split("?")[1]||t;return pe(()=>{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(V(r)){const s=parseInt(t,10);i?r[s]=G(e):(r[s]=r[s]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[s])}else K(r)&&(i?r[t]=G(e):(r[t]=r[t]||(isNaN(parseInt(o[n+1],10))?{}:[]),r=r[t]))})}),t})()}function Oe(e){if(!e)return"";const t=[],n=encodeURIComponent;function o(e,r){null!=r&&(V(r)?r.forEach((t,n)=>o(`${e}[${n}]`,t)):K(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 xe(e){return void 0===e||U(e,"")?e:JSON.stringify(e)}function ke(e={}){return N({"Content-Type":"application/json; charset=utf-8"},e)}function Ee(e){return e?e.trim().replace(/^'|'$/g,"").trim():""}function Se(e,t,n){return function(...o){let r;const i="post"+t,s=n["pre"+t],a=n[i];return r=s?s({fn:e},...o):e(...o),a&&(r=a({fn:e,result:r},...o)),r}}function Ae(e){return e?{userAgent:e,browser:Pe(e),browserVersion:$e(e),os:Me(e),osVersion:Te(e),deviceType:_e(e)}:{}}function Pe(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 Me(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 Te(e){const t=e.match(/(?:Windows NT|Mac OS X|Android|iPhone OS) ([0-9._]+)/);return t?t[1].replace(/_/g,"."):void 0}function _e(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 Ce(e,t=[]){let n,o,r;U(e,{})||E("Invalid object"),U(e.name,"")?(n=e.name,[o,r]=n.split(" "),o&&r||E("Invalid event name")):U(e.entity,"")&&U(e.action,"")?(o=e.entity,r=e.action,n=`${o} ${r}`):E("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=pe(Ne,e=>{E(String(e))})(t,o,i,r)),U(i,t[o])&&(t[o]=i),t},t)},i)}function Ne(e,t,n,o){if(o.validate&&(n=pe(o.validate,e=>{E(String(e))})(n,t,e)),o.required&&void 0===n&&E("Missing required property"),U(n,""))o.maxLength&&n.length>o.maxLength&&(o.strict&&E("Value exceeds maxLength"),n=n.substring(0,o.maxLength));else if(U(n,1))U(o.min,1)&&n<o.min?(o.strict&&E("Value below min"),n=o.min):U(o.max,1)&&n>o.max&&(o.strict&&E("Value exceeds max"),n=o.max);else if(U(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&&E(`Type doesn't match (${n})`),r=pe(Ne,e=>{E(String(e))})(t,n,r,o)),r},n)}for(const e of Object.keys(n))o.allowedKeys&&!o.allowedKeys.includes(e)&&(o.strict&&E("Key not allowed"),delete n[e])}return n}function De(e){return function(e){return/\breturn\b/.test(e)}(e)?e:`return ${e}`}function Ve(e){const t=De(e);return new Function("value","mapping","collector",t)}function Ie(e){const t=De(e);return new Function("value","mapping","options",t)}function Le(e){const t=De(e);return new Function("value",t)}//# sourceMappingURL=index.js.map
|