@walkeros/server-destination-datamanager 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,153 @@
1
+ import { Mapping as Mapping$1, Destination as Destination$1 } from '@walkeros/core';
2
+ import { DestinationServer } from '@walkeros/server-core';
3
+
4
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
5
+
6
+ interface Settings {
7
+ /** OAuth 2.0 access token with datamanager scope */
8
+ accessToken: string;
9
+ /** Array of destination accounts and conversion actions/user lists */
10
+ destinations: Destination[];
11
+ /** Default event source if not specified per event */
12
+ eventSource?: EventSource;
13
+ /** Maximum number of events to batch before sending (max 2000) */
14
+ batchSize?: number;
15
+ /** Time in milliseconds to wait before auto-flushing batch */
16
+ batchInterval?: number;
17
+ /** If true, validate request without ingestion (testing mode) */
18
+ validateOnly?: boolean;
19
+ /** Override API endpoint (for testing) */
20
+ url?: string;
21
+ /** Request-level consent for all events */
22
+ consent?: Consent;
23
+ /** Test event code for debugging (optional) */
24
+ testEventCode?: string;
25
+ /** Log level for debugging (optional) */
26
+ logLevel?: LogLevel;
27
+ /** Guided helpers: User data mapping (applies to all events) */
28
+ userData?: Mapping$1.Map;
29
+ /** Guided helper: First-party user ID */
30
+ userId?: Mapping$1.Value;
31
+ /** Guided helper: GA4 client ID */
32
+ clientId?: Mapping$1.Value;
33
+ /** Guided helper: Privacy-safe attribution (Google's sessionAttributes) */
34
+ sessionAttributes?: Mapping$1.Value;
35
+ /** Consent mapping: Map consent field to adUserData (string = field name, boolean = static value) */
36
+ consentAdUserData?: string | boolean;
37
+ /** Consent mapping: Map consent field to adPersonalization (string = field name, boolean = static value) */
38
+ consentAdPersonalization?: string | boolean;
39
+ }
40
+ interface Mapping {
41
+ gclid?: Mapping$1.Value;
42
+ gbraid?: Mapping$1.Value;
43
+ wbraid?: Mapping$1.Value;
44
+ sessionAttributes?: Mapping$1.Value;
45
+ }
46
+ interface Env extends DestinationServer.Env {
47
+ fetch?: typeof fetch;
48
+ }
49
+ type Types = Destination$1.Types<Settings, Mapping, Env>;
50
+ type Config = {
51
+ settings: Settings;
52
+ } & DestinationServer.Config<Types>;
53
+ type Rule = Mapping$1.Rule<Mapping>;
54
+ /**
55
+ * Destination account and product identifier
56
+ * https://developers.google.com/data-manager/api/reference/rest/v1/Destination
57
+ */
58
+ interface Destination {
59
+ /** Operating account details */
60
+ operatingAccount: OperatingAccount;
61
+ /** Product-specific destination ID (conversion action or user list) */
62
+ productDestinationId: string;
63
+ }
64
+ /**
65
+ * Operating account information
66
+ */
67
+ interface OperatingAccount {
68
+ /** Account ID (e.g., "123-456-7890" for Google Ads) */
69
+ accountId: string;
70
+ /** Type of account */
71
+ accountType: AccountType;
72
+ }
73
+ type AccountType = 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY';
74
+ type EventSource = 'WEB' | 'APP' | 'IN_STORE' | 'PHONE' | 'OTHER';
75
+ /**
76
+ * Consent for Digital Markets Act (DMA) compliance
77
+ * https://developers.google.com/data-manager/api/devguides/concepts/dma
78
+ */
79
+ interface Consent {
80
+ /** Consent for data collection and use */
81
+ adUserData?: ConsentStatus;
82
+ /** Consent for ad personalization */
83
+ adPersonalization?: ConsentStatus;
84
+ }
85
+ type ConsentStatus = 'CONSENT_GRANTED' | 'CONSENT_DENIED';
86
+
87
+ /**
88
+ * Purchase event mapping for Google Ads conversion
89
+ */
90
+ declare const Purchase: Rule;
91
+ /**
92
+ * Lead event mapping
93
+ */
94
+ declare const Lead: Rule;
95
+ /**
96
+ * Page view mapping for GA4
97
+ */
98
+ declare const PageView: Rule;
99
+ /**
100
+ * Complete mapping configuration
101
+ */
102
+ declare const mapping: {
103
+ order: {
104
+ complete: Rule;
105
+ };
106
+ lead: {
107
+ submit: Rule;
108
+ };
109
+ page: {
110
+ view: Rule;
111
+ };
112
+ };
113
+ /**
114
+ * User data mapping configuration
115
+ * Maps walkerOS user properties to Data Manager user identifiers
116
+ */
117
+ declare const userDataMapping: Config;
118
+
119
+ declare const mapping$1_Lead: typeof Lead;
120
+ declare const mapping$1_PageView: typeof PageView;
121
+ declare const mapping$1_Purchase: typeof Purchase;
122
+ declare const mapping$1_mapping: typeof mapping;
123
+ declare const mapping$1_userDataMapping: typeof userDataMapping;
124
+ declare namespace mapping$1 {
125
+ export { mapping$1_Lead as Lead, mapping$1_PageView as PageView, mapping$1_Purchase as Purchase, mapping$1_mapping as mapping, mapping$1_userDataMapping as userDataMapping };
126
+ }
127
+
128
+ /**
129
+ * Minimal configuration for Google Data Manager
130
+ */
131
+ declare const minimal: Config;
132
+ /**
133
+ * Complete configuration with all options
134
+ */
135
+ declare const complete: Config;
136
+ /**
137
+ * GA4-specific configuration
138
+ */
139
+ declare const ga4: Config;
140
+ /**
141
+ * Debug configuration with logging enabled
142
+ */
143
+ declare const debug: Config;
144
+
145
+ declare const basic_complete: typeof complete;
146
+ declare const basic_debug: typeof debug;
147
+ declare const basic_ga4: typeof ga4;
148
+ declare const basic_minimal: typeof minimal;
149
+ declare namespace basic {
150
+ export { basic_complete as complete, basic_debug as debug, basic_ga4 as ga4, basic_minimal as minimal };
151
+ }
152
+
153
+ export { basic, mapping$1 as mapping };
@@ -0,0 +1,153 @@
1
+ import { Mapping as Mapping$1, Destination as Destination$1 } from '@walkeros/core';
2
+ import { DestinationServer } from '@walkeros/server-core';
3
+
4
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
5
+
6
+ interface Settings {
7
+ /** OAuth 2.0 access token with datamanager scope */
8
+ accessToken: string;
9
+ /** Array of destination accounts and conversion actions/user lists */
10
+ destinations: Destination[];
11
+ /** Default event source if not specified per event */
12
+ eventSource?: EventSource;
13
+ /** Maximum number of events to batch before sending (max 2000) */
14
+ batchSize?: number;
15
+ /** Time in milliseconds to wait before auto-flushing batch */
16
+ batchInterval?: number;
17
+ /** If true, validate request without ingestion (testing mode) */
18
+ validateOnly?: boolean;
19
+ /** Override API endpoint (for testing) */
20
+ url?: string;
21
+ /** Request-level consent for all events */
22
+ consent?: Consent;
23
+ /** Test event code for debugging (optional) */
24
+ testEventCode?: string;
25
+ /** Log level for debugging (optional) */
26
+ logLevel?: LogLevel;
27
+ /** Guided helpers: User data mapping (applies to all events) */
28
+ userData?: Mapping$1.Map;
29
+ /** Guided helper: First-party user ID */
30
+ userId?: Mapping$1.Value;
31
+ /** Guided helper: GA4 client ID */
32
+ clientId?: Mapping$1.Value;
33
+ /** Guided helper: Privacy-safe attribution (Google's sessionAttributes) */
34
+ sessionAttributes?: Mapping$1.Value;
35
+ /** Consent mapping: Map consent field to adUserData (string = field name, boolean = static value) */
36
+ consentAdUserData?: string | boolean;
37
+ /** Consent mapping: Map consent field to adPersonalization (string = field name, boolean = static value) */
38
+ consentAdPersonalization?: string | boolean;
39
+ }
40
+ interface Mapping {
41
+ gclid?: Mapping$1.Value;
42
+ gbraid?: Mapping$1.Value;
43
+ wbraid?: Mapping$1.Value;
44
+ sessionAttributes?: Mapping$1.Value;
45
+ }
46
+ interface Env extends DestinationServer.Env {
47
+ fetch?: typeof fetch;
48
+ }
49
+ type Types = Destination$1.Types<Settings, Mapping, Env>;
50
+ type Config = {
51
+ settings: Settings;
52
+ } & DestinationServer.Config<Types>;
53
+ type Rule = Mapping$1.Rule<Mapping>;
54
+ /**
55
+ * Destination account and product identifier
56
+ * https://developers.google.com/data-manager/api/reference/rest/v1/Destination
57
+ */
58
+ interface Destination {
59
+ /** Operating account details */
60
+ operatingAccount: OperatingAccount;
61
+ /** Product-specific destination ID (conversion action or user list) */
62
+ productDestinationId: string;
63
+ }
64
+ /**
65
+ * Operating account information
66
+ */
67
+ interface OperatingAccount {
68
+ /** Account ID (e.g., "123-456-7890" for Google Ads) */
69
+ accountId: string;
70
+ /** Type of account */
71
+ accountType: AccountType;
72
+ }
73
+ type AccountType = 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY';
74
+ type EventSource = 'WEB' | 'APP' | 'IN_STORE' | 'PHONE' | 'OTHER';
75
+ /**
76
+ * Consent for Digital Markets Act (DMA) compliance
77
+ * https://developers.google.com/data-manager/api/devguides/concepts/dma
78
+ */
79
+ interface Consent {
80
+ /** Consent for data collection and use */
81
+ adUserData?: ConsentStatus;
82
+ /** Consent for ad personalization */
83
+ adPersonalization?: ConsentStatus;
84
+ }
85
+ type ConsentStatus = 'CONSENT_GRANTED' | 'CONSENT_DENIED';
86
+
87
+ /**
88
+ * Purchase event mapping for Google Ads conversion
89
+ */
90
+ declare const Purchase: Rule;
91
+ /**
92
+ * Lead event mapping
93
+ */
94
+ declare const Lead: Rule;
95
+ /**
96
+ * Page view mapping for GA4
97
+ */
98
+ declare const PageView: Rule;
99
+ /**
100
+ * Complete mapping configuration
101
+ */
102
+ declare const mapping: {
103
+ order: {
104
+ complete: Rule;
105
+ };
106
+ lead: {
107
+ submit: Rule;
108
+ };
109
+ page: {
110
+ view: Rule;
111
+ };
112
+ };
113
+ /**
114
+ * User data mapping configuration
115
+ * Maps walkerOS user properties to Data Manager user identifiers
116
+ */
117
+ declare const userDataMapping: Config;
118
+
119
+ declare const mapping$1_Lead: typeof Lead;
120
+ declare const mapping$1_PageView: typeof PageView;
121
+ declare const mapping$1_Purchase: typeof Purchase;
122
+ declare const mapping$1_mapping: typeof mapping;
123
+ declare const mapping$1_userDataMapping: typeof userDataMapping;
124
+ declare namespace mapping$1 {
125
+ export { mapping$1_Lead as Lead, mapping$1_PageView as PageView, mapping$1_Purchase as Purchase, mapping$1_mapping as mapping, mapping$1_userDataMapping as userDataMapping };
126
+ }
127
+
128
+ /**
129
+ * Minimal configuration for Google Data Manager
130
+ */
131
+ declare const minimal: Config;
132
+ /**
133
+ * Complete configuration with all options
134
+ */
135
+ declare const complete: Config;
136
+ /**
137
+ * GA4-specific configuration
138
+ */
139
+ declare const ga4: Config;
140
+ /**
141
+ * Debug configuration with logging enabled
142
+ */
143
+ declare const debug: Config;
144
+
145
+ declare const basic_complete: typeof complete;
146
+ declare const basic_debug: typeof debug;
147
+ declare const basic_ga4: typeof ga4;
148
+ declare const basic_minimal: typeof minimal;
149
+ declare namespace basic {
150
+ export { basic_complete as complete, basic_debug as debug, basic_ga4 as ga4, basic_minimal as minimal };
151
+ }
152
+
153
+ export { basic, mapping$1 as mapping };
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/examples/index.ts
21
+ var examples_exports = {};
22
+ __export(examples_exports, {
23
+ basic: () => basic_exports,
24
+ mapping: () => mapping_exports
25
+ });
26
+ module.exports = __toCommonJS(examples_exports);
27
+
28
+ // src/examples/mapping.ts
29
+ var mapping_exports = {};
30
+ __export(mapping_exports, {
31
+ Lead: () => Lead,
32
+ PageView: () => PageView,
33
+ Purchase: () => Purchase,
34
+ mapping: () => mapping,
35
+ userDataMapping: () => userDataMapping
36
+ });
37
+ var import_core = require("@walkeros/core");
38
+ var Purchase = {
39
+ name: "purchase",
40
+ data: {
41
+ map: {
42
+ // Required fields
43
+ transactionId: "data.id",
44
+ conversionValue: "data.total",
45
+ currency: { key: "data.currency", value: "USD" },
46
+ eventName: { value: "purchase" },
47
+ // User identification
48
+ userId: "user.id",
49
+ email: "user.id",
50
+ // Will be hashed automatically
51
+ // Attribution identifiers (captured by browser source from URL)
52
+ gclid: "context.gclid",
53
+ // Google Click ID
54
+ gbraid: "context.gbraid",
55
+ // iOS attribution
56
+ wbraid: "context.wbraid",
57
+ // Web-to-app
58
+ // Shopping cart data
59
+ cartData: {
60
+ map: {
61
+ items: {
62
+ loop: [
63
+ "nested",
64
+ {
65
+ condition: (entity) => (0, import_core.isObject)(entity) && entity.entity === "product",
66
+ map: {
67
+ merchantProductId: "data.id",
68
+ price: "data.price",
69
+ quantity: { key: "data.quantity", value: 1 }
70
+ }
71
+ }
72
+ ]
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
78
+ };
79
+ var Lead = {
80
+ name: "generate_lead",
81
+ data: {
82
+ map: {
83
+ eventName: { value: "generate_lead" },
84
+ conversionValue: { value: 10 },
85
+ currency: { value: "USD" }
86
+ }
87
+ }
88
+ };
89
+ var PageView = {
90
+ name: "page_view",
91
+ data: {
92
+ map: {
93
+ eventName: { value: "page_view" }
94
+ }
95
+ }
96
+ };
97
+ var mapping = {
98
+ order: {
99
+ complete: Purchase
100
+ },
101
+ lead: {
102
+ submit: Lead
103
+ },
104
+ page: {
105
+ view: PageView
106
+ }
107
+ };
108
+ var userDataMapping = {
109
+ settings: {
110
+ accessToken: "ya29.c.xxx",
111
+ destinations: [
112
+ {
113
+ operatingAccount: {
114
+ accountId: "123-456-7890",
115
+ accountType: "GOOGLE_ADS"
116
+ },
117
+ productDestinationId: "AW-CONVERSION-123"
118
+ }
119
+ ]
120
+ },
121
+ data: {
122
+ map: {
123
+ email: "user.id",
124
+ phone: "data.phone",
125
+ firstName: "data.firstName",
126
+ lastName: "data.lastName",
127
+ regionCode: "data.country",
128
+ postalCode: "data.zip"
129
+ }
130
+ },
131
+ mapping
132
+ };
133
+
134
+ // src/examples/basic.ts
135
+ var basic_exports = {};
136
+ __export(basic_exports, {
137
+ complete: () => complete,
138
+ debug: () => debug,
139
+ ga4: () => ga4,
140
+ minimal: () => minimal
141
+ });
142
+ var minimal = {
143
+ settings: {
144
+ accessToken: "ya29.c.xxx",
145
+ destinations: [
146
+ {
147
+ operatingAccount: {
148
+ accountId: "123-456-7890",
149
+ accountType: "GOOGLE_ADS"
150
+ },
151
+ productDestinationId: "AW-CONVERSION-123"
152
+ }
153
+ ]
154
+ }
155
+ };
156
+ var complete = {
157
+ settings: {
158
+ accessToken: "ya29.c.xxx",
159
+ destinations: [
160
+ {
161
+ operatingAccount: {
162
+ accountId: "123-456-7890",
163
+ accountType: "GOOGLE_ADS"
164
+ },
165
+ productDestinationId: "AW-CONVERSION-123"
166
+ },
167
+ {
168
+ operatingAccount: {
169
+ accountId: "987654321",
170
+ accountType: "GOOGLE_ANALYTICS_PROPERTY"
171
+ },
172
+ productDestinationId: "G-XXXXXXXXXX"
173
+ }
174
+ ],
175
+ eventSource: "WEB",
176
+ batchSize: 100,
177
+ batchInterval: 5e3,
178
+ validateOnly: false,
179
+ consent: {
180
+ adUserData: "CONSENT_GRANTED",
181
+ adPersonalization: "CONSENT_GRANTED"
182
+ },
183
+ // Guided helpers (apply to all events)
184
+ userData: {
185
+ email: "user.id",
186
+ phone: "data.phone",
187
+ firstName: "data.firstName",
188
+ lastName: "data.lastName"
189
+ },
190
+ userId: "user.id",
191
+ clientId: "user.device",
192
+ sessionAttributes: "context.sessionAttributes"
193
+ },
194
+ data: {
195
+ map: {
196
+ eventSource: { value: "WEB" }
197
+ }
198
+ }
199
+ };
200
+ var ga4 = {
201
+ settings: {
202
+ accessToken: "ya29.c.xxx",
203
+ destinations: [
204
+ {
205
+ operatingAccount: {
206
+ accountId: "123456789",
207
+ accountType: "GOOGLE_ANALYTICS_PROPERTY"
208
+ },
209
+ productDestinationId: "G-XXXXXXXXXX"
210
+ }
211
+ ],
212
+ eventSource: "WEB"
213
+ }
214
+ };
215
+ var debug = {
216
+ settings: {
217
+ accessToken: "ya29.c.xxx",
218
+ destinations: [
219
+ {
220
+ operatingAccount: {
221
+ accountId: "123-456-7890",
222
+ accountType: "GOOGLE_ADS"
223
+ },
224
+ productDestinationId: "AW-CONVERSION-123"
225
+ }
226
+ ],
227
+ logLevel: "debug"
228
+ // Shows all API calls and responses
229
+ }
230
+ };
231
+ // Annotate the CommonJS export names for ESM import in node:
232
+ 0 && (module.exports = {
233
+ basic,
234
+ mapping
235
+ });