@walkeros/collector 0.0.0-next-20251219153324
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 +153 -0
- package/dist/dev.d.mts +7 -0
- package/dist/dev.d.ts +7 -0
- package/dist/dev.js +1 -0
- package/dist/dev.js.map +1 -0
- package/dist/dev.mjs +1 -0
- package/dist/dev.mjs.map +1 -0
- package/dist/index.d.mts +206 -0
- package/dist/index.d.ts +206 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
<p align="left">
|
|
2
|
+
<a href="https://www.walkeros.io">
|
|
3
|
+
<img title="elbwalker" src="https://www.walkeros.io/img/elbwalker_logo.png" width="256px"/>
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# Collector for walkerOS
|
|
8
|
+
|
|
9
|
+
[Source Code](https://github.com/elbwalker/walkerOS/tree/main/packages/collector)
|
|
10
|
+
• [NPM Package](https://www.npmjs.com/package/@walkeros/collector)
|
|
11
|
+
|
|
12
|
+
The collector is the central **processing engine** of walkerOS that receives
|
|
13
|
+
events from sources, **enriches** them with additional data, applies consent
|
|
14
|
+
rules, and **routes** them to destinations. It acts as the **intelligent
|
|
15
|
+
middleware** between event capture and event delivery.
|
|
16
|
+
|
|
17
|
+
### What it does
|
|
18
|
+
|
|
19
|
+
The Collector transforms raw events into enriched, compliant data streams by:
|
|
20
|
+
|
|
21
|
+
- **Event processing** - Validates, normalizes, and enriches incoming events
|
|
22
|
+
- **Consent management** - Applies privacy rules and user consent preferences
|
|
23
|
+
- **Data enrichment** - Adds session data, user context, and custom properties
|
|
24
|
+
- **Destination routing** - Sends processed events to configured analytics
|
|
25
|
+
platforms
|
|
26
|
+
|
|
27
|
+
### Key features
|
|
28
|
+
|
|
29
|
+
- **Compatibility** - Works in both web browsers and server environments
|
|
30
|
+
- **Privacy-first** - Built-in consent management and data protection
|
|
31
|
+
- **Event validation** - Ensures data quality and consistency
|
|
32
|
+
- **Flexible routing** - Send events to multiple destinations simultaneously
|
|
33
|
+
|
|
34
|
+
### Role in architecture
|
|
35
|
+
|
|
36
|
+
In the walkerOS data flow, the collector sits between sources and destinations:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Sources → Collector → Destinations
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Sources capture events and send them to the collector, which processes and
|
|
43
|
+
routes them to your chosen destinations like Google Analytics, custom APIs, or
|
|
44
|
+
data warehouses.
|
|
45
|
+
|
|
46
|
+
## Event Naming Convention
|
|
47
|
+
|
|
48
|
+
walkerOS enforces a **"entity action"** naming convention for all events. It
|
|
49
|
+
makes it easier to standardize enhancements and validations. It follows a clear
|
|
50
|
+
separation. The mapping translates walkerOS events into platform-specific ones.
|
|
51
|
+
|
|
52
|
+
✅ **Correct**: Use spaces to separate entity and action
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
await elb('order complete', { value: 99.99 });
|
|
56
|
+
await elb('product add', { id: 'abc123' });
|
|
57
|
+
await elb('page view', { path: '/home' });
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
❌ **Incorrect**: Do not use platform-specific formats
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// Don't use these in walkerOS
|
|
64
|
+
await elb('purchase'); // GA4 format - wrong here
|
|
65
|
+
await elb('order_complete', data); // Wrong: underscores
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The collector will validate event names and destinations handle
|
|
69
|
+
platform-specific transformations. If the event name isn't separated into entity
|
|
70
|
+
action by space the collector won't process it.
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm install @walkeros/collector
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Quick Start
|
|
79
|
+
|
|
80
|
+
### Basic setup
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { startFlow } from '@walkeros/collector';
|
|
84
|
+
|
|
85
|
+
const config = {
|
|
86
|
+
run: true,
|
|
87
|
+
consent: { functional: true },
|
|
88
|
+
sources: [
|
|
89
|
+
// add your event sources
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const { collector, elb } = await startFlow(config);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Advanced setup
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { startFlow } from '@walkeros/collector';
|
|
101
|
+
|
|
102
|
+
const { collector, elb } = await startFlow({
|
|
103
|
+
run: true,
|
|
104
|
+
consent: { functional: true },
|
|
105
|
+
sources: [
|
|
106
|
+
// add your event sources
|
|
107
|
+
],
|
|
108
|
+
destinations: [
|
|
109
|
+
// add your event destinations
|
|
110
|
+
],
|
|
111
|
+
logger: {
|
|
112
|
+
level: 'debug', // 'debug' | 'info' | 'warn' | 'error'
|
|
113
|
+
handler: (message, level) => {
|
|
114
|
+
console.log(`[${level}] ${message}`);
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Configuration
|
|
121
|
+
|
|
122
|
+
| Name | Type | Description | Required | Example |
|
|
123
|
+
| -------------- | --------- | ------------------------------------------------------------ | -------- | --------------------------------------- |
|
|
124
|
+
| `run` | `boolean` | Automatically start the collector pipeline on initialization | No | `true` |
|
|
125
|
+
| `sources` | `array` | Configurations for sources providing events to the collector | No | `[{ source, config }]` |
|
|
126
|
+
| `destinations` | `array` | Configurations for destinations receiving processed events | No | `[{ destination, config }]` |
|
|
127
|
+
| `consent` | `object` | Initial consent state to control routing of events | No | `{ analytics: true, marketing: false }` |
|
|
128
|
+
| `logger` | `object` | Logger configuration with level and custom handler | No | `{ level: 'info', handler: fn }` |
|
|
129
|
+
|
|
130
|
+
## Type Definitions
|
|
131
|
+
|
|
132
|
+
See [src/types/](./src/types/) for TypeScript interfaces:
|
|
133
|
+
|
|
134
|
+
- [flow.ts](./src/types/flow.ts) - Flow configuration
|
|
135
|
+
- [collector.ts](./src/types/collector.ts) - Collector interface
|
|
136
|
+
|
|
137
|
+
## Related
|
|
138
|
+
|
|
139
|
+
- [Website Documentation](https://www.walkeros.io/docs/getting-started/flow/)
|
|
140
|
+
- [Core Package](../core/) - Types and utilities
|
|
141
|
+
- [Web Sources](../web/sources/) - Browser event sources
|
|
142
|
+
- [Server Sources](../server/sources/) - Node.js event sources
|
|
143
|
+
|
|
144
|
+
## Contribute
|
|
145
|
+
|
|
146
|
+
Feel free to contribute by submitting an
|
|
147
|
+
[issue](https://github.com/elbwalker/walkerOS/issues), starting a
|
|
148
|
+
[discussion](https://github.com/elbwalker/walkerOS/discussions), or getting in
|
|
149
|
+
[contact](https://calendly.com/elb-alexander/30min).
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
This project is licensed under the MIT License.
|
package/dist/dev.d.mts
ADDED
package/dist/dev.d.ts
ADDED
package/dist/dev.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,r=Object.defineProperty,t=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,a={};((e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})})(a,{schemas:()=>c}),module.exports=(e=a,((e,a,c,n)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let l of o(a))s.call(e,l)||l===c||r(e,l,{get:()=>a[l],enumerable:!(n=t(a,l))||n.enumerable});return e})(r({},"__esModule",{value:!0}),e));var c={settings:require("@walkeros/core/dev").schemas.CollectorSchemas.initConfigJsonSchema};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts"],"sourcesContent":["import { schemas as coreSchemas, type JSONSchema } from '@walkeros/core/dev';\n\nexport const schemas: { settings: JSONSchema } = {\n settings: coreSchemas.CollectorSchemas.initConfigJsonSchema,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAwD;AAEjD,IAAM,UAAoC;AAAA,EAC/C,UAAU,WAAAA,QAAY,iBAAiB;AACzC;","names":["coreSchemas"]}
|
package/dist/dev.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{schemas as e}from"@walkeros/core/dev";var o={settings:e.CollectorSchemas.initConfigJsonSchema};export{o as schemas};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts"],"sourcesContent":["import { schemas as coreSchemas, type JSONSchema } from '@walkeros/core/dev';\n\nexport const schemas: { settings: JSONSchema } = {\n settings: coreSchemas.CollectorSchemas.initConfigJsonSchema,\n};\n"],"mappings":";AAAA,SAAS,WAAW,mBAAoC;AAEjD,IAAM,UAAoC;AAAA,EAC/C,UAAU,YAAY,iBAAiB;AACzC;","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { WalkerOS, Collector, Elb, Mapping, Destination, On, Source } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
interface RunState {
|
|
4
|
+
consent?: WalkerOS.Consent;
|
|
5
|
+
user?: WalkerOS.User;
|
|
6
|
+
globals?: WalkerOS.Properties;
|
|
7
|
+
custom?: WalkerOS.Properties;
|
|
8
|
+
}
|
|
9
|
+
type HandleCommandFn<T extends Collector.Instance> = (collector: T, action: string, data?: unknown, options?: unknown) => Promise<Elb.PushResult>;
|
|
10
|
+
type CommandTypes = 'Action' | 'Actions' | 'Config' | 'Consent' | 'Context' | 'Custom' | 'Destination' | 'Elb' | 'Globals' | 'Hook' | 'Init' | 'Link' | 'On' | 'Prefix' | 'Ready' | 'Run' | 'Session' | 'User' | 'Walker';
|
|
11
|
+
type StorageType = 'cookie' | 'local' | 'session';
|
|
12
|
+
interface CreateCollector {
|
|
13
|
+
collector: Collector.Instance;
|
|
14
|
+
elb: WalkerOS.Elb;
|
|
15
|
+
}
|
|
16
|
+
interface StartFlow<ElbPush extends WalkerOS.Elb = WalkerOS.Elb> {
|
|
17
|
+
collector: Collector.Instance;
|
|
18
|
+
elb: ElbPush;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Settings {
|
|
22
|
+
scripts?: string[];
|
|
23
|
+
init?: string;
|
|
24
|
+
on?: string;
|
|
25
|
+
push?: string;
|
|
26
|
+
pushBatch?: string;
|
|
27
|
+
}
|
|
28
|
+
interface CodeMapping extends Mapping.Rule<CodeMapping> {
|
|
29
|
+
push?: string;
|
|
30
|
+
pushBatch?: string;
|
|
31
|
+
}
|
|
32
|
+
type Types = Destination.Types<Settings, CodeMapping>;
|
|
33
|
+
type Config = Destination.Config<Types>;
|
|
34
|
+
type Context = Destination.Context<Types>;
|
|
35
|
+
type InitContext = Destination.InitContext<Types>;
|
|
36
|
+
type PushContext = Destination.PushContext<Types>;
|
|
37
|
+
type PushBatchContext = Destination.PushBatchContext<Types>;
|
|
38
|
+
type InitFn = (context: InitContext) => void;
|
|
39
|
+
type OnFn = (type: On.Types, context: Context) => void;
|
|
40
|
+
type PushFn = (event: WalkerOS.Event, context: PushContext) => void;
|
|
41
|
+
type PushBatchFn = (batch: Destination.Batch<CodeMapping>, context: PushBatchContext) => void;
|
|
42
|
+
|
|
43
|
+
type code_CodeMapping = CodeMapping;
|
|
44
|
+
type code_Config = Config;
|
|
45
|
+
type code_Context = Context;
|
|
46
|
+
type code_InitContext = InitContext;
|
|
47
|
+
type code_InitFn = InitFn;
|
|
48
|
+
type code_OnFn = OnFn;
|
|
49
|
+
type code_PushBatchContext = PushBatchContext;
|
|
50
|
+
type code_PushBatchFn = PushBatchFn;
|
|
51
|
+
type code_PushContext = PushContext;
|
|
52
|
+
type code_PushFn = PushFn;
|
|
53
|
+
type code_Settings = Settings;
|
|
54
|
+
type code_Types = Types;
|
|
55
|
+
declare namespace code {
|
|
56
|
+
export type { code_CodeMapping as CodeMapping, code_Config as Config, code_Context as Context, code_InitContext as InitContext, code_InitFn as InitFn, code_OnFn as OnFn, code_PushBatchContext as PushBatchContext, code_PushBatchFn as PushBatchFn, code_PushContext as PushContext, code_PushFn as PushFn, code_Settings as Settings, code_Types as Types };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare const Commands: Record<CommandTypes, Collector.CommandType>;
|
|
60
|
+
declare const Const: {
|
|
61
|
+
Commands: Record<CommandTypes, string>;
|
|
62
|
+
Utils: {
|
|
63
|
+
Storage: {
|
|
64
|
+
[key: string]: StorageType;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Sets the consent state and processes the queue.
|
|
71
|
+
*
|
|
72
|
+
* @param collector - The walkerOS collector instance.
|
|
73
|
+
* @param data - The consent data to set.
|
|
74
|
+
* @returns The result of the push operation.
|
|
75
|
+
*/
|
|
76
|
+
declare function setConsent(collector: Collector.Instance, data: WalkerOS.Consent): Promise<Elb.PushResult>;
|
|
77
|
+
|
|
78
|
+
declare function startFlow<ElbPush extends Elb.Fn = Elb.Fn>(initConfig?: Collector.InitConfig): Promise<StartFlow<ElbPush>>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Creates the push function for the collector.
|
|
82
|
+
* Handles source mapping, event creation, and routing to destinations.
|
|
83
|
+
*
|
|
84
|
+
* @param collector - The walkerOS collector instance
|
|
85
|
+
* @param prepareEvent - Function to enrich partial events
|
|
86
|
+
* @returns The push function
|
|
87
|
+
*/
|
|
88
|
+
declare function createPush<T extends Collector.Instance>(collector: T, prepareEvent: (event: WalkerOS.DeepPartialEvent) => WalkerOS.PartialEvent): Collector.PushFn;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Adds a new destination to the collector.
|
|
92
|
+
*
|
|
93
|
+
* @param collector - The walkerOS collector instance.
|
|
94
|
+
* @param data - The destination's init data.
|
|
95
|
+
* @param options - The destination's config.
|
|
96
|
+
* @returns The result of the push operation.
|
|
97
|
+
*/
|
|
98
|
+
declare function addDestination(collector: Collector.Instance, data: Destination.Init, options?: Destination.Config): Promise<Elb.PushResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Pushes an event to all or a subset of destinations.
|
|
101
|
+
*
|
|
102
|
+
* @param collector - The walkerOS collector instance.
|
|
103
|
+
* @param event - The event to push.
|
|
104
|
+
* @param destinations - The destinations to push to.
|
|
105
|
+
* @returns The result of the push operation.
|
|
106
|
+
*/
|
|
107
|
+
declare function pushToDestinations(collector: Collector.Instance, event?: WalkerOS.Event, destinations?: Collector.Destinations): Promise<Elb.PushResult>;
|
|
108
|
+
/**
|
|
109
|
+
* Initializes a destination.
|
|
110
|
+
*
|
|
111
|
+
* @template Destination
|
|
112
|
+
* @param collector - The walkerOS collector instance.
|
|
113
|
+
* @param destination - The destination to initialize.
|
|
114
|
+
* @returns Whether the destination was initialized successfully.
|
|
115
|
+
*/
|
|
116
|
+
declare function destinationInit<Destination extends Destination.Instance>(collector: Collector.Instance, destination: Destination): Promise<boolean>;
|
|
117
|
+
/**
|
|
118
|
+
* Pushes an event to a single destination.
|
|
119
|
+
* Handles mapping, batching, and consent checks.
|
|
120
|
+
*
|
|
121
|
+
* @template Destination
|
|
122
|
+
* @param collector - The walkerOS collector instance.
|
|
123
|
+
* @param destination - The destination to push to.
|
|
124
|
+
* @param event - The event to push.
|
|
125
|
+
* @returns Whether the event was pushed successfully.
|
|
126
|
+
*/
|
|
127
|
+
declare function destinationPush<Destination extends Destination.Instance>(collector: Collector.Instance, destination: Destination, event: WalkerOS.Event): Promise<boolean>;
|
|
128
|
+
/**
|
|
129
|
+
* Creates a standardized result object for push operations.
|
|
130
|
+
*
|
|
131
|
+
* @param partialResult - A partial result to merge with the default result.
|
|
132
|
+
* @returns The push result.
|
|
133
|
+
*/
|
|
134
|
+
declare function createPushResult(partialResult?: Partial<Elb.PushResult>): Elb.PushResult;
|
|
135
|
+
/**
|
|
136
|
+
* Initializes a map of destinations using ONLY the unified code/config/env pattern.
|
|
137
|
+
* Does NOT call destination.init() - that happens later during push with proper consent checks.
|
|
138
|
+
*
|
|
139
|
+
* @param destinations - The destinations to initialize.
|
|
140
|
+
* @param collector - The collector instance for destination init context.
|
|
141
|
+
* @returns The initialized destinations.
|
|
142
|
+
*/
|
|
143
|
+
declare function initDestinations(_collector: Collector.Instance, destinations?: Destination.InitDestinations): Promise<Collector.Destinations>;
|
|
144
|
+
/**
|
|
145
|
+
* Merges destination environment with config environment
|
|
146
|
+
* Config env takes precedence over destination env for overrides
|
|
147
|
+
*/
|
|
148
|
+
declare function mergeEnvironments(destinationEnv?: Destination.Env, configEnv?: Destination.Env): Destination.Env;
|
|
149
|
+
|
|
150
|
+
declare const destinationCode: Destination.Instance;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Handles common commands.
|
|
154
|
+
*
|
|
155
|
+
* @param collector The walkerOS collector instance.
|
|
156
|
+
* @param action The action to handle.
|
|
157
|
+
* @param data The data to handle.
|
|
158
|
+
* @param options The options to handle.
|
|
159
|
+
* @returns A promise that resolves with the push result or undefined.
|
|
160
|
+
*/
|
|
161
|
+
declare function commonHandleCommand(collector: Collector.Instance, action: string, data?: unknown, options?: unknown): Promise<Elb.PushResult>;
|
|
162
|
+
/**
|
|
163
|
+
* Creates a full event from a partial event.
|
|
164
|
+
*
|
|
165
|
+
* @param collector The walkerOS collector instance.
|
|
166
|
+
* @param partialEvent The partial event to transform.
|
|
167
|
+
* @returns The full event.
|
|
168
|
+
*/
|
|
169
|
+
declare function createEvent(collector: Collector.Instance, partialEvent: WalkerOS.PartialEvent): WalkerOS.Event;
|
|
170
|
+
/**
|
|
171
|
+
* Runs the collector by setting it to allowed state and processing queued events.
|
|
172
|
+
*
|
|
173
|
+
* @param collector The walkerOS collector instance.
|
|
174
|
+
* @param state Optional state to merge with the collector (user, globals, consent, custom).
|
|
175
|
+
* @returns A promise that resolves with the push result.
|
|
176
|
+
*/
|
|
177
|
+
declare function runCollector(collector: Collector.Instance, state?: RunState): Promise<Elb.PushResult>;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Registers a callback for a specific event type.
|
|
181
|
+
*
|
|
182
|
+
* @param collector The walkerOS collector instance.
|
|
183
|
+
* @param type The type of the event to listen for.
|
|
184
|
+
* @param option The callback function or an array of callback functions.
|
|
185
|
+
*/
|
|
186
|
+
declare function on(collector: Collector.Instance, type: On.Types, option: WalkerOS.SingleOrArray<On.Options>): void;
|
|
187
|
+
/**
|
|
188
|
+
* Applies all registered callbacks for a specific event type.
|
|
189
|
+
*
|
|
190
|
+
* @param collector The walkerOS collector instance.
|
|
191
|
+
* @param type The type of the event to apply the callbacks for.
|
|
192
|
+
* @param options The options for the callbacks.
|
|
193
|
+
* @param config The consent configuration.
|
|
194
|
+
*/
|
|
195
|
+
declare function onApply(collector: Collector.Instance, type: On.Types, options?: Array<On.Options>, config?: WalkerOS.Consent): void;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Initialize sources using the code/config/env pattern
|
|
199
|
+
*
|
|
200
|
+
* @param collector - The WalkerOS collector instance
|
|
201
|
+
* @param sources - Map of source definitions with code/config/env
|
|
202
|
+
* @returns Initialized sources
|
|
203
|
+
*/
|
|
204
|
+
declare function initSources(collector: Collector.Instance, sources?: Source.InitSources): Promise<Collector.Sources>;
|
|
205
|
+
|
|
206
|
+
export { code as Code, type CommandTypes, Commands, Const, type CreateCollector, type HandleCommandFn, type RunState, type StartFlow, type StorageType, addDestination, commonHandleCommand, createEvent, createPush, createPushResult, destinationCode, destinationInit, destinationPush, initDestinations, initSources, mergeEnvironments, on, onApply, pushToDestinations, runCollector, setConsent, startFlow };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { WalkerOS, Collector, Elb, Mapping, Destination, On, Source } from '@walkeros/core';
|
|
2
|
+
|
|
3
|
+
interface RunState {
|
|
4
|
+
consent?: WalkerOS.Consent;
|
|
5
|
+
user?: WalkerOS.User;
|
|
6
|
+
globals?: WalkerOS.Properties;
|
|
7
|
+
custom?: WalkerOS.Properties;
|
|
8
|
+
}
|
|
9
|
+
type HandleCommandFn<T extends Collector.Instance> = (collector: T, action: string, data?: unknown, options?: unknown) => Promise<Elb.PushResult>;
|
|
10
|
+
type CommandTypes = 'Action' | 'Actions' | 'Config' | 'Consent' | 'Context' | 'Custom' | 'Destination' | 'Elb' | 'Globals' | 'Hook' | 'Init' | 'Link' | 'On' | 'Prefix' | 'Ready' | 'Run' | 'Session' | 'User' | 'Walker';
|
|
11
|
+
type StorageType = 'cookie' | 'local' | 'session';
|
|
12
|
+
interface CreateCollector {
|
|
13
|
+
collector: Collector.Instance;
|
|
14
|
+
elb: WalkerOS.Elb;
|
|
15
|
+
}
|
|
16
|
+
interface StartFlow<ElbPush extends WalkerOS.Elb = WalkerOS.Elb> {
|
|
17
|
+
collector: Collector.Instance;
|
|
18
|
+
elb: ElbPush;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Settings {
|
|
22
|
+
scripts?: string[];
|
|
23
|
+
init?: string;
|
|
24
|
+
on?: string;
|
|
25
|
+
push?: string;
|
|
26
|
+
pushBatch?: string;
|
|
27
|
+
}
|
|
28
|
+
interface CodeMapping extends Mapping.Rule<CodeMapping> {
|
|
29
|
+
push?: string;
|
|
30
|
+
pushBatch?: string;
|
|
31
|
+
}
|
|
32
|
+
type Types = Destination.Types<Settings, CodeMapping>;
|
|
33
|
+
type Config = Destination.Config<Types>;
|
|
34
|
+
type Context = Destination.Context<Types>;
|
|
35
|
+
type InitContext = Destination.InitContext<Types>;
|
|
36
|
+
type PushContext = Destination.PushContext<Types>;
|
|
37
|
+
type PushBatchContext = Destination.PushBatchContext<Types>;
|
|
38
|
+
type InitFn = (context: InitContext) => void;
|
|
39
|
+
type OnFn = (type: On.Types, context: Context) => void;
|
|
40
|
+
type PushFn = (event: WalkerOS.Event, context: PushContext) => void;
|
|
41
|
+
type PushBatchFn = (batch: Destination.Batch<CodeMapping>, context: PushBatchContext) => void;
|
|
42
|
+
|
|
43
|
+
type code_CodeMapping = CodeMapping;
|
|
44
|
+
type code_Config = Config;
|
|
45
|
+
type code_Context = Context;
|
|
46
|
+
type code_InitContext = InitContext;
|
|
47
|
+
type code_InitFn = InitFn;
|
|
48
|
+
type code_OnFn = OnFn;
|
|
49
|
+
type code_PushBatchContext = PushBatchContext;
|
|
50
|
+
type code_PushBatchFn = PushBatchFn;
|
|
51
|
+
type code_PushContext = PushContext;
|
|
52
|
+
type code_PushFn = PushFn;
|
|
53
|
+
type code_Settings = Settings;
|
|
54
|
+
type code_Types = Types;
|
|
55
|
+
declare namespace code {
|
|
56
|
+
export type { code_CodeMapping as CodeMapping, code_Config as Config, code_Context as Context, code_InitContext as InitContext, code_InitFn as InitFn, code_OnFn as OnFn, code_PushBatchContext as PushBatchContext, code_PushBatchFn as PushBatchFn, code_PushContext as PushContext, code_PushFn as PushFn, code_Settings as Settings, code_Types as Types };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare const Commands: Record<CommandTypes, Collector.CommandType>;
|
|
60
|
+
declare const Const: {
|
|
61
|
+
Commands: Record<CommandTypes, string>;
|
|
62
|
+
Utils: {
|
|
63
|
+
Storage: {
|
|
64
|
+
[key: string]: StorageType;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Sets the consent state and processes the queue.
|
|
71
|
+
*
|
|
72
|
+
* @param collector - The walkerOS collector instance.
|
|
73
|
+
* @param data - The consent data to set.
|
|
74
|
+
* @returns The result of the push operation.
|
|
75
|
+
*/
|
|
76
|
+
declare function setConsent(collector: Collector.Instance, data: WalkerOS.Consent): Promise<Elb.PushResult>;
|
|
77
|
+
|
|
78
|
+
declare function startFlow<ElbPush extends Elb.Fn = Elb.Fn>(initConfig?: Collector.InitConfig): Promise<StartFlow<ElbPush>>;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Creates the push function for the collector.
|
|
82
|
+
* Handles source mapping, event creation, and routing to destinations.
|
|
83
|
+
*
|
|
84
|
+
* @param collector - The walkerOS collector instance
|
|
85
|
+
* @param prepareEvent - Function to enrich partial events
|
|
86
|
+
* @returns The push function
|
|
87
|
+
*/
|
|
88
|
+
declare function createPush<T extends Collector.Instance>(collector: T, prepareEvent: (event: WalkerOS.DeepPartialEvent) => WalkerOS.PartialEvent): Collector.PushFn;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Adds a new destination to the collector.
|
|
92
|
+
*
|
|
93
|
+
* @param collector - The walkerOS collector instance.
|
|
94
|
+
* @param data - The destination's init data.
|
|
95
|
+
* @param options - The destination's config.
|
|
96
|
+
* @returns The result of the push operation.
|
|
97
|
+
*/
|
|
98
|
+
declare function addDestination(collector: Collector.Instance, data: Destination.Init, options?: Destination.Config): Promise<Elb.PushResult>;
|
|
99
|
+
/**
|
|
100
|
+
* Pushes an event to all or a subset of destinations.
|
|
101
|
+
*
|
|
102
|
+
* @param collector - The walkerOS collector instance.
|
|
103
|
+
* @param event - The event to push.
|
|
104
|
+
* @param destinations - The destinations to push to.
|
|
105
|
+
* @returns The result of the push operation.
|
|
106
|
+
*/
|
|
107
|
+
declare function pushToDestinations(collector: Collector.Instance, event?: WalkerOS.Event, destinations?: Collector.Destinations): Promise<Elb.PushResult>;
|
|
108
|
+
/**
|
|
109
|
+
* Initializes a destination.
|
|
110
|
+
*
|
|
111
|
+
* @template Destination
|
|
112
|
+
* @param collector - The walkerOS collector instance.
|
|
113
|
+
* @param destination - The destination to initialize.
|
|
114
|
+
* @returns Whether the destination was initialized successfully.
|
|
115
|
+
*/
|
|
116
|
+
declare function destinationInit<Destination extends Destination.Instance>(collector: Collector.Instance, destination: Destination): Promise<boolean>;
|
|
117
|
+
/**
|
|
118
|
+
* Pushes an event to a single destination.
|
|
119
|
+
* Handles mapping, batching, and consent checks.
|
|
120
|
+
*
|
|
121
|
+
* @template Destination
|
|
122
|
+
* @param collector - The walkerOS collector instance.
|
|
123
|
+
* @param destination - The destination to push to.
|
|
124
|
+
* @param event - The event to push.
|
|
125
|
+
* @returns Whether the event was pushed successfully.
|
|
126
|
+
*/
|
|
127
|
+
declare function destinationPush<Destination extends Destination.Instance>(collector: Collector.Instance, destination: Destination, event: WalkerOS.Event): Promise<boolean>;
|
|
128
|
+
/**
|
|
129
|
+
* Creates a standardized result object for push operations.
|
|
130
|
+
*
|
|
131
|
+
* @param partialResult - A partial result to merge with the default result.
|
|
132
|
+
* @returns The push result.
|
|
133
|
+
*/
|
|
134
|
+
declare function createPushResult(partialResult?: Partial<Elb.PushResult>): Elb.PushResult;
|
|
135
|
+
/**
|
|
136
|
+
* Initializes a map of destinations using ONLY the unified code/config/env pattern.
|
|
137
|
+
* Does NOT call destination.init() - that happens later during push with proper consent checks.
|
|
138
|
+
*
|
|
139
|
+
* @param destinations - The destinations to initialize.
|
|
140
|
+
* @param collector - The collector instance for destination init context.
|
|
141
|
+
* @returns The initialized destinations.
|
|
142
|
+
*/
|
|
143
|
+
declare function initDestinations(_collector: Collector.Instance, destinations?: Destination.InitDestinations): Promise<Collector.Destinations>;
|
|
144
|
+
/**
|
|
145
|
+
* Merges destination environment with config environment
|
|
146
|
+
* Config env takes precedence over destination env for overrides
|
|
147
|
+
*/
|
|
148
|
+
declare function mergeEnvironments(destinationEnv?: Destination.Env, configEnv?: Destination.Env): Destination.Env;
|
|
149
|
+
|
|
150
|
+
declare const destinationCode: Destination.Instance;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Handles common commands.
|
|
154
|
+
*
|
|
155
|
+
* @param collector The walkerOS collector instance.
|
|
156
|
+
* @param action The action to handle.
|
|
157
|
+
* @param data The data to handle.
|
|
158
|
+
* @param options The options to handle.
|
|
159
|
+
* @returns A promise that resolves with the push result or undefined.
|
|
160
|
+
*/
|
|
161
|
+
declare function commonHandleCommand(collector: Collector.Instance, action: string, data?: unknown, options?: unknown): Promise<Elb.PushResult>;
|
|
162
|
+
/**
|
|
163
|
+
* Creates a full event from a partial event.
|
|
164
|
+
*
|
|
165
|
+
* @param collector The walkerOS collector instance.
|
|
166
|
+
* @param partialEvent The partial event to transform.
|
|
167
|
+
* @returns The full event.
|
|
168
|
+
*/
|
|
169
|
+
declare function createEvent(collector: Collector.Instance, partialEvent: WalkerOS.PartialEvent): WalkerOS.Event;
|
|
170
|
+
/**
|
|
171
|
+
* Runs the collector by setting it to allowed state and processing queued events.
|
|
172
|
+
*
|
|
173
|
+
* @param collector The walkerOS collector instance.
|
|
174
|
+
* @param state Optional state to merge with the collector (user, globals, consent, custom).
|
|
175
|
+
* @returns A promise that resolves with the push result.
|
|
176
|
+
*/
|
|
177
|
+
declare function runCollector(collector: Collector.Instance, state?: RunState): Promise<Elb.PushResult>;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Registers a callback for a specific event type.
|
|
181
|
+
*
|
|
182
|
+
* @param collector The walkerOS collector instance.
|
|
183
|
+
* @param type The type of the event to listen for.
|
|
184
|
+
* @param option The callback function or an array of callback functions.
|
|
185
|
+
*/
|
|
186
|
+
declare function on(collector: Collector.Instance, type: On.Types, option: WalkerOS.SingleOrArray<On.Options>): void;
|
|
187
|
+
/**
|
|
188
|
+
* Applies all registered callbacks for a specific event type.
|
|
189
|
+
*
|
|
190
|
+
* @param collector The walkerOS collector instance.
|
|
191
|
+
* @param type The type of the event to apply the callbacks for.
|
|
192
|
+
* @param options The options for the callbacks.
|
|
193
|
+
* @param config The consent configuration.
|
|
194
|
+
*/
|
|
195
|
+
declare function onApply(collector: Collector.Instance, type: On.Types, options?: Array<On.Options>, config?: WalkerOS.Consent): void;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Initialize sources using the code/config/env pattern
|
|
199
|
+
*
|
|
200
|
+
* @param collector - The WalkerOS collector instance
|
|
201
|
+
* @param sources - Map of source definitions with code/config/env
|
|
202
|
+
* @returns Initialized sources
|
|
203
|
+
*/
|
|
204
|
+
declare function initSources(collector: Collector.Instance, sources?: Source.InitSources): Promise<Collector.Sources>;
|
|
205
|
+
|
|
206
|
+
export { code as Code, type CommandTypes, Commands, Const, type CreateCollector, type HandleCommandFn, type RunState, type StartFlow, type StorageType, addDestination, commonHandleCommand, createEvent, createPush, createPushResult, destinationCode, destinationInit, destinationPush, initDestinations, initSources, mergeEnvironments, on, onApply, pushToDestinations, runCollector, setConsent, startFlow };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,n=Object.defineProperty,t=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,a={};((e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})})(a,{Code:()=>c,Commands:()=>i,Const:()=>r,addDestination:()=>f,commonHandleCommand:()=>D,createEvent:()=>P,createPush:()=>R,createPushResult:()=>b,destinationCode:()=>g,destinationInit:()=>m,destinationPush:()=>h,initDestinations:()=>y,initSources:()=>I,mergeEnvironments:()=>v,on:()=>C,onApply:()=>q,pushToDestinations:()=>p,runCollector:()=>x,setConsent:()=>j,startFlow:()=>$}),module.exports=(e=a,((e,a,c,i)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let r of o(a))s.call(e,r)||r===c||n(e,r,{get:()=>a[r],enumerable:!(i=t(a,r))||i.enumerable});return e})(n({},"__esModule",{value:!0}),e));var c={},i={Action:"action",Actions:"actions",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"},r={Commands:i,Utils:{Storage:{Cookie:"cookie",Local:"local",Session:"session"}}},u=require("@walkeros/core"),l=require("@walkeros/core"),g={type:"code",config:{},init(e){const{config:n,logger:t}=e,o=n.settings,s=o?.scripts;if(s&&"undefined"!=typeof document)for(const e of s){const n=document.createElement("script");n.src=e,n.async=!0,document.head.appendChild(n)}const a=o?.init;if(a)try{new Function("context",a)(e)}catch(e){t.error("Code destination init error:",e)}},push(e,n){const{mapping:t,config:o,logger:s}=n,a=t?.push??o.settings?.push;if(a)try{new Function("event","context",a)(e,n)}catch(e){s.error("Code destination push error:",e)}},pushBatch(e,n){const{mapping:t,config:o,logger:s}=n,a=t?.pushBatch??o.settings?.pushBatch;if(a)try{new Function("batch","context",a)(e,n)}catch(e){s.error("Code destination pushBatch error:",e)}},on(e,n){const{config:t,logger:o}=n,s=t.settings?.on;if(s)try{new Function("type","context",s)(e,n)}catch(e){o.error("Code destination on error:",e)}}};function d(e){return!0===e?g:e}async function f(e,n,t){const{code:o,config:s={},env:a={}}=n,c=t||s||{init:!1},i=d(o),r={...i,config:c,env:v(i.env,a)};let u=r.config.id;if(!u)do{u=(0,l.getId)(4)}while(e.destinations[u]);return e.destinations[u]=r,!1!==r.config.queue&&(r.queue=[...e.queue]),p(e,void 0,{[u]:r})}async function p(e,n,t){const{allowed:o,consent:s,globals:a,user:c}=e;if(!o)return b({ok:!1});n&&e.queue.push(n),t||(t=e.destinations);const i=await Promise.all(Object.entries(t||{}).map(async([t,o])=>{let i=(o.queue||[]).map(e=>({...e,consent:s}));if(o.queue=[],n){const e=(0,l.clone)(n);i.push(e)}if(!i.length)return{id:t,destination:o,skipped:!0};const r=[],u=i.filter(e=>{const n=(0,l.getGrantedConsent)(o.config.consent,s,e.consent);return!n||(e.consent=n,r.push(e),!1)});if(o.queue.concat(u),!r.length)return{id:t,destination:o,queue:i};if(!await(0,l.tryCatchAsync)(m)(e,o))return{id:t,destination:o,queue:i};let g=!1;return o.dlq||(o.dlq=[]),await Promise.all(r.map(async n=>(n.globals=(0,l.assign)(a,n.globals),n.user=(0,l.assign)(c,n.user),await(0,l.tryCatchAsync)(h,t=>{const s=o.type||"unknown";return e.logger.scope(s).error("Push failed",{error:t,event:n.name}),g=!0,o.dlq.push([n,t]),!1})(e,o,n),n))),{id:t,destination:o,error:g}})),r=[],u=[],g=[];for(const e of i){if(e.skipped)continue;const n=e.destination,t={id:e.id,destination:n};e.error?g.push(t):e.queue&&e.queue.length?(n.queue=(n.queue||[]).concat(e.queue),u.push(t)):r.push(t)}return b({ok:!g.length,event:n,successful:r,queued:u,failed:g})}async function m(e,n){if(n.init&&!n.config.init){const t=n.type||"unknown",o=e.logger.scope(t),s={collector:e,config:n.config,env:v(n.env,n.config.env),logger:o};o.debug("init");const a=await(0,l.useHooks)(n.init,"DestinationInit",e.hooks)(s);if(!1===a)return a;n.config={...a||n.config,init:!0},o.debug("init done")}return!0}async function h(e,n,t){const{config:o}=n,s=await(0,l.processEventMapping)(t,o,e);if(s.ignore)return!1;const a=n.type||"unknown",c=e.logger.scope(a),i={collector:e,config:o,data:s.data,mapping:s.mapping,env:v(n.env,o.env),logger:c},r=s.mapping,u=s.mappingKey||"* *";if(r?.batch&&n.pushBatch){if(n.batches=n.batches||{},!n.batches[u]){const t={key:u,events:[],data:[]};n.batches[u]={batched:t,batchFn:(0,l.debounce)(()=>{const t=n.batches[u].batched,s={collector:e,config:o,data:void 0,mapping:r,env:v(n.env,o.env),logger:c};c.debug("push batch",{events:t.events.length}),(0,l.useHooks)(n.pushBatch,"DestinationPushBatch",e.hooks)(t,s),c.debug("push batch done"),t.events=[],t.data=[]},r.batch)}}const t=n.batches[u];t.batched.events.push(s.event),(0,l.isDefined)(s.data)&&t.batched.data.push(s.data),t.batchFn()}else c.debug("push",{event:s.event.name}),await(0,l.useHooks)(n.push,"DestinationPush",e.hooks)(s.event,i),c.debug("push done");return!0}function b(e){return(0,l.assign)({ok:!e?.failed?.length,successful:[],queued:[],failed:[]},e)}async function y(e,n={}){const t={};for(const[e,o]of Object.entries(n)){const{code:n,config:s={},env:a={}}=o,c=d(n),i={...c.config,...s},r=v(c.env,a);t[e]={...c,config:i,env:r}}return t}function v(e,n){return e||n?n?e&&(0,l.isObject)(e)&&(0,l.isObject)(n)?{...e,...n}:n:e:{}}var w=require("@walkeros/core"),k=require("@walkeros/core");function C(e,n,t){const o=e.on,s=o[n]||[],a=(0,w.isArray)(t)?t:[t];a.forEach(e=>{s.push(e)}),o[n]=s,q(e,n,a)}function q(e,n,t,o){let s,a=t||[];switch(t||(a=e.on[n]||[]),n){case r.Commands.Consent:s=o||e.consent;break;case r.Commands.Session:s=e.session;break;case r.Commands.Ready:case r.Commands.Run:default:s=void 0}if(Object.values(e.sources).forEach(e=>{e.on&&(0,k.tryCatch)(e.on)(n,s)}),Object.values(e.destinations).forEach(t=>{if(t.on){const o=t.type||"unknown",a=e.logger.scope(o).scope("on").scope(n),c={collector:e,config:t.config,data:s,env:v(t.env,t.config.env),logger:a};(0,k.tryCatch)(t.on)(n,c)}}),a.length)switch(n){case r.Commands.Consent:!function(e,n,t){const o=t||e.consent;n.forEach(n=>{Object.keys(o).filter(e=>e in n).forEach(t=>{(0,k.tryCatch)(n[t])(e,o)})})}(e,a,o);break;case r.Commands.Ready:case r.Commands.Run:!function(e,n){e.allowed&&n.forEach(n=>{(0,k.tryCatch)(n)(e)})}(e,a);break;case r.Commands.Session:!function(e,n){if(!e.session)return;n.forEach(n=>{(0,k.tryCatch)(n)(e,e.session)})}(e,a)}}async function j(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=(0,u.assign)(t,s),q(e,"consent",void 0,s),o?p(e):b({ok:!0})}var O=require("@walkeros/core"),E=require("@walkeros/core"),A=require("@walkeros/core");async function D(e,n,t,o){let s;switch(n){case r.Commands.Config:(0,A.isObject)(t)&&(0,E.assign)(e.config,t,{shallow:!1});break;case r.Commands.Consent:(0,A.isObject)(t)&&(s=await j(e,t));break;case r.Commands.Custom:(0,A.isObject)(t)&&(e.custom=(0,E.assign)(e.custom,t));break;case r.Commands.Destination:(0,A.isObject)(t)&&(0,E.isFunction)(t.push)&&(s=await f(e,{code:t},o));break;case r.Commands.Globals:(0,A.isObject)(t)&&(e.globals=(0,E.assign)(e.globals,t));break;case r.Commands.On:(0,E.isString)(t)&&C(e,t,o);break;case r.Commands.Ready:q(e,"ready");break;case r.Commands.Run:s=await x(e,t);break;case r.Commands.Session:q(e,"session");break;case r.Commands.User:(0,A.isObject)(t)&&(0,E.assign)(e.user,t,{shallow:!1})}return s||{ok:!0,successful:[],queued:[],failed:[]}}function P(e,n){if(!n.name)throw new Error("Event name is required");const[t,o]=n.name.split(" ");if(!t||!o)throw new Error("Event name is invalid");++e.count;const{timestamp:s=Date.now(),group:a=e.group,count:c=e.count}=n,{name:i=`${t} ${o}`,data:r={},context:u={},globals:l=e.globals,custom:g={},user:d=e.user,nested:f=[],consent:p=e.consent,id:m=`${s}-${a}-${c}`,trigger:h="",entity:b=t,action:y=o,timing:v=0,version:w={source:e.version,tagging:e.config.tagging||0},source:k={type:"collector",id:"",previous_id:""}}=n;return{name:i,data:r,context:u,globals:l,custom:g,user:d,nested:f,consent:p,id:m,trigger:h,entity:b,action:y,timestamp:s,timing:v,group:a,count:c,version:w,source:k}}async function x(e,n){e.allowed=!0,e.count=0,e.group=(0,E.getId)(),e.timing=Date.now(),n&&(n.consent&&(e.consent=(0,E.assign)(e.consent,n.consent)),n.user&&(e.user=(0,E.assign)(e.user,n.user)),n.globals&&(e.globals=(0,E.assign)(e.config.globalsStatic||{},n.globals)),n.custom&&(e.custom=(0,E.assign)(e.custom,n.custom))),Object.values(e.destinations).forEach(e=>{e.queue=[]}),e.queue=[],e.round++;const t=await p(e);return q(e,"run"),t}var S=require("@walkeros/core");function R(e,n){return(0,S.useHooks)(async(t,o={})=>await(0,S.tryCatchAsync)(async()=>{let s=t;if(o.mapping){const n=await(0,S.processEventMapping)(s,o.mapping,e);if(n.ignore)return b({ok:!0});if(o.mapping.consent){if(!(0,S.getGrantedConsent)(o.mapping.consent,e.consent,n.event.consent))return b({ok:!0})}s=n.event}const a=n(s),c=P(e,a);return await p(e,c)},()=>b({ok:!1}))(),"Push",e.hooks)}var F=require("@walkeros/core");async function B(e){const n=(0,O.assign)({globalsStatic:{},sessionStatic:{},tagging:0,run:!0},e,{merge:!1,extend:!1}),t={level:e.logger?.level,handler:e.logger?.handler},o=(0,O.createLogger)(t),s={...n.globalsStatic,...e.globals},a={allowed:!1,config:n,consent:e.consent||{},count:0,custom:e.custom||{},destinations:{},globals:s,group:"",hooks:{},logger:o,on:{},queue:[],round:0,session:void 0,timing:Date.now(),user:e.user||{},version:"0.5.1-next.0",sources:{},push:void 0,command:void 0};return a.push=R(a,e=>({timing:Math.round((Date.now()-a.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),a.command=function(e,n){return(0,F.useHooks)(async(t,o,s)=>await(0,F.tryCatchAsync)(async()=>await n(e,t,o,s),()=>b({ok:!1}))(),"Command",e.hooks)}(a,D),a.destinations=await y(0,e.destinations||{}),a}var H=require("@walkeros/core");async function I(e,n={}){const t={};for(const[o,s]of Object.entries(n)){const{code:n,config:a={},env:c={},primary:i}=s,r=(n,t={})=>e.push(n,{...t,mapping:a}),u=e.logger.scope("source").scope(o),l={push:r,command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:u,...c},g=await(0,H.tryCatchAsync)(n)(a,l);if(!g)continue;const d=g.type||"unknown",f=e.logger.scope(d).scope(o);l.logger=f,i&&(g.config={...g.config,primary:i}),t[o]=g}return t}async function $(e){e=e||{};const n=await B(e),t=(o=n,{type:"elb",config:{},push:async(e,n,t,s,a,c)=>{if("string"==typeof e&&e.startsWith("walker ")){const s=e.replace("walker ","");return o.command(s,n,t)}let i;if("string"==typeof e)i={name:e},n&&"object"==typeof n&&!Array.isArray(n)&&(i.data=n);else{if(!e||"object"!=typeof e)return{ok:!1,successful:[],queued:[],failed:[]};i=e,n&&"object"==typeof n&&!Array.isArray(n)&&(i.data={...i.data||{},...n})}return s&&"object"==typeof s&&(i.context=s),a&&Array.isArray(a)&&(i.nested=a),c&&"object"==typeof c&&(i.custom=c),o.push(i)}});var o;n.sources.elb=t;const s=await I(n,e.sources||{});Object.assign(n.sources,s);const{consent:a,user:c,globals:i,custom:r}=e;a&&await n.command("consent",a),c&&await n.command("user",c),i&&Object.assign(n.globals,i),r&&Object.assign(n.custom,r),n.config.run&&await n.command("run");let u=t.push;const l=Object.values(n.sources).filter(e=>"elb"!==e.type),g=l.find(e=>e.config.primary);return g?u=g.push:l.length>0&&(u=l[0].push),{collector:n,elb:u}}//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/types/code.ts","../src/constants.ts","../src/consent.ts","../src/destination.ts","../src/destination-code.ts","../src/on.ts","../src/collector.ts","../src/handle.ts","../src/push.ts","../src/command.ts","../src/elb.ts","../src/source.ts","../src/flow.ts"],"sourcesContent":["export * from './types';\n\nexport * from './constants';\n\nexport * from './consent';\nexport * from './flow';\nexport * from './push';\nexport * from './destination';\nexport * from './destination-code';\nexport * from './handle';\nexport * from './on';\nexport * from './source';\n","import type { Destination, Mapping, On, WalkerOS } from '@walkeros/core';\n\nexport interface Settings {\n scripts?: string[];\n init?: string;\n on?: string;\n push?: string;\n pushBatch?: string;\n}\n\nexport interface CodeMapping extends Mapping.Rule<CodeMapping> {\n push?: string;\n pushBatch?: string;\n}\n\nexport type Types = Destination.Types<Settings, CodeMapping>;\nexport type Config = Destination.Config<Types>;\nexport type Context = Destination.Context<Types>;\nexport type InitContext = Destination.InitContext<Types>;\nexport type PushContext = Destination.PushContext<Types>;\nexport type PushBatchContext = Destination.PushBatchContext<Types>;\n\nexport type InitFn = (context: InitContext) => void;\nexport type OnFn = (type: On.Types, context: Context) => void;\nexport type PushFn = (event: WalkerOS.Event, context: PushContext) => void;\nexport type PushBatchFn = (\n batch: Destination.Batch<CodeMapping>,\n context: PushBatchContext,\n) => void;\n","import type { Collector } from '@walkeros/core';\nimport type { CommandTypes, StorageType } from './types/collector';\n\nexport const Commands: Record<CommandTypes, Collector.CommandType> = {\n Action: 'action',\n Actions: 'actions',\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\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 debounce,\n getId,\n getGrantedConsent,\n isDefined,\n isObject,\n processEventMapping,\n tryCatchAsync,\n useHooks,\n} from '@walkeros/core';\nimport { destinationCode } from './destination-code';\n\nfunction resolveCode(code: Destination.Instance | true): Destination.Instance {\n return code === true ? destinationCode : code;\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 const { code, config: dataConfig = {}, env = {} } = data;\n const config = options || dataConfig || { init: false };\n\n const resolved = resolveCode(code);\n const destination: Destination.Instance = {\n ...resolved,\n config,\n env: mergeEnvironments(resolved.env, env),\n };\n\n let id = destination.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 (destination.config.queue !== false)\n 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 const currentEvent = clone(event);\n\n // Note: Policy is now applied in processEventMapping() within destinationPush()\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 // Log the error with destination scope\n const destType = destination.type || 'unknown';\n collector.logger.scope(destType).error('Push failed', {\n error: err,\n event: event.name,\n });\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 // Create scoped logger for this destination: [type:id] or [unknown:id]\n const destType = destination.type || 'unknown';\n const destLogger = collector.logger.scope(destType);\n\n const context = {\n collector,\n config: destination.config,\n env: mergeEnvironments(destination.env, destination.config.env),\n logger: destLogger,\n } as Destination.InitContext;\n\n destLogger.debug('init');\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 destLogger.debug('init done');\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\n const processed = await processEventMapping(event, config, collector);\n\n if (processed.ignore) return false;\n\n // Create scoped logger for this destination: [type] or [unknown]\n const destType = destination.type || 'unknown';\n const destLogger = collector.logger.scope(destType);\n\n const context: Destination.PushContext = {\n collector,\n config,\n data: processed.data,\n mapping: processed.mapping,\n env: mergeEnvironments(destination.env, config.env),\n logger: destLogger,\n };\n\n const eventMapping = processed.mapping;\n const mappingKey = processed.mappingKey || '* *';\n\n if (eventMapping?.batch && destination.pushBatch) {\n // Initialize batch registry on destination (not on shared mapping config)\n destination.batches = destination.batches || {};\n\n // Get or create batch state for this mapping key\n if (!destination.batches[mappingKey]) {\n const batched: Destination.Batch<unknown> = {\n key: mappingKey,\n events: [],\n data: [],\n };\n\n destination.batches[mappingKey] = {\n batched,\n batchFn: debounce(() => {\n const batchState = destination.batches![mappingKey];\n const currentBatched = batchState.batched;\n\n const batchContext: Destination.PushBatchContext = {\n collector,\n config,\n // Note: batch.data contains all transformed data; context.data is for single events\n data: undefined,\n mapping: eventMapping,\n env: mergeEnvironments(destination.env, config.env),\n logger: destLogger,\n };\n\n destLogger.debug('push batch', {\n events: currentBatched.events.length,\n });\n\n useHooks(\n destination.pushBatch!,\n 'DestinationPushBatch',\n collector.hooks,\n )(currentBatched, batchContext);\n\n destLogger.debug('push batch done');\n\n // Reset batch\n currentBatched.events = [];\n currentBatched.data = [];\n }, eventMapping.batch),\n };\n }\n\n // Add event to batch\n const batchState = destination.batches[mappingKey];\n batchState.batched.events.push(processed.event);\n if (isDefined(processed.data)) batchState.batched.data.push(processed.data);\n\n // Trigger debounced batch\n batchState.batchFn();\n } else {\n destLogger.debug('push', { event: processed.event.name });\n\n // It's time to go to the destination's side now\n await useHooks(\n destination.push,\n 'DestinationPush',\n collector.hooks,\n )(processed.event, context);\n\n destLogger.debug('push done');\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 using ONLY the unified code/config/env pattern.\n * Does NOT call destination.init() - that happens later during push with proper consent checks.\n *\n * @param destinations - The destinations to initialize.\n * @param collector - The collector instance for destination init context.\n * @returns The initialized destinations.\n */\nexport async function initDestinations(\n _collector: Collector.Instance,\n destinations: Destination.InitDestinations = {},\n): Promise<Collector.Destinations> {\n const result: Collector.Destinations = {};\n\n for (const [name, destinationDef] of Object.entries(destinations)) {\n const { code, config = {}, env = {} } = destinationDef;\n const resolved = resolveCode(code);\n\n const mergedConfig = {\n ...resolved.config,\n ...config,\n };\n\n const mergedEnv = mergeEnvironments(resolved.env, env);\n\n result[name] = {\n ...resolved,\n config: mergedConfig,\n env: mergedEnv,\n };\n }\n\n return result;\n}\n\n/**\n * Merges destination environment with config environment\n * Config env takes precedence over destination env for overrides\n */\nexport function mergeEnvironments(\n destinationEnv?: Destination.Env,\n configEnv?: Destination.Env,\n): Destination.Env {\n // If neither environment exists, return empty object\n if (!destinationEnv && !configEnv) return {};\n\n // If only one exists, return it\n if (!configEnv) return destinationEnv!;\n if (!destinationEnv) return configEnv;\n\n // Both exist - merge objects with configEnv taking precedence\n if (isObject(destinationEnv) && isObject(configEnv)) {\n return { ...destinationEnv, ...configEnv };\n }\n\n // If they're not both objects, config env overrides destination env\n return configEnv;\n}\n","import type { Destination } from '@walkeros/core';\nimport type { CodeMapping, Settings } from './types/code';\n\nexport const destinationCode: Destination.Instance = {\n type: 'code',\n config: {},\n\n init(context) {\n const { config, logger } = context;\n const settings = config.settings as Settings | undefined;\n\n // Inject scripts (fire and forget)\n const scripts = settings?.scripts;\n if (scripts && typeof document !== 'undefined') {\n for (const src of scripts) {\n const script = document.createElement('script');\n script.src = src;\n script.async = true;\n document.head.appendChild(script);\n }\n }\n\n // Execute init code\n const initCode = settings?.init;\n if (!initCode) return;\n try {\n const fn = new Function('context', initCode);\n fn(context);\n } catch (e) {\n logger.error('Code destination init error:', e);\n }\n },\n\n push(event, context) {\n const { mapping, config, logger } = context;\n const pushCode =\n (mapping as CodeMapping | undefined)?.push ??\n (config.settings as Settings | undefined)?.push;\n if (!pushCode) return;\n try {\n const fn = new Function('event', 'context', pushCode);\n fn(event, context);\n } catch (e) {\n logger.error('Code destination push error:', e);\n }\n },\n\n pushBatch(batch, context) {\n const { mapping, config, logger } = context;\n const pushBatchCode =\n (mapping as CodeMapping | undefined)?.pushBatch ??\n (config.settings as Settings | undefined)?.pushBatch;\n if (!pushBatchCode) return;\n try {\n const fn = new Function('batch', 'context', pushBatchCode);\n fn(batch, context);\n } catch (e) {\n logger.error('Code destination pushBatch error:', e);\n }\n },\n\n on(type, context) {\n const { config, logger } = context;\n const onCode = (config.settings as Settings | undefined)?.on;\n if (!onCode) return;\n try {\n const fn = new Function('type', 'context', onCode);\n fn(type, context);\n } catch (e) {\n logger.error('Code destination on error:', e);\n }\n },\n};\n\nexport default destinationCode;\n","import type { Collector, On, WalkerOS, Destination } from '@walkeros/core';\nimport { isArray } from '@walkeros/core';\nimport { Const } from './constants';\nimport { tryCatch } from '@walkeros/core';\nimport { mergeEnvironments } from './destination';\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\n // Calculate context data once for all sources and destinations\n let contextData: unknown;\n\n switch (type) {\n case Const.Commands.Consent:\n contextData = config || collector.consent;\n break;\n case Const.Commands.Session:\n contextData = collector.session;\n break;\n case Const.Commands.Ready:\n case Const.Commands.Run:\n default:\n contextData = undefined;\n break;\n }\n\n Object.values(collector.sources).forEach((source) => {\n if (source.on) {\n tryCatch(source.on)(type, contextData);\n }\n });\n\n Object.values(collector.destinations).forEach((destination) => {\n if (destination.on) {\n const destType = destination.type || 'unknown';\n const destLogger = collector.logger\n .scope(destType)\n .scope('on')\n .scope(type);\n\n const context: Destination.Context = {\n collector,\n config: destination.config,\n data: contextData as Destination.Data,\n env: mergeEnvironments(destination.env, destination.config.env),\n logger: destLogger,\n };\n\n tryCatch(destination.on)(type, context);\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, Logger, WalkerOS } from '@walkeros/core';\nimport { assign, createLogger } from '@walkeros/core';\nimport { commonHandleCommand } from './handle';\nimport { initDestinations } from './destination';\nimport { createPush } from './push';\nimport { createCommand } from './command';\nimport { initSources } from './source';\n\ndeclare const __VERSION__: string;\n\nexport async function collector(\n initConfig: Collector.InitConfig,\n): Promise<Collector.Instance> {\n const version = __VERSION__;\n\n const defaultConfig: Collector.Config = {\n globalsStatic: {},\n sessionStatic: {},\n tagging: 0,\n run: true,\n };\n\n const config: Collector.Config = assign(defaultConfig, initConfig, {\n merge: false,\n extend: false,\n });\n\n // Create logger with config from initConfig\n const loggerConfig: Logger.Config = {\n level: initConfig.logger?.level,\n handler: initConfig.logger?.handler,\n };\n const logger = createLogger(loggerConfig);\n\n // Enhanced globals with static globals from config\n const finalGlobals = { ...config.globalsStatic, ...initConfig.globals };\n\n const collector: Collector.Instance = {\n allowed: false,\n config,\n consent: initConfig.consent || {},\n count: 0,\n custom: initConfig.custom || {},\n destinations: {},\n globals: finalGlobals,\n group: '',\n hooks: {},\n logger,\n on: {},\n queue: [],\n round: 0,\n session: undefined,\n timing: Date.now(),\n user: initConfig.user || {},\n version,\n sources: {},\n push: undefined as unknown as Collector.PushFn, // Placeholder, will be set below\n command: undefined as unknown as Collector.CommandFn, // Placeholder, will be set below\n };\n\n // Set the push and command functions with the collector reference\n collector.push = createPush(\n collector,\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 collector.command = createCommand(collector, commonHandleCommand);\n\n // Initialize destinations after collector is fully created\n // Sources are initialized in startFlow after ELB source is created\n collector.destinations = await initDestinations(\n collector,\n initConfig.destinations || {},\n );\n\n return collector;\n}\n","import type { Collector, WalkerOS, Destination, Elb, On } from '@walkeros/core';\nimport { Const } from './constants';\nimport { addDestination, pushToDestinations } from './destination';\nimport { assign, getId, isFunction, isString } from '@walkeros/core';\nimport { isObject } 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 { code: data as unknown as Destination.Instance },\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.Ready:\n onApply(collector, 'ready');\n break;\n\n case Const.Commands.Run:\n result = await runCollector(collector, data as RunState);\n break;\n\n case Const.Commands.Session:\n onApply(collector, 'session');\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 a full event from a partial event.\n *\n * @param collector The walkerOS collector instance.\n * @param partialEvent The partial event to transform.\n * @returns The full event.\n */\nexport function createEvent(\n collector: Collector.Instance,\n partialEvent: WalkerOS.PartialEvent,\n): WalkerOS.Event {\n if (!partialEvent.name) throw new Error('Event name is required');\n\n const [entityValue, actionValue] = partialEvent.name.split(' ');\n if (!entityValue || !actionValue) throw new Error('Event name is invalid');\n\n ++collector.count;\n\n const {\n timestamp = Date.now(),\n group = collector.group,\n count = collector.count,\n } = partialEvent;\n\n const {\n name = `${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 return {\n name,\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\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 // Reset collector queue for this run\n collector.queue = [];\n\n // Increase round counter\n collector.round++;\n\n // Process any queued events now that the collector is allowed\n const result = await pushToDestinations(collector);\n\n // Call the predefined run events\n onApply(collector, 'run');\n\n return result;\n}\n","import type { Collector, WalkerOS, Elb } from '@walkeros/core';\nimport {\n getGrantedConsent,\n processEventMapping,\n tryCatchAsync,\n useHooks,\n} from '@walkeros/core';\nimport { createEvent } from './handle';\nimport { pushToDestinations, createPushResult } from './destination';\n\n/**\n * Creates the push function for the collector.\n * Handles source mapping, event creation, and routing to destinations.\n *\n * @param collector - The walkerOS collector instance\n * @param prepareEvent - Function to enrich partial events\n * @returns The push function\n */\nexport function createPush<T extends Collector.Instance>(\n collector: T,\n prepareEvent: (event: WalkerOS.DeepPartialEvent) => WalkerOS.PartialEvent,\n): Collector.PushFn {\n return useHooks(\n async (\n event: WalkerOS.DeepPartialEvent,\n context: Collector.PushContext = {},\n ): Promise<Elb.PushResult> => {\n return await tryCatchAsync(\n async (): Promise<Elb.PushResult> => {\n let partialEvent = event;\n\n // Apply source mapping if provided in context\n if (context.mapping) {\n const processed = await processEventMapping(\n partialEvent,\n context.mapping,\n collector,\n );\n\n // Check ignore flag\n if (processed.ignore) {\n return createPushResult({ ok: true });\n }\n\n // Check consent requirements\n if (context.mapping.consent) {\n const grantedConsent = getGrantedConsent(\n context.mapping.consent,\n collector.consent,\n processed.event.consent as WalkerOS.Consent | undefined,\n );\n\n if (!grantedConsent) {\n return createPushResult({ ok: true });\n }\n }\n\n partialEvent = processed.event;\n }\n\n // Prepare event (add timing, source info)\n const enrichedEvent = prepareEvent(partialEvent);\n\n // Create full event\n const fullEvent = createEvent(collector, enrichedEvent);\n\n // Push to destinations\n return await pushToDestinations(collector, fullEvent);\n },\n () => {\n return createPushResult({ ok: false });\n },\n )();\n },\n 'Push',\n collector.hooks,\n ) as Collector.PushFn;\n}\n","import type { Collector, Elb } from '@walkeros/core';\nimport type { HandleCommandFn } from './types/collector';\nimport { useHooks, tryCatchAsync } from '@walkeros/core';\nimport { createPushResult } from './destination';\n\n/**\n * Creates the command function for the collector.\n * Handles walker commands (config, consent, destination, etc.)\n *\n * @param collector - The walkerOS collector instance\n * @param handleCommand - Command handler function\n * @returns The command function\n */\nexport function createCommand<T extends Collector.Instance>(\n collector: T,\n handleCommand: HandleCommandFn<T>,\n): Collector.CommandFn {\n return useHooks(\n async (\n command: string,\n data?: unknown,\n options?: unknown,\n ): Promise<Elb.PushResult> => {\n return await tryCatchAsync(\n async (): Promise<Elb.PushResult> => {\n return await handleCommand(collector, command, data, options);\n },\n () => {\n return createPushResult({ ok: false });\n },\n )();\n },\n 'Command',\n collector.hooks,\n ) as Collector.CommandFn;\n}\n","import type { Collector, Source, WalkerOS, Elb } from '@walkeros/core';\n\n/**\n * Creates the default ELB source.\n * Routes between collector.push and collector.command based on input.\n * Provides backward-compatible flexible argument interface.\n *\n * @param collector - The walkerOS collector instance\n * @returns ELB source instance\n */\nexport function createElbSource(\n collector: Collector.Instance,\n): Source.Instance {\n return {\n type: 'elb',\n config: {},\n\n // The push function is the elb() interface users interact with\n push: async (\n eventOrCommand?: unknown,\n data?: unknown,\n options?: unknown,\n context?: unknown,\n nested?: WalkerOS.Entities,\n custom?: WalkerOS.Properties,\n ): Promise<Elb.PushResult> => {\n // Detect walker commands\n if (\n typeof eventOrCommand === 'string' &&\n eventOrCommand.startsWith('walker ')\n ) {\n const command = eventOrCommand.replace('walker ', '');\n return collector.command(command, data, options);\n }\n\n // Build event object\n let event: WalkerOS.DeepPartialEvent;\n\n if (typeof eventOrCommand === 'string') {\n // Convert string to object: elb('page view', { title: 'Home' })\n event = { name: eventOrCommand };\n if (data && typeof data === 'object' && !Array.isArray(data)) {\n event.data = data as WalkerOS.Properties;\n }\n } else if (eventOrCommand && typeof eventOrCommand === 'object') {\n // Use object directly: elb({ name: 'page view', data: {...} })\n event = eventOrCommand as WalkerOS.DeepPartialEvent;\n // Merge additional data if provided\n if (data && typeof data === 'object' && !Array.isArray(data)) {\n event.data = {\n ...(event.data || {}),\n ...(data as WalkerOS.Properties),\n };\n }\n } else {\n // Invalid input\n return { ok: false, successful: [], queued: [], failed: [] };\n }\n\n // Add optional properties if provided\n if (context && typeof context === 'object') {\n event.context = context as WalkerOS.OrderedProperties;\n }\n if (nested && Array.isArray(nested)) {\n event.nested = nested;\n }\n if (custom && typeof custom === 'object') {\n event.custom = custom as WalkerOS.Properties;\n }\n\n // Call collector.push with event object\n return collector.push(event);\n },\n };\n}\n","import type { Collector, Source, WalkerOS } from '@walkeros/core';\nimport { tryCatchAsync } from '@walkeros/core';\n\n/**\n * Initialize sources using the code/config/env pattern\n *\n * @param collector - The WalkerOS collector instance\n * @param sources - Map of source definitions with code/config/env\n * @returns Initialized sources\n */\nexport async function initSources(\n collector: Collector.Instance,\n sources: Source.InitSources = {},\n): Promise<Collector.Sources> {\n const result: Collector.Sources = {};\n\n for (const [sourceId, sourceDefinition] of Object.entries(sources)) {\n const { code, config = {}, env = {}, primary } = sourceDefinition;\n\n // Create wrapped push that auto-applies source mapping config\n const wrappedPush: Collector.PushFn = (\n event: WalkerOS.DeepPartialEvent,\n context: Collector.PushContext = {},\n ) => {\n // Pass source config as mapping in context\n return collector.push(event, {\n ...context,\n mapping: config,\n });\n };\n\n // Create initial logger scoped to sourceId (type will be added after init)\n const initialLogger = collector.logger.scope('source').scope(sourceId);\n\n const cleanEnv: Source.Env = {\n push: wrappedPush,\n command: collector.command,\n sources: collector.sources, // Provide access to all sources for chaining\n elb: collector.sources.elb.push, // ELB source is always available\n logger: initialLogger,\n ...env,\n };\n\n // Call source function with config and environment separately\n const sourceInstance = await tryCatchAsync(code)(config, cleanEnv);\n\n if (!sourceInstance) continue; // Skip failed source initialization\n\n // Update logger with actual source type: [type:sourceId] or [unknown:sourceId]\n const sourceType = sourceInstance.type || 'unknown';\n const sourceLogger = collector.logger.scope(sourceType).scope(sourceId);\n cleanEnv.logger = sourceLogger;\n\n // Store the primary flag in the source config for later access\n if (primary) {\n sourceInstance.config = { ...sourceInstance.config, primary };\n }\n\n result[sourceId] = sourceInstance;\n }\n\n return result;\n}\n","import type { Collector, Elb } from '@walkeros/core';\nimport type { StartFlow } from './types';\nimport { collector } from './collector';\nimport { createElbSource } from './elb';\nimport { initSources } from './source';\n\nexport async function startFlow<ElbPush extends Elb.Fn = Elb.Fn>(\n initConfig?: Collector.InitConfig,\n): Promise<StartFlow<ElbPush>> {\n initConfig = initConfig || {};\n const instance = await collector(initConfig);\n\n // Create and register ELB source first\n const elbSource = createElbSource(instance);\n instance.sources.elb = elbSource;\n\n // Now initialize other sources with ELB source available\n const additionalSources = await initSources(\n instance,\n initConfig.sources || {},\n );\n Object.assign(instance.sources, additionalSources);\n\n const { consent, user, globals, custom } = initConfig;\n\n if (consent) await instance.command('consent', consent);\n if (user) await instance.command('user', user);\n if (globals) Object.assign(instance.globals, globals);\n if (custom) Object.assign(instance.custom, custom);\n\n if (instance.config.run) await instance.command('run');\n\n // Determine the primary elb:\n // 1. Use explicitly marked primary source\n // 2. Use first non-elb source if any exist\n // 3. Fallback to ELB source\n let primaryElb: Elb.Fn = elbSource.push as Elb.Fn;\n\n const sources = Object.values(instance.sources).filter(\n (source) => source.type !== 'elb',\n );\n\n // First, check for explicitly marked primary source\n const markedPrimary = sources.find(\n (source) => (source.config as { primary?: boolean }).primary,\n );\n\n if (markedPrimary) {\n primaryElb = markedPrimary.push as Elb.Fn;\n } else if (sources.length > 0) {\n // Use first source as default\n primaryElb = sources[0].push as Elb.Fn;\n }\n\n return {\n collector: instance,\n elb: primaryElb as ElbPush,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;;;ACGO,IAAM,WAAwD;AAAA,EACnE,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,KAAK;AAAA,EACL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AC9B;AAGA,QAAM,gBAAgB,QAAQ;AAAA,IAC5B,CAAC,WAAY,OAAO,OAAiC;AAAA,EACvD;AAEA,MAAI,eAAe;AACjB,iBAAa,cAAc;AAAA,EAC7B,WAAW,QAAQ,SAAS,GAAG;AAE7B,iBAAa,QAAQ,CAAC,EAAE;AAAA,EAC1B;AAEA,SAAO;AAAA,IACL,WAAW;AAAA,IACX,KAAK;AAAA,EACP;AACF;","names":["import_core","collector","event","batchState","import_core","import_core","collector","on","option","collector","import_core","import_core","collector","import_core","collector","import_core","collector","collector","collector","import_core","collector"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={},n={Action:"action",Actions:"actions",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"},o={Commands:n,Utils:{Storage:{Cookie:"cookie",Local:"local",Session:"session"}}};import{assign as t}from"@walkeros/core";import{assign as s,clone as a,debounce as c,getId as i,getGrantedConsent as r,isDefined as u,isObject as l,processEventMapping as g,tryCatchAsync as d,useHooks as f}from"@walkeros/core";var m={type:"code",config:{},init(e){const{config:n,logger:o}=e,t=n.settings,s=t?.scripts;if(s&&"undefined"!=typeof document)for(const e of s){const n=document.createElement("script");n.src=e,n.async=!0,document.head.appendChild(n)}const a=t?.init;if(a)try{new Function("context",a)(e)}catch(e){o.error("Code destination init error:",e)}},push(e,n){const{mapping:o,config:t,logger:s}=n,a=o?.push??t.settings?.push;if(a)try{new Function("event","context",a)(e,n)}catch(e){s.error("Code destination push error:",e)}},pushBatch(e,n){const{mapping:o,config:t,logger:s}=n,a=o?.pushBatch??t.settings?.pushBatch;if(a)try{new Function("batch","context",a)(e,n)}catch(e){s.error("Code destination pushBatch error:",e)}},on(e,n){const{config:o,logger:t}=n,s=o.settings?.on;if(s)try{new Function("type","context",s)(e,n)}catch(e){t.error("Code destination on error:",e)}}};function p(e){return!0===e?m:e}async function h(e,n,o){const{code:t,config:s={},env:a={}}=n,c=o||s||{init:!1},r=p(t),u={...r,config:c,env:C(r.env,a)};let l=u.config.id;if(!l)do{l=i(4)}while(e.destinations[l]);return e.destinations[l]=u,!1!==u.config.queue&&(u.queue=[...e.queue]),b(e,void 0,{[l]:u})}async function b(e,n,o){const{allowed:t,consent:c,globals:i,user:u}=e;if(!t)return k({ok:!1});n&&e.queue.push(n),o||(o=e.destinations);const l=await Promise.all(Object.entries(o||{}).map(async([o,t])=>{let l=(t.queue||[]).map(e=>({...e,consent:c}));if(t.queue=[],n){const e=a(n);l.push(e)}if(!l.length)return{id:o,destination:t,skipped:!0};const g=[],f=l.filter(e=>{const n=r(t.config.consent,c,e.consent);return!n||(e.consent=n,g.push(e),!1)});if(t.queue.concat(f),!g.length)return{id:o,destination:t,queue:l};if(!await d(y)(e,t))return{id:o,destination:t,queue:l};let m=!1;return t.dlq||(t.dlq=[]),await Promise.all(g.map(async n=>(n.globals=s(i,n.globals),n.user=s(u,n.user),await d(w,o=>{const s=t.type||"unknown";return e.logger.scope(s).error("Push failed",{error:o,event:n.name}),m=!0,t.dlq.push([n,o]),!1})(e,t,n),n))),{id:o,destination:t,error:m}})),g=[],f=[],m=[];for(const e of l){if(e.skipped)continue;const n=e.destination,o={id:e.id,destination:n};e.error?m.push(o):e.queue&&e.queue.length?(n.queue=(n.queue||[]).concat(e.queue),f.push(o)):g.push(o)}return k({ok:!m.length,event:n,successful:g,queued:f,failed:m})}async function y(e,n){if(n.init&&!n.config.init){const o=n.type||"unknown",t=e.logger.scope(o),s={collector:e,config:n.config,env:C(n.env,n.config.env),logger:t};t.debug("init");const a=await f(n.init,"DestinationInit",e.hooks)(s);if(!1===a)return a;n.config={...a||n.config,init:!0},t.debug("init done")}return!0}async function w(e,n,o){const{config:t}=n,s=await g(o,t,e);if(s.ignore)return!1;const a=n.type||"unknown",i=e.logger.scope(a),r={collector:e,config:t,data:s.data,mapping:s.mapping,env:C(n.env,t.env),logger:i},l=s.mapping,d=s.mappingKey||"* *";if(l?.batch&&n.pushBatch){if(n.batches=n.batches||{},!n.batches[d]){const o={key:d,events:[],data:[]};n.batches[d]={batched:o,batchFn:c(()=>{const o=n.batches[d].batched,s={collector:e,config:t,data:void 0,mapping:l,env:C(n.env,t.env),logger:i};i.debug("push batch",{events:o.events.length}),f(n.pushBatch,"DestinationPushBatch",e.hooks)(o,s),i.debug("push batch done"),o.events=[],o.data=[]},l.batch)}}const o=n.batches[d];o.batched.events.push(s.event),u(s.data)&&o.batched.data.push(s.data),o.batchFn()}else i.debug("push",{event:s.event.name}),await f(n.push,"DestinationPush",e.hooks)(s.event,r),i.debug("push done");return!0}function k(e){return s({ok:!e?.failed?.length,successful:[],queued:[],failed:[]},e)}async function v(e,n={}){const o={};for(const[e,t]of Object.entries(n)){const{code:n,config:s={},env:a={}}=t,c=p(n),i={...c.config,...s},r=C(c.env,a);o[e]={...c,config:i,env:r}}return o}function C(e,n){return e||n?n?e&&l(e)&&l(n)?{...e,...n}:n:e:{}}import{isArray as q}from"@walkeros/core";import{tryCatch as j}from"@walkeros/core";function E(e,n,o){const t=e.on,s=t[n]||[],a=q(o)?o:[o];a.forEach(e=>{s.push(e)}),t[n]=s,O(e,n,a)}function O(e,n,t,s){let a,c=t||[];switch(t||(c=e.on[n]||[]),n){case o.Commands.Consent:a=s||e.consent;break;case o.Commands.Session:a=e.session;break;case o.Commands.Ready:case o.Commands.Run:default:a=void 0}if(Object.values(e.sources).forEach(e=>{e.on&&j(e.on)(n,a)}),Object.values(e.destinations).forEach(o=>{if(o.on){const t=o.type||"unknown",s=e.logger.scope(t).scope("on").scope(n),c={collector:e,config:o.config,data:a,env:C(o.env,o.config.env),logger:s};j(o.on)(n,c)}}),c.length)switch(n){case o.Commands.Consent:!function(e,n,o){const t=o||e.consent;n.forEach(n=>{Object.keys(t).filter(e=>e in n).forEach(o=>{j(n[o])(e,t)})})}(e,c,s);break;case o.Commands.Ready:case o.Commands.Run:!function(e,n){e.allowed&&n.forEach(n=>{j(n)(e)})}(e,c);break;case o.Commands.Session:!function(e,n){if(!e.session)return;n.forEach(n=>{j(n)(e,e.session)})}(e,c)}}async function x(e,n){const{consent:o}=e;let s=!1;const a={};return Object.entries(n).forEach(([e,n])=>{const o=!!n;a[e]=o,s=s||o}),e.consent=t(o,a),O(e,"consent",void 0,a),s?b(e):k({ok:!0})}import{assign as A,createLogger as S}from"@walkeros/core";import{assign as D,getId as R,isFunction as B,isString as P}from"@walkeros/core";import{isObject as F}from"@walkeros/core";async function $(e,n,t,s){let a;switch(n){case o.Commands.Config:F(t)&&D(e.config,t,{shallow:!1});break;case o.Commands.Consent:F(t)&&(a=await x(e,t));break;case o.Commands.Custom:F(t)&&(e.custom=D(e.custom,t));break;case o.Commands.Destination:F(t)&&B(t.push)&&(a=await h(e,{code:t},s));break;case o.Commands.Globals:F(t)&&(e.globals=D(e.globals,t));break;case o.Commands.On:P(t)&&E(e,t,s);break;case o.Commands.Ready:O(e,"ready");break;case o.Commands.Run:a=await H(e,t);break;case o.Commands.Session:O(e,"session");break;case o.Commands.User:F(t)&&D(e.user,t,{shallow:!1})}return a||{ok:!0,successful:[],queued:[],failed:[]}}function G(e,n){if(!n.name)throw new Error("Event name is required");const[o,t]=n.name.split(" ");if(!o||!t)throw new Error("Event name is invalid");++e.count;const{timestamp:s=Date.now(),group:a=e.group,count:c=e.count}=n,{name:i=`${o} ${t}`,data:r={},context:u={},globals:l=e.globals,custom:g={},user:d=e.user,nested:f=[],consent:m=e.consent,id:p=`${s}-${a}-${c}`,trigger:h="",entity:b=o,action:y=t,timing:w=0,version:k={source:e.version,tagging:e.config.tagging||0},source:v={type:"collector",id:"",previous_id:""}}=n;return{name:i,data:r,context:u,globals:l,custom:g,user:d,nested:f,consent:m,id:p,trigger:h,entity:b,action:y,timestamp:s,timing:w,group:a,count:c,version:k,source:v}}async function H(e,n){e.allowed=!0,e.count=0,e.group=R(),e.timing=Date.now(),n&&(n.consent&&(e.consent=D(e.consent,n.consent)),n.user&&(e.user=D(e.user,n.user)),n.globals&&(e.globals=D(e.config.globalsStatic||{},n.globals)),n.custom&&(e.custom=D(e.custom,n.custom))),Object.values(e.destinations).forEach(e=>{e.queue=[]}),e.queue=[],e.round++;const o=await b(e);return O(e,"run"),o}import{getGrantedConsent as I,processEventMapping as U,tryCatchAsync as L,useHooks as M}from"@walkeros/core";function W(e,n){return M(async(o,t={})=>await L(async()=>{let s=o;if(t.mapping){const n=await U(s,t.mapping,e);if(n.ignore)return k({ok:!0});if(t.mapping.consent){if(!I(t.mapping.consent,e.consent,n.event.consent))return k({ok:!0})}s=n.event}const a=n(s),c=G(e,a);return await b(e,c)},()=>k({ok:!1}))(),"Push",e.hooks)}import{useHooks as _,tryCatchAsync as K}from"@walkeros/core";async function z(e){const n=A({globalsStatic:{},sessionStatic:{},tagging:0,run:!0},e,{merge:!1,extend:!1}),o={level:e.logger?.level,handler:e.logger?.handler},t=S(o),s={...n.globalsStatic,...e.globals},a={allowed:!1,config:n,consent:e.consent||{},count:0,custom:e.custom||{},destinations:{},globals:s,group:"",hooks:{},logger:t,on:{},queue:[],round:0,session:void 0,timing:Date.now(),user:e.user||{},version:"0.5.1-next.0",sources:{},push:void 0,command:void 0};return a.push=W(a,e=>({timing:Math.round((Date.now()-a.timing)/10)/100,source:{type:"collector",id:"",previous_id:""},...e})),a.command=function(e,n){return _(async(o,t,s)=>await K(async()=>await n(e,o,t,s),()=>k({ok:!1}))(),"Command",e.hooks)}(a,$),a.destinations=await v(0,e.destinations||{}),a}import{tryCatchAsync as J}from"@walkeros/core";async function N(e,n={}){const o={};for(const[t,s]of Object.entries(n)){const{code:n,config:a={},env:c={},primary:i}=s,r=(n,o={})=>e.push(n,{...o,mapping:a}),u=e.logger.scope("source").scope(t),l={push:r,command:e.command,sources:e.sources,elb:e.sources.elb.push,logger:u,...c},g=await J(n)(a,l);if(!g)continue;const d=g.type||"unknown",f=e.logger.scope(d).scope(t);l.logger=f,i&&(g.config={...g.config,primary:i}),o[t]=g}return o}async function Q(e){e=e||{};const n=await z(e),o=(t=n,{type:"elb",config:{},push:async(e,n,o,s,a,c)=>{if("string"==typeof e&&e.startsWith("walker ")){const s=e.replace("walker ","");return t.command(s,n,o)}let i;if("string"==typeof e)i={name:e},n&&"object"==typeof n&&!Array.isArray(n)&&(i.data=n);else{if(!e||"object"!=typeof e)return{ok:!1,successful:[],queued:[],failed:[]};i=e,n&&"object"==typeof n&&!Array.isArray(n)&&(i.data={...i.data||{},...n})}return s&&"object"==typeof s&&(i.context=s),a&&Array.isArray(a)&&(i.nested=a),c&&"object"==typeof c&&(i.custom=c),t.push(i)}});var t;n.sources.elb=o;const s=await N(n,e.sources||{});Object.assign(n.sources,s);const{consent:a,user:c,globals:i,custom:r}=e;a&&await n.command("consent",a),c&&await n.command("user",c),i&&Object.assign(n.globals,i),r&&Object.assign(n.custom,r),n.config.run&&await n.command("run");let u=o.push;const l=Object.values(n.sources).filter(e=>"elb"!==e.type),g=l.find(e=>e.config.primary);return g?u=g.push:l.length>0&&(u=l[0].push),{collector:n,elb:u}}export{e as Code,n as Commands,o as Const,h as addDestination,$ as commonHandleCommand,G as createEvent,W as createPush,k as createPushResult,m as destinationCode,y as destinationInit,w as destinationPush,v as initDestinations,N as initSources,C as mergeEnvironments,E as on,O as onApply,b as pushToDestinations,H as runCollector,x as setConsent,Q as startFlow};//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types/code.ts","../src/constants.ts","../src/consent.ts","../src/destination.ts","../src/destination-code.ts","../src/on.ts","../src/collector.ts","../src/handle.ts","../src/push.ts","../src/command.ts","../src/elb.ts","../src/source.ts","../src/flow.ts"],"sourcesContent":["import type { Destination, Mapping, On, WalkerOS } from '@walkeros/core';\n\nexport interface Settings {\n scripts?: string[];\n init?: string;\n on?: string;\n push?: string;\n pushBatch?: string;\n}\n\nexport interface CodeMapping extends Mapping.Rule<CodeMapping> {\n push?: string;\n pushBatch?: string;\n}\n\nexport type Types = Destination.Types<Settings, CodeMapping>;\nexport type Config = Destination.Config<Types>;\nexport type Context = Destination.Context<Types>;\nexport type InitContext = Destination.InitContext<Types>;\nexport type PushContext = Destination.PushContext<Types>;\nexport type PushBatchContext = Destination.PushBatchContext<Types>;\n\nexport type InitFn = (context: InitContext) => void;\nexport type OnFn = (type: On.Types, context: Context) => void;\nexport type PushFn = (event: WalkerOS.Event, context: PushContext) => void;\nexport type PushBatchFn = (\n batch: Destination.Batch<CodeMapping>,\n context: PushBatchContext,\n) => void;\n","import type { Collector } from '@walkeros/core';\nimport type { CommandTypes, StorageType } from './types/collector';\n\nexport const Commands: Record<CommandTypes, Collector.CommandType> = {\n Action: 'action',\n Actions: 'actions',\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\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 debounce,\n getId,\n getGrantedConsent,\n isDefined,\n isObject,\n processEventMapping,\n tryCatchAsync,\n useHooks,\n} from '@walkeros/core';\nimport { destinationCode } from './destination-code';\n\nfunction resolveCode(code: Destination.Instance | true): Destination.Instance {\n return code === true ? destinationCode : code;\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 const { code, config: dataConfig = {}, env = {} } = data;\n const config = options || dataConfig || { init: false };\n\n const resolved = resolveCode(code);\n const destination: Destination.Instance = {\n ...resolved,\n config,\n env: mergeEnvironments(resolved.env, env),\n };\n\n let id = destination.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 (destination.config.queue !== false)\n 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 const currentEvent = clone(event);\n\n // Note: Policy is now applied in processEventMapping() within destinationPush()\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 // Log the error with destination scope\n const destType = destination.type || 'unknown';\n collector.logger.scope(destType).error('Push failed', {\n error: err,\n event: event.name,\n });\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 // Create scoped logger for this destination: [type:id] or [unknown:id]\n const destType = destination.type || 'unknown';\n const destLogger = collector.logger.scope(destType);\n\n const context = {\n collector,\n config: destination.config,\n env: mergeEnvironments(destination.env, destination.config.env),\n logger: destLogger,\n } as Destination.InitContext;\n\n destLogger.debug('init');\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 destLogger.debug('init done');\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\n const processed = await processEventMapping(event, config, collector);\n\n if (processed.ignore) return false;\n\n // Create scoped logger for this destination: [type] or [unknown]\n const destType = destination.type || 'unknown';\n const destLogger = collector.logger.scope(destType);\n\n const context: Destination.PushContext = {\n collector,\n config,\n data: processed.data,\n mapping: processed.mapping,\n env: mergeEnvironments(destination.env, config.env),\n logger: destLogger,\n };\n\n const eventMapping = processed.mapping;\n const mappingKey = processed.mappingKey || '* *';\n\n if (eventMapping?.batch && destination.pushBatch) {\n // Initialize batch registry on destination (not on shared mapping config)\n destination.batches = destination.batches || {};\n\n // Get or create batch state for this mapping key\n if (!destination.batches[mappingKey]) {\n const batched: Destination.Batch<unknown> = {\n key: mappingKey,\n events: [],\n data: [],\n };\n\n destination.batches[mappingKey] = {\n batched,\n batchFn: debounce(() => {\n const batchState = destination.batches![mappingKey];\n const currentBatched = batchState.batched;\n\n const batchContext: Destination.PushBatchContext = {\n collector,\n config,\n // Note: batch.data contains all transformed data; context.data is for single events\n data: undefined,\n mapping: eventMapping,\n env: mergeEnvironments(destination.env, config.env),\n logger: destLogger,\n };\n\n destLogger.debug('push batch', {\n events: currentBatched.events.length,\n });\n\n useHooks(\n destination.pushBatch!,\n 'DestinationPushBatch',\n collector.hooks,\n )(currentBatched, batchContext);\n\n destLogger.debug('push batch done');\n\n // Reset batch\n currentBatched.events = [];\n currentBatched.data = [];\n }, eventMapping.batch),\n };\n }\n\n // Add event to batch\n const batchState = destination.batches[mappingKey];\n batchState.batched.events.push(processed.event);\n if (isDefined(processed.data)) batchState.batched.data.push(processed.data);\n\n // Trigger debounced batch\n batchState.batchFn();\n } else {\n destLogger.debug('push', { event: processed.event.name });\n\n // It's time to go to the destination's side now\n await useHooks(\n destination.push,\n 'DestinationPush',\n collector.hooks,\n )(processed.event, context);\n\n destLogger.debug('push done');\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 using ONLY the unified code/config/env pattern.\n * Does NOT call destination.init() - that happens later during push with proper consent checks.\n *\n * @param destinations - The destinations to initialize.\n * @param collector - The collector instance for destination init context.\n * @returns The initialized destinations.\n */\nexport async function initDestinations(\n _collector: Collector.Instance,\n destinations: Destination.InitDestinations = {},\n): Promise<Collector.Destinations> {\n const result: Collector.Destinations = {};\n\n for (const [name, destinationDef] of Object.entries(destinations)) {\n const { code, config = {}, env = {} } = destinationDef;\n const resolved = resolveCode(code);\n\n const mergedConfig = {\n ...resolved.config,\n ...config,\n };\n\n const mergedEnv = mergeEnvironments(resolved.env, env);\n\n result[name] = {\n ...resolved,\n config: mergedConfig,\n env: mergedEnv,\n };\n }\n\n return result;\n}\n\n/**\n * Merges destination environment with config environment\n * Config env takes precedence over destination env for overrides\n */\nexport function mergeEnvironments(\n destinationEnv?: Destination.Env,\n configEnv?: Destination.Env,\n): Destination.Env {\n // If neither environment exists, return empty object\n if (!destinationEnv && !configEnv) return {};\n\n // If only one exists, return it\n if (!configEnv) return destinationEnv!;\n if (!destinationEnv) return configEnv;\n\n // Both exist - merge objects with configEnv taking precedence\n if (isObject(destinationEnv) && isObject(configEnv)) {\n return { ...destinationEnv, ...configEnv };\n }\n\n // If they're not both objects, config env overrides destination env\n return configEnv;\n}\n","import type { Destination } from '@walkeros/core';\nimport type { CodeMapping, Settings } from './types/code';\n\nexport const destinationCode: Destination.Instance = {\n type: 'code',\n config: {},\n\n init(context) {\n const { config, logger } = context;\n const settings = config.settings as Settings | undefined;\n\n // Inject scripts (fire and forget)\n const scripts = settings?.scripts;\n if (scripts && typeof document !== 'undefined') {\n for (const src of scripts) {\n const script = document.createElement('script');\n script.src = src;\n script.async = true;\n document.head.appendChild(script);\n }\n }\n\n // Execute init code\n const initCode = settings?.init;\n if (!initCode) return;\n try {\n const fn = new Function('context', initCode);\n fn(context);\n } catch (e) {\n logger.error('Code destination init error:', e);\n }\n },\n\n push(event, context) {\n const { mapping, config, logger } = context;\n const pushCode =\n (mapping as CodeMapping | undefined)?.push ??\n (config.settings as Settings | undefined)?.push;\n if (!pushCode) return;\n try {\n const fn = new Function('event', 'context', pushCode);\n fn(event, context);\n } catch (e) {\n logger.error('Code destination push error:', e);\n }\n },\n\n pushBatch(batch, context) {\n const { mapping, config, logger } = context;\n const pushBatchCode =\n (mapping as CodeMapping | undefined)?.pushBatch ??\n (config.settings as Settings | undefined)?.pushBatch;\n if (!pushBatchCode) return;\n try {\n const fn = new Function('batch', 'context', pushBatchCode);\n fn(batch, context);\n } catch (e) {\n logger.error('Code destination pushBatch error:', e);\n }\n },\n\n on(type, context) {\n const { config, logger } = context;\n const onCode = (config.settings as Settings | undefined)?.on;\n if (!onCode) return;\n try {\n const fn = new Function('type', 'context', onCode);\n fn(type, context);\n } catch (e) {\n logger.error('Code destination on error:', e);\n }\n },\n};\n\nexport default destinationCode;\n","import type { Collector, On, WalkerOS, Destination } from '@walkeros/core';\nimport { isArray } from '@walkeros/core';\nimport { Const } from './constants';\nimport { tryCatch } from '@walkeros/core';\nimport { mergeEnvironments } from './destination';\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\n // Calculate context data once for all sources and destinations\n let contextData: unknown;\n\n switch (type) {\n case Const.Commands.Consent:\n contextData = config || collector.consent;\n break;\n case Const.Commands.Session:\n contextData = collector.session;\n break;\n case Const.Commands.Ready:\n case Const.Commands.Run:\n default:\n contextData = undefined;\n break;\n }\n\n Object.values(collector.sources).forEach((source) => {\n if (source.on) {\n tryCatch(source.on)(type, contextData);\n }\n });\n\n Object.values(collector.destinations).forEach((destination) => {\n if (destination.on) {\n const destType = destination.type || 'unknown';\n const destLogger = collector.logger\n .scope(destType)\n .scope('on')\n .scope(type);\n\n const context: Destination.Context = {\n collector,\n config: destination.config,\n data: contextData as Destination.Data,\n env: mergeEnvironments(destination.env, destination.config.env),\n logger: destLogger,\n };\n\n tryCatch(destination.on)(type, context);\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, Logger, WalkerOS } from '@walkeros/core';\nimport { assign, createLogger } from '@walkeros/core';\nimport { commonHandleCommand } from './handle';\nimport { initDestinations } from './destination';\nimport { createPush } from './push';\nimport { createCommand } from './command';\nimport { initSources } from './source';\n\ndeclare const __VERSION__: string;\n\nexport async function collector(\n initConfig: Collector.InitConfig,\n): Promise<Collector.Instance> {\n const version = __VERSION__;\n\n const defaultConfig: Collector.Config = {\n globalsStatic: {},\n sessionStatic: {},\n tagging: 0,\n run: true,\n };\n\n const config: Collector.Config = assign(defaultConfig, initConfig, {\n merge: false,\n extend: false,\n });\n\n // Create logger with config from initConfig\n const loggerConfig: Logger.Config = {\n level: initConfig.logger?.level,\n handler: initConfig.logger?.handler,\n };\n const logger = createLogger(loggerConfig);\n\n // Enhanced globals with static globals from config\n const finalGlobals = { ...config.globalsStatic, ...initConfig.globals };\n\n const collector: Collector.Instance = {\n allowed: false,\n config,\n consent: initConfig.consent || {},\n count: 0,\n custom: initConfig.custom || {},\n destinations: {},\n globals: finalGlobals,\n group: '',\n hooks: {},\n logger,\n on: {},\n queue: [],\n round: 0,\n session: undefined,\n timing: Date.now(),\n user: initConfig.user || {},\n version,\n sources: {},\n push: undefined as unknown as Collector.PushFn, // Placeholder, will be set below\n command: undefined as unknown as Collector.CommandFn, // Placeholder, will be set below\n };\n\n // Set the push and command functions with the collector reference\n collector.push = createPush(\n collector,\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 collector.command = createCommand(collector, commonHandleCommand);\n\n // Initialize destinations after collector is fully created\n // Sources are initialized in startFlow after ELB source is created\n collector.destinations = await initDestinations(\n collector,\n initConfig.destinations || {},\n );\n\n return collector;\n}\n","import type { Collector, WalkerOS, Destination, Elb, On } from '@walkeros/core';\nimport { Const } from './constants';\nimport { addDestination, pushToDestinations } from './destination';\nimport { assign, getId, isFunction, isString } from '@walkeros/core';\nimport { isObject } 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 { code: data as unknown as Destination.Instance },\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.Ready:\n onApply(collector, 'ready');\n break;\n\n case Const.Commands.Run:\n result = await runCollector(collector, data as RunState);\n break;\n\n case Const.Commands.Session:\n onApply(collector, 'session');\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 a full event from a partial event.\n *\n * @param collector The walkerOS collector instance.\n * @param partialEvent The partial event to transform.\n * @returns The full event.\n */\nexport function createEvent(\n collector: Collector.Instance,\n partialEvent: WalkerOS.PartialEvent,\n): WalkerOS.Event {\n if (!partialEvent.name) throw new Error('Event name is required');\n\n const [entityValue, actionValue] = partialEvent.name.split(' ');\n if (!entityValue || !actionValue) throw new Error('Event name is invalid');\n\n ++collector.count;\n\n const {\n timestamp = Date.now(),\n group = collector.group,\n count = collector.count,\n } = partialEvent;\n\n const {\n name = `${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 return {\n name,\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\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 // Reset collector queue for this run\n collector.queue = [];\n\n // Increase round counter\n collector.round++;\n\n // Process any queued events now that the collector is allowed\n const result = await pushToDestinations(collector);\n\n // Call the predefined run events\n onApply(collector, 'run');\n\n return result;\n}\n","import type { Collector, WalkerOS, Elb } from '@walkeros/core';\nimport {\n getGrantedConsent,\n processEventMapping,\n tryCatchAsync,\n useHooks,\n} from '@walkeros/core';\nimport { createEvent } from './handle';\nimport { pushToDestinations, createPushResult } from './destination';\n\n/**\n * Creates the push function for the collector.\n * Handles source mapping, event creation, and routing to destinations.\n *\n * @param collector - The walkerOS collector instance\n * @param prepareEvent - Function to enrich partial events\n * @returns The push function\n */\nexport function createPush<T extends Collector.Instance>(\n collector: T,\n prepareEvent: (event: WalkerOS.DeepPartialEvent) => WalkerOS.PartialEvent,\n): Collector.PushFn {\n return useHooks(\n async (\n event: WalkerOS.DeepPartialEvent,\n context: Collector.PushContext = {},\n ): Promise<Elb.PushResult> => {\n return await tryCatchAsync(\n async (): Promise<Elb.PushResult> => {\n let partialEvent = event;\n\n // Apply source mapping if provided in context\n if (context.mapping) {\n const processed = await processEventMapping(\n partialEvent,\n context.mapping,\n collector,\n );\n\n // Check ignore flag\n if (processed.ignore) {\n return createPushResult({ ok: true });\n }\n\n // Check consent requirements\n if (context.mapping.consent) {\n const grantedConsent = getGrantedConsent(\n context.mapping.consent,\n collector.consent,\n processed.event.consent as WalkerOS.Consent | undefined,\n );\n\n if (!grantedConsent) {\n return createPushResult({ ok: true });\n }\n }\n\n partialEvent = processed.event;\n }\n\n // Prepare event (add timing, source info)\n const enrichedEvent = prepareEvent(partialEvent);\n\n // Create full event\n const fullEvent = createEvent(collector, enrichedEvent);\n\n // Push to destinations\n return await pushToDestinations(collector, fullEvent);\n },\n () => {\n return createPushResult({ ok: false });\n },\n )();\n },\n 'Push',\n collector.hooks,\n ) as Collector.PushFn;\n}\n","import type { Collector, Elb } from '@walkeros/core';\nimport type { HandleCommandFn } from './types/collector';\nimport { useHooks, tryCatchAsync } from '@walkeros/core';\nimport { createPushResult } from './destination';\n\n/**\n * Creates the command function for the collector.\n * Handles walker commands (config, consent, destination, etc.)\n *\n * @param collector - The walkerOS collector instance\n * @param handleCommand - Command handler function\n * @returns The command function\n */\nexport function createCommand<T extends Collector.Instance>(\n collector: T,\n handleCommand: HandleCommandFn<T>,\n): Collector.CommandFn {\n return useHooks(\n async (\n command: string,\n data?: unknown,\n options?: unknown,\n ): Promise<Elb.PushResult> => {\n return await tryCatchAsync(\n async (): Promise<Elb.PushResult> => {\n return await handleCommand(collector, command, data, options);\n },\n () => {\n return createPushResult({ ok: false });\n },\n )();\n },\n 'Command',\n collector.hooks,\n ) as Collector.CommandFn;\n}\n","import type { Collector, Source, WalkerOS, Elb } from '@walkeros/core';\n\n/**\n * Creates the default ELB source.\n * Routes between collector.push and collector.command based on input.\n * Provides backward-compatible flexible argument interface.\n *\n * @param collector - The walkerOS collector instance\n * @returns ELB source instance\n */\nexport function createElbSource(\n collector: Collector.Instance,\n): Source.Instance {\n return {\n type: 'elb',\n config: {},\n\n // The push function is the elb() interface users interact with\n push: async (\n eventOrCommand?: unknown,\n data?: unknown,\n options?: unknown,\n context?: unknown,\n nested?: WalkerOS.Entities,\n custom?: WalkerOS.Properties,\n ): Promise<Elb.PushResult> => {\n // Detect walker commands\n if (\n typeof eventOrCommand === 'string' &&\n eventOrCommand.startsWith('walker ')\n ) {\n const command = eventOrCommand.replace('walker ', '');\n return collector.command(command, data, options);\n }\n\n // Build event object\n let event: WalkerOS.DeepPartialEvent;\n\n if (typeof eventOrCommand === 'string') {\n // Convert string to object: elb('page view', { title: 'Home' })\n event = { name: eventOrCommand };\n if (data && typeof data === 'object' && !Array.isArray(data)) {\n event.data = data as WalkerOS.Properties;\n }\n } else if (eventOrCommand && typeof eventOrCommand === 'object') {\n // Use object directly: elb({ name: 'page view', data: {...} })\n event = eventOrCommand as WalkerOS.DeepPartialEvent;\n // Merge additional data if provided\n if (data && typeof data === 'object' && !Array.isArray(data)) {\n event.data = {\n ...(event.data || {}),\n ...(data as WalkerOS.Properties),\n };\n }\n } else {\n // Invalid input\n return { ok: false, successful: [], queued: [], failed: [] };\n }\n\n // Add optional properties if provided\n if (context && typeof context === 'object') {\n event.context = context as WalkerOS.OrderedProperties;\n }\n if (nested && Array.isArray(nested)) {\n event.nested = nested;\n }\n if (custom && typeof custom === 'object') {\n event.custom = custom as WalkerOS.Properties;\n }\n\n // Call collector.push with event object\n return collector.push(event);\n },\n };\n}\n","import type { Collector, Source, WalkerOS } from '@walkeros/core';\nimport { tryCatchAsync } from '@walkeros/core';\n\n/**\n * Initialize sources using the code/config/env pattern\n *\n * @param collector - The WalkerOS collector instance\n * @param sources - Map of source definitions with code/config/env\n * @returns Initialized sources\n */\nexport async function initSources(\n collector: Collector.Instance,\n sources: Source.InitSources = {},\n): Promise<Collector.Sources> {\n const result: Collector.Sources = {};\n\n for (const [sourceId, sourceDefinition] of Object.entries(sources)) {\n const { code, config = {}, env = {}, primary } = sourceDefinition;\n\n // Create wrapped push that auto-applies source mapping config\n const wrappedPush: Collector.PushFn = (\n event: WalkerOS.DeepPartialEvent,\n context: Collector.PushContext = {},\n ) => {\n // Pass source config as mapping in context\n return collector.push(event, {\n ...context,\n mapping: config,\n });\n };\n\n // Create initial logger scoped to sourceId (type will be added after init)\n const initialLogger = collector.logger.scope('source').scope(sourceId);\n\n const cleanEnv: Source.Env = {\n push: wrappedPush,\n command: collector.command,\n sources: collector.sources, // Provide access to all sources for chaining\n elb: collector.sources.elb.push, // ELB source is always available\n logger: initialLogger,\n ...env,\n };\n\n // Call source function with config and environment separately\n const sourceInstance = await tryCatchAsync(code)(config, cleanEnv);\n\n if (!sourceInstance) continue; // Skip failed source initialization\n\n // Update logger with actual source type: [type:sourceId] or [unknown:sourceId]\n const sourceType = sourceInstance.type || 'unknown';\n const sourceLogger = collector.logger.scope(sourceType).scope(sourceId);\n cleanEnv.logger = sourceLogger;\n\n // Store the primary flag in the source config for later access\n if (primary) {\n sourceInstance.config = { ...sourceInstance.config, primary };\n }\n\n result[sourceId] = sourceInstance;\n }\n\n return result;\n}\n","import type { Collector, Elb } from '@walkeros/core';\nimport type { StartFlow } from './types';\nimport { collector } from './collector';\nimport { createElbSource } from './elb';\nimport { initSources } from './source';\n\nexport async function startFlow<ElbPush extends Elb.Fn = Elb.Fn>(\n initConfig?: Collector.InitConfig,\n): Promise<StartFlow<ElbPush>> {\n initConfig = initConfig || {};\n const instance = await collector(initConfig);\n\n // Create and register ELB source first\n const elbSource = createElbSource(instance);\n instance.sources.elb = elbSource;\n\n // Now initialize other sources with ELB source available\n const additionalSources = await initSources(\n instance,\n initConfig.sources || {},\n );\n Object.assign(instance.sources, additionalSources);\n\n const { consent, user, globals, custom } = initConfig;\n\n if (consent) await instance.command('consent', consent);\n if (user) await instance.command('user', user);\n if (globals) Object.assign(instance.globals, globals);\n if (custom) Object.assign(instance.custom, custom);\n\n if (instance.config.run) await instance.command('run');\n\n // Determine the primary elb:\n // 1. Use explicitly marked primary source\n // 2. Use first non-elb source if any exist\n // 3. Fallback to ELB source\n let primaryElb: Elb.Fn = elbSource.push as Elb.Fn;\n\n const sources = Object.values(instance.sources).filter(\n (source) => source.type !== 'elb',\n );\n\n // First, check for explicitly marked primary source\n const markedPrimary = sources.find(\n (source) => (source.config as { primary?: boolean }).primary,\n );\n\n if (markedPrimary) {\n primaryElb = markedPrimary.push as Elb.Fn;\n } else if (sources.length > 0) {\n // Use first source as default\n primaryEl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MAAM;AAAA,IAC9B;AAAA,IACA,WAAW,WAAW,CAAC;AAAA,EACzB;AACA,SAAO,OAAO,SAAS,SAAS,iBAAiB;AAEjD,QAAM,EAAE,SAAS,MAAM,SAAS,OAAO,IAAI;AAE3C,MAAI,QAAS,OAAM,SAAS,QAAQ,WAAW,OAAO;AACtD,MAAI,KAAM,OAAM,SAAS,QAAQ,QAAQ,IAAI;AAC7C,MAAI,QAAS,QAAO,OAAO,SAAS,SAAS,OAAO;AACpD,MAAI,OAAQ,QAAO,OAAO,SAAS,QAAQ,MAAM;AAEjD,MAAI,SAAS,OAAO,IAAK,OAAM,SAAS,QAAQ,KAAK;AAMrD,MAAI,aAAqB,UAAU;AAEnC,QAAM,UAAU,OAAO,OAAO,SAAS,OAAO,EAAE;AAAA,IAC9C,CAAC,WAAW,OAAO,SAAS;AAAA,EAC9B;AAGA,QAAM,gBAAgB,QAAQ;AAAA,IAC5B,CAAC,WAAY,OAAO,OAAiC;AAAA,EACvD;AAEA,MAAI,eAAe;AACjB,iBAAa,cAAc;AAAA,EAC7B,WAAW,QAAQ,SAAS,GAAG;AAE7B,iBAAa,QAAQ,CAAC,EAAE;AAAA,EAC1B;AAEA,SAAO;AAAA,IACL,WAAW;AAAA,IACX,KAAK;AAAA,EACP;AACF;","names":["assign","collector","event","batchState","collector","on","option","collector","assign","assign","assign","getId","isObject","collector","isObject","assign","getId","getGrantedConsent","processEventMapping","tryCatchAsync","useHooks","collector","useHooks","tryCatchAsync","processEventMapping","getGrantedConsent","useHooks","tryCatchAsync","collector","useHooks","tryCatchAsync","assign","collector","collector","tryCatchAsync","collector"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@walkeros/collector",
|
|
3
|
+
"description": "Unified platform-agnostic collector for walkerOS",
|
|
4
|
+
"version": "0.0.0-next-20251219153324",
|
|
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
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.mjs",
|
|
16
|
+
"require": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./dev": {
|
|
19
|
+
"types": "./dist/dev.d.ts",
|
|
20
|
+
"import": "./dist/dev.mjs",
|
|
21
|
+
"require": "./dist/dev.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup --silent",
|
|
26
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
27
|
+
"dev": "jest --watchAll --colors",
|
|
28
|
+
"lint": "tsc && eslint \"**/*.ts*\"",
|
|
29
|
+
"test": "jest",
|
|
30
|
+
"update": "npx npm-check-updates -u && npm update"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@walkeros/core": "0.0.0-next-20251219153324"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {},
|
|
36
|
+
"repository": {
|
|
37
|
+
"url": "git+https://github.com/elbwalker/walkerOS.git",
|
|
38
|
+
"directory": "packages/collector"
|
|
39
|
+
},
|
|
40
|
+
"author": "elbwalker <hello@elbwalker.com>",
|
|
41
|
+
"homepage": "https://github.com/elbwalker/walkerOS#readme",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/elbwalker/walkerOS/issues"
|
|
44
|
+
},
|
|
45
|
+
"keywords": [
|
|
46
|
+
"walker",
|
|
47
|
+
"walkerOS",
|
|
48
|
+
"analytics",
|
|
49
|
+
"tracking",
|
|
50
|
+
"data collection",
|
|
51
|
+
"measurement",
|
|
52
|
+
"data privacy",
|
|
53
|
+
"privacy friendly",
|
|
54
|
+
"collector",
|
|
55
|
+
"event processing"
|
|
56
|
+
],
|
|
57
|
+
"funding": [
|
|
58
|
+
{
|
|
59
|
+
"type": "GitHub Sponsors",
|
|
60
|
+
"url": "https://github.com/sponsors/elbwalker"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|