@walkeros/server-destination-datamanager 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 +820 -0
- package/dist/dev.d.mts +233 -0
- package/dist/dev.d.ts +233 -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/examples/index.d.mts +218 -0
- package/dist/examples/index.d.ts +218 -0
- package/dist/examples/index.js +320 -0
- package/dist/examples/index.mjs +297 -0
- package/dist/index.d.mts +388 -0
- package/dist/index.d.ts +388 -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/dist/schemas.d.mts +6 -0
- package/dist/schemas.d.ts +6 -0
- package/dist/schemas.js +1 -0
- package/dist/schemas.js.map +1 -0
- package/dist/schemas.mjs +1 -0
- package/dist/schemas.mjs.map +1 -0
- package/package.json +66 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { Destination as Destination$1, Mapping as Mapping$1 } from '@walkeros/core';
|
|
2
|
+
import { DestinationServer } from '@walkeros/server-core';
|
|
3
|
+
import { OAuth2Client } from 'google-auth-library';
|
|
4
|
+
|
|
5
|
+
interface Settings {
|
|
6
|
+
/**
|
|
7
|
+
* Service account credentials (client_email + private_key)
|
|
8
|
+
* Recommended for serverless environments (AWS Lambda, Docker, etc.)
|
|
9
|
+
*/
|
|
10
|
+
credentials?: {
|
|
11
|
+
client_email: string;
|
|
12
|
+
private_key: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Path to service account JSON file
|
|
16
|
+
* For local development or environments with filesystem access
|
|
17
|
+
*/
|
|
18
|
+
keyFilename?: string;
|
|
19
|
+
/**
|
|
20
|
+
* OAuth scopes for Data Manager API
|
|
21
|
+
* @default ['https://www.googleapis.com/auth/datamanager']
|
|
22
|
+
*/
|
|
23
|
+
scopes?: string[];
|
|
24
|
+
/** Array of destination accounts and conversion actions/user lists */
|
|
25
|
+
destinations: Destination[];
|
|
26
|
+
/** Event source for all events. Defaults to WEB if not specified */
|
|
27
|
+
eventSource?: EventSource;
|
|
28
|
+
/** Maximum number of events to batch before sending (max 2000) */
|
|
29
|
+
batchSize?: number;
|
|
30
|
+
/** Time in milliseconds to wait before auto-flushing batch */
|
|
31
|
+
batchInterval?: number;
|
|
32
|
+
/** If true, validate request without ingestion (testing mode) */
|
|
33
|
+
validateOnly?: boolean;
|
|
34
|
+
/** Override API endpoint (for testing) */
|
|
35
|
+
url?: string;
|
|
36
|
+
/** Request-level consent for all events */
|
|
37
|
+
consent?: Consent;
|
|
38
|
+
/** Test event code for debugging (optional) */
|
|
39
|
+
testEventCode?: string;
|
|
40
|
+
/** Guided helpers: User data mapping (applies to all events) */
|
|
41
|
+
userData?: Mapping$1.Map;
|
|
42
|
+
/** Guided helper: First-party user ID */
|
|
43
|
+
userId?: Mapping$1.Value;
|
|
44
|
+
/** Guided helper: GA4 client ID */
|
|
45
|
+
clientId?: Mapping$1.Value;
|
|
46
|
+
/** Guided helper: Privacy-safe attribution (Google's sessionAttributes) */
|
|
47
|
+
sessionAttributes?: Mapping$1.Value;
|
|
48
|
+
/** Consent mapping: Map consent field to adUserData (string = field name, boolean = static value) */
|
|
49
|
+
consentAdUserData?: string | boolean;
|
|
50
|
+
/** Consent mapping: Map consent field to adPersonalization (string = field name, boolean = static value) */
|
|
51
|
+
consentAdPersonalization?: string | boolean;
|
|
52
|
+
}
|
|
53
|
+
interface Mapping {
|
|
54
|
+
gclid?: Mapping$1.Value;
|
|
55
|
+
gbraid?: Mapping$1.Value;
|
|
56
|
+
wbraid?: Mapping$1.Value;
|
|
57
|
+
sessionAttributes?: Mapping$1.Value;
|
|
58
|
+
}
|
|
59
|
+
interface Env extends DestinationServer.Env {
|
|
60
|
+
fetch?: typeof fetch;
|
|
61
|
+
authClient?: OAuth2Client | null;
|
|
62
|
+
}
|
|
63
|
+
type InitSettings = Partial<Settings>;
|
|
64
|
+
type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
|
|
65
|
+
interface DestinationInterface extends DestinationServer.Destination<Types> {
|
|
66
|
+
init: DestinationServer.InitFn<Types>;
|
|
67
|
+
}
|
|
68
|
+
type Config = {
|
|
69
|
+
settings: Settings;
|
|
70
|
+
} & DestinationServer.Config<Types>;
|
|
71
|
+
/**
|
|
72
|
+
* Config after validation - settings is guaranteed to exist with required fields
|
|
73
|
+
* Use this type after calling getConfig() to get proper type narrowing
|
|
74
|
+
* After validation, eventSource is always set (defaults to 'WEB')
|
|
75
|
+
*/
|
|
76
|
+
type ValidatedConfig = Omit<Config, 'settings'> & {
|
|
77
|
+
settings: Settings & {
|
|
78
|
+
eventSource: EventSource;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
type InitFn = DestinationServer.InitFn<Types>;
|
|
82
|
+
type PushFn = DestinationServer.PushFn<Types>;
|
|
83
|
+
type PartialConfig = DestinationServer.PartialConfig<Types>;
|
|
84
|
+
type PushEvents = DestinationServer.PushEvents<Mapping>;
|
|
85
|
+
type Rule = Mapping$1.Rule<Mapping>;
|
|
86
|
+
type Rules = Mapping$1.Rules<Rule>;
|
|
87
|
+
/**
|
|
88
|
+
* Destination account and product identifier
|
|
89
|
+
* https://developers.google.com/data-manager/api/reference/rest/v1/Destination
|
|
90
|
+
*/
|
|
91
|
+
interface Destination {
|
|
92
|
+
/** Reference identifier for this destination */
|
|
93
|
+
reference?: string;
|
|
94
|
+
/** Login account (account initiating the request) */
|
|
95
|
+
loginAccount?: ProductAccount;
|
|
96
|
+
/** Linked account (child account linked to login account) */
|
|
97
|
+
linkedAccount?: ProductAccount;
|
|
98
|
+
/** Operating account (account where data is sent) */
|
|
99
|
+
operatingAccount?: ProductAccount;
|
|
100
|
+
/** Product-specific destination ID (conversion action or user list) */
|
|
101
|
+
productDestinationId?: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Product account information
|
|
105
|
+
*/
|
|
106
|
+
interface ProductAccount {
|
|
107
|
+
/** Account ID (e.g., "123-456-7890" for Google Ads) */
|
|
108
|
+
accountId: string;
|
|
109
|
+
/** Type of account */
|
|
110
|
+
accountType: AccountType;
|
|
111
|
+
}
|
|
112
|
+
type AccountType = 'ACCOUNT_TYPE_UNSPECIFIED' | 'GOOGLE_ADS' | 'DISPLAY_VIDEO_ADVERTISER' | 'DISPLAY_VIDEO_PARTNER' | 'GOOGLE_ANALYTICS_PROPERTY' | 'DATA_PARTNER';
|
|
113
|
+
type EventSource = 'WEB' | 'APP' | 'IN_STORE' | 'PHONE' | 'OTHER';
|
|
114
|
+
/**
|
|
115
|
+
* Consent for Digital Markets Act (DMA) compliance
|
|
116
|
+
* https://developers.google.com/data-manager/api/devguides/concepts/dma
|
|
117
|
+
*/
|
|
118
|
+
interface Consent {
|
|
119
|
+
/** Consent for data collection and use */
|
|
120
|
+
adUserData?: ConsentStatus;
|
|
121
|
+
/** Consent for ad personalization */
|
|
122
|
+
adPersonalization?: ConsentStatus;
|
|
123
|
+
}
|
|
124
|
+
type ConsentStatus = 'CONSENT_GRANTED' | 'CONSENT_DENIED';
|
|
125
|
+
/**
|
|
126
|
+
* Request body for events.ingest API
|
|
127
|
+
* https://developers.google.com/data-manager/api/reference/rest/v1/events/ingest
|
|
128
|
+
*/
|
|
129
|
+
interface IngestEventsRequest {
|
|
130
|
+
/** Array of destinations for these events (max 10) */
|
|
131
|
+
destinations: Destination[];
|
|
132
|
+
/** Array of events to ingest (max 2000) */
|
|
133
|
+
events: Event[];
|
|
134
|
+
/** Request-level consent (overridden by event-level) */
|
|
135
|
+
consent?: Consent;
|
|
136
|
+
/** If true, validate without ingestion */
|
|
137
|
+
validateOnly?: boolean;
|
|
138
|
+
/** Test event code for debugging */
|
|
139
|
+
testEventCode?: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Single event for ingestion
|
|
143
|
+
* https://developers.google.com/data-manager/api/reference/rest/v1/Event
|
|
144
|
+
*/
|
|
145
|
+
interface Event {
|
|
146
|
+
/** Destination references for routing */
|
|
147
|
+
destinationReferences?: string[];
|
|
148
|
+
/** Transaction ID for deduplication (max 512 chars) */
|
|
149
|
+
transactionId?: string;
|
|
150
|
+
/** Event timestamp in RFC 3339 format */
|
|
151
|
+
eventTimestamp?: string;
|
|
152
|
+
/** Last updated timestamp in RFC 3339 format */
|
|
153
|
+
lastUpdatedTimestamp?: string;
|
|
154
|
+
/** User data with identifiers (max 10 identifiers) */
|
|
155
|
+
userData?: UserData;
|
|
156
|
+
/** Event-level consent (overrides request-level) */
|
|
157
|
+
consent?: Consent;
|
|
158
|
+
/** Attribution identifiers */
|
|
159
|
+
adIdentifiers?: AdIdentifiers;
|
|
160
|
+
/** Currency code (ISO 4217, 3 chars) */
|
|
161
|
+
currency?: string;
|
|
162
|
+
/** Conversion value */
|
|
163
|
+
conversionValue?: number;
|
|
164
|
+
/** Source of the event */
|
|
165
|
+
eventSource?: EventSource;
|
|
166
|
+
/** Device information for the event */
|
|
167
|
+
eventDeviceInfo?: DeviceInfo;
|
|
168
|
+
/** Shopping cart data */
|
|
169
|
+
cartData?: CartData;
|
|
170
|
+
/** Custom variables for the event */
|
|
171
|
+
customVariables?: CustomVariable[];
|
|
172
|
+
/** Experimental fields (subject to change) */
|
|
173
|
+
experimentalFields?: ExperimentalField[];
|
|
174
|
+
/** User properties */
|
|
175
|
+
userProperties?: UserProperties;
|
|
176
|
+
/** Event name for GA4 (max 40 chars, required for GA4) */
|
|
177
|
+
eventName?: string;
|
|
178
|
+
/** Google Analytics client ID (max 255 chars) */
|
|
179
|
+
clientId?: string;
|
|
180
|
+
/** First-party user ID (max 256 chars) */
|
|
181
|
+
userId?: string;
|
|
182
|
+
/** Additional event parameters */
|
|
183
|
+
additionalEventParameters?: EventParameter[];
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Device information
|
|
187
|
+
*/
|
|
188
|
+
interface DeviceInfo {
|
|
189
|
+
/** User agent string */
|
|
190
|
+
userAgent?: string;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Custom variable
|
|
194
|
+
*/
|
|
195
|
+
interface CustomVariable {
|
|
196
|
+
/** Variable name */
|
|
197
|
+
name?: string;
|
|
198
|
+
/** Variable value */
|
|
199
|
+
value?: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Experimental field
|
|
203
|
+
*/
|
|
204
|
+
interface ExperimentalField {
|
|
205
|
+
/** Field name */
|
|
206
|
+
name?: string;
|
|
207
|
+
/** Field value */
|
|
208
|
+
value?: string;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* User properties
|
|
212
|
+
*/
|
|
213
|
+
interface UserProperties {
|
|
214
|
+
/** Property values */
|
|
215
|
+
[key: string]: string | number | boolean | undefined;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Event parameter
|
|
219
|
+
*/
|
|
220
|
+
interface EventParameter {
|
|
221
|
+
/** Parameter name */
|
|
222
|
+
name?: string;
|
|
223
|
+
/** Parameter value */
|
|
224
|
+
value?: string | number;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* User data with identifiers
|
|
228
|
+
* https://developers.google.com/data-manager/api/reference/rest/v1/UserData
|
|
229
|
+
*/
|
|
230
|
+
interface UserData {
|
|
231
|
+
/** Array of user identifiers (max 10) */
|
|
232
|
+
userIdentifiers: UserIdentifier[];
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* User identifier (email, phone, or address)
|
|
236
|
+
*/
|
|
237
|
+
type UserIdentifier = {
|
|
238
|
+
emailAddress: string;
|
|
239
|
+
} | {
|
|
240
|
+
phoneNumber: string;
|
|
241
|
+
} | {
|
|
242
|
+
address: Address;
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Address for user identification
|
|
246
|
+
* https://developers.google.com/data-manager/api/reference/rest/v1/Address
|
|
247
|
+
*/
|
|
248
|
+
interface Address {
|
|
249
|
+
/** Given name (first name) - SHA-256 hashed */
|
|
250
|
+
givenName?: string;
|
|
251
|
+
/** Family name (last name) - SHA-256 hashed */
|
|
252
|
+
familyName?: string;
|
|
253
|
+
/** ISO-3166-1 alpha-2 country code - NOT hashed (e.g., "US", "GB") */
|
|
254
|
+
regionCode?: string;
|
|
255
|
+
/** Postal code - NOT hashed */
|
|
256
|
+
postalCode?: string;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Attribution identifiers
|
|
260
|
+
* https://developers.google.com/data-manager/api/reference/rest/v1/AdIdentifiers
|
|
261
|
+
*/
|
|
262
|
+
interface AdIdentifiers {
|
|
263
|
+
/** Session attributes (privacy-safe attribution) */
|
|
264
|
+
sessionAttributes?: string;
|
|
265
|
+
/** Google Click ID (primary attribution) */
|
|
266
|
+
gclid?: string;
|
|
267
|
+
/** iOS attribution identifier (post-ATT) */
|
|
268
|
+
gbraid?: string;
|
|
269
|
+
/** Web-to-app attribution identifier */
|
|
270
|
+
wbraid?: string;
|
|
271
|
+
/** Device information for landing page */
|
|
272
|
+
landingPageDeviceInfo?: DeviceInfo;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Shopping cart data
|
|
276
|
+
* https://developers.google.com/data-manager/api/reference/rest/v1/CartData
|
|
277
|
+
*/
|
|
278
|
+
interface CartData {
|
|
279
|
+
/** Array of cart items (max 200) */
|
|
280
|
+
items: CartItem[];
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Single cart item
|
|
284
|
+
* https://developers.google.com/data-manager/api/reference/rest/v1/CartItem
|
|
285
|
+
*/
|
|
286
|
+
interface CartItem {
|
|
287
|
+
/** Merchant product ID (max 127 chars) */
|
|
288
|
+
merchantProductId?: string;
|
|
289
|
+
/** Item price */
|
|
290
|
+
price?: number;
|
|
291
|
+
/** Item quantity */
|
|
292
|
+
quantity?: number;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Response from events.ingest API
|
|
296
|
+
* https://developers.google.com/data-manager/api/reference/rest/v1/IngestEventsResponse
|
|
297
|
+
*/
|
|
298
|
+
interface IngestEventsResponse {
|
|
299
|
+
/** Unique request ID for status checking */
|
|
300
|
+
requestId: string;
|
|
301
|
+
/** Validation errors (only if validateOnly=true) */
|
|
302
|
+
validationErrors?: ValidationError[];
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Validation error
|
|
306
|
+
*/
|
|
307
|
+
interface ValidationError {
|
|
308
|
+
/** Error code */
|
|
309
|
+
code: string;
|
|
310
|
+
/** Human-readable error message */
|
|
311
|
+
message: string;
|
|
312
|
+
/** Field path that caused the error */
|
|
313
|
+
fieldPath?: string;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Request status response
|
|
317
|
+
* https://developers.google.com/data-manager/api/reference/rest/v1/requestStatus/retrieve
|
|
318
|
+
*/
|
|
319
|
+
interface RequestStatusResponse {
|
|
320
|
+
/** Unique request ID */
|
|
321
|
+
requestId: string;
|
|
322
|
+
/** Processing state */
|
|
323
|
+
state: RequestState;
|
|
324
|
+
/** Number of events successfully ingested */
|
|
325
|
+
eventsIngested?: number;
|
|
326
|
+
/** Number of events that failed */
|
|
327
|
+
eventsFailed?: number;
|
|
328
|
+
/** Array of errors (if any) */
|
|
329
|
+
errors?: RequestError[];
|
|
330
|
+
}
|
|
331
|
+
type RequestState = 'STATE_UNSPECIFIED' | 'PENDING' | 'PROCESSING' | 'SUCCEEDED' | 'FAILED' | 'PARTIALLY_SUCCEEDED';
|
|
332
|
+
/**
|
|
333
|
+
* Request error
|
|
334
|
+
*/
|
|
335
|
+
interface RequestError {
|
|
336
|
+
/** Error code */
|
|
337
|
+
code: string;
|
|
338
|
+
/** Human-readable error message */
|
|
339
|
+
message: string;
|
|
340
|
+
/** Number of events affected by this error */
|
|
341
|
+
eventCount?: number;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
type index_AccountType = AccountType;
|
|
345
|
+
type index_AdIdentifiers = AdIdentifiers;
|
|
346
|
+
type index_Address = Address;
|
|
347
|
+
type index_CartData = CartData;
|
|
348
|
+
type index_CartItem = CartItem;
|
|
349
|
+
type index_Config = Config;
|
|
350
|
+
type index_Consent = Consent;
|
|
351
|
+
type index_ConsentStatus = ConsentStatus;
|
|
352
|
+
type index_CustomVariable = CustomVariable;
|
|
353
|
+
type index_Destination = Destination;
|
|
354
|
+
type index_DestinationInterface = DestinationInterface;
|
|
355
|
+
type index_DeviceInfo = DeviceInfo;
|
|
356
|
+
type index_Env = Env;
|
|
357
|
+
type index_Event = Event;
|
|
358
|
+
type index_EventParameter = EventParameter;
|
|
359
|
+
type index_EventSource = EventSource;
|
|
360
|
+
type index_ExperimentalField = ExperimentalField;
|
|
361
|
+
type index_IngestEventsRequest = IngestEventsRequest;
|
|
362
|
+
type index_IngestEventsResponse = IngestEventsResponse;
|
|
363
|
+
type index_InitFn = InitFn;
|
|
364
|
+
type index_InitSettings = InitSettings;
|
|
365
|
+
type index_Mapping = Mapping;
|
|
366
|
+
type index_PartialConfig = PartialConfig;
|
|
367
|
+
type index_ProductAccount = ProductAccount;
|
|
368
|
+
type index_PushEvents = PushEvents;
|
|
369
|
+
type index_PushFn = PushFn;
|
|
370
|
+
type index_RequestError = RequestError;
|
|
371
|
+
type index_RequestState = RequestState;
|
|
372
|
+
type index_RequestStatusResponse = RequestStatusResponse;
|
|
373
|
+
type index_Rule = Rule;
|
|
374
|
+
type index_Rules = Rules;
|
|
375
|
+
type index_Settings = Settings;
|
|
376
|
+
type index_Types = Types;
|
|
377
|
+
type index_UserData = UserData;
|
|
378
|
+
type index_UserIdentifier = UserIdentifier;
|
|
379
|
+
type index_UserProperties = UserProperties;
|
|
380
|
+
type index_ValidatedConfig = ValidatedConfig;
|
|
381
|
+
type index_ValidationError = ValidationError;
|
|
382
|
+
declare namespace index {
|
|
383
|
+
export type { index_AccountType as AccountType, index_AdIdentifiers as AdIdentifiers, index_Address as Address, index_CartData as CartData, index_CartItem as CartItem, index_Config as Config, index_Consent as Consent, index_ConsentStatus as ConsentStatus, index_CustomVariable as CustomVariable, index_Destination as Destination, index_DestinationInterface as DestinationInterface, index_DeviceInfo as DeviceInfo, index_Env as Env, index_Event as Event, index_EventParameter as EventParameter, index_EventSource as EventSource, index_ExperimentalField as ExperimentalField, index_IngestEventsRequest as IngestEventsRequest, index_IngestEventsResponse as IngestEventsResponse, index_InitFn as InitFn, index_InitSettings as InitSettings, index_Mapping as Mapping, index_PartialConfig as PartialConfig, index_ProductAccount as ProductAccount, index_PushEvents as PushEvents, index_PushFn as PushFn, index_RequestError as RequestError, index_RequestState as RequestState, index_RequestStatusResponse as RequestStatusResponse, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types, index_UserData as UserData, index_UserIdentifier as UserIdentifier, index_UserProperties as UserProperties, index_ValidatedConfig as ValidatedConfig, index_ValidationError as ValidationError };
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
declare const destinationDataManager: DestinationInterface;
|
|
387
|
+
|
|
388
|
+
export { index as DestinationDataManager, destinationDataManager as default, destinationDataManager };
|