@walkeros/collector 0.0.7

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 ADDED
@@ -0,0 +1,100 @@
1
+ <p align="left">
2
+ <a href="https://elbwalker.com">
3
+ <img title="elbwalker" src='https://www.elbwalker.com/img/elbwalker_logo.png' width="256px"/>
4
+ </a>
5
+ </p>
6
+
7
+ # Collector for walkerOS
8
+
9
+ The walkerOS Collector is the central event processing engine that unifies data
10
+ collection across web and server environments. It acts as the orchestrator
11
+ between sources (where events originate) and destinations (where events are
12
+ sent), providing consistent event processing, consent management, and data
13
+ validation across your entire data collection infrastructure.
14
+
15
+ ## Role in walkerOS Ecosystem
16
+
17
+ walkerOS follows a **source → collector → destination** architecture:
18
+
19
+ - **Sources**: Capture events from various environments (browser DOM, dataLayer,
20
+ server requests)
21
+ - **Collector**: Processes, validates, and routes events with consent awareness
22
+ - **Destinations**: Send processed events to analytics platforms (GA4, Meta,
23
+ custom APIs)
24
+
25
+ The Collector serves as the foundation that both web and server sources depend
26
+ on, ensuring consistent event handling regardless of the environment.
27
+
28
+ ## Installation
29
+
30
+ ```sh
31
+ npm install @walkeros/collector
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ The collector provides a factory function for creating collector instances:
37
+
38
+ ```typescript
39
+ import { createCollector } from '@walkeros/collector';
40
+
41
+ // Basic setup
42
+ const { collector, elb } = await createCollector({
43
+ consent: { functional: true },
44
+ destinations: [
45
+ // Add your destinations here
46
+ ],
47
+ });
48
+
49
+ // Process events - use elb as the standard API
50
+ await elb('page view', {
51
+ page: '/home',
52
+ });
53
+ ```
54
+
55
+ ## Event Naming Convention
56
+
57
+ walkerOS enforces a **"entity action"** naming convention for all events. It
58
+ makes it easier to standardize enhancements and validations. It follows a clear
59
+ separation. The mapping translates walkerOS events into platform-specific ones.
60
+
61
+ ✅ **Correct**: Use spaces to separate entity and action
62
+
63
+ ```typescript
64
+ await elb('order complete', { value: 99.99 });
65
+ await elb('product add', { id: 'abc123' });
66
+ await elb('page view', { path: '/home' });
67
+ ```
68
+
69
+ ❌ **Incorrect**: Do not use platform-specific formats
70
+
71
+ ```typescript
72
+ // Don't use these in walkerOS
73
+ await elb('purchase'); // GA4 format - wrong here
74
+ await elb('order_complete', data); // Wrong: underscores
75
+ ```
76
+
77
+ The collector will validate event names and destinations handle
78
+ platform-specific transformations. If the event name isn't separated into entity
79
+ action by space the collector won't process it.
80
+
81
+ ## Core Features
82
+
83
+ - **Event Processing**: Validates and enriches events with context and metadata
84
+ - **Consent Management**: Respects user consent preferences across all
85
+ destinations
86
+ - **Destination Routing**: Translates and routes events to configured
87
+ destinations
88
+ - **State Management**: Maintains consistent state across the collection
89
+ pipeline
90
+
91
+ ## Contribute
92
+
93
+ Feel free to contribute by submitting an
94
+ [issue](https://github.com/elbwalker/walkerOS/issues), starting a
95
+ [discussion](https://github.com/elbwalker/walkerOS/discussions), or getting in
96
+ [contact](https://calendly.com/elb-alexander/30min).
97
+
98
+ ## License
99
+
100
+ This project is licensed under the MIT License.
@@ -0,0 +1,179 @@
1
+ import { Source, WalkerOS, Collector, Elb, Destination, On } from '@walkeros/core';
2
+
3
+ /**
4
+ * Core source factory function that creates sources with consistent error handling and lifecycle management.
5
+ *
6
+ * @template T - The source configuration type
7
+ * @param collector - The WalkerOS collector instance
8
+ * @param source - The source function
9
+ * @param config - The source configuration
10
+ * @returns Promise resolving to the created source with its elb function
11
+ */
12
+ declare function createSource<T extends Source.Config, E = WalkerOS.AnyFunction>(collector: Collector.Instance, source: Source.Init<T, E>, config: Source.InitConfig): Promise<Source.CreateSource<T, E>>;
13
+ interface SourceInit<T extends Source.Config = Source.Config, E = WalkerOS.AnyFunction> {
14
+ code: Source.Init<T, E>;
15
+ config?: Partial<T>;
16
+ }
17
+ interface InitSources {
18
+ [sourceId: string]: SourceInit<any, any>;
19
+ }
20
+ /**
21
+ * Initialize multiple sources for a collector
22
+ *
23
+ * @param collector - The WalkerOS collector instance
24
+ * @param sources - Map of source configurations
25
+ */
26
+ declare function initSources(collector: Collector.Instance, sources?: InitSources): Promise<void>;
27
+
28
+ interface RunState {
29
+ consent?: WalkerOS.Consent;
30
+ user?: WalkerOS.User;
31
+ globals?: WalkerOS.Properties;
32
+ custom?: WalkerOS.Properties;
33
+ }
34
+ interface CreateCollector {
35
+ collector: Collector.Instance;
36
+ elb: WalkerOS.Elb;
37
+ }
38
+ type InitSource = Partial<Collector.CollectorSource>;
39
+ interface CollectorConfig extends Collector.Config {
40
+ sources?: InitSources;
41
+ }
42
+
43
+ type CommandTypes = 'Action' | 'Config' | 'Consent' | 'Context' | 'Custom' | 'Destination' | 'Elb' | 'Globals' | 'Hook' | 'Init' | 'Link' | 'On' | 'Prefix' | 'Ready' | 'Run' | 'Session' | 'User' | 'Walker';
44
+ declare const Commands: Record<CommandTypes, Collector.CommandType>;
45
+ type StorageType = 'cookie' | 'local' | 'session';
46
+ declare const Const: {
47
+ Commands: Record<CommandTypes, string>;
48
+ Utils: {
49
+ Storage: {
50
+ [key: string]: StorageType;
51
+ };
52
+ };
53
+ };
54
+
55
+ /**
56
+ * Sets the consent state and processes the queue.
57
+ *
58
+ * @param collector - The walkerOS collector instance.
59
+ * @param data - The consent data to set.
60
+ * @returns The result of the push operation.
61
+ */
62
+ declare function setConsent(collector: Collector.Instance, data: WalkerOS.Consent): Promise<Elb.PushResult>;
63
+
64
+ declare function createCollector<TConfig extends Partial<CollectorConfig> = Partial<CollectorConfig>>(initConfig?: TConfig): Promise<CreateCollector>;
65
+
66
+ type HandleCommandFn<T extends Collector.Instance> = (collector: T, action: string, data?: Elb.PushData, options?: unknown) => Promise<Elb.PushResult>;
67
+ /**
68
+ * Creates the main push function for the collector.
69
+ *
70
+ * @template T, F
71
+ * @param collector - The walkerOS collector instance.
72
+ * @param handleCommand - TBD.
73
+ * @param prepareEvent - TBD.
74
+ * @returns The push function.
75
+ */
76
+ declare function createPush<T extends Collector.Instance>(collector: T, handleCommand: HandleCommandFn<T>, prepareEvent: (event: WalkerOS.DeepPartialEvent) => WalkerOS.PartialEvent): Elb.Fn;
77
+ /**
78
+ * Adds a new destination to the collector.
79
+ *
80
+ * @param collector - The walkerOS collector instance.
81
+ * @param data - The destination's init data.
82
+ * @param options - The destination's config.
83
+ * @returns The result of the push operation.
84
+ */
85
+ declare function addDestination(collector: Collector.Instance, data: Destination.Init, options?: Destination.Config): Promise<Elb.PushResult>;
86
+ /**
87
+ * Pushes an event to all or a subset of destinations.
88
+ *
89
+ * @param collector - The walkerOS collector instance.
90
+ * @param event - The event to push.
91
+ * @param destinations - The destinations to push to.
92
+ * @returns The result of the push operation.
93
+ */
94
+ declare function pushToDestinations(collector: Collector.Instance, event?: WalkerOS.Event, destinations?: Collector.Destinations): Promise<Elb.PushResult>;
95
+ /**
96
+ * Initializes a destination.
97
+ *
98
+ * @template Destination
99
+ * @param collector - The walkerOS collector instance.
100
+ * @param destination - The destination to initialize.
101
+ * @returns Whether the destination was initialized successfully.
102
+ */
103
+ declare function destinationInit<Destination extends Destination.Instance>(collector: Collector.Instance, destination: Destination): Promise<boolean>;
104
+ /**
105
+ * Pushes an event to a single destination.
106
+ * Handles mapping, batching, and consent checks.
107
+ *
108
+ * @template Destination
109
+ * @param collector - The walkerOS collector instance.
110
+ * @param destination - The destination to push to.
111
+ * @param event - The event to push.
112
+ * @returns Whether the event was pushed successfully.
113
+ */
114
+ declare function destinationPush<Destination extends Destination.Instance>(collector: Collector.Instance, destination: Destination, event: WalkerOS.Event): Promise<boolean>;
115
+ /**
116
+ * Creates a standardized result object for push operations.
117
+ *
118
+ * @param partialResult - A partial result to merge with the default result.
119
+ * @returns The push result.
120
+ */
121
+ declare function createPushResult(partialResult?: Partial<Elb.PushResult>): Elb.PushResult;
122
+ /**
123
+ * Initializes a map of destinations.
124
+ *
125
+ * @param destinations - The destinations to initialize.
126
+ * @returns The initialized destinations.
127
+ */
128
+ declare function initDestinations(destinations: Destination.InitDestinations): Collector.Destinations;
129
+
130
+ /**
131
+ * Handles common commands.
132
+ *
133
+ * @param collector The walkerOS collector instance.
134
+ * @param action The action to handle.
135
+ * @param data The data to handle.
136
+ * @param options The options to handle.
137
+ * @returns A promise that resolves with the push result or undefined.
138
+ */
139
+ declare function commonHandleCommand(collector: Collector.Instance, action: string, data?: unknown, options?: unknown): Promise<Elb.PushResult>;
140
+ /**
141
+ * Creates an event or a command from a partial event.
142
+ *
143
+ * @param collector The walkerOS collector instance.
144
+ * @param nameOrEvent The name of the event or a partial event.
145
+ * @param defaults The default values for the event.
146
+ * @returns An object with the event or the command.
147
+ */
148
+ declare function createEventOrCommand(collector: Collector.Instance, nameOrEvent: unknown, defaults?: WalkerOS.PartialEvent): {
149
+ event?: WalkerOS.Event;
150
+ command?: string;
151
+ };
152
+ /**
153
+ * Runs the collector by setting it to allowed state and processing queued events.
154
+ *
155
+ * @param collector The walkerOS collector instance.
156
+ * @param state Optional state to merge with the collector (user, globals, consent, custom).
157
+ * @returns A promise that resolves with the push result.
158
+ */
159
+ declare function runCollector(collector: Collector.Instance, state?: RunState): Promise<Elb.PushResult>;
160
+
161
+ /**
162
+ * Registers a callback for a specific event type.
163
+ *
164
+ * @param collector The walkerOS collector instance.
165
+ * @param type The type of the event to listen for.
166
+ * @param option The callback function or an array of callback functions.
167
+ */
168
+ declare function on(collector: Collector.Instance, type: On.Types, option: WalkerOS.SingleOrArray<On.Options>): void;
169
+ /**
170
+ * Applies all registered callbacks for a specific event type.
171
+ *
172
+ * @param collector The walkerOS collector instance.
173
+ * @param type The type of the event to apply the callbacks for.
174
+ * @param options The options for the callbacks.
175
+ * @param config The consent configuration.
176
+ */
177
+ declare function onApply(collector: Collector.Instance, type: On.Types, options?: Array<On.Options>, config?: WalkerOS.Consent): void;
178
+
179
+ export { type CollectorConfig, type CommandTypes, Commands, Const, type CreateCollector, type HandleCommandFn, type InitSource, type InitSources, type RunState, type SourceInit, type StorageType, addDestination, commonHandleCommand, createCollector, createEventOrCommand, createPush, createPushResult, createSource, destinationInit, destinationPush, initDestinations, initSources, on, onApply, pushToDestinations, runCollector, setConsent };
@@ -0,0 +1,179 @@
1
+ import { Source, WalkerOS, Collector, Elb, Destination, On } from '@walkeros/core';
2
+
3
+ /**
4
+ * Core source factory function that creates sources with consistent error handling and lifecycle management.
5
+ *
6
+ * @template T - The source configuration type
7
+ * @param collector - The WalkerOS collector instance
8
+ * @param source - The source function
9
+ * @param config - The source configuration
10
+ * @returns Promise resolving to the created source with its elb function
11
+ */
12
+ declare function createSource<T extends Source.Config, E = WalkerOS.AnyFunction>(collector: Collector.Instance, source: Source.Init<T, E>, config: Source.InitConfig): Promise<Source.CreateSource<T, E>>;
13
+ interface SourceInit<T extends Source.Config = Source.Config, E = WalkerOS.AnyFunction> {
14
+ code: Source.Init<T, E>;
15
+ config?: Partial<T>;
16
+ }
17
+ interface InitSources {
18
+ [sourceId: string]: SourceInit<any, any>;
19
+ }
20
+ /**
21
+ * Initialize multiple sources for a collector
22
+ *
23
+ * @param collector - The WalkerOS collector instance
24
+ * @param sources - Map of source configurations
25
+ */
26
+ declare function initSources(collector: Collector.Instance, sources?: InitSources): Promise<void>;
27
+
28
+ interface RunState {
29
+ consent?: WalkerOS.Consent;
30
+ user?: WalkerOS.User;
31
+ globals?: WalkerOS.Properties;
32
+ custom?: WalkerOS.Properties;
33
+ }
34
+ interface CreateCollector {
35
+ collector: Collector.Instance;
36
+ elb: WalkerOS.Elb;
37
+ }
38
+ type InitSource = Partial<Collector.CollectorSource>;
39
+ interface CollectorConfig extends Collector.Config {
40
+ sources?: InitSources;
41
+ }
42
+
43
+ type CommandTypes = 'Action' | 'Config' | 'Consent' | 'Context' | 'Custom' | 'Destination' | 'Elb' | 'Globals' | 'Hook' | 'Init' | 'Link' | 'On' | 'Prefix' | 'Ready' | 'Run' | 'Session' | 'User' | 'Walker';
44
+ declare const Commands: Record<CommandTypes, Collector.CommandType>;
45
+ type StorageType = 'cookie' | 'local' | 'session';
46
+ declare const Const: {
47
+ Commands: Record<CommandTypes, string>;
48
+ Utils: {
49
+ Storage: {
50
+ [key: string]: StorageType;
51
+ };
52
+ };
53
+ };
54
+
55
+ /**
56
+ * Sets the consent state and processes the queue.
57
+ *
58
+ * @param collector - The walkerOS collector instance.
59
+ * @param data - The consent data to set.
60
+ * @returns The result of the push operation.
61
+ */
62
+ declare function setConsent(collector: Collector.Instance, data: WalkerOS.Consent): Promise<Elb.PushResult>;
63
+
64
+ declare function createCollector<TConfig extends Partial<CollectorConfig> = Partial<CollectorConfig>>(initConfig?: TConfig): Promise<CreateCollector>;
65
+
66
+ type HandleCommandFn<T extends Collector.Instance> = (collector: T, action: string, data?: Elb.PushData, options?: unknown) => Promise<Elb.PushResult>;
67
+ /**
68
+ * Creates the main push function for the collector.
69
+ *
70
+ * @template T, F
71
+ * @param collector - The walkerOS collector instance.
72
+ * @param handleCommand - TBD.
73
+ * @param prepareEvent - TBD.
74
+ * @returns The push function.
75
+ */
76
+ declare function createPush<T extends Collector.Instance>(collector: T, handleCommand: HandleCommandFn<T>, prepareEvent: (event: WalkerOS.DeepPartialEvent) => WalkerOS.PartialEvent): Elb.Fn;
77
+ /**
78
+ * Adds a new destination to the collector.
79
+ *
80
+ * @param collector - The walkerOS collector instance.
81
+ * @param data - The destination's init data.
82
+ * @param options - The destination's config.
83
+ * @returns The result of the push operation.
84
+ */
85
+ declare function addDestination(collector: Collector.Instance, data: Destination.Init, options?: Destination.Config): Promise<Elb.PushResult>;
86
+ /**
87
+ * Pushes an event to all or a subset of destinations.
88
+ *
89
+ * @param collector - The walkerOS collector instance.
90
+ * @param event - The event to push.
91
+ * @param destinations - The destinations to push to.
92
+ * @returns The result of the push operation.
93
+ */
94
+ declare function pushToDestinations(collector: Collector.Instance, event?: WalkerOS.Event, destinations?: Collector.Destinations): Promise<Elb.PushResult>;
95
+ /**
96
+ * Initializes a destination.
97
+ *
98
+ * @template Destination
99
+ * @param collector - The walkerOS collector instance.
100
+ * @param destination - The destination to initialize.
101
+ * @returns Whether the destination was initialized successfully.
102
+ */
103
+ declare function destinationInit<Destination extends Destination.Instance>(collector: Collector.Instance, destination: Destination): Promise<boolean>;
104
+ /**
105
+ * Pushes an event to a single destination.
106
+ * Handles mapping, batching, and consent checks.
107
+ *
108
+ * @template Destination
109
+ * @param collector - The walkerOS collector instance.
110
+ * @param destination - The destination to push to.
111
+ * @param event - The event to push.
112
+ * @returns Whether the event was pushed successfully.
113
+ */
114
+ declare function destinationPush<Destination extends Destination.Instance>(collector: Collector.Instance, destination: Destination, event: WalkerOS.Event): Promise<boolean>;
115
+ /**
116
+ * Creates a standardized result object for push operations.
117
+ *
118
+ * @param partialResult - A partial result to merge with the default result.
119
+ * @returns The push result.
120
+ */
121
+ declare function createPushResult(partialResult?: Partial<Elb.PushResult>): Elb.PushResult;
122
+ /**
123
+ * Initializes a map of destinations.
124
+ *
125
+ * @param destinations - The destinations to initialize.
126
+ * @returns The initialized destinations.
127
+ */
128
+ declare function initDestinations(destinations: Destination.InitDestinations): Collector.Destinations;
129
+
130
+ /**
131
+ * Handles common commands.
132
+ *
133
+ * @param collector The walkerOS collector instance.
134
+ * @param action The action to handle.
135
+ * @param data The data to handle.
136
+ * @param options The options to handle.
137
+ * @returns A promise that resolves with the push result or undefined.
138
+ */
139
+ declare function commonHandleCommand(collector: Collector.Instance, action: string, data?: unknown, options?: unknown): Promise<Elb.PushResult>;
140
+ /**
141
+ * Creates an event or a command from a partial event.
142
+ *
143
+ * @param collector The walkerOS collector instance.
144
+ * @param nameOrEvent The name of the event or a partial event.
145
+ * @param defaults The default values for the event.
146
+ * @returns An object with the event or the command.
147
+ */
148
+ declare function createEventOrCommand(collector: Collector.Instance, nameOrEvent: unknown, defaults?: WalkerOS.PartialEvent): {
149
+ event?: WalkerOS.Event;
150
+ command?: string;
151
+ };
152
+ /**
153
+ * Runs the collector by setting it to allowed state and processing queued events.
154
+ *
155
+ * @param collector The walkerOS collector instance.
156
+ * @param state Optional state to merge with the collector (user, globals, consent, custom).
157
+ * @returns A promise that resolves with the push result.
158
+ */
159
+ declare function runCollector(collector: Collector.Instance, state?: RunState): Promise<Elb.PushResult>;
160
+
161
+ /**
162
+ * Registers a callback for a specific event type.
163
+ *
164
+ * @param collector The walkerOS collector instance.
165
+ * @param type The type of the event to listen for.
166
+ * @param option The callback function or an array of callback functions.
167
+ */
168
+ declare function on(collector: Collector.Instance, type: On.Types, option: WalkerOS.SingleOrArray<On.Options>): void;
169
+ /**
170
+ * Applies all registered callbacks for a specific event type.
171
+ *
172
+ * @param collector The walkerOS collector instance.
173
+ * @param type The type of the event to apply the callbacks for.
174
+ * @param options The options for the callbacks.
175
+ * @param config The consent configuration.
176
+ */
177
+ declare function onApply(collector: Collector.Instance, type: On.Types, options?: Array<On.Options>, config?: WalkerOS.Consent): void;
178
+
179
+ export { type CollectorConfig, type CommandTypes, Commands, Const, type CreateCollector, type HandleCommandFn, type InitSource, type InitSources, type RunState, type SourceInit, type StorageType, addDestination, commonHandleCommand, createCollector, createEventOrCommand, createPush, createPushResult, createSource, destinationInit, destinationPush, initDestinations, initSources, on, onApply, pushToDestinations, runCollector, setConsent };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e,t,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a=(e={"package.json"(e,t){t.exports={name:"@walkeros/collector",description:"Unified platform-agnostic collector for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{"@walkeros/core":"0.0.7"},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/collector"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","collector","event processing"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return t||(0,e[o(e)[0]])((t={exports:{}}).exports,t),t.exports}),r={};((e,t)=>{for(var s in t)n(e,s,{get:t[s],enumerable:!0})})(r,{Commands:()=>c,Const:()=>u,addDestination:()=>C,commonHandleCommand:()=>w,createCollector:()=>H,createEventOrCommand:()=>k,createPush:()=>v,createPushResult:()=>E,createSource:()=>A,destinationInit:()=>q,destinationPush:()=>j,initDestinations:()=>S,initSources:()=>M,on:()=>b,onApply:()=>h,pushToDestinations:()=>O,runCollector:()=>y,setConsent:()=>x}),module.exports=(e=>((e,t,a,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of o(t))i.call(e,c)||c===a||n(e,c,{get:()=>t[c],enumerable:!(r=s(t,c))||r.enumerable});return e})(n({},"__esModule",{value:!0}),e))(r);var c={Action:"action",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",User:"user",Walker:"walker"},u={Commands:c,Utils:{Storage:{Cookie:"cookie",Local:"local",Session:"session"}}},l=require("@walkeros/core"),d=require("@walkeros/core"),g=require("@walkeros/core"),p=require("@walkeros/core"),f=require("@walkeros/core"),m=require("@walkeros/core");function b(e,t,n){const s=e.on,o=s[t]||[],i=(0,f.isArray)(n)?n:[n];i.forEach(e=>{o.push(e)}),s[t]=o,h(e,t,i)}function h(e,t,n,s){let o=n||[];if(n||(o=e.on[t]||[],Object.values(e.destinations).forEach(e=>{const n=e.config.on?.[t];n&&(o=o.concat(n))})),o.length)switch(t){case u.Commands.Consent:!function(e,t,n){const s=n||e.consent;t.forEach(t=>{Object.keys(s).filter(e=>e in t).forEach(n=>{(0,m.tryCatch)(t[n])(e,s)})})}(e,o,s);break;case u.Commands.Ready:case u.Commands.Run:!function(e,t){e.allowed&&t.forEach(t=>{(0,m.tryCatch)(t)(e)})}(e,o);break;case u.Commands.Session:!function(e,t){if(!e.session)return;t.forEach(t=>{(0,m.tryCatch)(t)(e,e.session)})}(e,o)}}async function w(e,t,n,s){let o;switch(t){case u.Commands.Config:(0,p.isObject)(n)&&(0,g.assign)(e.config,n,{shallow:!1});break;case u.Commands.Consent:(0,p.isObject)(n)&&(o=await x(e,n));break;case u.Commands.Custom:(0,p.isObject)(n)&&(e.custom=(0,g.assign)(e.custom,n));break;case u.Commands.Destination:(0,p.isObject)(n)&&(0,g.isFunction)(n.push)&&(o=await C(e,n,s));break;case u.Commands.Globals:(0,p.isObject)(n)&&(e.globals=(0,g.assign)(e.globals,n));break;case u.Commands.On:(0,g.isString)(n)&&b(e,n,s);break;case u.Commands.Run:o=await y(e,n);break;case u.Commands.User:(0,p.isObject)(n)&&(0,g.assign)(e.user,n,{shallow:!1})}return o||{ok:!0,successful:[],queued:[],failed:[]}}function k(e,t,n={}){const s=(0,p.isSameType)(t,"")?{event:t,...n}:{...n,...t||{}};if(!s.event)throw new Error("Event name is required");const[o,i]=s.event.split(" ");if(!o||!i)throw new Error("Event name is invalid");if(o===c.Walker)return{command:i};++e.count;const{timestamp:a=Date.now(),group:r=e.group,count:u=e.count}=s,{event:l=`${o} ${i}`,data:d={},context:g={},globals:f=e.globals,custom:m={},user:b=e.user,nested:h=[],consent:w=e.consent,id:k=`${a}-${r}-${u}`,trigger:y="",entity:v=o,action:C=i,timing:O=0,version:q={source:e.version,tagging:e.config.tagging||0},source:j={type:"collector",id:"",previous_id:""}}=s;return{event:{event:l,data:d,context:g,globals:f,custom:m,user:b,nested:h,consent:w,id:k,trigger:y,entity:v,action:C,timestamp:a,timing:O,group:r,count:u,version:q,source:j}}}async function y(e,t){e.allowed=!0,e.count=0,e.group=(0,g.getId)(),e.timing=Date.now(),t&&(t.consent&&(e.consent=(0,g.assign)(e.consent,t.consent)),t.user&&(e.user=(0,g.assign)(e.user,t.user)),t.globals&&(e.globals=(0,g.assign)(e.config.globalsStatic||{},t.globals)),t.custom&&(e.custom=(0,g.assign)(e.custom,t.custom))),Object.values(e.destinations).forEach(e=>{e.queue=[]}),e.round++,h(e,"run");return await O(e)}function v(e,t,n){return(0,d.useHooks)(async(s,o,i)=>await(0,d.tryCatchAsync)(async()=>{if("string"==typeof s&&s.startsWith("walker ")){const n=s.replace("walker ","");return await t(e,n,o,i)}{const a=n("string"==typeof s?{event:s}:s),{event:r,command:c}=k(e,a.event,a);return c?await t(e,c,o,i):await O(e,r)}},()=>E({ok:!1}))(),"Push",e.hooks)}async function C(e,t,n){const s=n||t.config||{init:!1},o={...t,config:s};let i=s.id;if(!i)do{i=(0,d.getId)(4)}while(e.destinations[i]);return e.destinations[i]=o,!1!==s.queue&&(o.queue=[...e.queue]),O(e,void 0,{[i]:o})}async function O(e,t,n){const{allowed:s,consent:o,globals:i,user:a}=e;if(!s)return E({ok:!1});t&&e.queue.push(t),n||(n=e.destinations);const r=await Promise.all(Object.entries(n||{}).map(async([n,s])=>{let r=(s.queue||[]).map(e=>({...e,consent:o}));if(s.queue=[],t){let n=(0,d.clone)(t);await Promise.all(Object.entries(s.config.policy||[]).map(async([s,o])=>{const i=await(0,d.getMappingValue)(t,o,{collector:e});n=(0,d.setByPath)(n,s,i)})),r.push(n)}if(!r.length)return{id:n,destination:s,skipped:!0};const c=[],u=r.filter(e=>{const t=(0,d.getGrantedConsent)(s.config.consent,o,e.consent);return!t||(e.consent=t,c.push(e),!1)});if(s.queue.concat(u),!c.length)return{id:n,destination:s,queue:r};if(!await(0,d.tryCatchAsync)(q)(e,s))return{id:n,destination:s,queue:r};let l=!1;return s.dlq||(s.dlq=[]),await Promise.all(c.map(async t=>(t.globals=(0,d.assign)(i,t.globals),t.user=(0,d.assign)(a,t.user),await(0,d.tryCatchAsync)(j,n=>(e.config.onError&&e.config.onError(n,e),l=!0,s.dlq.push([t,n]),!1))(e,s,t),t))),{id:n,destination:s,error:l}})),c=[],u=[],l=[];for(const e of r){if(e.skipped)continue;const t=e.destination,n={id:e.id,destination:t};e.error?l.push(n):e.queue&&e.queue.length?(t.queue=(t.queue||[]).concat(e.queue),u.push(n)):c.push(n)}return E({ok:!l.length,event:t,successful:c,queued:u,failed:l})}async function q(e,t){if(t.init&&!t.config.init){const n={collector:e,config:t.config,wrap:D(t,e)},s=await(0,d.useHooks)(t.init,"DestinationInit",e.hooks)(n);if(!1===s)return s;t.config={...s||t.config,init:!0}}return!0}async function j(e,t,n){const{config:s}=t,{eventMapping:o,mappingKey:i}=await(0,d.getMappingEvent)(n,s.mapping);let a=s.data&&await(0,d.getMappingValue)(n,s.data,{collector:e});if(o){if(o.ignore)return!1;if(o.name&&(n.event=o.name),o.data){const t=o.data&&await(0,d.getMappingValue)(n,o.data,{collector:e});a=(0,d.isObject)(a)&&(0,d.isObject)(t)?(0,d.assign)(a,t):t}}const r={collector:e,config:s,data:a,mapping:o,wrap:D(t,e)};if(o?.batch&&t.pushBatch){const r=o.batched||{key:i||"",events:[],data:[]};r.events.push(n),(0,d.isDefined)(a)&&r.data.push(a),o.batchFn=o.batchFn||(0,d.debounce)((e,t)=>{const n={collector:t,config:s,data:a,mapping:o,wrap:D(e,t)};(0,d.useHooks)(e.pushBatch,"DestinationPushBatch",t.hooks)(r,n),r.events=[],r.data=[]},o.batch),o.batched=r,o.batchFn?.(t,e)}else await(0,d.useHooks)(t.push,"DestinationPush",e.hooks)(n,r);return!0}function E(e){return(0,d.assign)({ok:!e?.failed?.length,successful:[],queued:[],failed:[]},e)}function S(e){return Object.entries(e).reduce((e,[t,n])=>(e[t]={...n,config:(0,d.isObject)(n.config)?n.config:{}},e),{})}function D(e,t){const n=e.config.wrapper||{},s=e.config.dryRun??t?.config.dryRun;return(0,d.createWrapper)(e.type||"unknown",{...n,...(0,d.isDefined)(s)&&{dryRun:s}})}async function x(e,t){const{consent:n}=e;let s=!1;const o={};return Object.entries(t).forEach(([e,t])=>{const n=!!t;o[e]=n,s=s||n}),e.consent=(0,l.assign)(n,o),h(e,"consent",void 0,o),s?O(e):E({ok:!0})}var P=require("@walkeros/core"),R=require("@walkeros/core");async function A(e,t,n){const s={disabled:n.disabled??!1,settings:n.settings??{},onError:n.onError};if(s.disabled)return{};const o=await(0,R.tryCatchAsync)(t)(e,s);if(!o||!o.source)return{};const i=s.type||o.source.type||"",a=n.id||`${i}_${(0,R.getId)(5)}`;if(o.source&&o.elb){o.source.elb=o.elb}return e.sources[a]={type:i,settings:s.settings,mapping:void 0,elb:o.elb},o}async function M(e,t={}){for(const[n,s]of Object.entries(t)){const{code:t,config:o={}}=s,i={id:n,...o},a=await A(e,t,i);if(a.source){if(a.elb){a.source.elb=a.elb}e.sources[n]={type:a.source.type,settings:a.source.config.settings,mapping:void 0,elb:a.elb}}}}async function H(e={}){const t=function(e){const{version:t}=a(),n={dryRun:!1,globalsStatic:{},sessionStatic:{},tagging:0,verbose:!1,onLog:o,run:!0,destinations:{},consent:{},user:{},globals:{},custom:{}},s=(0,P.assign)(n,e,{merge:!1,extend:!1});function o(e,t){(0,P.onLog)({message:e},t||s.verbose)}s.onLog=o;const i={...s.globalsStatic,...s.globals},r={allowed:!1,config:s,consent:s.consent||{},count:0,custom:s.custom||{},destinations:S(s.destinations||{}),globals:i,group:"",hooks:{},on:{},queue:[],round:0,session:void 0,timing:Date.now(),user:s.user||{},version:t,sources:{},push:void 0};return r.push=v(r,w,e=>({timing:Math.round((Date.now()-r.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),r}(e),{consent:n,user:s,globals:o,custom:i,sources:r}=e;return n&&await t.push("walker consent",n),s&&await t.push("walker user",s),o&&Object.assign(t.globals,o),i&&Object.assign(t.custom,i),r&&await M(t,r),t.config.run&&await t.push("walker run"),{collector:t,elb:t.push}}//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../package.json","../src/index.ts","../src/constants.ts","../src/consent.ts","../src/destination.ts","../src/handle.ts","../src/on.ts","../src/collector.ts","../src/source.ts"],"sourcesContent":["{\n \"name\": \"@walkeros/collector\",\n \"description\": \"Unified platform-agnostic collector for walkerOS\",\n \"version\": \"0.0.7\",\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"files\": [\n \"dist/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup --silent\",\n \"clean\": \"rm -rf .turbo && rm -rf node_modules && rm -rf dist\",\n \"dev\": \"jest --watchAll --colors\",\n \"lint\": \"tsc && eslint \\\"**/*.ts*\\\"\",\n \"test\": \"jest\",\n \"update\": \"npx npm-check-updates -u && npm update\"\n },\n \"dependencies\": {\n \"@walkeros/core\": \"0.0.7\"\n },\n \"devDependencies\": {},\n \"repository\": {\n \"url\": \"git+https://github.com/elbwalker/walkerOS.git\",\n \"directory\": \"packages/collector\"\n },\n \"author\": \"elbwalker <hello@elbwalker.com>\",\n \"homepage\": \"https://github.com/elbwalker/walkerOS#readme\",\n \"bugs\": {\n \"url\": \"https://github.com/elbwalker/walkerOS/issues\"\n },\n \"keywords\": [\n \"walker\",\n \"walkerOS\",\n \"analytics\",\n \"tracking\",\n \"data collection\",\n \"measurement\",\n \"data privacy\",\n \"privacy friendly\",\n \"collector\",\n \"event processing\"\n ],\n \"funding\": [\n {\n \"type\": \"GitHub Sponsors\",\n \"url\": \"https://github.com/sponsors/elbwalker\"\n }\n ]\n}\n","export * from './types';\n\nexport * from './constants';\nexport * from './consent';\nexport * from './collector';\nexport * from './destination';\nexport * from './handle';\nexport * from './on';\nexport * from './source';\n","import type { Collector } from '@walkeros/core';\nimport type { WalkerOS } from '@walkeros/core';\n\nexport type CommandTypes =\n | 'Action'\n | 'Config'\n | 'Consent'\n | 'Context'\n | 'Custom'\n | 'Destination'\n | 'Elb'\n | 'Globals'\n | 'Hook'\n | 'Init'\n | 'Link'\n | 'On'\n | 'Prefix'\n | 'Ready'\n | 'Run'\n | 'Session'\n | 'User'\n | 'Walker';\n\nexport const Commands: Record<CommandTypes, Collector.CommandType> = {\n Action: 'action',\n Config: 'config',\n Consent: 'consent',\n Context: 'context',\n Custom: 'custom',\n Destination: 'destination',\n Elb: 'elb',\n Globals: 'globals',\n Hook: 'hook',\n Init: 'init',\n Link: 'link',\n On: 'on',\n Prefix: 'data-elb',\n Ready: 'ready',\n Run: 'run',\n Session: 'session',\n User: 'user',\n Walker: 'walker',\n} as const;\n\nexport type StorageType = 'cookie' | 'local' | 'session';\n\nconst UtilsStorage: { [key: string]: StorageType } = {\n Cookie: 'cookie',\n Local: 'local',\n Session: 'session',\n} as const;\n\nconst Utils = {\n Storage: UtilsStorage,\n};\n\nexport const Const = {\n Commands,\n Utils,\n};\n\nexport default Const;\n","import type { Collector, WalkerOS, Elb } from '@walkeros/core';\nimport { assign } from '@walkeros/core';\nimport { pushToDestinations, createPushResult } from './destination';\nimport { onApply } from './on';\n\n/**\n * Sets the consent state and processes the queue.\n *\n * @param collector - The walkerOS collector instance.\n * @param data - The consent data to set.\n * @returns The result of the push operation.\n */\nexport async function setConsent(\n collector: Collector.Instance,\n data: WalkerOS.Consent,\n): Promise<Elb.PushResult> {\n const { consent } = collector;\n\n let runQueue = false;\n const update: WalkerOS.Consent = {};\n Object.entries(data).forEach(([name, granted]) => {\n const state = !!granted;\n\n update[name] = state;\n\n // Only run queue if state was set to true\n runQueue = runQueue || state;\n });\n\n // Update consent state\n collector.consent = assign(consent, update);\n\n // Run on consent events\n onApply(collector, 'consent', undefined, update);\n\n // Process previous events if not disabled\n return runQueue\n ? pushToDestinations(collector)\n : createPushResult({ ok: true });\n}\n","import type { Collector, WalkerOS, Elb, Destination } from '@walkeros/core';\nimport {\n assign,\n clone,\n createWrapper,\n debounce,\n getId,\n getGrantedConsent,\n getMappingEvent,\n getMappingValue,\n isDefined,\n isObject,\n setByPath,\n tryCatchAsync,\n useHooks,\n} from '@walkeros/core';\nimport { createEventOrCommand } from './handle';\n\nexport type HandleCommandFn<T extends Collector.Instance> = (\n collector: T,\n action: string,\n data?: Elb.PushData,\n options?: unknown,\n) => Promise<Elb.PushResult>;\n\n/**\n * Creates the main push function for the collector.\n *\n * @template T, F\n * @param collector - The walkerOS collector instance.\n * @param handleCommand - TBD.\n * @param prepareEvent - TBD.\n * @returns The push function.\n */\nexport function createPush<T extends Collector.Instance>(\n collector: T,\n handleCommand: HandleCommandFn<T>,\n prepareEvent: (event: WalkerOS.DeepPartialEvent) => WalkerOS.PartialEvent,\n): Elb.Fn {\n return useHooks(\n async (\n eventOrCommand: unknown,\n data?: Elb.PushData,\n options?: unknown,\n ): Promise<Elb.PushResult> => {\n return await tryCatchAsync(\n async (): Promise<Elb.PushResult> => {\n // Handle simplified core collector interface\n if (\n typeof eventOrCommand === 'string' &&\n eventOrCommand.startsWith('walker ')\n ) {\n // Walker command format: 'walker action', data, options\n const command = eventOrCommand.replace('walker ', '');\n return await handleCommand(collector, command, data, options);\n } else {\n // Event format: event object or string\n const partialEvent =\n typeof eventOrCommand === 'string'\n ? { event: eventOrCommand }\n : (eventOrCommand as WalkerOS.DeepPartialEvent);\n\n const enrichedEvent = prepareEvent(partialEvent);\n\n const { event, command } = createEventOrCommand(\n collector,\n enrichedEvent.event,\n enrichedEvent,\n );\n\n const result = command\n ? await handleCommand(collector, command, data, options)\n : await pushToDestinations(collector, event);\n\n return result;\n }\n },\n () => {\n return createPushResult({ ok: false });\n },\n )();\n },\n 'Push',\n collector.hooks,\n ) as Elb.Fn;\n}\n\n/**\n * Adds a new destination to the collector.\n *\n * @param collector - The walkerOS collector instance.\n * @param data - The destination's init data.\n * @param options - The destination's config.\n * @returns The result of the push operation.\n */\nexport async function addDestination(\n collector: Collector.Instance,\n data: Destination.Init,\n options?: Destination.Config,\n): Promise<Elb.PushResult> {\n // Prefer explicit given config over default config\n const config = options || data.config || { init: false };\n // @TODO might not be the best solution to use options || data.config\n\n const destination: Destination.Instance = {\n ...data,\n config,\n };\n\n let id = config.id; // Use given id\n if (!id) {\n // Generate a new id if none was given\n do {\n id = getId(4);\n } while (collector.destinations[id]);\n }\n\n // Add the destination\n collector.destinations[id] = destination;\n\n // Process previous events if not disabled\n if (config.queue !== false) destination.queue = [...collector.queue];\n\n return pushToDestinations(collector, undefined, { [id]: destination });\n}\n\n/**\n * Pushes an event to all or a subset of destinations.\n *\n * @param collector - The walkerOS collector instance.\n * @param event - The event to push.\n * @param destinations - The destinations to push to.\n * @returns The result of the push operation.\n */\nexport async function pushToDestinations(\n collector: Collector.Instance,\n event?: WalkerOS.Event,\n destinations?: Collector.Destinations,\n): Promise<Elb.PushResult> {\n const { allowed, consent, globals, user } = collector;\n\n // Check if collector is allowed to push\n if (!allowed) return createPushResult({ ok: false });\n\n // Add event to the collector queue\n if (event) collector.queue.push(event);\n\n // Use given destinations or use internal destinations\n if (!destinations) destinations = collector.destinations;\n\n const results = await Promise.all(\n // Process all destinations in parallel\n Object.entries(destinations || {}).map(async ([id, destination]) => {\n // Create a queue of events to be processed\n let currentQueue = (destination.queue || []).map((event) => ({\n ...event,\n consent,\n }));\n\n // Reset original queue while processing to enable async processing\n destination.queue = [];\n\n // Add event to queue stack\n if (event) {\n // Clone the event to avoid mutating the original event\n let currentEvent = clone(event);\n\n // Policy check\n await Promise.all(\n Object.entries(destination.config.policy || []).map(\n async ([key, mapping]) => {\n const value = await getMappingValue(event, mapping, {\n collector,\n });\n currentEvent = setByPath(currentEvent, key, value);\n },\n ),\n );\n\n // Add event to queue stack\n currentQueue.push(currentEvent);\n }\n\n // Nothing to do here if the queue is empty\n if (!currentQueue.length) return { id, destination, skipped: true };\n\n const allowedEvents: WalkerOS.Events = [];\n const skippedEvents = currentQueue.filter((queuedEvent) => {\n const grantedConsent = getGrantedConsent(\n destination.config.consent, // Required\n consent, // Current collector state\n queuedEvent.consent, // Individual event state\n );\n\n if (grantedConsent) {\n queuedEvent.consent = grantedConsent; // Save granted consent states only\n\n allowedEvents.push(queuedEvent); // Add to allowed queue\n return false; // Remove from destination queue\n }\n\n return true; // Keep denied events in the queue\n });\n\n // Add skipped events back to the queue\n destination.queue.concat(skippedEvents);\n\n // Execution shall not pass if no events are allowed\n if (!allowedEvents.length) {\n return { id, destination, queue: currentQueue }; // Don't push if not allowed\n }\n\n // Initialize the destination if needed\n const isInitialized = await tryCatchAsync(destinationInit)(\n collector,\n destination,\n );\n\n if (!isInitialized) return { id, destination, queue: currentQueue };\n\n // Process the destinations event queue\n let error = false;\n if (!destination.dlq) destination.dlq = [];\n\n // Process allowed events and store failed ones in the dead letter queue (DLQ)\n await Promise.all(\n allowedEvents.map(async (event) => {\n // Merge event with collector state, prioritizing event properties\n event.globals = assign(globals, event.globals);\n event.user = assign(user, event.user);\n\n await tryCatchAsync(destinationPush, (err) => {\n // Call custom error handling if available\n if (collector.config.onError)\n collector.config.onError(err, collector);\n error = true; // oh no\n\n // Add failed event to destinations DLQ\n destination.dlq!.push([event, err]);\n\n return false;\n })(collector, destination, event);\n\n return event;\n }),\n );\n\n return { id, destination, error };\n }),\n );\n\n const successful = [];\n const queued = [];\n const failed = [];\n\n for (const result of results) {\n if (result.skipped) continue;\n\n const destination = result.destination;\n\n const ref = { id: result.id, destination };\n\n if (result.error) {\n failed.push(ref);\n } else if (result.queue && result.queue.length) {\n // Merge queue with existing queue\n destination.queue = (destination.queue || []).concat(result.queue);\n queued.push(ref);\n } else {\n successful.push(ref);\n }\n }\n\n return createPushResult({\n ok: !failed.length,\n event,\n successful,\n queued,\n failed,\n });\n}\n\n/**\n * Initializes a destination.\n *\n * @template Destination\n * @param collector - The walkerOS collector instance.\n * @param destination - The destination to initialize.\n * @returns Whether the destination was initialized successfully.\n */\nexport async function destinationInit<Destination extends Destination.Instance>(\n collector: Collector.Instance,\n destination: Destination,\n): Promise<boolean> {\n // Check if the destination was initialized properly or try to do so\n if (destination.init && !destination.config.init) {\n const context: Destination.Context = {\n collector,\n config: destination.config,\n wrap: getWrapper(destination, collector),\n };\n\n const configResult = await useHooks(\n destination.init,\n 'DestinationInit',\n collector.hooks,\n )(context);\n\n // Actively check for errors (when false)\n if (configResult === false) return configResult; // don't push if init is false\n\n // Update the destination config if it was returned\n destination.config = {\n ...(configResult || destination.config),\n init: true, // Remember that the destination was initialized\n };\n }\n\n return true; // Destination is ready to push\n}\n\n/**\n * Pushes an event to a single destination.\n * Handles mapping, batching, and consent checks.\n *\n * @template Destination\n * @param collector - The walkerOS collector instance.\n * @param destination - The destination to push to.\n * @param event - The event to push.\n * @returns Whether the event was pushed successfully.\n */\nexport async function destinationPush<Destination extends Destination.Instance>(\n collector: Collector.Instance,\n destination: Destination,\n event: WalkerOS.Event,\n): Promise<boolean> {\n const { config } = destination;\n const { eventMapping, mappingKey } = await getMappingEvent(\n event,\n config.mapping,\n );\n\n let data =\n config.data && (await getMappingValue(event, config.data, { collector }));\n\n if (eventMapping) {\n // Check if event should be processed or ignored\n if (eventMapping.ignore) return false;\n\n // Check to use specific event names\n if (eventMapping.name) event.event = eventMapping.name;\n\n // Transform event to a custom data\n if (eventMapping.data) {\n const dataEvent =\n eventMapping.data &&\n (await getMappingValue(event, eventMapping.data, { collector }));\n data =\n isObject(data) && isObject(dataEvent) // Only merge objects\n ? assign(data, dataEvent)\n : dataEvent;\n }\n }\n\n const context: Destination.PushContext = {\n collector,\n config,\n data,\n mapping: eventMapping,\n wrap: getWrapper(destination, collector),\n };\n\n if (eventMapping?.batch && destination.pushBatch) {\n const batched = eventMapping.batched || {\n key: mappingKey || '',\n events: [],\n data: [],\n };\n batched.events.push(event);\n if (isDefined(data)) batched.data.push(data);\n\n eventMapping.batchFn =\n eventMapping.batchFn ||\n debounce((destination, collector) => {\n const batchContext: Destination.PushBatchContext = {\n collector,\n config,\n data,\n mapping: eventMapping,\n wrap: getWrapper(destination, collector as Collector.Instance),\n };\n\n useHooks(\n destination.pushBatch!,\n 'DestinationPushBatch',\n (collector as Collector.Instance).hooks,\n )(batched, batchContext);\n\n // Reset the batched queues\n batched.events = [];\n batched.data = [];\n }, eventMapping.batch);\n\n eventMapping.batched = batched;\n eventMapping.batchFn?.(destination, collector);\n } else {\n // It's time to go to the destination's side now\n await useHooks(\n destination.push,\n 'DestinationPush',\n collector.hooks,\n )(event, context);\n }\n\n return true;\n}\n\n/**\n * Creates a standardized result object for push operations.\n *\n * @param partialResult - A partial result to merge with the default result.\n * @returns The push result.\n */\nexport function createPushResult(\n partialResult?: Partial<Elb.PushResult>,\n): Elb.PushResult {\n return assign(\n {\n ok: !partialResult?.failed?.length,\n successful: [],\n queued: [],\n failed: [],\n },\n partialResult,\n );\n}\n\n/**\n * Initializes a map of destinations.\n *\n * @param destinations - The destinations to initialize.\n * @returns The initialized destinations.\n */\nexport function initDestinations(\n destinations: Destination.InitDestinations,\n): Collector.Destinations {\n return Object.entries(destinations).reduce<Collector.Destinations>(\n (acc, [name, destination]) => {\n acc[name] = {\n ...destination,\n config: isObject(destination.config) ? destination.config : {},\n };\n return acc;\n },\n {},\n );\n}\n\nfunction getWrapper(\n destination: Destination.Instance,\n collector?: Collector.Instance,\n) {\n const wrapperConfig = destination.config.wrapper || {};\n const dryRun = destination.config.dryRun ?? collector?.config.dryRun;\n\n return createWrapper(destination.type || 'unknown', {\n ...wrapperConfig,\n ...(isDefined(dryRun) && { dryRun }),\n });\n}\n","import type { Collector, WalkerOS, Destination, Elb, On } from '@walkeros/core';\nimport { Commands, Const } from './constants';\nimport { addDestination, pushToDestinations } from './destination';\nimport { assign, getId, isFunction, isString } from '@walkeros/core';\nimport { isObject, isSameType } from '@walkeros/core';\nimport { setConsent } from './consent';\nimport { on, onApply } from './on';\nimport type { RunState } from './types/collector';\n\n/**\n * Handles common commands.\n *\n * @param collector The walkerOS collector instance.\n * @param action The action to handle.\n * @param data The data to handle.\n * @param options The options to handle.\n * @returns A promise that resolves with the push result or undefined.\n */\nexport async function commonHandleCommand(\n collector: Collector.Instance,\n action: string,\n data?: unknown,\n options?: unknown,\n): Promise<Elb.PushResult> {\n let result: Elb.PushResult | undefined;\n switch (action) {\n case Const.Commands.Config:\n if (isObject(data)) {\n assign(collector.config, data as Partial<Collector.Config>, {\n shallow: false,\n });\n }\n break;\n\n case Const.Commands.Consent:\n if (isObject(data)) {\n result = await setConsent(collector, data as WalkerOS.Consent);\n }\n break;\n\n case Const.Commands.Custom:\n if (isObject(data)) {\n collector.custom = assign(\n collector.custom,\n data as WalkerOS.Properties,\n );\n }\n break;\n\n case Const.Commands.Destination:\n if (isObject(data) && isFunction(data.push)) {\n result = await addDestination(\n collector,\n data as Destination.Init,\n options as Destination.Config,\n );\n }\n break;\n\n case Const.Commands.Globals:\n if (isObject(data)) {\n collector.globals = assign(\n collector.globals,\n data as WalkerOS.Properties,\n );\n }\n break;\n\n case Const.Commands.On:\n if (isString(data)) {\n on(\n collector,\n data as On.Types,\n options as WalkerOS.SingleOrArray<On.Options>,\n );\n }\n break;\n\n case Const.Commands.Run:\n result = await runCollector(collector, data as RunState);\n break;\n\n case Const.Commands.User:\n if (isObject(data)) {\n assign(collector.user, data as WalkerOS.User, { shallow: false });\n }\n break;\n }\n\n return (\n result || {\n ok: true,\n successful: [],\n queued: [],\n failed: [],\n }\n );\n}\n\n/**\n * Creates an event or a command from a partial event.\n *\n * @param collector The walkerOS collector instance.\n * @param nameOrEvent The name of the event or a partial event.\n * @param defaults The default values for the event.\n * @returns An object with the event or the command.\n */\nexport function createEventOrCommand(\n collector: Collector.Instance,\n nameOrEvent: unknown,\n defaults: WalkerOS.PartialEvent = {},\n): { event?: WalkerOS.Event; command?: string } {\n // Determine the partial event\n const partialEvent: WalkerOS.PartialEvent = isSameType(\n nameOrEvent,\n '' as string,\n )\n ? { event: nameOrEvent, ...defaults }\n : { ...defaults, ...(nameOrEvent || {}) };\n\n if (!partialEvent.event) throw new Error('Event name is required');\n\n // Check for valid entity and action event format\n const [entityValue, actionValue] = partialEvent.event.split(' ');\n if (!entityValue || !actionValue) throw new Error('Event name is invalid');\n\n // It's a walker command\n if (entityValue === Commands.Walker) {\n return { command: actionValue };\n }\n\n // Regular event\n ++collector.count;\n\n // Values that are eventually used by other properties\n const {\n timestamp = Date.now(),\n group = collector.group,\n count = collector.count,\n } = partialEvent;\n\n // Extract properties with default fallbacks\n const {\n event = `${entityValue} ${actionValue}`,\n data = {},\n context = {},\n globals = collector.globals,\n custom = {},\n user = collector.user,\n nested = [],\n consent = collector.consent,\n id = `${timestamp}-${group}-${count}`,\n trigger = '',\n entity = entityValue,\n action = actionValue,\n timing = 0,\n version = {\n source: collector.version,\n tagging: collector.config.tagging || 0,\n },\n source = { type: 'collector', id: '', previous_id: '' },\n } = partialEvent;\n\n const fullEvent: WalkerOS.Event = {\n event,\n data,\n context,\n globals,\n custom,\n user,\n nested,\n consent,\n id,\n trigger,\n entity,\n action,\n timestamp,\n timing,\n group,\n count,\n version,\n source,\n };\n\n return { event: fullEvent };\n}\n\n/**\n * Runs the collector by setting it to allowed state and processing queued events.\n *\n * @param collector The walkerOS collector instance.\n * @param state Optional state to merge with the collector (user, globals, consent, custom).\n * @returns A promise that resolves with the push result.\n */\nexport async function runCollector(\n collector: Collector.Instance,\n state?: RunState,\n): Promise<Elb.PushResult> {\n // Set the collector to allowed state\n collector.allowed = true;\n\n // Reset count and generate new group ID\n collector.count = 0;\n collector.group = getId();\n\n // Update timing for this run\n collector.timing = Date.now();\n\n // Update collector state if provided\n if (state) {\n // Update consent if provided\n if (state.consent) {\n collector.consent = assign(collector.consent, state.consent);\n }\n\n // Update user if provided\n if (state.user) {\n collector.user = assign(collector.user, state.user);\n }\n\n // Update globals if provided\n if (state.globals) {\n collector.globals = assign(\n collector.config.globalsStatic || {},\n state.globals,\n );\n }\n\n // Update custom if provided\n if (state.custom) {\n collector.custom = assign(collector.custom, state.custom);\n }\n }\n\n // Reset destination queues\n Object.values(collector.destinations).forEach((destination) => {\n destination.queue = [];\n });\n\n // Increase round counter\n collector.round++;\n\n // Call the predefined run events\n onApply(collector, 'run');\n\n // Process any queued events now that the collector is allowed\n const result = await pushToDestinations(collector);\n\n return result;\n}\n","import type { Collector, On, WalkerOS } from '@walkeros/core';\nimport { isArray } from '@walkeros/core';\nimport { Const } from './constants';\nimport { tryCatch } from '@walkeros/core';\n\n/**\n * Registers a callback for a specific event type.\n *\n * @param collector The walkerOS collector instance.\n * @param type The type of the event to listen for.\n * @param option The callback function or an array of callback functions.\n */\nexport function on(\n collector: Collector.Instance,\n type: On.Types,\n option: WalkerOS.SingleOrArray<On.Options>,\n) {\n const on = collector.on;\n const onType: Array<On.Options> = on[type] || [];\n const options = isArray(option) ? option : [option];\n\n options.forEach((option) => {\n onType.push(option);\n });\n\n // Update collector on state\n (on[type] as typeof onType) = onType;\n\n // Execute the on function directly\n onApply(collector, type, options);\n}\n\n/**\n * Applies all registered callbacks for a specific event type.\n *\n * @param collector The walkerOS collector instance.\n * @param type The type of the event to apply the callbacks for.\n * @param options The options for the callbacks.\n * @param config The consent configuration.\n */\nexport function onApply(\n collector: Collector.Instance,\n type: On.Types,\n options?: Array<On.Options>,\n config?: WalkerOS.Consent,\n) {\n // Use the optionally provided options\n let onConfig = options || [];\n\n if (!options) {\n // Get the collector on events\n onConfig = collector.on[type] || [];\n\n // Add all available on events from the destinations\n Object.values(collector.destinations).forEach((destination) => {\n const onTypeConfig = destination.config.on?.[type];\n if (onTypeConfig) onConfig = onConfig.concat(onTypeConfig);\n });\n }\n\n if (!onConfig.length) return; // No on-events registered, nothing to do\n\n switch (type) {\n case Const.Commands.Consent:\n onConsent(collector, onConfig as Array<On.ConsentConfig>, config);\n break;\n case Const.Commands.Ready:\n onReady(collector, onConfig as Array<On.ReadyConfig>);\n break;\n case Const.Commands.Run:\n onRun(collector, onConfig as Array<On.RunConfig>);\n break;\n case Const.Commands.Session:\n onSession(collector, onConfig as Array<On.SessionConfig>);\n break;\n default:\n break;\n }\n}\n\nfunction onConsent(\n collector: Collector.Instance,\n onConfig: Array<On.ConsentConfig>,\n currentConsent?: WalkerOS.Consent,\n): void {\n const consentState = currentConsent || collector.consent;\n\n onConfig.forEach((consentConfig) => {\n // Collect functions whose consent keys match the rule keys directly\n // Directly execute functions whose consent keys match the rule keys\n Object.keys(consentState) // consent keys\n .filter((consent) => consent in consentConfig) // check for matching rule keys\n .forEach((consent) => {\n // Execute the function\n tryCatch(consentConfig[consent])(collector, consentState);\n });\n });\n}\n\nfunction onReady(\n collector: Collector.Instance,\n onConfig: Array<On.ReadyConfig>,\n): void {\n if (collector.allowed)\n onConfig.forEach((func) => {\n tryCatch(func)(collector);\n });\n}\n\nfunction onRun(\n collector: Collector.Instance,\n onConfig: Array<On.RunConfig>,\n): void {\n if (collector.allowed)\n onConfig.forEach((func) => {\n tryCatch(func)(collector);\n });\n}\n\nfunction onSession(\n collector: Collector.Instance,\n onConfig: Array<On.SessionConfig>,\n): void {\n if (!collector.session) return;\n\n onConfig.forEach((func) => {\n tryCatch(func)(collector, collector.session);\n });\n}\n","import type { Collector, WalkerOS, Elb } from '@walkeros/core';\nimport type { CreateCollector, CollectorConfig } from './types';\nimport { assign, onLog } from '@walkeros/core';\nimport { commonHandleCommand } from './handle';\nimport { initDestinations, createPush } from './destination';\nimport { initSources } from './source';\n\nexport async function createCollector<\n TConfig extends Partial<CollectorConfig> = Partial<CollectorConfig>,\n>(initConfig: TConfig = {} as TConfig): Promise<CreateCollector> {\n const instance = collector(initConfig);\n const { consent, user, globals, custom, sources } = initConfig;\n\n if (consent) await instance.push('walker consent', consent);\n if (user) await instance.push('walker user', user);\n if (globals) Object.assign(instance.globals, globals);\n if (custom) Object.assign(instance.custom, custom);\n\n // Initialize sources if provided\n if (sources) {\n await initSources(instance, sources);\n }\n\n if (instance.config.run) await instance.push('walker run');\n\n return {\n collector: instance,\n elb: instance.push,\n };\n}\n\nfunction collector(initConfig: Partial<CollectorConfig>): Collector.Instance {\n const { version } = require('../package.json');\n\n const defaultConfig: Collector.Config = {\n dryRun: false,\n globalsStatic: {},\n sessionStatic: {},\n tagging: 0,\n verbose: false,\n onLog: log,\n run: true,\n destinations: {},\n consent: {},\n user: {},\n globals: {},\n custom: {},\n };\n\n const config: Collector.Config = assign(defaultConfig, initConfig, {\n merge: false,\n extend: false,\n });\n\n function log(message: string, verbose?: boolean) {\n onLog({ message }, verbose || config.verbose);\n }\n config.onLog = log;\n\n // Enhanced globals with static globals from config\n const finalGlobals = { ...config.globalsStatic, ...config.globals };\n\n const collector: Collector.Instance = {\n allowed: false,\n config,\n consent: config.consent || {},\n count: 0,\n custom: config.custom || {},\n destinations: initDestinations(config.destinations || {}),\n globals: finalGlobals,\n group: '',\n hooks: {},\n on: {},\n queue: [],\n round: 0,\n session: undefined,\n timing: Date.now(),\n user: config.user || {},\n version,\n sources: {},\n push: undefined as unknown as Elb.Fn, // Placeholder, will be set below\n };\n\n // Set the push function with the collector reference\n collector.push = createPush(\n collector,\n commonHandleCommand,\n (event: WalkerOS.DeepPartialEvent): WalkerOS.PartialEvent =>\n ({\n timing: Math.round((Date.now() - collector.timing) / 10) / 100,\n source: { type: 'collector', id: '', previous_id: '' },\n ...event,\n }) as WalkerOS.PartialEvent,\n );\n\n return collector;\n}\n","import type { Collector, WalkerOS, Source } from '@walkeros/core';\nimport { tryCatchAsync, getId } from '@walkeros/core';\n\n/**\n * Core source factory function that creates sources with consistent error handling and lifecycle management.\n *\n * @template T - The source configuration type\n * @param collector - The WalkerOS collector instance\n * @param source - The source function\n * @param config - The source configuration\n * @returns Promise resolving to the created source with its elb function\n */\nexport async function createSource<\n T extends Source.Config,\n E = WalkerOS.AnyFunction,\n>(\n collector: Collector.Instance,\n source: Source.Init<T, E>,\n config: Source.InitConfig,\n): Promise<Source.CreateSource<T, E>> {\n const fullConfig: T = {\n disabled: config.disabled ?? false,\n settings: config.settings ?? {},\n onError: config.onError, // TODO: add default onError\n } as T;\n\n if (fullConfig.disabled) return {};\n\n // Initialize the source\n const result = await tryCatchAsync(source)(collector, fullConfig);\n\n if (!result || !result.source) return {};\n\n const type = fullConfig.type || result.source.type || '';\n const id = config.id || `${type}_${getId(5)}`;\n\n // Store the elb function on the source instance for easy access\n if (result.source && result.elb) {\n const sourceWithElb = result.source as Source.Instance & { elb?: E };\n sourceWithElb.elb = result.elb;\n }\n\n // Register the source in the collector\n collector.sources[id] = {\n type,\n settings: fullConfig.settings,\n mapping: undefined, // Sources handle their own mapping\n elb: result.elb as WalkerOS.AnyFunction | undefined,\n };\n\n return result;\n}\n\n// Types for source initialization\nexport interface SourceInit<\n T extends Source.Config = Source.Config,\n E = WalkerOS.AnyFunction,\n> {\n code: Source.Init<T, E>;\n config?: Partial<T>;\n}\n\nexport interface InitSources {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [sourceId: string]: SourceInit<any, any>;\n}\n\n/**\n * Initialize multiple sources for a collector\n *\n * @param collector - The WalkerOS collector instance\n * @param sources - Map of source configurations\n */\nexport async function initSources(\n collector: Collector.Instance,\n sources: InitSources = {},\n): Promise<void> {\n for (const [sourceId, initSource] of Object.entries(sources)) {\n const { code, config = {} } = initSource;\n\n const fullConfig: Source.InitConfig = {\n id: sourceId,\n ...config,\n };\n\n const result = await createSource(collector, code, fullConfig);\n\n if (result.source) {\n // Store source with elb attached\n if (result.elb) {\n const sourceWithElb = result.source as Source.Instance & {\n elb?: WalkerOS.AnyFunction;\n };\n sourceWithElb.elb = result.elb;\n }\n // Store as CollectorSource format\n collector.sources[sourceId] = {\n type: result.source.type,\n settings: result.source.config.settings,\n mapping: undefined,\n elb: result.elb as WalkerOS.AnyFunction | undefined,\n };\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,iBAAAA,UAAAC,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,MAAQ;AAAA,MACR,aAAe;AAAA,MACf,SAAW;AAAA,MACX,MAAQ;AAAA,MACR,QAAU;AAAA,MACV,OAAS;AAAA,MACT,SAAW;AAAA,MACX,OAAS;AAAA,QACP;AAAA,MACF;AAAA,MACA,SAAW;AAAA,QACT,OAAS;AAAA,QACT,OAAS;AAAA,QACT,KAAO;AAAA,QACP,MAAQ;AAAA,QACR,MAAQ;AAAA,QACR,QAAU;A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,QAAQ,KAAK,IAAI;AAAA,IACjB,MAAM,OAAO,QAAQ,CAAC;AAAA,IACtB;AAAA,IACA,SAAS,CAAC;AAAA,IACV,MAAM;AAAA;AAAA,EACR;AAGA,EAAAA,WAAU,OAAO;AAAA,IACfA;AAAA,IACA;AAAA,IACA,CAAC,WACE;AAAA,MACC,QAAQ,KAAK,OAAO,KAAK,IAAI,IAAIA,WAAU,UAAU,EAAE,IAAI;AAAA,MAC3D,QAAQ,EAAE,MAAM,aAAa,IAAI,IAAI,aAAa,GAAG;AAAA,MACrD,GAAG;AAAA,IACL;AAAA,EACJ;AAEA,SAAOA;AACT;","names":["exports","module","import_core","import_core","import_core","import_core","collector","on","option","collector","collector","event","destination","collector","import_core","import_core","collector","collector"]}
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ var e,n,t=Object.getOwnPropertyNames,o=(e={"package.json"(e,n){n.exports={name:"@walkeros/collector",description:"Unified platform-agnostic collector for walkerOS",version:"0.0.7",main:"./dist/index.js",module:"./dist/index.mjs",types:"./dist/index.d.ts",license:"MIT",files:["dist/**"],scripts:{build:"tsup --silent",clean:"rm -rf .turbo && rm -rf node_modules && rm -rf dist",dev:"jest --watchAll --colors",lint:'tsc && eslint "**/*.ts*"',test:"jest",update:"npx npm-check-updates -u && npm update"},dependencies:{"@walkeros/core":"0.0.7"},devDependencies:{},repository:{url:"git+https://github.com/elbwalker/walkerOS.git",directory:"packages/collector"},author:"elbwalker <hello@elbwalker.com>",homepage:"https://github.com/elbwalker/walkerOS#readme",bugs:{url:"https://github.com/elbwalker/walkerOS/issues"},keywords:["walker","walkerOS","analytics","tracking","data collection","measurement","data privacy","privacy friendly","collector","event processing"],funding:[{type:"GitHub Sponsors",url:"https://github.com/sponsors/elbwalker"}]}}},function(){return n||(0,e[t(e)[0]])((n={exports:{}}).exports,n),n.exports}),s={Action:"action",Config:"config",Consent:"consent",Context:"context",Custom:"custom",Destination:"destination",Elb:"elb",Globals:"globals",Hook:"hook",Init:"init",Link:"link",On:"on",Prefix:"data-elb",Ready:"ready",Run:"run",Session:"session",User:"user",Walker:"walker"},i={Commands:s,Utils:{Storage:{Cookie:"cookie",Local:"local",Session:"session"}}};import{assign as a}from"@walkeros/core";import{assign as r,clone as c,createWrapper as u,debounce as l,getId as d,getGrantedConsent as g,getMappingEvent as f,getMappingValue as m,isDefined as p,isObject as b,setByPath as w,tryCatchAsync as h,useHooks as k}from"@walkeros/core";import{assign as y,getId as v,isFunction as q,isString as C}from"@walkeros/core";import{isObject as O,isSameType as j}from"@walkeros/core";import{isArray as E}from"@walkeros/core";import{tryCatch as x}from"@walkeros/core";function S(e,n,t){const o=e.on,s=o[n]||[],i=E(t)?t:[t];i.forEach(e=>{s.push(e)}),o[n]=s,D(e,n,i)}function D(e,n,t,o){let s=t||[];if(t||(s=e.on[n]||[],Object.values(e.destinations).forEach(e=>{const t=e.config.on?.[n];t&&(s=s.concat(t))})),s.length)switch(n){case i.Commands.Consent:!function(e,n,t){const o=t||e.consent;n.forEach(n=>{Object.keys(o).filter(e=>e in n).forEach(t=>{x(n[t])(e,o)})})}(e,s,o);break;case i.Commands.Ready:case i.Commands.Run:!function(e,n){e.allowed&&n.forEach(n=>{x(n)(e)})}(e,s);break;case i.Commands.Session:!function(e,n){if(!e.session)return;n.forEach(n=>{x(n)(e,e.session)})}(e,s)}}async function R(e,n,t,o){let s;switch(n){case i.Commands.Config:O(t)&&y(e.config,t,{shallow:!1});break;case i.Commands.Consent:O(t)&&(s=await M(e,t));break;case i.Commands.Custom:O(t)&&(e.custom=y(e.custom,t));break;case i.Commands.Destination:O(t)&&q(t.push)&&(s=await L(e,t,o));break;case i.Commands.Globals:O(t)&&(e.globals=y(e.globals,t));break;case i.Commands.On:C(t)&&S(e,t,o);break;case i.Commands.Run:s=await $(e,t);break;case i.Commands.User:O(t)&&y(e.user,t,{shallow:!1})}return s||{ok:!0,successful:[],queued:[],failed:[]}}function P(e,n,t={}){const o=j(n,"")?{event:n,...t}:{...t,...n||{}};if(!o.event)throw new Error("Event name is required");const[i,a]=o.event.split(" ");if(!i||!a)throw new Error("Event name is invalid");if(i===s.Walker)return{command:a};++e.count;const{timestamp:r=Date.now(),group:c=e.group,count:u=e.count}=o,{event:l=`${i} ${a}`,data:d={},context:g={},globals:f=e.globals,custom:m={},user:p=e.user,nested:b=[],consent:w=e.consent,id:h=`${r}-${c}-${u}`,trigger:k="",entity:y=i,action:v=a,timing:q=0,version:C={source:e.version,tagging:e.config.tagging||0},source:O={type:"collector",id:"",previous_id:""}}=o;return{event:{event:l,data:d,context:g,globals:f,custom:m,user:p,nested:b,consent:w,id:h,trigger:k,entity:y,action:v,timestamp:r,timing:q,group:c,count:u,version:C,source:O}}}async function $(e,n){e.allowed=!0,e.count=0,e.group=v(),e.timing=Date.now(),n&&(n.consent&&(e.consent=y(e.consent,n.consent)),n.user&&(e.user=y(e.user,n.user)),n.globals&&(e.globals=y(e.config.globalsStatic||{},n.globals)),n.custom&&(e.custom=y(e.custom,n.custom))),Object.values(e.destinations).forEach(e=>{e.queue=[]}),e.round++,D(e,"run");return await U(e)}function I(e,n,t){return k(async(o,s,i)=>await h(async()=>{if("string"==typeof o&&o.startsWith("walker ")){const t=o.replace("walker ","");return await n(e,t,s,i)}{const a=t("string"==typeof o?{event:o}:o),{event:r,command:c}=P(e,a.event,a);return c?await n(e,c,s,i):await U(e,r)}},()=>B({ok:!1}))(),"Push",e.hooks)}async function L(e,n,t){const o=t||n.config||{init:!1},s={...n,config:o};let i=o.id;if(!i)do{i=d(4)}while(e.destinations[i]);return e.destinations[i]=s,!1!==o.queue&&(s.queue=[...e.queue]),U(e,void 0,{[i]:s})}async function U(e,n,t){const{allowed:o,consent:s,globals:i,user:a}=e;if(!o)return B({ok:!1});n&&e.queue.push(n),t||(t=e.destinations);const u=await Promise.all(Object.entries(t||{}).map(async([t,o])=>{let u=(o.queue||[]).map(e=>({...e,consent:s}));if(o.queue=[],n){let t=c(n);await Promise.all(Object.entries(o.config.policy||[]).map(async([o,s])=>{const i=await m(n,s,{collector:e});t=w(t,o,i)})),u.push(t)}if(!u.length)return{id:t,destination:o,skipped:!0};const l=[],d=u.filter(e=>{const n=g(o.config.consent,s,e.consent);return!n||(e.consent=n,l.push(e),!1)});if(o.queue.concat(d),!l.length)return{id:t,destination:o,queue:u};if(!await h(_)(e,o))return{id:t,destination:o,queue:u};let f=!1;return o.dlq||(o.dlq=[]),await Promise.all(l.map(async n=>(n.globals=r(i,n.globals),n.user=r(a,n.user),await h(A,t=>(e.config.onError&&e.config.onError(t,e),f=!0,o.dlq.push([n,t]),!1))(e,o,n),n))),{id:t,destination:o,error:f}})),l=[],d=[],f=[];for(const e of u){if(e.skipped)continue;const n=e.destination,t={id:e.id,destination:n};e.error?f.push(t):e.queue&&e.queue.length?(n.queue=(n.queue||[]).concat(e.queue),d.push(t)):l.push(t)}return B({ok:!f.length,event:n,successful:l,queued:d,failed:f})}async function _(e,n){if(n.init&&!n.config.init){const t={collector:e,config:n.config,wrap:G(n,e)},o=await k(n.init,"DestinationInit",e.hooks)(t);if(!1===o)return o;n.config={...o||n.config,init:!0}}return!0}async function A(e,n,t){const{config:o}=n,{eventMapping:s,mappingKey:i}=await f(t,o.mapping);let a=o.data&&await m(t,o.data,{collector:e});if(s){if(s.ignore)return!1;if(s.name&&(t.event=s.name),s.data){const n=s.data&&await m(t,s.data,{collector:e});a=b(a)&&b(n)?r(a,n):n}}const c={collector:e,config:o,data:a,mapping:s,wrap:G(n,e)};if(s?.batch&&n.pushBatch){const r=s.batched||{key:i||"",events:[],data:[]};r.events.push(t),p(a)&&r.data.push(a),s.batchFn=s.batchFn||l((e,n)=>{const t={collector:n,config:o,data:a,mapping:s,wrap:G(e,n)};k(e.pushBatch,"DestinationPushBatch",n.hooks)(r,t),r.events=[],r.data=[]},s.batch),s.batched=r,s.batchFn?.(n,e)}else await k(n.push,"DestinationPush",e.hooks)(t,c);return!0}function B(e){return r({ok:!e?.failed?.length,successful:[],queued:[],failed:[]},e)}function F(e){return Object.entries(e).reduce((e,[n,t])=>(e[n]={...t,config:b(t.config)?t.config:{}},e),{})}function G(e,n){const t=e.config.wrapper||{},o=e.config.dryRun??n?.config.dryRun;return u(e.type||"unknown",{...t,...p(o)&&{dryRun:o}})}async function M(e,n){const{consent:t}=e;let o=!1;const s={};return Object.entries(n).forEach(([e,n])=>{const t=!!n;s[e]=t,o=o||t}),e.consent=a(t,s),D(e,"consent",void 0,s),o?U(e):B({ok:!0})}import{assign as W,onLog as H}from"@walkeros/core";import{tryCatchAsync as K,getId as N}from"@walkeros/core";async function T(e,n,t){const o={disabled:t.disabled??!1,settings:t.settings??{},onError:t.onError};if(o.disabled)return{};const s=await K(n)(e,o);if(!s||!s.source)return{};const i=o.type||s.source.type||"",a=t.id||`${i}_${N(5)}`;if(s.source&&s.elb){s.source.elb=s.elb}return e.sources[a]={type:i,settings:o.settings,mapping:void 0,elb:s.elb},s}async function z(e,n={}){for(const[t,o]of Object.entries(n)){const{code:n,config:s={}}=o,i={id:t,...s},a=await T(e,n,i);if(a.source){if(a.elb){a.source.elb=a.elb}e.sources[t]={type:a.source.type,settings:a.source.config.settings,mapping:void 0,elb:a.elb}}}}async function J(e={}){const n=function(e){const{version:n}=o(),t=W({dryRun:!1,globalsStatic:{},sessionStatic:{},tagging:0,verbose:!1,onLog:s,run:!0,destinations:{},consent:{},user:{},globals:{},custom:{}},e,{merge:!1,extend:!1});function s(e,n){H({message:e},n||t.verbose)}t.onLog=s;const i={...t.globalsStatic,...t.globals},a={allowed:!1,config:t,consent:t.consent||{},count:0,custom:t.custom||{},destinations:F(t.destinations||{}),globals:i,group:"",hooks:{},on:{},queue:[],round:0,session:void 0,timing:Date.now(),user:t.user||{},version:n,sources:{},push:void 0};return a.push=I(a,R,e=>({timing:Math.round((Date.now()-a.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),a}(e),{consent:t,user:s,globals:i,custom:a,sources:r}=e;return t&&await n.push("walker consent",t),s&&await n.push("walker user",s),i&&Object.assign(n.globals,i),a&&Object.assign(n.custom,a),r&&await z(n,r),n.config.run&&await n.push("walker run"),{collector:n,elb:n.push}}export{s as Commands,i as Const,L as addDestination,R as commonHandleCommand,J as createCollector,P as createEventOrCommand,I as createPush,B as createPushResult,T as createSource,_ as destinationInit,A as destinationPush,F as initDestinations,z as initSources,S as on,D as onApply,U as pushToDestinations,$ as runCollector,M as setConsent};//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../package.json","../src/constants.ts","../src/consent.ts","../src/destination.ts","../src/handle.ts","../src/on.ts","../src/collector.ts","../src/source.ts"],"sourcesContent":["{\n \"name\": \"@walkeros/collector\",\n \"description\": \"Unified platform-agnostic collector for walkerOS\",\n \"version\": \"0.0.7\",\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"license\": \"MIT\",\n \"files\": [\n \"dist/**\"\n ],\n \"scripts\": {\n \"build\": \"tsup --silent\",\n \"clean\": \"rm -rf .turbo && rm -rf node_modules && rm -rf dist\",\n \"dev\": \"jest --watchAll --colors\",\n \"lint\": \"tsc && eslint \\\"**/*.ts*\\\"\",\n \"test\": \"jest\",\n \"update\": \"npx npm-check-updates -u && npm update\"\n },\n \"dependencies\": {\n \"@walkeros/core\": \"0.0.7\"\n },\n \"devDependencies\": {},\n \"repository\": {\n \"url\": \"git+https://github.com/elbwalker/walkerOS.git\",\n \"directory\": \"packages/collector\"\n },\n \"author\": \"elbwalker <hello@elbwalker.com>\",\n \"homepage\": \"https://github.com/elbwalker/walkerOS#readme\",\n \"bugs\": {\n \"url\": \"https://github.com/elbwalker/walkerOS/issues\"\n },\n \"keywords\": [\n \"walker\",\n \"walkerOS\",\n \"analytics\",\n \"tracking\",\n \"data collection\",\n \"measurement\",\n \"data privacy\",\n \"privacy friendly\",\n \"collector\",\n \"event processing\"\n ],\n \"funding\": [\n {\n \"type\": \"GitHub Sponsors\",\n \"url\": \"https://github.com/sponsors/elbwalker\"\n }\n ]\n}\n","import type { Collector } from '@walkeros/core';\nimport type { WalkerOS } from '@walkeros/core';\n\nexport type CommandTypes =\n | 'Action'\n | 'Config'\n | 'Consent'\n | 'Context'\n | 'Custom'\n | 'Destination'\n | 'Elb'\n | 'Globals'\n | 'Hook'\n | 'Init'\n | 'Link'\n | 'On'\n | 'Prefix'\n | 'Ready'\n | 'Run'\n | 'Session'\n | 'User'\n | 'Walker';\n\nexport const Commands: Record<CommandTypes, Collector.CommandType> = {\n Action: 'action',\n Config: 'config',\n Consent: 'consent',\n Context: 'context',\n Custom: 'custom',\n Destination: 'destination',\n Elb: 'elb',\n Globals: 'globals',\n Hook: 'hook',\n Init: 'init',\n Link: 'link',\n On: 'on',\n Prefix: 'data-elb',\n Ready: 'ready',\n Run: 'run',\n Session: 'session',\n User: 'user',\n Walker: 'walker',\n} as const;\n\nexport type StorageType = 'cookie' | 'local' | 'session';\n\nconst UtilsStorage: { [key: string]: StorageType } = {\n Cookie: 'cookie',\n Local: 'local',\n Session: 'session',\n} as const;\n\nconst Utils = {\n Storage: UtilsStorage,\n};\n\nexport const Const = {\n Commands,\n Utils,\n};\n\nexport default Const;\n","import type { Collector, WalkerOS, Elb } from '@walkeros/core';\nimport { assign } from '@walkeros/core';\nimport { pushToDestinations, createPushResult } from './destination';\nimport { onApply } from './on';\n\n/**\n * Sets the consent state and processes the queue.\n *\n * @param collector - The walkerOS collector instance.\n * @param data - The consent data to set.\n * @returns The result of the push operation.\n */\nexport async function setConsent(\n collector: Collector.Instance,\n data: WalkerOS.Consent,\n): Promise<Elb.PushResult> {\n const { consent } = collector;\n\n let runQueue = false;\n const update: WalkerOS.Consent = {};\n Object.entries(data).forEach(([name, granted]) => {\n const state = !!granted;\n\n update[name] = state;\n\n // Only run queue if state was set to true\n runQueue = runQueue || state;\n });\n\n // Update consent state\n collector.consent = assign(consent, update);\n\n // Run on consent events\n onApply(collector, 'consent', undefined, update);\n\n // Process previous events if not disabled\n return runQueue\n ? pushToDestinations(collector)\n : createPushResult({ ok: true });\n}\n","import type { Collector, WalkerOS, Elb, Destination } from '@walkeros/core';\nimport {\n assign,\n clone,\n createWrapper,\n debounce,\n getId,\n getGrantedConsent,\n getMappingEvent,\n getMappingValue,\n isDefined,\n isObject,\n setByPath,\n tryCatchAsync,\n useHooks,\n} from '@walkeros/core';\nimport { createEventOrCommand } from './handle';\n\nexport type HandleCommandFn<T extends Collector.Instance> = (\n collector: T,\n action: string,\n data?: Elb.PushData,\n options?: unknown,\n) => Promise<Elb.PushResult>;\n\n/**\n * Creates the main push function for the collector.\n *\n * @template T, F\n * @param collector - The walkerOS collector instance.\n * @param handleCommand - TBD.\n * @param prepareEvent - TBD.\n * @returns The push function.\n */\nexport function createPush<T extends Collector.Instance>(\n collector: T,\n handleCommand: HandleCommandFn<T>,\n prepareEvent: (event: WalkerOS.DeepPartialEvent) => WalkerOS.PartialEvent,\n): Elb.Fn {\n return useHooks(\n async (\n eventOrCommand: unknown,\n data?: Elb.PushData,\n options?: unknown,\n ): Promise<Elb.PushResult> => {\n return await tryCatchAsync(\n async (): Promise<Elb.PushResult> => {\n // Handle simplified core collector interface\n if (\n typeof eventOrCommand === 'string' &&\n eventOrCommand.startsWith('walker ')\n ) {\n // Walker command format: 'walker action', data, options\n const command = eventOrCommand.replace('walker ', '');\n return await handleCommand(collector, command, data, options);\n } else {\n // Event format: event object or string\n const partialEvent =\n typeof eventOrCommand === 'string'\n ? { event: eventOrCommand }\n : (eventOrCommand as WalkerOS.DeepPartialEvent);\n\n const enrichedEvent = prepareEvent(partialEvent);\n\n const { event, command } = createEventOrCommand(\n collector,\n enrichedEvent.event,\n enrichedEvent,\n );\n\n const result = command\n ? await handleCommand(collector, command, data, options)\n : await pushToDestinations(collector, event);\n\n return result;\n }\n },\n () => {\n return createPushResult({ ok: false });\n },\n )();\n },\n 'Push',\n collector.hooks,\n ) as Elb.Fn;\n}\n\n/**\n * Adds a new destination to the collector.\n *\n * @param collector - The walkerOS collector instance.\n * @param data - The destination's init data.\n * @param options - The destination's config.\n * @returns The result of the push operation.\n */\nexport async function addDestination(\n collector: Collector.Instance,\n data: Destination.Init,\n options?: Destination.Config,\n): Promise<Elb.PushResult> {\n // Prefer explicit given config over default config\n const config = options || data.config || { init: false };\n // @TODO might not be the best solution to use options || data.config\n\n const destination: Destination.Instance = {\n ...data,\n config,\n };\n\n let id = config.id; // Use given id\n if (!id) {\n // Generate a new id if none was given\n do {\n id = getId(4);\n } while (collector.destinations[id]);\n }\n\n // Add the destination\n collector.destinations[id] = destination;\n\n // Process previous events if not disabled\n if (config.queue !== false) destination.queue = [...collector.queue];\n\n return pushToDestinations(collector, undefined, { [id]: destination });\n}\n\n/**\n * Pushes an event to all or a subset of destinations.\n *\n * @param collector - The walkerOS collector instance.\n * @param event - The event to push.\n * @param destinations - The destinations to push to.\n * @returns The result of the push operation.\n */\nexport async function pushToDestinations(\n collector: Collector.Instance,\n event?: WalkerOS.Event,\n destinations?: Collector.Destinations,\n): Promise<Elb.PushResult> {\n const { allowed, consent, globals, user } = collector;\n\n // Check if collector is allowed to push\n if (!allowed) return createPushResult({ ok: false });\n\n // Add event to the collector queue\n if (event) collector.queue.push(event);\n\n // Use given destinations or use internal destinations\n if (!destinations) destinations = collector.destinations;\n\n const results = await Promise.all(\n // Process all destinations in parallel\n Object.entries(destinations || {}).map(async ([id, destination]) => {\n // Create a queue of events to be processed\n let currentQueue = (destination.queue || []).map((event) => ({\n ...event,\n consent,\n }));\n\n // Reset original queue while processing to enable async processing\n destination.queue = [];\n\n // Add event to queue stack\n if (event) {\n // Clone the event to avoid mutating the original event\n let currentEvent = clone(event);\n\n // Policy check\n await Promise.all(\n Object.entries(destination.config.policy || []).map(\n async ([key, mapping]) => {\n const value = await getMappingValue(event, mapping, {\n collector,\n });\n currentEvent = setByPath(currentEvent, key, value);\n },\n ),\n );\n\n // Add event to queue stack\n currentQueue.push(currentEvent);\n }\n\n // Nothing to do here if the queue is empty\n if (!currentQueue.length) return { id, destination, skipped: true };\n\n const allowedEvents: WalkerOS.Events = [];\n const skippedEvents = currentQueue.filter((queuedEvent) => {\n const grantedConsent = getGrantedConsent(\n destination.config.consent, // Required\n consent, // Current collector state\n queuedEvent.consent, // Individual event state\n );\n\n if (grantedConsent) {\n queuedEvent.consent = grantedConsent; // Save granted consent states only\n\n allowedEvents.push(queuedEvent); // Add to allowed queue\n return false; // Remove from destination queue\n }\n\n return true; // Keep denied events in the queue\n });\n\n // Add skipped events back to the queue\n destination.queue.concat(skippedEvents);\n\n // Execution shall not pass if no events are allowed\n if (!allowedEvents.length) {\n return { id, destination, queue: currentQueue }; // Don't push if not allowed\n }\n\n // Initialize the destination if needed\n const isInitialized = await tryCatchAsync(destinationInit)(\n collector,\n destination,\n );\n\n if (!isInitialized) return { id, destination, queue: currentQueue };\n\n // Process the destinations event queue\n let error = false;\n if (!destination.dlq) destination.dlq = [];\n\n // Process allowed events and store failed ones in the dead letter queue (DLQ)\n await Promise.all(\n allowedEvents.map(async (event) => {\n // Merge event with collector state, prioritizing event properties\n event.globals = assign(globals, event.globals);\n event.user = assign(user, event.user);\n\n await tryCatchAsync(destinationPush, (err) => {\n // Call custom error handling if available\n if (collector.config.onError)\n collector.config.onError(err, collector);\n error = true; // oh no\n\n // Add failed event to destinations DLQ\n destination.dlq!.push([event, err]);\n\n return false;\n })(collector, destination, event);\n\n return event;\n }),\n );\n\n return { id, destination, error };\n }),\n );\n\n const successful = [];\n const queued = [];\n const failed = [];\n\n for (const result of results) {\n if (result.skipped) continue;\n\n const destination = result.destination;\n\n const ref = { id: result.id, destination };\n\n if (result.error) {\n failed.push(ref);\n } else if (result.queue && result.queue.length) {\n // Merge queue with existing queue\n destination.queue = (destination.queue || []).concat(result.queue);\n queued.push(ref);\n } else {\n successful.push(ref);\n }\n }\n\n return createPushResult({\n ok: !failed.length,\n event,\n successful,\n queued,\n failed,\n });\n}\n\n/**\n * Initializes a destination.\n *\n * @template Destination\n * @param collector - The walkerOS collector instance.\n * @param destination - The destination to initialize.\n * @returns Whether the destination was initialized successfully.\n */\nexport async function destinationInit<Destination extends Destination.Instance>(\n collector: Collector.Instance,\n destination: Destination,\n): Promise<boolean> {\n // Check if the destination was initialized properly or try to do so\n if (destination.init && !destination.config.init) {\n const context: Destination.Context = {\n collector,\n config: destination.config,\n wrap: getWrapper(destination, collector),\n };\n\n const configResult = await useHooks(\n destination.init,\n 'DestinationInit',\n collector.hooks,\n )(context);\n\n // Actively check for errors (when false)\n if (configResult === false) return configResult; // don't push if init is false\n\n // Update the destination config if it was returned\n destination.config = {\n ...(configResult || destination.config),\n init: true, // Remember that the destination was initialized\n };\n }\n\n return true; // Destination is ready to push\n}\n\n/**\n * Pushes an event to a single destination.\n * Handles mapping, batching, and consent checks.\n *\n * @template Destination\n * @param collector - The walkerOS collector instance.\n * @param destination - The destination to push to.\n * @param event - The event to push.\n * @returns Whether the event was pushed successfully.\n */\nexport async function destinationPush<Destination extends Destination.Instance>(\n collector: Collector.Instance,\n destination: Destination,\n event: WalkerOS.Event,\n): Promise<boolean> {\n const { config } = destination;\n const { eventMapping, mappingKey } = await getMappingEvent(\n event,\n config.mapping,\n );\n\n let data =\n config.data && (await getMappingValue(event, config.data, { collector }));\n\n if (eventMapping) {\n // Check if event should be processed or ignored\n if (eventMapping.ignore) return false;\n\n // Check to use specific event names\n if (eventMapping.name) event.event = eventMapping.name;\n\n // Transform event to a custom data\n if (eventMapping.data) {\n const dataEvent =\n eventMapping.data &&\n (await getMappingValue(event, eventMapping.data, { collector }));\n data =\n isObject(data) && isObject(dataEvent) // Only merge objects\n ? assign(data, dataEvent)\n : dataEvent;\n }\n }\n\n const context: Destination.PushContext = {\n collector,\n config,\n data,\n mapping: eventMapping,\n wrap: getWrapper(destination, collector),\n };\n\n if (eventMapping?.batch && destination.pushBatch) {\n const batched = eventMapping.batched || {\n key: mappingKey || '',\n events: [],\n data: [],\n };\n batched.events.push(event);\n if (isDefined(data)) batched.data.push(data);\n\n eventMapping.batchFn =\n eventMapping.batchFn ||\n debounce((destination, collector) => {\n const batchContext: Destination.PushBatchContext = {\n collector,\n config,\n data,\n mapping: eventMapping,\n wrap: getWrapper(destination, collector as Collector.Instance),\n };\n\n useHooks(\n destination.pushBatch!,\n 'DestinationPushBatch',\n (collector as Collector.Instance).hooks,\n )(batched, batchContext);\n\n // Reset the batched queues\n batched.events = [];\n batched.data = [];\n }, eventMapping.batch);\n\n eventMapping.batched = batched;\n eventMapping.batchFn?.(destination, collector);\n } else {\n // It's time to go to the destination's side now\n await useHooks(\n destination.push,\n 'DestinationPush',\n collector.hooks,\n )(event, context);\n }\n\n return true;\n}\n\n/**\n * Creates a standardized result object for push operations.\n *\n * @param partialResult - A partial result to merge with the default result.\n * @returns The push result.\n */\nexport function createPushResult(\n partialResult?: Partial<Elb.PushResult>,\n): Elb.PushResult {\n return assign(\n {\n ok: !partialResult?.failed?.length,\n successful: [],\n queued: [],\n failed: [],\n },\n partialResult,\n );\n}\n\n/**\n * Initializes a map of destinations.\n *\n * @param destinations - The destinations to initialize.\n * @returns The initialized destinations.\n */\nexport function initDestinations(\n destinations: Destination.InitDestinations,\n): Collector.Destinations {\n return Object.entries(destinations).reduce<Collector.Destinations>(\n (acc, [name, destination]) => {\n acc[name] = {\n ...destination,\n config: isObject(destination.config) ? destination.config : {},\n };\n return acc;\n },\n {},\n );\n}\n\nfunction getWrapper(\n destination: Destination.Instance,\n collector?: Collector.Instance,\n) {\n const wrapperConfig = destination.config.wrapper || {};\n const dryRun = destination.config.dryRun ?? collector?.config.dryRun;\n\n return createWrapper(destination.type || 'unknown', {\n ...wrapperConfig,\n ...(isDefined(dryRun) && { dryRun }),\n });\n}\n","import type { Collector, WalkerOS, Destination, Elb, On } from '@walkeros/core';\nimport { Commands, Const } from './constants';\nimport { addDestination, pushToDestinations } from './destination';\nimport { assign, getId, isFunction, isString } from '@walkeros/core';\nimport { isObject, isSameType } from '@walkeros/core';\nimport { setConsent } from './consent';\nimport { on, onApply } from './on';\nimport type { RunState } from './types/collector';\n\n/**\n * Handles common commands.\n *\n * @param collector The walkerOS collector instance.\n * @param action The action to handle.\n * @param data The data to handle.\n * @param options The options to handle.\n * @returns A promise that resolves with the push result or undefined.\n */\nexport async function commonHandleCommand(\n collector: Collector.Instance,\n action: string,\n data?: unknown,\n options?: unknown,\n): Promise<Elb.PushResult> {\n let result: Elb.PushResult | undefined;\n switch (action) {\n case Const.Commands.Config:\n if (isObject(data)) {\n assign(collector.config, data as Partial<Collector.Config>, {\n shallow: false,\n });\n }\n break;\n\n case Const.Commands.Consent:\n if (isObject(data)) {\n result = await setConsent(collector, data as WalkerOS.Consent);\n }\n break;\n\n case Const.Commands.Custom:\n if (isObject(data)) {\n collector.custom = assign(\n collector.custom,\n data as WalkerOS.Properties,\n );\n }\n break;\n\n case Const.Commands.Destination:\n if (isObject(data) && isFunction(data.push)) {\n result = await addDestination(\n collector,\n data as Destination.Init,\n options as Destination.Config,\n );\n }\n break;\n\n case Const.Commands.Globals:\n if (isObject(data)) {\n collector.globals = assign(\n collector.globals,\n data as WalkerOS.Properties,\n );\n }\n break;\n\n case Const.Commands.On:\n if (isString(data)) {\n on(\n collector,\n data as On.Types,\n options as WalkerOS.SingleOrArray<On.Options>,\n );\n }\n break;\n\n case Const.Commands.Run:\n result = await runCollector(collector, data as RunState);\n break;\n\n case Const.Commands.User:\n if (isObject(data)) {\n assign(collector.user, data as WalkerOS.User, { shallow: false });\n }\n break;\n }\n\n return (\n result || {\n ok: true,\n successful: [],\n queued: [],\n failed: [],\n }\n );\n}\n\n/**\n * Creates an event or a command from a partial event.\n *\n * @param collector The walkerOS collector instance.\n * @param nameOrEvent The name of the event or a partial event.\n * @param defaults The default values for the event.\n * @returns An object with the event or the command.\n */\nexport function createEventOrCommand(\n collector: Collector.Instance,\n nameOrEvent: unknown,\n defaults: WalkerOS.PartialEvent = {},\n): { event?: WalkerOS.Event; command?: string } {\n // Determine the partial event\n const partialEvent: WalkerOS.PartialEvent = isSameType(\n nameOrEvent,\n '' as string,\n )\n ? { event: nameOrEvent, ...defaults }\n : { ...defaults, ...(nameOrEvent || {}) };\n\n if (!partialEvent.event) throw new Error('Event name is required');\n\n // Check for valid entity and action event format\n const [entityValue, actionValue] = partialEvent.event.split(' ');\n if (!entityValue || !actionValue) throw new Error('Event name is invalid');\n\n // It's a walker command\n if (entityValue === Commands.Walker) {\n return { command: actionValue };\n }\n\n // Regular event\n ++collector.count;\n\n // Values that are eventually used by other properties\n const {\n timestamp = Date.now(),\n group = collector.group,\n count = collector.count,\n } = partialEvent;\n\n // Extract properties with default fallbacks\n const {\n event = `${entityValue} ${actionValue}`,\n data = {},\n context = {},\n globals = collector.globals,\n custom = {},\n user = collector.user,\n nested = [],\n consent = collector.consent,\n id = `${timestamp}-${group}-${count}`,\n trigger = '',\n entity = entityValue,\n action = actionValue,\n timing = 0,\n version = {\n source: collector.version,\n tagging: collector.config.tagging || 0,\n },\n source = { type: 'collector', id: '', previous_id: '' },\n } = partialEvent;\n\n const fullEvent: WalkerOS.Event = {\n event,\n data,\n context,\n globals,\n custom,\n user,\n nested,\n consent,\n id,\n trigger,\n entity,\n action,\n timestamp,\n timing,\n group,\n count,\n version,\n source,\n };\n\n return { event: fullEvent };\n}\n\n/**\n * Runs the collector by setting it to allowed state and processing queued events.\n *\n * @param collector The walkerOS collector instance.\n * @param state Optional state to merge with the collector (user, globals, consent, custom).\n * @returns A promise that resolves with the push result.\n */\nexport async function runCollector(\n collector: Collector.Instance,\n state?: RunState,\n): Promise<Elb.PushResult> {\n // Set the collector to allowed state\n collector.allowed = true;\n\n // Reset count and generate new group ID\n collector.count = 0;\n collector.group = getId();\n\n // Update timing for this run\n collector.timing = Date.now();\n\n // Update collector state if provided\n if (state) {\n // Update consent if provided\n if (state.consent) {\n collector.consent = assign(collector.consent, state.consent);\n }\n\n // Update user if provided\n if (state.user) {\n collector.user = assign(collector.user, state.user);\n }\n\n // Update globals if provided\n if (state.globals) {\n collector.globals = assign(\n collector.config.globalsStatic || {},\n state.globals,\n );\n }\n\n // Update custom if provided\n if (state.custom) {\n collector.custom = assign(collector.custom, state.custom);\n }\n }\n\n // Reset destination queues\n Object.values(collector.destinations).forEach((destination) => {\n destination.queue = [];\n });\n\n // Increase round counter\n collector.round++;\n\n // Call the predefined run events\n onApply(collector, 'run');\n\n // Process any queued events now that the collector is allowed\n const result = await pushToDestinations(collector);\n\n return result;\n}\n","import type { Collector, On, WalkerOS } from '@walkeros/core';\nimport { isArray } from '@walkeros/core';\nimport { Const } from './constants';\nimport { tryCatch } from '@walkeros/core';\n\n/**\n * Registers a callback for a specific event type.\n *\n * @param collector The walkerOS collector instance.\n * @param type The type of the event to listen for.\n * @param option The callback function or an array of callback functions.\n */\nexport function on(\n collector: Collector.Instance,\n type: On.Types,\n option: WalkerOS.SingleOrArray<On.Options>,\n) {\n const on = collector.on;\n const onType: Array<On.Options> = on[type] || [];\n const options = isArray(option) ? option : [option];\n\n options.forEach((option) => {\n onType.push(option);\n });\n\n // Update collector on state\n (on[type] as typeof onType) = onType;\n\n // Execute the on function directly\n onApply(collector, type, options);\n}\n\n/**\n * Applies all registered callbacks for a specific event type.\n *\n * @param collector The walkerOS collector instance.\n * @param type The type of the event to apply the callbacks for.\n * @param options The options for the callbacks.\n * @param config The consent configuration.\n */\nexport function onApply(\n collector: Collector.Instance,\n type: On.Types,\n options?: Array<On.Options>,\n config?: WalkerOS.Consent,\n) {\n // Use the optionally provided options\n let onConfig = options || [];\n\n if (!options) {\n // Get the collector on events\n onConfig = collector.on[type] || [];\n\n // Add all available on events from the destinations\n Object.values(collector.destinations).forEach((destination) => {\n const onTypeConfig = destination.config.on?.[type];\n if (onTypeConfig) onConfig = onConfig.concat(onTypeConfig);\n });\n }\n\n if (!onConfig.length) return; // No on-events registered, nothing to do\n\n switch (type) {\n case Const.Commands.Consent:\n onConsent(collector, onConfig as Array<On.ConsentConfig>, config);\n break;\n case Const.Commands.Ready:\n onReady(collector, onConfig as Array<On.ReadyConfig>);\n break;\n case Const.Commands.Run:\n onRun(collector, onConfig as Array<On.RunConfig>);\n break;\n case Const.Commands.Session:\n onSession(collector, onConfig as Array<On.SessionConfig>);\n break;\n default:\n break;\n }\n}\n\nfunction onConsent(\n collector: Collector.Instance,\n onConfig: Array<On.ConsentConfig>,\n currentConsent?: WalkerOS.Consent,\n): void {\n const consentState = currentConsent || collector.consent;\n\n onConfig.forEach((consentConfig) => {\n // Collect functions whose consent keys match the rule keys directly\n // Directly execute functions whose consent keys match the rule keys\n Object.keys(consentState) // consent keys\n .filter((consent) => consent in consentConfig) // check for matching rule keys\n .forEach((consent) => {\n // Execute the function\n tryCatch(consentConfig[consent])(collector, consentState);\n });\n });\n}\n\nfunction onReady(\n collector: Collector.Instance,\n onConfig: Array<On.ReadyConfig>,\n): void {\n if (collector.allowed)\n onConfig.forEach((func) => {\n tryCatch(func)(collector);\n });\n}\n\nfunction onRun(\n collector: Collector.Instance,\n onConfig: Array<On.RunConfig>,\n): void {\n if (collector.allowed)\n onConfig.forEach((func) => {\n tryCatch(func)(collector);\n });\n}\n\nfunction onSession(\n collector: Collector.Instance,\n onConfig: Array<On.SessionConfig>,\n): void {\n if (!collector.session) return;\n\n onConfig.forEach((func) => {\n tryCatch(func)(collector, collector.session);\n });\n}\n","import type { Collector, WalkerOS, Elb } from '@walkeros/core';\nimport type { CreateCollector, CollectorConfig } from './types';\nimport { assign, onLog } from '@walkeros/core';\nimport { commonHandleCommand } from './handle';\nimport { initDestinations, createPush } from './destination';\nimport { initSources } from './source';\n\nexport async function createCollector<\n TConfig extends Partial<CollectorConfig> = Partial<CollectorConfig>,\n>(initConfig: TConfig = {} as TConfig): Promise<CreateCollector> {\n const instance = collector(initConfig);\n const { consent, user, globals, custom, sources } = initConfig;\n\n if (consent) await instance.push('walker consent', consent);\n if (user) await instance.push('walker user', user);\n if (globals) Object.assign(instance.globals, globals);\n if (custom) Object.assign(instance.custom, custom);\n\n // Initialize sources if provided\n if (sources) {\n await initSources(instance, sources);\n }\n\n if (instance.config.run) await instance.push('walker run');\n\n return {\n collector: instance,\n elb: instance.push,\n };\n}\n\nfunction collector(initConfig: Partial<CollectorConfig>): Collector.Instance {\n const { version } = require('../package.json');\n\n const defaultConfig: Collector.Config = {\n dryRun: false,\n globalsStatic: {},\n sessionStatic: {},\n tagging: 0,\n verbose: false,\n onLog: log,\n run: true,\n destinations: {},\n consent: {},\n user: {},\n globals: {},\n custom: {},\n };\n\n const config: Collector.Config = assign(defaultConfig, initConfig, {\n merge: false,\n extend: false,\n });\n\n function log(message: string, verbose?: boolean) {\n onLog({ message }, verbose || config.verbose);\n }\n config.onLog = log;\n\n // Enhanced globals with static globals from config\n const finalGlobals = { ...config.globalsStatic, ...config.globals };\n\n const collector: Collector.Instance = {\n allowed: false,\n config,\n consent: config.consent || {},\n count: 0,\n custom: config.custom || {},\n destinations: initDestinations(config.destinations || {}),\n globals: finalGlobals,\n group: '',\n hooks: {},\n on: {},\n queue: [],\n round: 0,\n session: undefined,\n timing: Date.now(),\n user: config.user || {},\n version,\n sources: {},\n push: undefined as unknown as Elb.Fn, // Placeholder, will be set below\n };\n\n // Set the push function with the collector reference\n collector.push = createPush(\n collector,\n commonHandleCommand,\n (event: WalkerOS.DeepPartialEvent): WalkerOS.PartialEvent =>\n ({\n timing: Math.round((Date.now() - collector.timing) / 10) / 100,\n source: { type: 'collector', id: '', previous_id: '' },\n ...event,\n }) as WalkerOS.PartialEvent,\n );\n\n return collector;\n}\n","import type { Collector, WalkerOS, Source } from '@walkeros/core';\nimport { tryCatchAsync, getId } from '@walkeros/core';\n\n/**\n * Core source factory function that creates sources with consistent error handling and lifecycle management.\n *\n * @template T - The source configuration type\n * @param collector - The WalkerOS collector instance\n * @param source - The source function\n * @param config - The source configuration\n * @returns Promise resolving to the created source with its elb function\n */\nexport async function createSource<\n T extends Source.Config,\n E = WalkerOS.AnyFunction,\n>(\n collector: Collector.Instance,\n source: Source.Init<T, E>,\n config: Source.InitConfig,\n): Promise<Source.CreateSource<T, E>> {\n const fullConfig: T = {\n disabled: config.disabled ?? false,\n settings: config.settings ?? {},\n onError: config.onError, // TODO: add default onError\n } as T;\n\n if (fullConfig.disabled) return {};\n\n // Initialize the source\n const result = await tryCatchAsync(source)(collector, fullConfig);\n\n if (!result || !result.source) return {};\n\n const type = fullConfig.type || result.source.type || '';\n const id = config.id || `${type}_${getId(5)}`;\n\n // Store the elb function on the source instance for easy access\n if (result.source && result.elb) {\n const sourceWithElb = result.source as Source.Instance & { elb?: E };\n sourceWithElb.elb = result.elb;\n }\n\n // Register the source in the collector\n collector.sources[id] = {\n type,\n settings: fullConfig.settings,\n mapping: undefined, // Sources handle their own mapping\n elb: result.elb as WalkerOS.AnyFunction | undefined,\n };\n\n return result;\n}\n\n// Types for source initialization\nexport interface SourceInit<\n T extends Source.Config = Source.Config,\n E = WalkerOS.AnyFunction,\n> {\n code: Source.Init<T, E>;\n config?: Partial<T>;\n}\n\nexport interface InitSources {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [sourceId: string]: SourceInit<any, any>;\n}\n\n/**\n * Initialize multiple sources for a collector\n *\n * @param collector - The WalkerOS collector instance\n * @param sources - Map of source configurations\n */\nexport async function initSources(\n collector: Collector.Instance,\n sources: InitSources = {},\n): Promise<void> {\n for (const [sourceId, initSource] of Object.entries(sources)) {\n const { code, config = {} } = initSource;\n\n const fullConfig: Source.InitConfig = {\n id: sourceId,\n ...config,\n };\n\n const result = await createSource(collector, code, fullConfig);\n\n if (result.source) {\n // Store source with elb attached\n if (result.elb) {\n const sourceWithElb = result.source as Source.Instance & {\n elb?: WalkerOS.AnyFunction;\n };\n sourceWithElb.elb = result.elb;\n }\n // Store as CollectorSource format\n collector.sources[sourceId] = {\n type: result.source.type,\n settings: result.source.config.settings,\n mapping: undefined,\n elb: result.elb as WalkerOS.AnyFunction | undefined,\n };\n }\n }\n}\n"],"mappings":";;;;;;AAAA;AAAA;AAAA;AAAA,MACE,MAAQ;AAAA,MACR,aAAe;AAAA,MACf,SAAW;AAAA,MACX,MAAQ;AAAA,MACR,QAAU;AAAA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B,OAAO;AAAA,IACP,QAAQ,OAAO,UAAU,CAAC;AAAA,IAC1B,cAAc,iBAAiB,OAAO,gBAAgB,CAAC,CAAC;AAAA,IACxD,SAAS;AAAA,IACT,OAAO;AAAA,IACP,OAAO,CAAC;AAAA,IACR,IAAI,CAAC;AAAA,IACL,OAAO,CAAC;AAAA,IACR,OAAO;AAAA,IACP,SAAS;AAAA,IACT,QAAQ,KAAK,IAAI;AAAA,IACjB,MAAM,OAAO,QAAQ,CAAC;AAAA,IACtB;AAAA,IACA,SAAS,CAAC;AAAA,IACV,MAAM;AAAA;AAAA,EACR;AAGA,EAAAA,WAAU,OAAO;AAAA,IACfA;AAAA,IACA;AAAA,IACA,CAAC,WACE;AAAA,MACC,QAAQ,KAAK,OAAO,KAAK,IAAI,IAAIA,WAAU,UAAU,EAAE,IAAI;AAAA,MAC3D,QAAQ,EAAE,MAAM,aAAa,IAAI,IAAI,aAAa,GAAG;AAAA,MACrD,GAAG;AAAA,IACL;AAAA,EACJ;AAEA,SAAOA;AACT;","names":["assign","assign","getId","isObject","collector","on","option","collector","collector","getId","event","assign","isObject","destination","collector","assign","assign","tryCatchAsync","getId","collector","assign","collector"]}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@walkeros/collector",
3
+ "description": "Unified platform-agnostic collector for walkerOS",
4
+ "version": "0.0.7",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "license": "MIT",
9
+ "files": [
10
+ "dist/**"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsup --silent",
14
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
15
+ "dev": "jest --watchAll --colors",
16
+ "lint": "tsc && eslint \"**/*.ts*\"",
17
+ "test": "jest",
18
+ "update": "npx npm-check-updates -u && npm update"
19
+ },
20
+ "dependencies": {
21
+ "@walkeros/core": "0.0.7"
22
+ },
23
+ "devDependencies": {},
24
+ "repository": {
25
+ "url": "git+https://github.com/elbwalker/walkerOS.git",
26
+ "directory": "packages/collector"
27
+ },
28
+ "author": "elbwalker <hello@elbwalker.com>",
29
+ "homepage": "https://github.com/elbwalker/walkerOS#readme",
30
+ "bugs": {
31
+ "url": "https://github.com/elbwalker/walkerOS/issues"
32
+ },
33
+ "keywords": [
34
+ "walker",
35
+ "walkerOS",
36
+ "analytics",
37
+ "tracking",
38
+ "data collection",
39
+ "measurement",
40
+ "data privacy",
41
+ "privacy friendly",
42
+ "collector",
43
+ "event processing"
44
+ ],
45
+ "funding": [
46
+ {
47
+ "type": "GitHub Sponsors",
48
+ "url": "https://github.com/sponsors/elbwalker"
49
+ }
50
+ ]
51
+ }