@walkeros/server-destination-datamanager 4.9.0 → 4.10.0-next-1794522704623

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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @walkeros/server-destination-datamanager
2
2
 
3
+ ## 4.10.0-next-1794522704623
4
+
5
+ ### Minor Changes
6
+
7
+ - fda46e3: Data Manager follows Google's current API: `testEventCode`,
8
+ `batchSize`, `batchInterval` and the Display & Video 360 account types are
9
+ removed (a flow that still sets `testEventCode` now ingests real events, so
10
+ test with `validateOnly: true`), account IDs are digits only, `loginAccount`
11
+ is accepted, and a Google Analytics destination needs no `transactionId` and
12
+ sends no IP or user agent unless you set one. Identifiers follow Google's
13
+ formatting rules (a phone number needs `+` or `00` and its country code, a
14
+ value that is already hashed is not hashed again, an incomplete address is not
15
+ sent), and a refused request, a value the destination cannot send and a field
16
+ Google drops are each named on an ERROR line; the push returns Google's
17
+ `requestId`. Tests and simulations that injected `env.fetch` now inject
18
+ `env.sendServer`, an injected `env.authClient` now answers
19
+ `getRequestHeaders()` instead of `getAccessToken()`, and the exported types no
20
+ longer include API fields and request-status types the destination never
21
+ sends.
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [61030f8]
26
+ - Updated dependencies [61030f8]
27
+ - Updated dependencies [61030f8]
28
+ - @walkeros/core@4.10.0-next-1794522704623
29
+ - @walkeros/server-core@4.10.0-next-1794522704623
30
+
3
31
  ## 4.9.0
4
32
 
5
33
  ### Patch Changes
package/README.md CHANGED
@@ -6,8 +6,8 @@
6
6
 
7
7
  # @walkeros/server-destination-datamanager
8
8
 
9
- Server-side event ingestion via the Google Data Manager API to Google Ads,
10
- Display & Video 360, and Google Analytics 4.
9
+ Server-side event ingestion via the Google Data Manager API to Google Ads and
10
+ Google Analytics 4.
11
11
 
12
12
  [Documentation](https://www.walkeros.io/docs/destinations/server/datamanager)
13
13
  •
@@ -33,12 +33,19 @@ npm install @walkeros/server-destination-datamanager
33
33
  "datamanager": {
34
34
  "package": "@walkeros/server-destination-datamanager",
35
35
  "config": {
36
- "data": { "map": { "transactionId": "id" } },
36
+ "mapping": {
37
+ "*": { "*": { "ignore": true } },
38
+ "order": {
39
+ "complete": {
40
+ "data": { "map": { "transactionId": "data.id" } }
41
+ }
42
+ }
43
+ },
37
44
  "settings": {
38
45
  "destinations": [
39
46
  {
40
47
  "operatingAccount": {
41
- "accountId": "123-456-7890",
48
+ "accountId": "1234567890",
42
49
  "accountType": "GOOGLE_ADS"
43
50
  },
44
51
  "productDestinationId": "YOUR_CONVERSION_ACTION_ID"
@@ -53,10 +60,10 @@ npm install @walkeros/server-destination-datamanager
53
60
  }
54
61
  ```
55
62
 
56
- The destination sends an event only when it carries a `transactionId`; this
57
- quick start maps the walkerOS event `id` to it. For an order that the Google tag
58
- also reports, map the order ID the tag sends instead, so Google can deduplicate
59
- the two.
63
+ A Google Ads destination needs a `transactionId`: this quick start maps the
64
+ order ID (`data.id`) and ignores every other event. For an order that the Google
65
+ tag also reports, map the order ID the tag sends, so Google can deduplicate the
66
+ two.
60
67
 
61
68
  ## Documentation
62
69
 
package/dist/dev.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _walkeros_core_dev from '@walkeros/core/dev';
2
- import { DestinationServer } from '@walkeros/server-core';
2
+ import { DestinationServer, sendServer } from '@walkeros/server-core';
3
3
  import { Flow } from '@walkeros/core';
4
4
 
5
5
  declare const settings: _walkeros_core_dev.JSONSchema;
@@ -13,16 +13,14 @@ declare namespace schemas {
13
13
 
14
14
  /**
15
15
  * The part of a Google auth client this destination calls. Structural so an
16
- * injected client (tests, simulate) needs no cast; `OAuth2Client` and the
17
- * client `GoogleAuth.getClient()` returns both satisfy it.
16
+ * injected client (tests, simulate) needs no cast; every client
17
+ * `GoogleAuth.getClient()` returns satisfies it.
18
18
  */
19
19
  interface AuthClient {
20
- getAccessToken(): Promise<{
21
- token?: string | null;
22
- }>;
20
+ getRequestHeaders(): Promise<Headers>;
23
21
  }
24
22
  interface Env extends DestinationServer.Env {
25
- fetch?: typeof fetch;
23
+ sendServer?: typeof sendServer;
26
24
  authClient?: AuthClient | null;
27
25
  }
28
26
 
@@ -37,23 +35,27 @@ declare namespace env {
37
35
 
38
36
  declare const purchase: Flow.StepExample;
39
37
  declare const lead: Flow.StepExample;
40
- declare const ga4PageView: Flow.StepExample;
41
38
  /** A silent rule sends nothing to the Data Manager API. */
42
39
  declare const silentRule: Flow.StepExample;
43
40
  /**
44
- * No transaction id -- an order complete event without data has no
45
- * transactionId, which Data Manager requires, so the push fails with
46
- * missing-input instead of counting as delivered.
41
+ * No transaction id: an order complete event without data has no
42
+ * transactionId, which a Google Ads destination requires, so the push fails
43
+ * with missing-input instead of counting as delivered.
47
44
  */
48
45
  declare const orderWithoutTransactionId: Flow.StepExample;
46
+ /** Google refuses the request: the answer names the reason and the field. */
47
+ declare const refusedRequest: Flow.StepExample;
48
+ /** Google's documented 429 for the per-minute project quota. */
49
+ declare const quotaExhausted: Flow.StepExample;
49
50
 
50
- declare const step_ga4PageView: typeof ga4PageView;
51
51
  declare const step_lead: typeof lead;
52
52
  declare const step_orderWithoutTransactionId: typeof orderWithoutTransactionId;
53
53
  declare const step_purchase: typeof purchase;
54
+ declare const step_quotaExhausted: typeof quotaExhausted;
55
+ declare const step_refusedRequest: typeof refusedRequest;
54
56
  declare const step_silentRule: typeof silentRule;
55
57
  declare namespace step {
56
- export { step_ga4PageView as ga4PageView, step_lead as lead, step_orderWithoutTransactionId as orderWithoutTransactionId, step_purchase as purchase, step_silentRule as silentRule };
58
+ export { step_lead as lead, step_orderWithoutTransactionId as orderWithoutTransactionId, step_purchase as purchase, step_quotaExhausted as quotaExhausted, step_refusedRequest as refusedRequest, step_silentRule as silentRule };
57
59
  }
58
60
 
59
61
  /**
package/dist/dev.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _walkeros_core_dev from '@walkeros/core/dev';
2
- import { DestinationServer } from '@walkeros/server-core';
2
+ import { DestinationServer, sendServer } from '@walkeros/server-core';
3
3
  import { Flow } from '@walkeros/core';
4
4
 
5
5
  declare const settings: _walkeros_core_dev.JSONSchema;
@@ -13,16 +13,14 @@ declare namespace schemas {
13
13
 
14
14
  /**
15
15
  * The part of a Google auth client this destination calls. Structural so an
16
- * injected client (tests, simulate) needs no cast; `OAuth2Client` and the
17
- * client `GoogleAuth.getClient()` returns both satisfy it.
16
+ * injected client (tests, simulate) needs no cast; every client
17
+ * `GoogleAuth.getClient()` returns satisfies it.
18
18
  */
19
19
  interface AuthClient {
20
- getAccessToken(): Promise<{
21
- token?: string | null;
22
- }>;
20
+ getRequestHeaders(): Promise<Headers>;
23
21
  }
24
22
  interface Env extends DestinationServer.Env {
25
- fetch?: typeof fetch;
23
+ sendServer?: typeof sendServer;
26
24
  authClient?: AuthClient | null;
27
25
  }
28
26
 
@@ -37,23 +35,27 @@ declare namespace env {
37
35
 
38
36
  declare const purchase: Flow.StepExample;
39
37
  declare const lead: Flow.StepExample;
40
- declare const ga4PageView: Flow.StepExample;
41
38
  /** A silent rule sends nothing to the Data Manager API. */
42
39
  declare const silentRule: Flow.StepExample;
43
40
  /**
44
- * No transaction id -- an order complete event without data has no
45
- * transactionId, which Data Manager requires, so the push fails with
46
- * missing-input instead of counting as delivered.
41
+ * No transaction id: an order complete event without data has no
42
+ * transactionId, which a Google Ads destination requires, so the push fails
43
+ * with missing-input instead of counting as delivered.
47
44
  */
48
45
  declare const orderWithoutTransactionId: Flow.StepExample;
46
+ /** Google refuses the request: the answer names the reason and the field. */
47
+ declare const refusedRequest: Flow.StepExample;
48
+ /** Google's documented 429 for the per-minute project quota. */
49
+ declare const quotaExhausted: Flow.StepExample;
49
50
 
50
- declare const step_ga4PageView: typeof ga4PageView;
51
51
  declare const step_lead: typeof lead;
52
52
  declare const step_orderWithoutTransactionId: typeof orderWithoutTransactionId;
53
53
  declare const step_purchase: typeof purchase;
54
+ declare const step_quotaExhausted: typeof quotaExhausted;
55
+ declare const step_refusedRequest: typeof refusedRequest;
54
56
  declare const step_silentRule: typeof silentRule;
55
57
  declare namespace step {
56
- export { step_ga4PageView as ga4PageView, step_lead as lead, step_orderWithoutTransactionId as orderWithoutTransactionId, step_purchase as purchase, step_silentRule as silentRule };
58
+ export { step_lead as lead, step_orderWithoutTransactionId as orderWithoutTransactionId, step_purchase as purchase, step_quotaExhausted as quotaExhausted, step_refusedRequest as refusedRequest, step_silentRule as silentRule };
57
59
  }
58
60
 
59
61
  /**
package/dist/dev.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,s=(e,a)=>{for(var n in a)t(e,n,{get:a[n],enumerable:!0})},r={};s(r,{examples:()=>E,schemas:()=>o}),module.exports=(e=r,((e,s,r,o)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let c of n(s))i.call(e,c)||c===r||t(e,c,{get:()=>s[c],enumerable:!(o=a(s,c))||o.enumerable});return e})(t({},"__esModule",{value:!0}),e));var o={};s(o,{mapping:()=>z,settings:()=>A});var c=require("@walkeros/core/dev"),d=c.z.enum(["GOOGLE_ADS","DISPLAY_VIDEO_ADVERTISER","DISPLAY_VIDEO_PARTNER","GOOGLE_ANALYTICS_PROPERTY"]),l=c.z.enum(["WEB","APP","IN_STORE","PHONE","OTHER"]),u=c.z.enum(["CONSENT_GRANTED","CONSENT_DENIED"]),p=c.z.object({adUserData:u.describe("Consent for data collection and use").optional(),adPersonalization:u.describe("Consent for ad personalization").optional()}),m=c.z.object({accountId:c.z.string().min(1).describe('Account ID (e.g., "123-456-7890" for Google Ads)'),accountType:d.describe("Type of account")}),v=c.z.object({operatingAccount:m.describe("Operating account details"),productDestinationId:c.z.string().min(1).describe("Product-specific destination ID, like a conversion action ID")}),g=require("@walkeros/core/dev"),f=g.z.union([g.schemas.MappingSchemas.ValueSchema,g.z.literal(!1)]),b=g.z.object({client_email:g.z.string().email().describe("Service account email"),private_key:g.z.string().min(1).describe("Service account private key (PEM format)")}),h=g.z.object({credentials:b.optional().describe("Service account credentials (client_email + private_key). Prefer config.credentials; set here, they are used and the destination logs a WARN line."),keyFilename:g.z.string().optional().describe("Path to service account JSON file. For local development or environments with filesystem access."),scopes:g.z.array(g.z.string()).optional().describe("OAuth scopes for Data Manager API. Defaults to datamanager scope."),destinations:g.z.array(v).min(1).max(10).describe("Array of destination accounts and conversion actions (max 10)"),eventSource:l.optional().default("WEB").describe("Event source for all events. Defaults to WEB. Values: WEB, APP, IN_STORE, PHONE, OTHER"),batchSize:g.z.number().int().min(1).max(2e3).describe("Has no effect: every event is sent in its own request (accepts 1 to 2000)").optional(),batchInterval:g.z.number().int().min(0).describe("Has no effect: every event is sent in its own request (accepts milliseconds, like 5000)").optional(),validateOnly:g.z.boolean().describe("If true, validate request without ingestion (testing mode)").optional(),url:g.z.string().url().describe("Override API endpoint for testing (like https://datamanager.googleapis.com/v1)").optional(),consent:p.describe("Request-level consent, sent with every request and applied to each event that carries no consent of its own").optional(),testEventCode:g.z.string().describe("Test event code for debugging (like TEST12345)").optional(),userData:g.z.record(g.z.string(),g.z.unknown()).describe("Guided helper: User data mapping for all events (like { email: 'user.email', phone: 'data.phone' })").optional(),userId:g.z.any().describe("Guided helper: First-party user ID for all events (like 'user.id')").optional(),clientId:g.z.any().describe("Guided helper: GA4 client ID for all events (like 'user.device')").optional(),appInstanceId:g.z.any().describe("Guided helper: GA4 app instance ID (Firebase) for all events (like 'user.appInstanceId')").optional(),sessionAttributes:g.z.any().describe("Guided helper: Privacy-safe attribution for all events (like 'context.sessionAttributes')").optional(),consentAdUserData:g.z.union([g.z.string(),g.z.boolean()]).describe("Consent mapping: Field name from event.consent (like 'marketing') or static boolean value").optional(),consentAdPersonalization:g.z.union([g.z.string(),g.z.boolean()]).describe("Consent mapping: Field name from event.consent (like 'targeting') or static boolean value").optional(),ip:f.describe('Client IP, sent as eventDeviceInfo.ipAddress. Resolves against { ingest, event }. Default: ["ingest.ip", "event.user.ip"]. false switches it off. A mapped ipAddress wins.').optional(),userAgent:f.describe('Client user agent, sent as eventDeviceInfo.userAgent. Resolves against { ingest, event }. Default: ["ingest.userAgent", "event.user.userAgent"]. false switches it off. A mapped userAgent wins.').optional()}).strict(),y=require("@walkeros/core/dev").z.object({}),I=require("@walkeros/core/dev"),A=(0,I.zodToSchema)(h),z=(0,I.zodToSchema)(y),E={};s(E,{env:()=>D,minimal:()=>j,step:()=>S});var D={};s(D,{push:()=>O,simulation:()=>w});var O={fetch:async function(){return new Response(JSON.stringify({requestId:"mock-request-id",validationErrors:[]}),{status:200,headers:{"Content-Type":"application/json"}})},authClient:{getAccessToken:async()=>({token:"ya29.c.test_token"})}},w=["fetch"],S={};s(S,{ga4PageView:()=>G,lead:()=>R,orderWithoutTransactionId:()=>C,purchase:()=>_,silentRule:()=>q});var P=require("@walkeros/core"),T="https://datamanager.googleapis.com/v1/events:ingest",k=[{operatingAccount:{accountId:"123-456-7890",accountType:"GOOGLE_ADS"},productDestinationId:"AW-CONVERSION-123"}],N=e=>({method:"POST",headers:{Authorization:"Bearer ya29.c.test_token","Content-Type":"application/json"},body:e}),_={title:"Purchase",description:"A completed order is posted to Google Data Manager as a purchase conversion with hashed user identifiers.",in:(0,P.getEvent)("order complete",{id:"ev-1700000900000",timestamp:17000009e5,data:{id:"ORD-600",value:149.99,currency:"EUR"},user:{id:"user-abc",email:"buyer@example.com"},source:{type:"express",platform:"server"}}),mapping:{name:"purchase",data:{map:{transactionId:"data.id",conversionValue:"data.value",currency:{key:"data.currency",value:"USD"},eventName:{value:"purchase"},userId:"user.id",email:"user.email"}}},out:[["fetch",T,N(JSON.stringify({events:[{eventTimestamp:"2023-11-14T22:28:20.000Z",transactionId:"ORD-600",userId:"user-abc",userData:{userIdentifiers:[{emailAddress:"6a6c26195c3682faa816966af789717c3bfa834eee6c599d667d2b3429c27cfd"}]},conversionValue:149.99,currency:"EUR",eventName:"purchase",eventSource:"WEB"}],destinations:k,encoding:"HEX"}))]]},R={title:"Lead",description:"A demo request form submission is sent to Data Manager as a generate_lead conversion with a hashed email.",in:(0,P.createEvent)({name:"form submit",id:"ev-1700000901000",timestamp:1700000901e3,data:{type:"demo-request"},user:{email:"prospect@example.com"},source:{type:"express",platform:"server"}}),mapping:{name:"generate_lead",data:{map:{transactionId:"id",eventName:{value:"generate_lead"},conversionValue:{value:10},currency:{value:"USD"},email:"user.email"}}},out:[["fetch",T,N(JSON.stringify({events:[{eventTimestamp:"2023-11-14T22:28:21.000Z",transactionId:"ev-1700000901000",userData:{userIdentifiers:[{emailAddress:"395ec5f334be0ab5b28568a1e7f6ed5ea80e443fb1ce3d803340586a3df46642"}]},conversionValue:10,currency:"USD",eventName:"generate_lead",eventSource:"WEB"}],destinations:k,encoding:"HEX"}))]]},G={title:"Page view",description:"A page view is sent to Data Manager as a page_view event tied to the walker user id.",in:(0,P.getEvent)("page view",{id:"ev-1700000902000",timestamp:1700000902e3,data:{title:"Pricing",url:"https://example.com/pricing"},user:{id:"visitor-55"},source:{type:"express",platform:"server"}}),mapping:{name:"page_view",data:{map:{transactionId:"id",eventName:{value:"page_view"},userId:"user.id"}}},out:[["fetch",T,N(JSON.stringify({events:[{eventTimestamp:"2023-11-14T22:28:22.000Z",transactionId:"ev-1700000902000",userId:"visitor-55",eventName:"page_view",eventSource:"WEB"}],destinations:k,encoding:"HEX"}))]]},q={public:!1,description:"A rule with silent: true sends no request to the Data Manager API.",in:(0,P.getEvent)("page view",{timestamp:170000099e4}),mapping:{silent:!0},out:[]},C={public:!1,description:"An order complete event without a transaction id cannot be sent to the Data Manager API: the push fails with missing-input instead of counting as delivered.",in:{name:"order complete",entity:"order",action:"complete",timestamp:1700000991e3},out:[],outcome:{status:"failed",code:"missing-input",retryable:!1}},j={settings:{destinations:[{operatingAccount:{accountId:"123-456-7890",accountType:"GOOGLE_ADS"},productDestinationId:"AW-CONVERSION-123"}]}};//# sourceMappingURL=dev.js.map
1
+ "use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,i=(e,a)=>{for(var n in a)t(e,n,{get:a[n],enumerable:!0})},o={};i(o,{examples:()=>D,schemas:()=>r}),module.exports=(e=o,((e,i,o,r)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of n(i))s.call(e,c)||c===o||t(e,c,{get:()=>i[c],enumerable:!(r=a(i,c))||r.enumerable});return e})(t({},"__esModule",{value:!0}),e));var r={};i(r,{mapping:()=>I,settings:()=>E});var c=require("@walkeros/core/dev"),d=c.z.enum(["GOOGLE_ADS","GOOGLE_ANALYTICS_PROPERTY"]),l=c.z.enum(["WEB","APP","IN_STORE","PHONE","MESSAGE","OTHER"]),u=c.z.enum(["CONSENT_GRANTED","CONSENT_DENIED"]),p=c.z.object({adUserData:u.describe("Consent for data collection and use").optional(),adPersonalization:u.describe("Consent for ad personalization").optional()}),m=c.z.object({accountId:c.z.string().regex(/^\d+$/).describe("Numeric account ID: the 10-digit Google Ads customer ID without hyphens, or the Google Analytics property ID"),accountType:d.describe("Type of account")}),g=c.z.object({operatingAccount:m.describe("Operating account details"),loginAccount:m.optional().describe("Account the credentials belong to, when it is not the operating account: a Google Ads manager account above it"),productDestinationId:c.z.string().min(1).describe("Numeric Google Ads conversion action ID; for Google Analytics, the measurement ID (G-...) of a web stream or the Firebase App ID of an app stream")}),v=require("@walkeros/core/dev"),f=v.z.union([v.schemas.MappingSchemas.ValueSchema,v.z.literal(!1)]),b=v.z.object({client_email:v.z.string().email().describe("Service account email"),private_key:v.z.string().min(1).describe("Service account private key (PEM format)")}),h=v.z.object({credentials:b.optional().describe("Service account credentials (client_email + private_key). Prefer config.credentials; set here, they are used and the destination logs a WARN line."),keyFilename:v.z.string().optional().describe("Absolute path to a service account JSON file"),scopes:v.z.array(v.z.string()).optional().describe("OAuth scopes for Data Manager API. Defaults to datamanager scope."),destinations:v.z.array(g).min(1).max(10).describe("Destination accounts and conversion actions (max 10); every event goes to every entry"),eventSource:l.optional().default("WEB").describe("Event source for all events. Defaults to WEB. Values: WEB, APP, IN_STORE, PHONE, MESSAGE, OTHER"),validateOnly:v.z.boolean().describe("If true, validate request without ingestion (testing mode)").optional(),url:v.z.string().url().describe("Override API endpoint for testing (like https://datamanager.googleapis.com/v1)").optional(),consent:p.describe("Request-level consent, sent with every request and applied to each event that carries no consent of its own").optional(),userData:v.z.record(v.z.string(),v.z.unknown()).describe("Guided helper: User data mapping for all events (like { email: 'user.email', phone: 'data.phone' })").optional(),userId:v.z.any().describe("Guided helper: First-party user ID for all events (like 'user.id')").optional(),clientId:v.z.any().describe("Guided helper: Google Analytics client ID of the web stream, the one your Google tag sets, for all events").optional(),appInstanceId:v.z.any().describe("Guided helper: GA4 app instance ID (Firebase) for all events (like 'user.appInstanceId')").optional(),sessionAttributes:v.z.any().describe("Guided helper: Privacy-safe attribution for all events (like 'context.sessionAttributes')").optional(),consentAdUserData:v.z.union([v.z.string(),v.z.boolean()]).describe("Consent mapping: Field name from event.consent (like 'marketing') or static boolean value").optional(),consentAdPersonalization:v.z.union([v.z.string(),v.z.boolean()]).describe("Consent mapping: Field name from event.consent (like 'targeting') or static boolean value").optional(),ip:f.describe('Client IP, sent as eventDeviceInfo.ipAddress. Resolves against { ingest, event }. Filled by default only when an entry is GOOGLE_ADS, from ["ingest.ip", "event.user.ip"]; a Google Analytics-only step sends none unless this is set or ipAddress is mapped. false switches it off. A mapped ipAddress wins.').optional(),userAgent:f.describe('Client user agent, sent as eventDeviceInfo.userAgent. Resolves against { ingest, event }. Filled by default only when an entry is GOOGLE_ADS, from ["ingest.userAgent", "event.user.userAgent"]; a Google Analytics-only step sends none unless this is set or userAgent is mapped. false switches it off. A mapped userAgent wins.').optional()}).strict(),y=require("@walkeros/core/dev").z.object({}),A=require("@walkeros/core/dev"),E=(0,A.zodToSchema)(h),I=(0,A.zodToSchema)(y),D={};i(D,{env:()=>z,minimal:()=>x,step:()=>S});var z={};i(z,{push:()=>O,simulation:()=>G});var O={sendServer:async function(){return{data:{requestId:"mock-request-id"}}},authClient:{getRequestHeaders:async()=>new Headers({authorization:"Bearer ya29.c.test_token"})}},G=["sendServer"],S={};i(S,{lead:()=>T,orderWithoutTransactionId:()=>k,purchase:()=>P,quotaExhausted:()=>j,refusedRequest:()=>M,silentRule:()=>q});var R=require("@walkeros/core"),_="https://datamanager.googleapis.com/v1/events:ingest",w=[{operatingAccount:{accountId:"1234567890",accountType:"GOOGLE_ADS"},productDestinationId:"987654321"}],N={headers:{authorization:"Bearer ya29.c.test_token"},timeout:1e4},P={title:"Purchase",description:"A completed order is posted to Google Data Manager as a purchase conversion with hashed user identifiers.",in:(0,R.getEvent)("order complete",{id:"ev-1700000900000",timestamp:17000009e5,data:{id:"ORD-600",value:149.99,currency:"EUR"},user:{id:"user-abc",email:"buyer@example.com"},source:{type:"express",platform:"server"}}),mapping:{name:"purchase",data:{map:{transactionId:"data.id",conversionValue:"data.value",currency:{key:"data.currency",value:"USD"},eventName:{value:"purchase"},userId:"user.id",email:"user.email"}}},out:[["sendServer",_,JSON.stringify({events:[{eventTimestamp:"2023-11-14T22:28:20.000Z",transactionId:"ORD-600",userId:"user-abc",userData:{userIdentifiers:[{emailAddress:"6a6c26195c3682faa816966af789717c3bfa834eee6c599d667d2b3429c27cfd"}]},conversionValue:149.99,currency:"EUR",eventName:"purchase",eventSource:"WEB"}],destinations:w,encoding:"HEX"}),N]]},T={title:"Lead",description:"A demo request form submission is sent to Data Manager as a generate_lead conversion with a hashed email.",in:(0,R.createEvent)({name:"form submit",id:"ev-1700000901000",timestamp:1700000901e3,data:{type:"demo-request"},user:{email:"prospect@example.com"},source:{type:"express",platform:"server"}}),mapping:{name:"generate_lead",data:{map:{transactionId:"id",eventName:{value:"generate_lead"},conversionValue:{value:10},currency:{value:"USD"},email:"user.email"}}},out:[["sendServer",_,JSON.stringify({events:[{eventTimestamp:"2023-11-14T22:28:21.000Z",transactionId:"ev-1700000901000",userData:{userIdentifiers:[{emailAddress:"395ec5f334be0ab5b28568a1e7f6ed5ea80e443fb1ce3d803340586a3df46642"}]},conversionValue:10,currency:"USD",eventName:"generate_lead",eventSource:"WEB"}],destinations:w,encoding:"HEX"}),N]]},q={public:!1,description:"A rule with silent: true sends no request to the Data Manager API.",in:(0,R.getEvent)("page view",{timestamp:170000099e4}),mapping:{silent:!0},out:[]},k={public:!1,description:"An order complete event without a transaction id cannot be sent for a Google Ads destination: the push fails with missing-input instead of counting as delivered.",in:{name:"order complete",entity:"order",action:"complete",timestamp:1700000991e3},out:[],outcome:{status:"failed",code:"missing-input",retryable:!1}},M={public:!1,description:"Google refuses the request, for example a customer ID with hyphens: the push fails, is not retried, and the ERROR line names Google's reason and field.",in:P.in,mapping:P.mapping,respond:{status:400,body:{error:{code:400,message:"Request contains an invalid argument.",status:"INVALID_ARGUMENT",details:[{"@type":"type.googleapis.com/google.rpc.BadRequest",fieldViolations:[{field:"destinations[0].login_account.account_id",description:"String is not a valid number.",reason:"INVALID_NUMBER_FORMAT"}]}]}}},outcome:{status:"failed",code:"transport",retryable:!1}},j={public:!1,description:"Google's per-minute quota for the project is used up: the push fails and may be redelivered; the ERROR line names the quota.",in:P.in,mapping:P.mapping,respond:{status:429,body:{error:{code:429,status:"RESOURCE_EXHAUSTED",details:[{"@type":"type.googleapis.com/google.rpc.ErrorInfo",reason:"RATE_LIMIT_EXCEEDED",metadata:{quota_limit:"IngestionMutateRequestsPerMinutePerProject"}}]}}},outcome:{status:"failed",code:"transport",retryable:!0}},x={settings:{destinations:[{operatingAccount:{accountId:"1234567890",accountType:"GOOGLE_ADS"},productDestinationId:"987654321"}]}};//# sourceMappingURL=dev.js.map
package/dist/dev.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/dev.ts","../src/schemas.ts","../src/schemas/primitives.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/schemas/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/minimal.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","// Browser-safe schema-only exports\n// This file exports ONLY schemas without any Node.js dependencies\nexport { settings, mapping } from './schemas/index';\n","import { z } from '@walkeros/core/dev';\n\nexport const AccountTypeSchema = z.enum([\n 'GOOGLE_ADS',\n 'DISPLAY_VIDEO_ADVERTISER',\n 'DISPLAY_VIDEO_PARTNER',\n 'GOOGLE_ANALYTICS_PROPERTY',\n]);\n\nexport const EventSourceSchema = z.enum([\n 'WEB',\n 'APP',\n 'IN_STORE',\n 'PHONE',\n 'OTHER',\n]);\n\nexport const ConsentStatusSchema = z.enum([\n 'CONSENT_GRANTED',\n 'CONSENT_DENIED',\n]);\n\nexport const ConsentSchema = z.object({\n adUserData: ConsentStatusSchema.describe(\n 'Consent for data collection and use',\n ).optional(),\n adPersonalization: ConsentStatusSchema.describe(\n 'Consent for ad personalization',\n ).optional(),\n});\n\nexport const OperatingAccountSchema = z.object({\n accountId: z\n .string()\n .min(1)\n .describe('Account ID (e.g., \"123-456-7890\" for Google Ads)'),\n accountType: AccountTypeSchema.describe('Type of account'),\n});\n\nexport const DestinationSchema = z.object({\n operatingAccount: OperatingAccountSchema.describe(\n 'Operating account details',\n ),\n productDestinationId: z\n .string()\n .min(1)\n .describe('Product-specific destination ID, like a conversion action ID'),\n});\n","import { schemas, z } from '@walkeros/core/dev';\nimport {\n DestinationSchema,\n EventSourceSchema,\n ConsentSchema,\n} from './primitives';\n\nconst InputSchema = z.union([\n schemas.MappingSchemas.ValueSchema,\n z.literal(false),\n]);\n\n/**\n * Service account credentials schema\n */\nconst CredentialsSchema = z.object({\n client_email: z.string().email().describe('Service account email'),\n private_key: z\n .string()\n .min(1)\n .describe('Service account private key (PEM format)'),\n});\n\nexport const SettingsSchema = z\n .object({\n credentials: CredentialsSchema.optional().describe(\n 'Service account credentials (client_email + private_key). Prefer config.credentials; set here, they are used and the destination logs a WARN line.',\n ),\n keyFilename: z\n .string()\n .optional()\n .describe(\n 'Path to service account JSON file. For local development or environments with filesystem access.',\n ),\n scopes: z\n .array(z.string())\n .optional()\n .describe(\n 'OAuth scopes for Data Manager API. Defaults to datamanager scope.',\n ),\n destinations: z\n .array(DestinationSchema)\n .min(1)\n .max(10)\n .describe(\n 'Array of destination accounts and conversion actions (max 10)',\n ),\n eventSource: EventSourceSchema.optional()\n .default('WEB')\n .describe(\n 'Event source for all events. Defaults to WEB. Values: WEB, APP, IN_STORE, PHONE, OTHER',\n ),\n batchSize: z\n .number()\n .int()\n .min(1)\n .max(2000)\n .describe(\n 'Has no effect: every event is sent in its own request (accepts 1 to 2000)',\n )\n .optional(),\n batchInterval: z\n .number()\n .int()\n .min(0)\n .describe(\n 'Has no effect: every event is sent in its own request (accepts milliseconds, like 5000)',\n )\n .optional(),\n validateOnly: z\n .boolean()\n .describe('If true, validate request without ingestion (testing mode)')\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Override API endpoint for testing (like https://datamanager.googleapis.com/v1)',\n )\n .optional(),\n consent: ConsentSchema.describe(\n 'Request-level consent, sent with every request and applied to each event that carries no consent of its own',\n ).optional(),\n testEventCode: z\n .string()\n .describe('Test event code for debugging (like TEST12345)')\n .optional(),\n userData: z\n .record(z.string(), z.unknown())\n .describe(\n \"Guided helper: User data mapping for all events (like { email: 'user.email', phone: 'data.phone' })\",\n )\n .optional(),\n userId: z\n .any()\n .describe(\n \"Guided helper: First-party user ID for all events (like 'user.id')\",\n )\n .optional(),\n clientId: z\n .any()\n .describe(\n \"Guided helper: GA4 client ID for all events (like 'user.device')\",\n )\n .optional(),\n appInstanceId: z\n .any()\n .describe(\n \"Guided helper: GA4 app instance ID (Firebase) for all events (like 'user.appInstanceId')\",\n )\n .optional(),\n sessionAttributes: z\n .any()\n .describe(\n \"Guided helper: Privacy-safe attribution for all events (like 'context.sessionAttributes')\",\n )\n .optional(),\n consentAdUserData: z\n .union([z.string(), z.boolean()])\n .describe(\n \"Consent mapping: Field name from event.consent (like 'marketing') or static boolean value\",\n )\n .optional(),\n consentAdPersonalization: z\n .union([z.string(), z.boolean()])\n .describe(\n \"Consent mapping: Field name from event.consent (like 'targeting') or static boolean value\",\n )\n .optional(),\n ip: InputSchema.describe(\n 'Client IP, sent as eventDeviceInfo.ipAddress. Resolves against { ingest, event }. Default: [\"ingest.ip\", \"event.user.ip\"]. false switches it off. A mapped ipAddress wins.',\n ).optional(),\n userAgent: InputSchema.describe(\n 'Client user agent, sent as eventDeviceInfo.userAgent. Resolves against { ingest, event }. Default: [\"ingest.userAgent\", \"event.user.userAgent\"]. false switches it off. A mapped userAgent wins.',\n ).optional(),\n })\n .strict();\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n// Data Manager uses flexible mapping via walkerOS mapping system\n// No event-specific mapping schema needed (similar to Meta CAPI pattern)\nexport const MappingSchema = z.object({});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * from './primitives';\nexport * from './settings';\nexport * from './mapping';\n\nimport { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","export * as env from './env';\nexport * as step from './step';\nexport { minimal } from './minimal';\n","import type { AuthClient, Env } from '../types';\n\n/**\n * Example environment configurations for Google Data Manager destination.\n *\n * The destination invokes `env.fetch(url, { method, headers, body })` once\n * per push, with `Authorization: Bearer <accessToken>` obtained from\n * `env.authClient` via `getAccessToken`.\n *\n * For tests we use a stub `authClient` (jest mocks the `getAccessToken`\n * helper at module level) and a mock `fetch` returning a successful ingest\n * response.\n */\n\nasync function mockFetch(): Promise<Response> {\n return new Response(\n JSON.stringify({ requestId: 'mock-request-id', validationErrors: [] }),\n { status: 200, headers: { 'Content-Type': 'application/json' } },\n );\n}\n\nconst mockAuthClient: AuthClient = {\n getAccessToken: async () => ({ token: 'ya29.c.test_token' }),\n};\n\nexport const push: Env = {\n fetch: mockFetch,\n authClient: mockAuthClient,\n};\n\nexport const simulation = ['fetch'];\n","import type { Flow } from '@walkeros/core';\nimport { createEvent, getEvent } from '@walkeros/core';\n\n/**\n * Google Data Manager step examples.\n *\n * At push time, the destination calls\n * `env.fetch(url, { method, headers, body })` where:\n * - `url` is `${settings.url}/events:ingest` (default\n * `https://datamanager.googleapis.com/v1`)\n * - `method` is `'POST'`\n * - `headers` is `{ Authorization: 'Bearer <accessToken>', 'Content-Type': 'application/json' }`\n * - `body` is the JSON-stringified `{ events: [dataManagerEvent], destinations }` payload\n *\n * The access token is obtained from `env.authClient` via `getAccessToken`.\n * The test fixture mocks both so the captured Authorization header is stable\n * (`Bearer ya29.c.test_token`).\n *\n * Event fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * eventTimestamp, transactionId?, clientId?, userId?, userData?,\n * adIdentifiers?, conversionValue?, currency?, cartData?, eventName?,\n * [eventSource is appended last by push.ts when not already present].\n *\n * Emails are normalized (trim, lowercase, strip dots for Gmail) and hashed\n * with SHA-256.\n */\nconst ENDPOINT = 'https://datamanager.googleapis.com/v1/events:ingest';\nconst DESTINATIONS = [\n {\n operatingAccount: {\n accountId: '123-456-7890',\n accountType: 'GOOGLE_ADS',\n },\n productDestinationId: 'AW-CONVERSION-123',\n },\n];\nconst INIT_OPTIONS = (body: string) => ({\n method: 'POST',\n headers: {\n Authorization: 'Bearer ya29.c.test_token',\n 'Content-Type': 'application/json',\n },\n body,\n});\n\nexport const purchase: Flow.StepExample = {\n title: 'Purchase',\n description:\n 'A completed order is posted to Google Data Manager as a purchase conversion with hashed user identifiers.',\n in: getEvent('order complete', {\n id: 'ev-1700000900000',\n timestamp: 1700000900000,\n data: { id: 'ORD-600', value: 149.99, currency: 'EUR' },\n user: { id: 'user-abc', email: 'buyer@example.com' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n name: 'purchase',\n data: {\n map: {\n transactionId: 'data.id',\n conversionValue: 'data.value',\n currency: { key: 'data.currency', value: 'USD' },\n eventName: { value: 'purchase' },\n userId: 'user.id',\n email: 'user.email',\n },\n },\n },\n out: [\n [\n 'fetch',\n ENDPOINT,\n INIT_OPTIONS(\n JSON.stringify({\n events: [\n {\n eventTimestamp: '2023-11-14T22:28:20.000Z',\n transactionId: 'ORD-600',\n userId: 'user-abc',\n userData: {\n userIdentifiers: [\n {\n // sha256('buyer@example.com')\n emailAddress:\n '6a6c26195c3682faa816966af789717c3bfa834eee6c599d667d2b3429c27cfd',\n },\n ],\n },\n conversionValue: 149.99,\n currency: 'EUR',\n eventName: 'purchase',\n eventSource: 'WEB',\n },\n ],\n destinations: DESTINATIONS,\n encoding: 'HEX',\n }),\n ),\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Lead',\n description:\n 'A demo request form submission is sent to Data Manager as a generate_lead conversion with a hashed email.',\n in: createEvent({\n name: 'form submit',\n id: 'ev-1700000901000',\n timestamp: 1700000901000,\n data: { type: 'demo-request' },\n user: { email: 'prospect@example.com' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n name: 'generate_lead',\n data: {\n map: {\n transactionId: 'id',\n eventName: { value: 'generate_lead' },\n conversionValue: { value: 10 },\n currency: { value: 'USD' },\n email: 'user.email',\n },\n },\n },\n out: [\n [\n 'fetch',\n ENDPOINT,\n INIT_OPTIONS(\n JSON.stringify({\n events: [\n {\n eventTimestamp: '2023-11-14T22:28:21.000Z',\n transactionId: 'ev-1700000901000',\n userData: {\n userIdentifiers: [\n {\n // sha256('prospect@example.com')\n emailAddress:\n '395ec5f334be0ab5b28568a1e7f6ed5ea80e443fb1ce3d803340586a3df46642',\n },\n ],\n },\n conversionValue: 10,\n currency: 'USD',\n eventName: 'generate_lead',\n eventSource: 'WEB',\n },\n ],\n destinations: DESTINATIONS,\n encoding: 'HEX',\n }),\n ),\n ],\n ],\n};\n\nexport const ga4PageView: Flow.StepExample = {\n title: 'Page view',\n description:\n 'A page view is sent to Data Manager as a page_view event tied to the walker user id.',\n in: getEvent('page view', {\n id: 'ev-1700000902000',\n timestamp: 1700000902000,\n data: { title: 'Pricing', url: 'https://example.com/pricing' },\n user: { id: 'visitor-55' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n name: 'page_view',\n data: {\n map: {\n transactionId: 'id',\n eventName: { value: 'page_view' },\n userId: 'user.id',\n },\n },\n },\n out: [\n [\n 'fetch',\n ENDPOINT,\n INIT_OPTIONS(\n JSON.stringify({\n events: [\n {\n eventTimestamp: '2023-11-14T22:28:22.000Z',\n transactionId: 'ev-1700000902000',\n userId: 'visitor-55',\n eventName: 'page_view',\n eventSource: 'WEB',\n },\n ],\n destinations: DESTINATIONS,\n encoding: 'HEX',\n }),\n ),\n ],\n ],\n};\n\n/** A silent rule sends nothing to the Data Manager API. */\nexport const silentRule: Flow.StepExample = {\n public: false,\n description:\n 'A rule with silent: true sends no request to the Data Manager API.',\n in: getEvent('page view', { timestamp: 1700000990000 }),\n mapping: { silent: true },\n out: [],\n};\n\n/**\n * No transaction id -- an order complete event without data has no\n * transactionId, which Data Manager requires, so the push fails with\n * missing-input instead of counting as delivered.\n */\nexport const orderWithoutTransactionId: Flow.StepExample = {\n public: false,\n description:\n 'An order complete event without a transaction id cannot be sent to the Data Manager API: the push fails with missing-input instead of counting as delivered.',\n in: {\n name: 'order complete',\n entity: 'order',\n action: 'complete',\n timestamp: 1700000991000,\n },\n out: [],\n outcome: { status: 'failed', code: 'missing-input', retryable: false },\n};\n","import type { Flow } from '@walkeros/core';\n\n/**\n * The setting the Data Manager API needs to deliver: one destination\n * account with its conversion action. Authentication comes from the\n * environment's Google credentials.\n */\nexport const minimal: Flow.MinimalExample = {\n settings: {\n destinations: [\n {\n operatingAccount: {\n accountId: '123-456-7890',\n accountType: 'GOOGLE_ADS',\n },\n productDestinationId: 'AW-CONVERSION-123',\n },\n ],\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;A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AQ;AAAA,YACN;AAAA,cACE,gBAAgB;AAAA,cAChB,eAAe;AAAA,cACf,QAAQ;AAAA,cACR,WAAW;AAAA,cACX,aAAa;AAAA,YACf;AAAA,UACF;AAAA,UACA,cAAc;AAAA,UACd,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;AAGO,IAAM,aAA+B;AAAA,EAC1C,QAAQ;AAAA,EACR,aACE;AAAA,EACF,QAAI,sBAAS,aAAa,EAAE,WAAW,YAAc,CAAC;AAAA,EACtD,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,KAAK,CAAC;AACR;AAOO,IAAM,4BAA8C;AAAA,EACzD,QAAQ;AAAA,EACR,aACE;AAAA,EACF,IAAI;AAAA,IACF,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AAAA,EACA,KAAK,CAAC;AAAA,EACN,SAAS,EAAE,QAAQ,UAAU,MAAM,iBAAiB,WAAW,MAAM;AACvE;;;ACjOO,IAAM,UAA+B;AAAA,EAC1C,UAAU;AAAA,IACR,cAAc;AAAA,MACZ;AAAA,QACE,kBAAkB;AAAA,UAChB,WAAW;AAAA,UACX,aAAa;AAAA,QACf;AAAA,QACA,sBAAsB;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AACF;","names":["import_dev","import_dev","import_dev"]}
1
+ {"version":3,"sources":["../src/dev.ts","../src/schemas.ts","../src/schemas/primitives.ts","../src/constants.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/schemas/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/minimal.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","// Browser-safe schema-only exports\n// This file exports ONLY schemas without any Node.js dependencies\nexport { settings, mapping } from './schemas/index';\n","import { z } from '@walkeros/core/dev';\nimport { EVENT_SOURCES } from '../constants';\n\nexport const AccountTypeSchema = z.enum([\n 'GOOGLE_ADS',\n 'GOOGLE_ANALYTICS_PROPERTY',\n]);\n\nexport const EventSourceSchema = z.enum(EVENT_SOURCES);\n\nexport const ConsentStatusSchema = z.enum([\n 'CONSENT_GRANTED',\n 'CONSENT_DENIED',\n]);\n\nexport const ConsentSchema = z.object({\n adUserData: ConsentStatusSchema.describe(\n 'Consent for data collection and use',\n ).optional(),\n adPersonalization: ConsentStatusSchema.describe(\n 'Consent for ad personalization',\n ).optional(),\n});\n\nexport const OperatingAccountSchema = z.object({\n accountId: z\n .string()\n .regex(/^\\d+$/)\n .describe(\n 'Numeric account ID: the 10-digit Google Ads customer ID without hyphens, or the Google Analytics property ID',\n ),\n accountType: AccountTypeSchema.describe('Type of account'),\n});\n\nexport const DestinationSchema = z.object({\n operatingAccount: OperatingAccountSchema.describe(\n 'Operating account details',\n ),\n loginAccount: OperatingAccountSchema.optional().describe(\n 'Account the credentials belong to, when it is not the operating account: a Google Ads manager account above it',\n ),\n productDestinationId: z\n .string()\n .min(1)\n .describe(\n 'Numeric Google Ads conversion action ID; for Google Analytics, the measurement ID (G-...) of a web stream or the Firebase App ID of an app stream',\n ),\n});\n","/**\n * The values and keys Google's Data Manager API takes. The settings schema,\n * the types and format.ts derive from these lists, so each is defined once.\n * https://developers.google.com/data-manager/api/reference/rest/v1/Event\n */\n\n/** Google's EventSource values. */\nexport const EVENT_SOURCES = [\n 'WEB',\n 'APP',\n 'IN_STORE',\n 'PHONE',\n 'MESSAGE',\n 'OTHER',\n] as const;\n\n/** The mapped keys this destination sends; any other key is reported. */\nexport const KNOWN_KEYS = [\n 'transactionId',\n 'clientId',\n 'userId',\n 'email',\n 'phone',\n 'firstName',\n 'lastName',\n 'regionCode',\n 'postalCode',\n 'gclid',\n 'gbraid',\n 'wbraid',\n 'sessionAttributes',\n 'conversionValue',\n 'currency',\n 'cartData',\n 'eventName',\n 'appInstanceId',\n 'storeId',\n 'ipAddress',\n 'userAgent',\n 'eventSource',\n 'adUserData',\n 'adPersonalization',\n] as const;\n\n/** Google's CartData fields. */\nexport const CART_DATA_KEYS = [\n 'merchantId',\n 'merchantFeedLabel',\n 'merchantFeedLanguageCode',\n 'transactionDiscount',\n 'items',\n 'couponCodes',\n] as const;\n\n/** Google's Item fields. */\nexport const CART_ITEM_KEYS = [\n 'merchantProductId',\n 'quantity',\n 'unitPrice',\n 'itemId',\n 'additionalItemParameters',\n 'merchantId',\n 'merchantFeedLabel',\n 'merchantFeedLanguageCode',\n 'customVariables',\n 'conversionValue',\n] as const;\n","import { schemas, z } from '@walkeros/core/dev';\nimport {\n DestinationSchema,\n EventSourceSchema,\n ConsentSchema,\n} from './primitives';\n\nconst InputSchema = z.union([\n schemas.MappingSchemas.ValueSchema,\n z.literal(false),\n]);\n\n/**\n * Service account credentials schema\n */\nconst CredentialsSchema = z.object({\n client_email: z.string().email().describe('Service account email'),\n private_key: z\n .string()\n .min(1)\n .describe('Service account private key (PEM format)'),\n});\n\nexport const SettingsSchema = z\n .object({\n credentials: CredentialsSchema.optional().describe(\n 'Service account credentials (client_email + private_key). Prefer config.credentials; set here, they are used and the destination logs a WARN line.',\n ),\n keyFilename: z\n .string()\n .optional()\n .describe('Absolute path to a service account JSON file'),\n scopes: z\n .array(z.string())\n .optional()\n .describe(\n 'OAuth scopes for Data Manager API. Defaults to datamanager scope.',\n ),\n destinations: z\n .array(DestinationSchema)\n .min(1)\n .max(10)\n .describe(\n 'Destination accounts and conversion actions (max 10); every event goes to every entry',\n ),\n eventSource: EventSourceSchema.optional()\n .default('WEB')\n .describe(\n 'Event source for all events. Defaults to WEB. Values: WEB, APP, IN_STORE, PHONE, MESSAGE, OTHER',\n ),\n validateOnly: z\n .boolean()\n .describe('If true, validate request without ingestion (testing mode)')\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Override API endpoint for testing (like https://datamanager.googleapis.com/v1)',\n )\n .optional(),\n consent: ConsentSchema.describe(\n 'Request-level consent, sent with every request and applied to each event that carries no consent of its own',\n ).optional(),\n userData: z\n .record(z.string(), z.unknown())\n .describe(\n \"Guided helper: User data mapping for all events (like { email: 'user.email', phone: 'data.phone' })\",\n )\n .optional(),\n userId: z\n .any()\n .describe(\n \"Guided helper: First-party user ID for all events (like 'user.id')\",\n )\n .optional(),\n clientId: z\n .any()\n .describe(\n 'Guided helper: Google Analytics client ID of the web stream, the one your Google tag sets, for all events',\n )\n .optional(),\n appInstanceId: z\n .any()\n .describe(\n \"Guided helper: GA4 app instance ID (Firebase) for all events (like 'user.appInstanceId')\",\n )\n .optional(),\n sessionAttributes: z\n .any()\n .describe(\n \"Guided helper: Privacy-safe attribution for all events (like 'context.sessionAttributes')\",\n )\n .optional(),\n consentAdUserData: z\n .union([z.string(), z.boolean()])\n .describe(\n \"Consent mapping: Field name from event.consent (like 'marketing') or static boolean value\",\n )\n .optional(),\n consentAdPersonalization: z\n .union([z.string(), z.boolean()])\n .describe(\n \"Consent mapping: Field name from event.consent (like 'targeting') or static boolean value\",\n )\n .optional(),\n ip: InputSchema.describe(\n 'Client IP, sent as eventDeviceInfo.ipAddress. Resolves against { ingest, event }. Filled by default only when an entry is GOOGLE_ADS, from [\"ingest.ip\", \"event.user.ip\"]; a Google Analytics-only step sends none unless this is set or ipAddress is mapped. false switches it off. A mapped ipAddress wins.',\n ).optional(),\n userAgent: InputSchema.describe(\n 'Client user agent, sent as eventDeviceInfo.userAgent. Resolves against { ingest, event }. Filled by default only when an entry is GOOGLE_ADS, from [\"ingest.userAgent\", \"event.user.userAgent\"]; a Google Analytics-only step sends none unless this is set or userAgent is mapped. false switches it off. A mapped userAgent wins.',\n ).optional(),\n })\n .strict();\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n// Data Manager uses flexible mapping via walkerOS mapping system\n// No event-specific mapping schema needed (similar to Meta CAPI pattern)\nexport const MappingSchema = z.object({});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * from './primitives';\nexport * from './settings';\nexport * from './mapping';\n\nimport { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","export * as env from './env';\nexport * as step from './step';\nexport { minimal } from './minimal';\n","import type { SendResponse } from '@walkeros/core';\nimport type { AuthClient, Env } from '../types';\n\n/**\n * Example environment configurations for Google Data Manager destination.\n *\n * The destination calls `env.sendServer(url, body, { headers, timeout })`\n * once per push, with the headers `env.authClient.getRequestHeaders()`\n * returns (an `authorization` header with the access token).\n *\n * For tests we use a stub `authClient` with a fixed token and a mock\n * `sendServer` returning a successful ingest answer.\n */\n\nasync function mockSendServer(): Promise<SendResponse> {\n return { data: { requestId: 'mock-request-id' } };\n}\n\nconst mockAuthClient: AuthClient = {\n getRequestHeaders: async () =>\n new Headers({ authorization: 'Bearer ya29.c.test_token' }),\n};\n\nexport const push: Env = {\n sendServer: mockSendServer,\n authClient: mockAuthClient,\n};\n\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { createEvent, getEvent } from '@walkeros/core';\n\n/**\n * Google Data Manager step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(url, body, { headers, timeout })` where:\n * - `url` is `${settings.url}/events:ingest` (default\n * `https://datamanager.googleapis.com/v1`)\n * - `body` is the JSON-stringified `{ events: [dataManagerEvent], destinations }` payload\n * - `headers` are the ones `env.authClient.getRequestHeaders()` returns,\n * as a plain object (`sendServer` posts and adds the JSON content type)\n * - `timeout` is the destination's `config.timeout`, or the collector's\n * default of 10000 ms\n *\n * The example env's auth client answers a fixed token, so the captured\n * header is stable (`authorization: 'Bearer ya29.c.test_token'`).\n *\n * Event fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * eventTimestamp, transactionId?, clientId?, userId?, userData?,\n * adIdentifiers?, conversionValue?, currency?, cartData?, eventName?,\n * [eventSource is appended last by push.ts when not already present].\n *\n * Emails are normalized (whitespace removed, lowercase; gmail.com and\n * googlemail.com addresses drop their dots and their +alias) and hashed\n * with SHA-256. A value that already is a SHA-256 digest passes lowercased,\n * not hashed again.\n */\nconst ENDPOINT = 'https://datamanager.googleapis.com/v1/events:ingest';\nconst DESTINATIONS = [\n {\n operatingAccount: {\n accountId: '1234567890',\n accountType: 'GOOGLE_ADS',\n },\n productDestinationId: '987654321',\n },\n];\nconst SEND_OPTIONS = {\n headers: { authorization: 'Bearer ya29.c.test_token' },\n timeout: 10000,\n};\n\nexport const purchase: Flow.StepExample = {\n title: 'Purchase',\n description:\n 'A completed order is posted to Google Data Manager as a purchase conversion with hashed user identifiers.',\n in: getEvent('order complete', {\n id: 'ev-1700000900000',\n timestamp: 1700000900000,\n data: { id: 'ORD-600', value: 149.99, currency: 'EUR' },\n user: { id: 'user-abc', email: 'buyer@example.com' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n name: 'purchase',\n data: {\n map: {\n transactionId: 'data.id',\n conversionValue: 'data.value',\n currency: { key: 'data.currency', value: 'USD' },\n eventName: { value: 'purchase' },\n userId: 'user.id',\n email: 'user.email',\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n eventTimestamp: '2023-11-14T22:28:20.000Z',\n transactionId: 'ORD-600',\n userId: 'user-abc',\n userData: {\n userIdentifiers: [\n {\n // sha256('buyer@example.com')\n emailAddress:\n '6a6c26195c3682faa816966af789717c3bfa834eee6c599d667d2b3429c27cfd',\n },\n ],\n },\n conversionValue: 149.99,\n currency: 'EUR',\n eventName: 'purchase',\n eventSource: 'WEB',\n },\n ],\n destinations: DESTINATIONS,\n encoding: 'HEX',\n }),\n SEND_OPTIONS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Lead',\n description:\n 'A demo request form submission is sent to Data Manager as a generate_lead conversion with a hashed email.',\n in: createEvent({\n name: 'form submit',\n id: 'ev-1700000901000',\n timestamp: 1700000901000,\n data: { type: 'demo-request' },\n user: { email: 'prospect@example.com' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n name: 'generate_lead',\n data: {\n map: {\n transactionId: 'id',\n eventName: { value: 'generate_lead' },\n conversionValue: { value: 10 },\n currency: { value: 'USD' },\n email: 'user.email',\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n eventTimestamp: '2023-11-14T22:28:21.000Z',\n transactionId: 'ev-1700000901000',\n userData: {\n userIdentifiers: [\n {\n // sha256('prospect@example.com')\n emailAddress:\n '395ec5f334be0ab5b28568a1e7f6ed5ea80e443fb1ce3d803340586a3df46642',\n },\n ],\n },\n conversionValue: 10,\n currency: 'USD',\n eventName: 'generate_lead',\n eventSource: 'WEB',\n },\n ],\n destinations: DESTINATIONS,\n encoding: 'HEX',\n }),\n SEND_OPTIONS,\n ],\n ],\n};\n\n/** A silent rule sends nothing to the Data Manager API. */\nexport const silentRule: Flow.StepExample = {\n public: false,\n description:\n 'A rule with silent: true sends no request to the Data Manager API.',\n in: getEvent('page view', { timestamp: 1700000990000 }),\n mapping: { silent: true },\n out: [],\n};\n\n/**\n * No transaction id: an order complete event without data has no\n * transactionId, which a Google Ads destination requires, so the push fails\n * with missing-input instead of counting as delivered.\n */\nexport const orderWithoutTransactionId: Flow.StepExample = {\n public: false,\n description:\n 'An order complete event without a transaction id cannot be sent for a Google Ads destination: the push fails with missing-input instead of counting as delivered.',\n in: {\n name: 'order complete',\n entity: 'order',\n action: 'complete',\n timestamp: 1700000991000,\n },\n out: [],\n outcome: { status: 'failed', code: 'missing-input', retryable: false },\n};\n\n/** Google refuses the request: the answer names the reason and the field. */\nexport const refusedRequest: Flow.StepExample = {\n public: false,\n description:\n \"Google refuses the request, for example a customer ID with hyphens: the push fails, is not retried, and the ERROR line names Google's reason and field.\",\n in: purchase.in,\n mapping: purchase.mapping,\n respond: {\n status: 400,\n body: {\n error: {\n code: 400,\n message: 'Request contains an invalid argument.',\n status: 'INVALID_ARGUMENT',\n details: [\n {\n '@type': 'type.googleapis.com/google.rpc.BadRequest',\n fieldViolations: [\n {\n field: 'destinations[0].login_account.account_id',\n description: 'String is not a valid number.',\n reason: 'INVALID_NUMBER_FORMAT',\n },\n ],\n },\n ],\n },\n },\n },\n outcome: { status: 'failed', code: 'transport', retryable: false },\n};\n\n/** Google's documented 429 for the per-minute project quota. */\nexport const quotaExhausted: Flow.StepExample = {\n public: false,\n description:\n \"Google's per-minute quota for the project is used up: the push fails and may be redelivered; the ERROR line names the quota.\",\n in: purchase.in,\n mapping: purchase.mapping,\n respond: {\n status: 429,\n body: {\n error: {\n code: 429,\n status: 'RESOURCE_EXHAUSTED',\n details: [\n {\n '@type': 'type.googleapis.com/google.rpc.ErrorInfo',\n reason: 'RATE_LIMIT_EXCEEDED',\n metadata: {\n quota_limit: 'IngestionMutateRequestsPerMinutePerProject',\n },\n },\n ],\n },\n },\n },\n outcome: { status: 'failed', code: 'transport', retryable: true },\n};\n","import type { Flow } from '@walkeros/core';\n\n/**\n * The setting the Data Manager API needs to deliver: one destination\n * account with its conversion action. Authentication comes from the\n * environment's Google credentials.\n */\nexport const minimal: Flow.MinimalExample = {\n settings: {\n destinations: [\n {\n operatingAccount: {\n accountId: '1234567890',\n accountType: 'GOOGLE_ADS',\n },\n productDestinationId: '987654321',\n },\n ],\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;;;ACOX,IAAM,gBAAgB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ADXO,IAAM,oBAAoB,aAAE,KAAK;AAAA,EACtC;AAAA,EACA;AACF,CAAC;AAEM,IAAM,oBAAoB,aAAE,KAAK,aAAa;AAE9C,IAAM,sBAAsB,aAAE,KAAK;AAAA,EACxC;AAAA,EACA;AACF,CAAC;AAEM,IAAM,gBAAgB,aAAE,OAAO;AAAA,EACpC,YAAY,oB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UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,SAAS,EAAE,QAAQ,UAAU,MAAM,aAAa,WAAW,KAAK;AAClE;;;AC9OO,IAAM,UAA+B;AAAA,EAC1C,UAAU;AAAA,IACR,cAAc;AAAA,MACZ;AAAA,QACE,kBAAkB;AAAA,UAChB,WAAW;AAAA,UACX,aAAa;AAAA,QACf;AAAA,QACA,sBAAsB;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AACF;","names":["import_dev","import_dev","import_dev"]}
package/dist/dev.mjs CHANGED
@@ -1 +1 @@
1
- import{createRequire as e}from"module";e(import.meta.url);var t=Object.defineProperty,a=(e,a)=>{for(var n in a)t(e,n,{get:a[n],enumerable:!0})},n={};a(n,{mapping:()=>A,settings:()=>I});import{z as i}from"@walkeros/core/dev";var s=i.enum(["GOOGLE_ADS","DISPLAY_VIDEO_ADVERTISER","DISPLAY_VIDEO_PARTNER","GOOGLE_ANALYTICS_PROPERTY"]),r=i.enum(["WEB","APP","IN_STORE","PHONE","OTHER"]),o=i.enum(["CONSENT_GRANTED","CONSENT_DENIED"]),c=i.object({adUserData:o.describe("Consent for data collection and use").optional(),adPersonalization:o.describe("Consent for ad personalization").optional()}),d=i.object({accountId:i.string().min(1).describe('Account ID (e.g., "123-456-7890" for Google Ads)'),accountType:s.describe("Type of account")}),l=i.object({operatingAccount:d.describe("Operating account details"),productDestinationId:i.string().min(1).describe("Product-specific destination ID, like a conversion action ID")});import{schemas as p,z as u}from"@walkeros/core/dev";var m=u.union([p.MappingSchemas.ValueSchema,u.literal(!1)]),v=u.object({client_email:u.string().email().describe("Service account email"),private_key:u.string().min(1).describe("Service account private key (PEM format)")}),g=u.object({credentials:v.optional().describe("Service account credentials (client_email + private_key). Prefer config.credentials; set here, they are used and the destination logs a WARN line."),keyFilename:u.string().optional().describe("Path to service account JSON file. For local development or environments with filesystem access."),scopes:u.array(u.string()).optional().describe("OAuth scopes for Data Manager API. Defaults to datamanager scope."),destinations:u.array(l).min(1).max(10).describe("Array of destination accounts and conversion actions (max 10)"),eventSource:r.optional().default("WEB").describe("Event source for all events. Defaults to WEB. Values: WEB, APP, IN_STORE, PHONE, OTHER"),batchSize:u.number().int().min(1).max(2e3).describe("Has no effect: every event is sent in its own request (accepts 1 to 2000)").optional(),batchInterval:u.number().int().min(0).describe("Has no effect: every event is sent in its own request (accepts milliseconds, like 5000)").optional(),validateOnly:u.boolean().describe("If true, validate request without ingestion (testing mode)").optional(),url:u.string().url().describe("Override API endpoint for testing (like https://datamanager.googleapis.com/v1)").optional(),consent:c.describe("Request-level consent, sent with every request and applied to each event that carries no consent of its own").optional(),testEventCode:u.string().describe("Test event code for debugging (like TEST12345)").optional(),userData:u.record(u.string(),u.unknown()).describe("Guided helper: User data mapping for all events (like { email: 'user.email', phone: 'data.phone' })").optional(),userId:u.any().describe("Guided helper: First-party user ID for all events (like 'user.id')").optional(),clientId:u.any().describe("Guided helper: GA4 client ID for all events (like 'user.device')").optional(),appInstanceId:u.any().describe("Guided helper: GA4 app instance ID (Firebase) for all events (like 'user.appInstanceId')").optional(),sessionAttributes:u.any().describe("Guided helper: Privacy-safe attribution for all events (like 'context.sessionAttributes')").optional(),consentAdUserData:u.union([u.string(),u.boolean()]).describe("Consent mapping: Field name from event.consent (like 'marketing') or static boolean value").optional(),consentAdPersonalization:u.union([u.string(),u.boolean()]).describe("Consent mapping: Field name from event.consent (like 'targeting') or static boolean value").optional(),ip:m.describe('Client IP, sent as eventDeviceInfo.ipAddress. Resolves against { ingest, event }. Default: ["ingest.ip", "event.user.ip"]. false switches it off. A mapped ipAddress wins.').optional(),userAgent:m.describe('Client user agent, sent as eventDeviceInfo.userAgent. Resolves against { ingest, event }. Default: ["ingest.userAgent", "event.user.userAgent"]. false switches it off. A mapped userAgent wins.').optional()}).strict();import{z as f}from"@walkeros/core/dev";var b=f.object({});import{zodToSchema as h}from"@walkeros/core/dev";var I=h(g),A=h(b),y={};a(y,{env:()=>D,minimal:()=>V,step:()=>S});var D={};a(D,{push:()=>E,simulation:()=>O});var E={fetch:async function(){return new Response(JSON.stringify({requestId:"mock-request-id",validationErrors:[]}),{status:200,headers:{"Content-Type":"application/json"}})},authClient:{getAccessToken:async()=>({token:"ya29.c.test_token"})}},O=["fetch"],S={};a(S,{ga4PageView:()=>G,lead:()=>R,orderWithoutTransactionId:()=>x,purchase:()=>_,silentRule:()=>C});import{createEvent as w,getEvent as k}from"@walkeros/core";var P="https://datamanager.googleapis.com/v1/events:ingest",T=[{operatingAccount:{accountId:"123-456-7890",accountType:"GOOGLE_ADS"},productDestinationId:"AW-CONVERSION-123"}],N=e=>({method:"POST",headers:{Authorization:"Bearer ya29.c.test_token","Content-Type":"application/json"},body:e}),_={title:"Purchase",description:"A completed order is posted to Google Data Manager as a purchase conversion with hashed user identifiers.",in:k("order complete",{id:"ev-1700000900000",timestamp:17000009e5,data:{id:"ORD-600",value:149.99,currency:"EUR"},user:{id:"user-abc",email:"buyer@example.com"},source:{type:"express",platform:"server"}}),mapping:{name:"purchase",data:{map:{transactionId:"data.id",conversionValue:"data.value",currency:{key:"data.currency",value:"USD"},eventName:{value:"purchase"},userId:"user.id",email:"user.email"}}},out:[["fetch",P,N(JSON.stringify({events:[{eventTimestamp:"2023-11-14T22:28:20.000Z",transactionId:"ORD-600",userId:"user-abc",userData:{userIdentifiers:[{emailAddress:"6a6c26195c3682faa816966af789717c3bfa834eee6c599d667d2b3429c27cfd"}]},conversionValue:149.99,currency:"EUR",eventName:"purchase",eventSource:"WEB"}],destinations:T,encoding:"HEX"}))]]},R={title:"Lead",description:"A demo request form submission is sent to Data Manager as a generate_lead conversion with a hashed email.",in:w({name:"form submit",id:"ev-1700000901000",timestamp:1700000901e3,data:{type:"demo-request"},user:{email:"prospect@example.com"},source:{type:"express",platform:"server"}}),mapping:{name:"generate_lead",data:{map:{transactionId:"id",eventName:{value:"generate_lead"},conversionValue:{value:10},currency:{value:"USD"},email:"user.email"}}},out:[["fetch",P,N(JSON.stringify({events:[{eventTimestamp:"2023-11-14T22:28:21.000Z",transactionId:"ev-1700000901000",userData:{userIdentifiers:[{emailAddress:"395ec5f334be0ab5b28568a1e7f6ed5ea80e443fb1ce3d803340586a3df46642"}]},conversionValue:10,currency:"USD",eventName:"generate_lead",eventSource:"WEB"}],destinations:T,encoding:"HEX"}))]]},G={title:"Page view",description:"A page view is sent to Data Manager as a page_view event tied to the walker user id.",in:k("page view",{id:"ev-1700000902000",timestamp:1700000902e3,data:{title:"Pricing",url:"https://example.com/pricing"},user:{id:"visitor-55"},source:{type:"express",platform:"server"}}),mapping:{name:"page_view",data:{map:{transactionId:"id",eventName:{value:"page_view"},userId:"user.id"}}},out:[["fetch",P,N(JSON.stringify({events:[{eventTimestamp:"2023-11-14T22:28:22.000Z",transactionId:"ev-1700000902000",userId:"visitor-55",eventName:"page_view",eventSource:"WEB"}],destinations:T,encoding:"HEX"}))]]},C={public:!1,description:"A rule with silent: true sends no request to the Data Manager API.",in:k("page view",{timestamp:170000099e4}),mapping:{silent:!0},out:[]},x={public:!1,description:"An order complete event without a transaction id cannot be sent to the Data Manager API: the push fails with missing-input instead of counting as delivered.",in:{name:"order complete",entity:"order",action:"complete",timestamp:1700000991e3},out:[],outcome:{status:"failed",code:"missing-input",retryable:!1}},V={settings:{destinations:[{operatingAccount:{accountId:"123-456-7890",accountType:"GOOGLE_ADS"},productDestinationId:"AW-CONVERSION-123"}]}};export{y as examples,n as schemas};//# sourceMappingURL=dev.mjs.map
1
+ import{createRequire as e}from"module";e(import.meta.url);var t=Object.defineProperty,a=(e,a)=>{for(var n in a)t(e,n,{get:a[n],enumerable:!0})},n={};a(n,{mapping:()=>A,settings:()=>y});import{z as s}from"@walkeros/core/dev";var i=s.enum(["GOOGLE_ADS","GOOGLE_ANALYTICS_PROPERTY"]),o=s.enum(["WEB","APP","IN_STORE","PHONE","MESSAGE","OTHER"]),r=s.enum(["CONSENT_GRANTED","CONSENT_DENIED"]),c=s.object({adUserData:r.describe("Consent for data collection and use").optional(),adPersonalization:r.describe("Consent for ad personalization").optional()}),d=s.object({accountId:s.string().regex(/^\d+$/).describe("Numeric account ID: the 10-digit Google Ads customer ID without hyphens, or the Google Analytics property ID"),accountType:i.describe("Type of account")}),l=s.object({operatingAccount:d.describe("Operating account details"),loginAccount:d.optional().describe("Account the credentials belong to, when it is not the operating account: a Google Ads manager account above it"),productDestinationId:s.string().min(1).describe("Numeric Google Ads conversion action ID; for Google Analytics, the measurement ID (G-...) of a web stream or the Firebase App ID of an app stream")});import{schemas as u,z as p}from"@walkeros/core/dev";var m=p.union([u.MappingSchemas.ValueSchema,p.literal(!1)]),g=p.object({client_email:p.string().email().describe("Service account email"),private_key:p.string().min(1).describe("Service account private key (PEM format)")}),v=p.object({credentials:g.optional().describe("Service account credentials (client_email + private_key). Prefer config.credentials; set here, they are used and the destination logs a WARN line."),keyFilename:p.string().optional().describe("Absolute path to a service account JSON file"),scopes:p.array(p.string()).optional().describe("OAuth scopes for Data Manager API. Defaults to datamanager scope."),destinations:p.array(l).min(1).max(10).describe("Destination accounts and conversion actions (max 10); every event goes to every entry"),eventSource:o.optional().default("WEB").describe("Event source for all events. Defaults to WEB. Values: WEB, APP, IN_STORE, PHONE, MESSAGE, OTHER"),validateOnly:p.boolean().describe("If true, validate request without ingestion (testing mode)").optional(),url:p.string().url().describe("Override API endpoint for testing (like https://datamanager.googleapis.com/v1)").optional(),consent:c.describe("Request-level consent, sent with every request and applied to each event that carries no consent of its own").optional(),userData:p.record(p.string(),p.unknown()).describe("Guided helper: User data mapping for all events (like { email: 'user.email', phone: 'data.phone' })").optional(),userId:p.any().describe("Guided helper: First-party user ID for all events (like 'user.id')").optional(),clientId:p.any().describe("Guided helper: Google Analytics client ID of the web stream, the one your Google tag sets, for all events").optional(),appInstanceId:p.any().describe("Guided helper: GA4 app instance ID (Firebase) for all events (like 'user.appInstanceId')").optional(),sessionAttributes:p.any().describe("Guided helper: Privacy-safe attribution for all events (like 'context.sessionAttributes')").optional(),consentAdUserData:p.union([p.string(),p.boolean()]).describe("Consent mapping: Field name from event.consent (like 'marketing') or static boolean value").optional(),consentAdPersonalization:p.union([p.string(),p.boolean()]).describe("Consent mapping: Field name from event.consent (like 'targeting') or static boolean value").optional(),ip:m.describe('Client IP, sent as eventDeviceInfo.ipAddress. Resolves against { ingest, event }. Filled by default only when an entry is GOOGLE_ADS, from ["ingest.ip", "event.user.ip"]; a Google Analytics-only step sends none unless this is set or ipAddress is mapped. false switches it off. A mapped ipAddress wins.').optional(),userAgent:m.describe('Client user agent, sent as eventDeviceInfo.userAgent. Resolves against { ingest, event }. Filled by default only when an entry is GOOGLE_ADS, from ["ingest.userAgent", "event.user.userAgent"]; a Google Analytics-only step sends none unless this is set or userAgent is mapped. false switches it off. A mapped userAgent wins.').optional()}).strict();import{z as f}from"@walkeros/core/dev";var h=f.object({});import{zodToSchema as b}from"@walkeros/core/dev";var y=b(v),A=b(h),I={};a(I,{env:()=>E,minimal:()=>C,step:()=>O});var E={};a(E,{push:()=>D,simulation:()=>G});var D={sendServer:async function(){return{data:{requestId:"mock-request-id"}}},authClient:{getRequestHeaders:async()=>new Headers({authorization:"Bearer ya29.c.test_token"})}},G=["sendServer"],O={};a(O,{lead:()=>k,orderWithoutTransactionId:()=>q,purchase:()=>T,quotaExhausted:()=>x,refusedRequest:()=>M,silentRule:()=>P});import{createEvent as S,getEvent as R}from"@walkeros/core";var _="https://datamanager.googleapis.com/v1/events:ingest",w=[{operatingAccount:{accountId:"1234567890",accountType:"GOOGLE_ADS"},productDestinationId:"987654321"}],N={headers:{authorization:"Bearer ya29.c.test_token"},timeout:1e4},T={title:"Purchase",description:"A completed order is posted to Google Data Manager as a purchase conversion with hashed user identifiers.",in:R("order complete",{id:"ev-1700000900000",timestamp:17000009e5,data:{id:"ORD-600",value:149.99,currency:"EUR"},user:{id:"user-abc",email:"buyer@example.com"},source:{type:"express",platform:"server"}}),mapping:{name:"purchase",data:{map:{transactionId:"data.id",conversionValue:"data.value",currency:{key:"data.currency",value:"USD"},eventName:{value:"purchase"},userId:"user.id",email:"user.email"}}},out:[["sendServer",_,JSON.stringify({events:[{eventTimestamp:"2023-11-14T22:28:20.000Z",transactionId:"ORD-600",userId:"user-abc",userData:{userIdentifiers:[{emailAddress:"6a6c26195c3682faa816966af789717c3bfa834eee6c599d667d2b3429c27cfd"}]},conversionValue:149.99,currency:"EUR",eventName:"purchase",eventSource:"WEB"}],destinations:w,encoding:"HEX"}),N]]},k={title:"Lead",description:"A demo request form submission is sent to Data Manager as a generate_lead conversion with a hashed email.",in:S({name:"form submit",id:"ev-1700000901000",timestamp:1700000901e3,data:{type:"demo-request"},user:{email:"prospect@example.com"},source:{type:"express",platform:"server"}}),mapping:{name:"generate_lead",data:{map:{transactionId:"id",eventName:{value:"generate_lead"},conversionValue:{value:10},currency:{value:"USD"},email:"user.email"}}},out:[["sendServer",_,JSON.stringify({events:[{eventTimestamp:"2023-11-14T22:28:21.000Z",transactionId:"ev-1700000901000",userData:{userIdentifiers:[{emailAddress:"395ec5f334be0ab5b28568a1e7f6ed5ea80e443fb1ce3d803340586a3df46642"}]},conversionValue:10,currency:"USD",eventName:"generate_lead",eventSource:"WEB"}],destinations:w,encoding:"HEX"}),N]]},P={public:!1,description:"A rule with silent: true sends no request to the Data Manager API.",in:R("page view",{timestamp:170000099e4}),mapping:{silent:!0},out:[]},q={public:!1,description:"An order complete event without a transaction id cannot be sent for a Google Ads destination: the push fails with missing-input instead of counting as delivered.",in:{name:"order complete",entity:"order",action:"complete",timestamp:1700000991e3},out:[],outcome:{status:"failed",code:"missing-input",retryable:!1}},M={public:!1,description:"Google refuses the request, for example a customer ID with hyphens: the push fails, is not retried, and the ERROR line names Google's reason and field.",in:T.in,mapping:T.mapping,respond:{status:400,body:{error:{code:400,message:"Request contains an invalid argument.",status:"INVALID_ARGUMENT",details:[{"@type":"type.googleapis.com/google.rpc.BadRequest",fieldViolations:[{field:"destinations[0].login_account.account_id",description:"String is not a valid number.",reason:"INVALID_NUMBER_FORMAT"}]}]}}},outcome:{status:"failed",code:"transport",retryable:!1}},x={public:!1,description:"Google's per-minute quota for the project is used up: the push fails and may be redelivered; the ERROR line names the quota.",in:T.in,mapping:T.mapping,respond:{status:429,body:{error:{code:429,status:"RESOURCE_EXHAUSTED",details:[{"@type":"type.googleapis.com/google.rpc.ErrorInfo",reason:"RATE_LIMIT_EXCEEDED",metadata:{quota_limit:"IngestionMutateRequestsPerMinutePerProject"}}]}}},outcome:{status:"failed",code:"transport",retryable:!0}},C={settings:{destinations:[{operatingAccount:{accountId:"1234567890",accountType:"GOOGLE_ADS"},productDestinationId:"987654321"}]}};export{I as examples,n as schemas};//# sourceMappingURL=dev.mjs.map
package/dist/dev.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schemas.ts","../src/schemas/primitives.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/schemas/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/minimal.ts"],"sourcesContent":["// Browser-safe schema-only exports\n// This file exports ONLY schemas without any Node.js dependencies\nexport { settings, mapping } from './schemas/index';\n","import { z } from '@walkeros/core/dev';\n\nexport const AccountTypeSchema = z.enum([\n 'GOOGLE_ADS',\n 'DISPLAY_VIDEO_ADVERTISER',\n 'DISPLAY_VIDEO_PARTNER',\n 'GOOGLE_ANALYTICS_PROPERTY',\n]);\n\nexport const EventSourceSchema = z.enum([\n 'WEB',\n 'APP',\n 'IN_STORE',\n 'PHONE',\n 'OTHER',\n]);\n\nexport const ConsentStatusSchema = z.enum([\n 'CONSENT_GRANTED',\n 'CONSENT_DENIED',\n]);\n\nexport const ConsentSchema = z.object({\n adUserData: ConsentStatusSchema.describe(\n 'Consent for data collection and use',\n ).optional(),\n adPersonalization: ConsentStatusSchema.describe(\n 'Consent for ad personalization',\n ).optional(),\n});\n\nexport const OperatingAccountSchema = z.object({\n accountId: z\n .string()\n .min(1)\n .describe('Account ID (e.g., \"123-456-7890\" for Google Ads)'),\n accountType: AccountTypeSchema.describe('Type of account'),\n});\n\nexport const DestinationSchema = z.object({\n operatingAccount: OperatingAccountSchema.describe(\n 'Operating account details',\n ),\n productDestinationId: z\n .string()\n .min(1)\n .describe('Product-specific destination ID, like a conversion action ID'),\n});\n","import { schemas, z } from '@walkeros/core/dev';\nimport {\n DestinationSchema,\n EventSourceSchema,\n ConsentSchema,\n} from './primitives';\n\nconst InputSchema = z.union([\n schemas.MappingSchemas.ValueSchema,\n z.literal(false),\n]);\n\n/**\n * Service account credentials schema\n */\nconst CredentialsSchema = z.object({\n client_email: z.string().email().describe('Service account email'),\n private_key: z\n .string()\n .min(1)\n .describe('Service account private key (PEM format)'),\n});\n\nexport const SettingsSchema = z\n .object({\n credentials: CredentialsSchema.optional().describe(\n 'Service account credentials (client_email + private_key). Prefer config.credentials; set here, they are used and the destination logs a WARN line.',\n ),\n keyFilename: z\n .string()\n .optional()\n .describe(\n 'Path to service account JSON file. For local development or environments with filesystem access.',\n ),\n scopes: z\n .array(z.string())\n .optional()\n .describe(\n 'OAuth scopes for Data Manager API. Defaults to datamanager scope.',\n ),\n destinations: z\n .array(DestinationSchema)\n .min(1)\n .max(10)\n .describe(\n 'Array of destination accounts and conversion actions (max 10)',\n ),\n eventSource: EventSourceSchema.optional()\n .default('WEB')\n .describe(\n 'Event source for all events. Defaults to WEB. Values: WEB, APP, IN_STORE, PHONE, OTHER',\n ),\n batchSize: z\n .number()\n .int()\n .min(1)\n .max(2000)\n .describe(\n 'Has no effect: every event is sent in its own request (accepts 1 to 2000)',\n )\n .optional(),\n batchInterval: z\n .number()\n .int()\n .min(0)\n .describe(\n 'Has no effect: every event is sent in its own request (accepts milliseconds, like 5000)',\n )\n .optional(),\n validateOnly: z\n .boolean()\n .describe('If true, validate request without ingestion (testing mode)')\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Override API endpoint for testing (like https://datamanager.googleapis.com/v1)',\n )\n .optional(),\n consent: ConsentSchema.describe(\n 'Request-level consent, sent with every request and applied to each event that carries no consent of its own',\n ).optional(),\n testEventCode: z\n .string()\n .describe('Test event code for debugging (like TEST12345)')\n .optional(),\n userData: z\n .record(z.string(), z.unknown())\n .describe(\n \"Guided helper: User data mapping for all events (like { email: 'user.email', phone: 'data.phone' })\",\n )\n .optional(),\n userId: z\n .any()\n .describe(\n \"Guided helper: First-party user ID for all events (like 'user.id')\",\n )\n .optional(),\n clientId: z\n .any()\n .describe(\n \"Guided helper: GA4 client ID for all events (like 'user.device')\",\n )\n .optional(),\n appInstanceId: z\n .any()\n .describe(\n \"Guided helper: GA4 app instance ID (Firebase) for all events (like 'user.appInstanceId')\",\n )\n .optional(),\n sessionAttributes: z\n .any()\n .describe(\n \"Guided helper: Privacy-safe attribution for all events (like 'context.sessionAttributes')\",\n )\n .optional(),\n consentAdUserData: z\n .union([z.string(), z.boolean()])\n .describe(\n \"Consent mapping: Field name from event.consent (like 'marketing') or static boolean value\",\n )\n .optional(),\n consentAdPersonalization: z\n .union([z.string(), z.boolean()])\n .describe(\n \"Consent mapping: Field name from event.consent (like 'targeting') or static boolean value\",\n )\n .optional(),\n ip: InputSchema.describe(\n 'Client IP, sent as eventDeviceInfo.ipAddress. Resolves against { ingest, event }. Default: [\"ingest.ip\", \"event.user.ip\"]. false switches it off. A mapped ipAddress wins.',\n ).optional(),\n userAgent: InputSchema.describe(\n 'Client user agent, sent as eventDeviceInfo.userAgent. Resolves against { ingest, event }. Default: [\"ingest.userAgent\", \"event.user.userAgent\"]. false switches it off. A mapped userAgent wins.',\n ).optional(),\n })\n .strict();\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n// Data Manager uses flexible mapping via walkerOS mapping system\n// No event-specific mapping schema needed (similar to Meta CAPI pattern)\nexport const MappingSchema = z.object({});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * from './primitives';\nexport * from './settings';\nexport * from './mapping';\n\nimport { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","export * as env from './env';\nexport * as step from './step';\nexport { minimal } from './minimal';\n","import type { AuthClient, Env } from '../types';\n\n/**\n * Example environment configurations for Google Data Manager destination.\n *\n * The destination invokes `env.fetch(url, { method, headers, body })` once\n * per push, with `Authorization: Bearer <accessToken>` obtained from\n * `env.authClient` via `getAccessToken`.\n *\n * For tests we use a stub `authClient` (jest mocks the `getAccessToken`\n * helper at module level) and a mock `fetch` returning a successful ingest\n * response.\n */\n\nasync function mockFetch(): Promise<Response> {\n return new Response(\n JSON.stringify({ requestId: 'mock-request-id', validationErrors: [] }),\n { status: 200, headers: { 'Content-Type': 'application/json' } },\n );\n}\n\nconst mockAuthClient: AuthClient = {\n getAccessToken: async () => ({ token: 'ya29.c.test_token' }),\n};\n\nexport const push: Env = {\n fetch: mockFetch,\n authClient: mockAuthClient,\n};\n\nexport const simulation = ['fetch'];\n","import type { Flow } from '@walkeros/core';\nimport { createEvent, getEvent } from '@walkeros/core';\n\n/**\n * Google Data Manager step examples.\n *\n * At push time, the destination calls\n * `env.fetch(url, { method, headers, body })` where:\n * - `url` is `${settings.url}/events:ingest` (default\n * `https://datamanager.googleapis.com/v1`)\n * - `method` is `'POST'`\n * - `headers` is `{ Authorization: 'Bearer <accessToken>', 'Content-Type': 'application/json' }`\n * - `body` is the JSON-stringified `{ events: [dataManagerEvent], destinations }` payload\n *\n * The access token is obtained from `env.authClient` via `getAccessToken`.\n * The test fixture mocks both so the captured Authorization header is stable\n * (`Bearer ya29.c.test_token`).\n *\n * Event fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * eventTimestamp, transactionId?, clientId?, userId?, userData?,\n * adIdentifiers?, conversionValue?, currency?, cartData?, eventName?,\n * [eventSource is appended last by push.ts when not already present].\n *\n * Emails are normalized (trim, lowercase, strip dots for Gmail) and hashed\n * with SHA-256.\n */\nconst ENDPOINT = 'https://datamanager.googleapis.com/v1/events:ingest';\nconst DESTINATIONS = [\n {\n operatingAccount: {\n accountId: '123-456-7890',\n accountType: 'GOOGLE_ADS',\n },\n productDestinationId: 'AW-CONVERSION-123',\n },\n];\nconst INIT_OPTIONS = (body: string) => ({\n method: 'POST',\n headers: {\n Authorization: 'Bearer ya29.c.test_token',\n 'Content-Type': 'application/json',\n },\n body,\n});\n\nexport const purchase: Flow.StepExample = {\n title: 'Purchase',\n description:\n 'A completed order is posted to Google Data Manager as a purchase conversion with hashed user identifiers.',\n in: getEvent('order complete', {\n id: 'ev-1700000900000',\n timestamp: 1700000900000,\n data: { id: 'ORD-600', value: 149.99, currency: 'EUR' },\n user: { id: 'user-abc', email: 'buyer@example.com' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n name: 'purchase',\n data: {\n map: {\n transactionId: 'data.id',\n conversionValue: 'data.value',\n currency: { key: 'data.currency', value: 'USD' },\n eventName: { value: 'purchase' },\n userId: 'user.id',\n email: 'user.email',\n },\n },\n },\n out: [\n [\n 'fetch',\n ENDPOINT,\n INIT_OPTIONS(\n JSON.stringify({\n events: [\n {\n eventTimestamp: '2023-11-14T22:28:20.000Z',\n transactionId: 'ORD-600',\n userId: 'user-abc',\n userData: {\n userIdentifiers: [\n {\n // sha256('buyer@example.com')\n emailAddress:\n '6a6c26195c3682faa816966af789717c3bfa834eee6c599d667d2b3429c27cfd',\n },\n ],\n },\n conversionValue: 149.99,\n currency: 'EUR',\n eventName: 'purchase',\n eventSource: 'WEB',\n },\n ],\n destinations: DESTINATIONS,\n encoding: 'HEX',\n }),\n ),\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Lead',\n description:\n 'A demo request form submission is sent to Data Manager as a generate_lead conversion with a hashed email.',\n in: createEvent({\n name: 'form submit',\n id: 'ev-1700000901000',\n timestamp: 1700000901000,\n data: { type: 'demo-request' },\n user: { email: 'prospect@example.com' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n name: 'generate_lead',\n data: {\n map: {\n transactionId: 'id',\n eventName: { value: 'generate_lead' },\n conversionValue: { value: 10 },\n currency: { value: 'USD' },\n email: 'user.email',\n },\n },\n },\n out: [\n [\n 'fetch',\n ENDPOINT,\n INIT_OPTIONS(\n JSON.stringify({\n events: [\n {\n eventTimestamp: '2023-11-14T22:28:21.000Z',\n transactionId: 'ev-1700000901000',\n userData: {\n userIdentifiers: [\n {\n // sha256('prospect@example.com')\n emailAddress:\n '395ec5f334be0ab5b28568a1e7f6ed5ea80e443fb1ce3d803340586a3df46642',\n },\n ],\n },\n conversionValue: 10,\n currency: 'USD',\n eventName: 'generate_lead',\n eventSource: 'WEB',\n },\n ],\n destinations: DESTINATIONS,\n encoding: 'HEX',\n }),\n ),\n ],\n ],\n};\n\nexport const ga4PageView: Flow.StepExample = {\n title: 'Page view',\n description:\n 'A page view is sent to Data Manager as a page_view event tied to the walker user id.',\n in: getEvent('page view', {\n id: 'ev-1700000902000',\n timestamp: 1700000902000,\n data: { title: 'Pricing', url: 'https://example.com/pricing' },\n user: { id: 'visitor-55' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n name: 'page_view',\n data: {\n map: {\n transactionId: 'id',\n eventName: { value: 'page_view' },\n userId: 'user.id',\n },\n },\n },\n out: [\n [\n 'fetch',\n ENDPOINT,\n INIT_OPTIONS(\n JSON.stringify({\n events: [\n {\n eventTimestamp: '2023-11-14T22:28:22.000Z',\n transactionId: 'ev-1700000902000',\n userId: 'visitor-55',\n eventName: 'page_view',\n eventSource: 'WEB',\n },\n ],\n destinations: DESTINATIONS,\n encoding: 'HEX',\n }),\n ),\n ],\n ],\n};\n\n/** A silent rule sends nothing to the Data Manager API. */\nexport const silentRule: Flow.StepExample = {\n public: false,\n description:\n 'A rule with silent: true sends no request to the Data Manager API.',\n in: getEvent('page view', { timestamp: 1700000990000 }),\n mapping: { silent: true },\n out: [],\n};\n\n/**\n * No transaction id -- an order complete event without data has no\n * transactionId, which Data Manager requires, so the push fails with\n * missing-input instead of counting as delivered.\n */\nexport const orderWithoutTransactionId: Flow.StepExample = {\n public: false,\n description:\n 'An order complete event without a transaction id cannot be sent to the Data Manager API: the push fails with missing-input instead of counting as delivered.',\n in: {\n name: 'order complete',\n entity: 'order',\n action: 'complete',\n timestamp: 1700000991000,\n },\n out: [],\n outcome: { status: 'failed', code: 'missing-input', retryable: false },\n};\n","import type { Flow } from '@walkeros/core';\n\n/**\n * The setting the Data Manager API needs to deliver: one destination\n * account with its conversion action. Authentication comes from the\n * environment's Google credentials.\n */\nexport const minimal: Flow.MinimalExample = {\n settings: {\n destinations: [\n {\n operatingAccount: {\n accountId: '123-456-7890',\n accountType: 'GOOGLE_ADS',\n },\n productDestinationId: 'AW-CONVERSION-123',\n },\n ],\n },\n};\n"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,SAAS,SAAS;AAEX,IAAM,oBAAoB,EAAE,KAAK;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,oBAAoB,EAAE,KAAK;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,sBAAsB,EAAE,KAAK;AAAA,EACxC;AAAA,EACA;AACF,CAAC;AAEM,IAAM,gBAAgB,EAAE,OAAO;AAAA,EACpC,YAAY,oBAAoB;AAAA,IAC9B;AAAA,EACF,EAAE,SAAS;AAAA,EACX,mBAAmB,oBAAoB;AAAA,IACrC;AAAA,EACF,EAAE,SAAS;AACb,CAAC;AAEM,IAAM,yBAAyB,EAAE,OAAO;AAAA,EAC7C,WAAW,EACR,OAAO,EACP,IAAI,CAAC,EACL,SAAS,kDAAkD;AAAA,EAC9D,aAAa,kBAAkB,SAAS,iBAAiB;AAC3D,CAAC;AAEM,IAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,kBAAkB,uBAAuB;AAAA,IACvC;AAAA,EACF;AAAA,EACA,sBAAsB,EACnB,OAAO,E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EAC1C,UAAU;AAAA,IACR,cAAc;AAAA,MACZ;AAAA,QACE,kBAAkB;AAAA,UAChB,WAAW;AAAA,UACX,aAAa;AAAA,QACf;AAAA,QACA,sBAAsB;AAAA,MACxB;AAAA,IACF;AAAA,EACF;AACF;","names":["z","z","z"]}
1
+ {"version":3,"sources":["../src/schemas.ts","../src/schemas/primitives.ts","../src/constants.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/schemas/index.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts","../src/examples/minimal.ts"],"sourcesContent":["// Browser-safe schema-only exports\n// This file exports ONLY schemas without any Node.js dependencies\nexport { settings, mapping } from './schemas/index';\n","import { z } from '@walkeros/core/dev';\nimport { EVENT_SOURCES } from '../constants';\n\nexport const AccountTypeSchema = z.enum([\n 'GOOGLE_ADS',\n 'GOOGLE_ANALYTICS_PROPERTY',\n]);\n\nexport const EventSourceSchema = z.enum(EVENT_SOURCES);\n\nexport const ConsentStatusSchema = z.enum([\n 'CONSENT_GRANTED',\n 'CONSENT_DENIED',\n]);\n\nexport const ConsentSchema = z.object({\n adUserData: ConsentStatusSchema.describe(\n 'Consent for data collection and use',\n ).optional(),\n adPersonalization: ConsentStatusSchema.describe(\n 'Consent for ad personalization',\n ).optional(),\n});\n\nexport const OperatingAccountSchema = z.object({\n accountId: z\n .string()\n .regex(/^\\d+$/)\n .describe(\n 'Numeric account ID: the 10-digit Google Ads customer ID without hyphens, or the Google Analytics property ID',\n ),\n accountType: AccountTypeSchema.describe('Type of account'),\n});\n\nexport const DestinationSchema = z.object({\n operatingAccount: OperatingAccountSchema.describe(\n 'Operating account details',\n ),\n loginAccount: OperatingAccountSchema.optional().describe(\n 'Account the credentials belong to, when it is not the operating account: a Google Ads manager account above it',\n ),\n productDestinationId: z\n .string()\n .min(1)\n .describe(\n 'Numeric Google Ads conversion action ID; for Google Analytics, the measurement ID (G-...) of a web stream or the Firebase App ID of an app stream',\n ),\n});\n","/**\n * The values and keys Google's Data Manager API takes. The settings schema,\n * the types and format.ts derive from these lists, so each is defined once.\n * https://developers.google.com/data-manager/api/reference/rest/v1/Event\n */\n\n/** Google's EventSource values. */\nexport const EVENT_SOURCES = [\n 'WEB',\n 'APP',\n 'IN_STORE',\n 'PHONE',\n 'MESSAGE',\n 'OTHER',\n] as const;\n\n/** The mapped keys this destination sends; any other key is reported. */\nexport const KNOWN_KEYS = [\n 'transactionId',\n 'clientId',\n 'userId',\n 'email',\n 'phone',\n 'firstName',\n 'lastName',\n 'regionCode',\n 'postalCode',\n 'gclid',\n 'gbraid',\n 'wbraid',\n 'sessionAttributes',\n 'conversionValue',\n 'currency',\n 'cartData',\n 'eventName',\n 'appInstanceId',\n 'storeId',\n 'ipAddress',\n 'userAgent',\n 'eventSource',\n 'adUserData',\n 'adPersonalization',\n] as const;\n\n/** Google's CartData fields. */\nexport const CART_DATA_KEYS = [\n 'merchantId',\n 'merchantFeedLabel',\n 'merchantFeedLanguageCode',\n 'transactionDiscount',\n 'items',\n 'couponCodes',\n] as const;\n\n/** Google's Item fields. */\nexport const CART_ITEM_KEYS = [\n 'merchantProductId',\n 'quantity',\n 'unitPrice',\n 'itemId',\n 'additionalItemParameters',\n 'merchantId',\n 'merchantFeedLabel',\n 'merchantFeedLanguageCode',\n 'customVariables',\n 'conversionValue',\n] as const;\n","import { schemas, z } from '@walkeros/core/dev';\nimport {\n DestinationSchema,\n EventSourceSchema,\n ConsentSchema,\n} from './primitives';\n\nconst InputSchema = z.union([\n schemas.MappingSchemas.ValueSchema,\n z.literal(false),\n]);\n\n/**\n * Service account credentials schema\n */\nconst CredentialsSchema = z.object({\n client_email: z.string().email().describe('Service account email'),\n private_key: z\n .string()\n .min(1)\n .describe('Service account private key (PEM format)'),\n});\n\nexport const SettingsSchema = z\n .object({\n credentials: CredentialsSchema.optional().describe(\n 'Service account credentials (client_email + private_key). Prefer config.credentials; set here, they are used and the destination logs a WARN line.',\n ),\n keyFilename: z\n .string()\n .optional()\n .describe('Absolute path to a service account JSON file'),\n scopes: z\n .array(z.string())\n .optional()\n .describe(\n 'OAuth scopes for Data Manager API. Defaults to datamanager scope.',\n ),\n destinations: z\n .array(DestinationSchema)\n .min(1)\n .max(10)\n .describe(\n 'Destination accounts and conversion actions (max 10); every event goes to every entry',\n ),\n eventSource: EventSourceSchema.optional()\n .default('WEB')\n .describe(\n 'Event source for all events. Defaults to WEB. Values: WEB, APP, IN_STORE, PHONE, MESSAGE, OTHER',\n ),\n validateOnly: z\n .boolean()\n .describe('If true, validate request without ingestion (testing mode)')\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Override API endpoint for testing (like https://datamanager.googleapis.com/v1)',\n )\n .optional(),\n consent: ConsentSchema.describe(\n 'Request-level consent, sent with every request and applied to each event that carries no consent of its own',\n ).optional(),\n userData: z\n .record(z.string(), z.unknown())\n .describe(\n \"Guided helper: User data mapping for all events (like { email: 'user.email', phone: 'data.phone' })\",\n )\n .optional(),\n userId: z\n .any()\n .describe(\n \"Guided helper: First-party user ID for all events (like 'user.id')\",\n )\n .optional(),\n clientId: z\n .any()\n .describe(\n 'Guided helper: Google Analytics client ID of the web stream, the one your Google tag sets, for all events',\n )\n .optional(),\n appInstanceId: z\n .any()\n .describe(\n \"Guided helper: GA4 app instance ID (Firebase) for all events (like 'user.appInstanceId')\",\n )\n .optional(),\n sessionAttributes: z\n .any()\n .describe(\n \"Guided helper: Privacy-safe attribution for all events (like 'context.sessionAttributes')\",\n )\n .optional(),\n consentAdUserData: z\n .union([z.string(), z.boolean()])\n .describe(\n \"Consent mapping: Field name from event.consent (like 'marketing') or static boolean value\",\n )\n .optional(),\n consentAdPersonalization: z\n .union([z.string(), z.boolean()])\n .describe(\n \"Consent mapping: Field name from event.consent (like 'targeting') or static boolean value\",\n )\n .optional(),\n ip: InputSchema.describe(\n 'Client IP, sent as eventDeviceInfo.ipAddress. Resolves against { ingest, event }. Filled by default only when an entry is GOOGLE_ADS, from [\"ingest.ip\", \"event.user.ip\"]; a Google Analytics-only step sends none unless this is set or ipAddress is mapped. false switches it off. A mapped ipAddress wins.',\n ).optional(),\n userAgent: InputSchema.describe(\n 'Client user agent, sent as eventDeviceInfo.userAgent. Resolves against { ingest, event }. Filled by default only when an entry is GOOGLE_ADS, from [\"ingest.userAgent\", \"event.user.userAgent\"]; a Google Analytics-only step sends none unless this is set or userAgent is mapped. false switches it off. A mapped userAgent wins.',\n ).optional(),\n })\n .strict();\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n// Data Manager uses flexible mapping via walkerOS mapping system\n// No event-specific mapping schema needed (similar to Meta CAPI pattern)\nexport const MappingSchema = z.object({});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * from './primitives';\nexport * from './settings';\nexport * from './mapping';\n\nimport { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","export * as env from './env';\nexport * as step from './step';\nexport { minimal } from './minimal';\n","import type { SendResponse } from '@walkeros/core';\nimport type { AuthClient, Env } from '../types';\n\n/**\n * Example environment configurations for Google Data Manager destination.\n *\n * The destination calls `env.sendServer(url, body, { headers, timeout })`\n * once per push, with the headers `env.authClient.getRequestHeaders()`\n * returns (an `authorization` header with the access token).\n *\n * For tests we use a stub `authClient` with a fixed token and a mock\n * `sendServer` returning a successful ingest answer.\n */\n\nasync function mockSendServer(): Promise<SendResponse> {\n return { data: { requestId: 'mock-request-id' } };\n}\n\nconst mockAuthClient: AuthClient = {\n getRequestHeaders: async () =>\n new Headers({ authorization: 'Bearer ya29.c.test_token' }),\n};\n\nexport const push: Env = {\n sendServer: mockSendServer,\n authClient: mockAuthClient,\n};\n\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { createEvent, getEvent } from '@walkeros/core';\n\n/**\n * Google Data Manager step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(url, body, { headers, timeout })` where:\n * - `url` is `${settings.url}/events:ingest` (default\n * `https://datamanager.googleapis.com/v1`)\n * - `body` is the JSON-stringified `{ events: [dataManagerEvent], destinations }` payload\n * - `headers` are the ones `env.authClient.getRequestHeaders()` returns,\n * as a plain object (`sendServer` posts and adds the JSON content type)\n * - `timeout` is the destination's `config.timeout`, or the collector's\n * default of 10000 ms\n *\n * The example env's auth client answers a fixed token, so the captured\n * header is stable (`authorization: 'Bearer ya29.c.test_token'`).\n *\n * Event fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * eventTimestamp, transactionId?, clientId?, userId?, userData?,\n * adIdentifiers?, conversionValue?, currency?, cartData?, eventName?,\n * [eventSource is appended last by push.ts when not already present].\n *\n * Emails are normalized (whitespace removed, lowercase; gmail.com and\n * googlemail.com addresses drop their dots and their +alias) and hashed\n * with SHA-256. A value that already is a SHA-256 digest passes lowercased,\n * not hashed again.\n */\nconst ENDPOINT = 'https://datamanager.googleapis.com/v1/events:ingest';\nconst DESTINATIONS = [\n {\n operatingAccount: {\n accountId: '1234567890',\n accountType: 'GOOGLE_ADS',\n },\n productDestinationId: '987654321',\n },\n];\nconst SEND_OPTIONS = {\n headers: { authorization: 'Bearer ya29.c.test_token' },\n timeout: 10000,\n};\n\nexport const purchase: Flow.StepExample = {\n title: 'Purchase',\n description:\n 'A completed order is posted to Google Data Manager as a purchase conversion with hashed user identifiers.',\n in: getEvent('order complete', {\n id: 'ev-1700000900000',\n timestamp: 1700000900000,\n data: { id: 'ORD-600', value: 149.99, currency: 'EUR' },\n user: { id: 'user-abc', email: 'buyer@example.com' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n name: 'purchase',\n data: {\n map: {\n transactionId: 'data.id',\n conversionValue: 'data.value',\n currency: { key: 'data.currency', value: 'USD' },\n eventName: { value: 'purchase' },\n userId: 'user.id',\n email: 'user.email',\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n eventTimestamp: '2023-11-14T22:28:20.000Z',\n transactionId: 'ORD-600',\n userId: 'user-abc',\n userData: {\n userIdentifiers: [\n {\n // sha256('buyer@example.com')\n emailAddress:\n '6a6c26195c3682faa816966af789717c3bfa834eee6c599d667d2b3429c27cfd',\n },\n ],\n },\n conversionValue: 149.99,\n currency: 'EUR',\n eventName: 'purchase',\n eventSource: 'WEB',\n },\n ],\n destinations: DESTINATIONS,\n encoding: 'HEX',\n }),\n SEND_OPTIONS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Lead',\n description:\n 'A demo request form submission is sent to Data Manager as a generate_lead conversion with a hashed email.',\n in: createEvent({\n name: 'form submit',\n id: 'ev-1700000901000',\n timestamp: 1700000901000,\n data: { type: 'demo-request' },\n user: { email: 'prospect@example.com' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n name: 'generate_lead',\n data: {\n map: {\n transactionId: 'id',\n eventName: { value: 'generate_lead' },\n conversionValue: { value: 10 },\n currency: { value: 'USD' },\n email: 'user.email',\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n eventTimestamp: '2023-11-14T22:28:21.000Z',\n transactionId: 'ev-1700000901000',\n userData: {\n userIdentifiers: [\n {\n // sha256('prospect@example.com')\n emailAddress:\n '395ec5f334be0ab5b28568a1e7f6ed5ea80e443fb1ce3d803340586a3df46642',\n },\n ],\n },\n conversionValue: 10,\n currency: 'USD',\n eventName: 'generate_lead',\n eventSource: 'WEB',\n },\n ],\n destinations: DESTINATIONS,\n encoding: 'HEX',\n }),\n SEND_OPTIONS,\n ],\n ],\n};\n\n/** A silent rule sends nothing to the Data Manager API. */\nexport const silentRule: Flow.StepExample = {\n public: false,\n description:\n 'A rule with silent: true sends no request to the Data Manager API.',\n in: getEvent('page view', { timestamp: 1700000990000 }),\n mapping: { silent: true },\n out: [],\n};\n\n/**\n * No transaction id: an order complete event without data has no\n * transactionId, which a Google Ads destination requires, so the push fails\n * with missing-input instead of counting as delivered.\n */\nexport const orderWithoutTransactionId: Flow.StepExample = {\n public: false,\n description:\n 'An order complete event without a transaction id cannot be sent for a Google Ads destination: the push fails with missing-input instead of counting as delivered.',\n in: {\n name: 'order complete',\n entity: 'order',\n action: 'complete',\n timestamp: 1700000991000,\n },\n out: [],\n outcome: { status: 'failed', code: 'missing-input', retryable: false },\n};\n\n/** Google refuses the request: the answer names the reason and the field. */\nexport const refusedRequest: Flow.StepExample = {\n public: false,\n description:\n \"Google refuses the request, for example a customer ID with hyphens: the push fails, is not retried, and the ERROR line names Google's reason and field.\",\n in: purchase.in,\n mapping: purchase.mapping,\n respond: {\n status: 400,\n body: {\n error: {\n code: 400,\n message: 'Request contains an invalid argument.',\n status: 'INVALID_ARGUMENT',\n details: [\n {\n '@type': 'type.googleapis.com/google.rpc.BadRequest',\n fieldViolations: [\n {\n field: 'destinations[0].login_account.account_id',\n description: 'String is not a valid number.',\n reason: 'INVALID_NUMBER_FORMAT',\n },\n ],\n },\n ],\n },\n },\n },\n outcome: { status: 'failed', code: 'transport', retryable: false },\n};\n\n/** Google's documented 429 for the per-minute project quota. */\nexport const quotaExhausted: Flow.StepExample = {\n public: false,\n description:\n \"Google's per-minute quota for the project is used up: the push fails and may be redelivered; the ERROR line names the quota.\",\n in: purchase.in,\n mapping: purchase.mapping,\n respond: {\n status: 429,\n body: {\n error: {\n code: 429,\n status: 'RESOURCE_EXHAUSTED',\n details: [\n {\n '@type': 'type.googleapis.com/google.rpc.ErrorInfo',\n reason: 'RATE_LIMIT_EXCEEDED',\n metadata: {\n quota_limit: 'IngestionMutateRequestsPerMinutePerProject',\n },\n },\n ],\n },\n },\n },\n outcome: { status: 'failed', code: 'transport', retryable: true },\n};\n","import type { Flow } from '@walkeros/core';\n\n/**\n * The setting the Data Manager API needs to deliver: one destination\n * account with its conversion action. Authentication comes from the\n * environment's Google credentials.\n */\nexport const minimal: Flow.MinimalExample = {\n settings: {\n destinations: [\n {\n operatingAccount: {\n acc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