@datalyr/web 1.0.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.
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Attribution Tracking Module
3
+ * Handles UTM parameters, click IDs, and customer journey
4
+ */
5
+ import type { Attribution, TouchPoint } from './types';
6
+ export declare class AttributionManager {
7
+ private attributionWindow;
8
+ private trackedParams;
9
+ private UTM_PARAMS;
10
+ private CLICK_IDS;
11
+ constructor(options?: {
12
+ attributionWindow?: number;
13
+ trackedParams?: string[];
14
+ });
15
+ /**
16
+ * Capture current attribution from URL
17
+ */
18
+ captureAttribution(): Attribution;
19
+ /**
20
+ * Store first touch attribution
21
+ */
22
+ storeFirstTouch(attribution: Attribution): void;
23
+ /**
24
+ * Get first touch attribution
25
+ */
26
+ getFirstTouch(): Attribution | null;
27
+ /**
28
+ * Store last touch attribution
29
+ */
30
+ storeLastTouch(attribution: Attribution): void;
31
+ /**
32
+ * Get last touch attribution
33
+ */
34
+ getLastTouch(): Attribution | null;
35
+ /**
36
+ * Add touchpoint to customer journey
37
+ */
38
+ addTouchpoint(sessionId: string, attribution: Attribution): void;
39
+ /**
40
+ * Get customer journey
41
+ */
42
+ getJourney(): TouchPoint[];
43
+ /**
44
+ * Get attribution data for event
45
+ */
46
+ getAttributionData(): Record<string, any>;
47
+ /**
48
+ * Determine source from attribution data
49
+ */
50
+ private determineSource;
51
+ /**
52
+ * Determine medium from attribution data
53
+ */
54
+ private determineMedium;
55
+ /**
56
+ * Extract hostname from URL
57
+ */
58
+ private extractHostname;
59
+ /**
60
+ * Check if attribution has expired
61
+ */
62
+ isAttributionExpired(attribution: Attribution): boolean;
63
+ /**
64
+ * Clear expired attribution
65
+ */
66
+ clearExpiredAttribution(): void;
67
+ }
68
+ //# sourceMappingURL=attribution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attribution.d.ts","sourceRoot":"","sources":["../src/attribution.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEvD,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,aAAa,CAAW;IAChC,OAAO,CAAC,UAAU,CAA2E;IAC7F,OAAO,CAAC,SAAS,CAA6F;gBAElG,OAAO,GAAE;QACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB;IAKN;;OAEG;IACH,kBAAkB,IAAI,WAAW;IAwDjC;;OAEG;IACH,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAU/C;;OAEG;IACH,aAAa,IAAI,WAAW,GAAG,IAAI;IAInC;;OAEG;IACH,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI;IAO9C;;OAEG;IACH,YAAY,IAAI,WAAW,GAAG,IAAI;IAIlC;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI;IAqBhE;;OAEG;IACH,UAAU,IAAI,UAAU,EAAE;IAI1B;;OAEG;IACH,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAgDzC;;OAEG;IACH,OAAO,CAAC,eAAe;IA6CvB;;OAEG;IACH,OAAO,CAAC,eAAe;IA2BvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAQvB;;OAEG;IACH,oBAAoB,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO;IAKvD;;OAEG;IACH,uBAAuB,IAAI,IAAI;CAYhC"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Container Script Manager
3
+ * Loads and manages third-party tracking scripts and pixels
4
+ */
5
+ export interface ContainerScript {
6
+ id: string;
7
+ name: string;
8
+ type: 'inline' | 'external' | 'pixel';
9
+ content: string;
10
+ trigger: 'page_load' | 'dom_ready' | 'window_load' | 'custom';
11
+ frequency: 'always' | 'once_per_page' | 'once_per_session';
12
+ enabled: boolean;
13
+ conditions?: Array<{
14
+ type: string;
15
+ operator: string;
16
+ value: any;
17
+ }>;
18
+ settings?: {
19
+ async?: boolean;
20
+ defer?: boolean;
21
+ integrity?: string;
22
+ crossorigin?: string;
23
+ };
24
+ }
25
+ export interface PixelConfig {
26
+ meta?: {
27
+ enabled: boolean;
28
+ pixel_id: string;
29
+ enhanced_conversions?: boolean;
30
+ };
31
+ google?: {
32
+ enabled: boolean;
33
+ tag_id: string;
34
+ enhanced_conversions?: boolean;
35
+ };
36
+ tiktok?: {
37
+ enabled: boolean;
38
+ pixel_id: string;
39
+ };
40
+ }
41
+ export declare class ContainerManager {
42
+ private scripts;
43
+ private loadedScripts;
44
+ private sessionLoadedScripts;
45
+ private pixels;
46
+ private workspaceId;
47
+ private endpoint;
48
+ private debug;
49
+ private initialized;
50
+ constructor(options: {
51
+ workspaceId: string;
52
+ endpoint?: string;
53
+ debug?: boolean;
54
+ });
55
+ /**
56
+ * Initialize container and load scripts
57
+ */
58
+ init(): Promise<void>;
59
+ /**
60
+ * Load scripts by trigger type
61
+ */
62
+ private loadScriptsByTrigger;
63
+ /**
64
+ * Check if script should be loaded based on frequency and conditions
65
+ */
66
+ private shouldLoadScript;
67
+ /**
68
+ * Evaluate script conditions
69
+ */
70
+ private evaluateConditions;
71
+ /**
72
+ * Evaluate string condition
73
+ */
74
+ private evaluateStringCondition;
75
+ /**
76
+ * Load a single script
77
+ */
78
+ private loadScript;
79
+ /**
80
+ * Load inline JavaScript
81
+ */
82
+ private loadInlineScript;
83
+ /**
84
+ * Load external JavaScript
85
+ */
86
+ private loadExternalScript;
87
+ /**
88
+ * Load tracking pixel
89
+ */
90
+ private loadPixel;
91
+ /**
92
+ * Initialize third-party pixels (Meta, Google, TikTok)
93
+ */
94
+ private initializePixels;
95
+ /**
96
+ * Initialize Meta (Facebook) Pixel
97
+ */
98
+ private initializeMetaPixel;
99
+ /**
100
+ * Initialize Google Tag
101
+ */
102
+ private initializeGoogleTag;
103
+ /**
104
+ * Initialize TikTok Pixel
105
+ */
106
+ private initializeTikTokPixel;
107
+ /**
108
+ * Track event to all initialized pixels
109
+ */
110
+ trackToPixels(eventName: string, properties?: any): void;
111
+ /**
112
+ * Manually trigger a custom script
113
+ */
114
+ triggerCustomScript(scriptId: string): void;
115
+ /**
116
+ * Get loaded scripts
117
+ */
118
+ getLoadedScripts(): string[];
119
+ /**
120
+ * Extract app endpoint from ingest endpoint
121
+ */
122
+ private extractAppEndpoint;
123
+ /**
124
+ * Check for malicious patterns in inline scripts
125
+ */
126
+ private containsMaliciousPatterns;
127
+ /**
128
+ * Validate script URL
129
+ */
130
+ private isValidScriptUrl;
131
+ /**
132
+ * Generate a nonce for CSP
133
+ */
134
+ private generateNonce;
135
+ /**
136
+ * Debug logging
137
+ */
138
+ private log;
139
+ }
140
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,aAAa,GAAG,QAAQ,CAAC;IAC9D,SAAS,EAAE,QAAQ,GAAG,eAAe,GAAG,kBAAkB,CAAC;IAC3D,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,KAAK,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,GAAG,CAAC;KACZ,CAAC,CAAC;IACH,QAAQ,CAAC,EAAE;QACT,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,CAAC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