@walkeros/server-destination-meta 4.6.1 → 4.7.0-next-1790187973605
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 +25 -0
- package/README.md +9 -1
- package/dist/browser-schemas.js +1 -1
- package/dist/browser-schemas.js.map +1 -1
- package/dist/browser-schemas.mjs +1 -1
- package/dist/browser-schemas.mjs.map +1 -1
- package/dist/dev.d.mts +28 -1
- package/dist/dev.d.ts +28 -1
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.js +11 -12
- package/dist/examples/index.mjs +12 -13
- package/dist/index.d.mts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +196 -18
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @walkeros/server-destination-meta
|
|
2
2
|
|
|
3
|
+
## 4.7.0-next-1790187973605
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ef02916: Customer information is now normalized per Meta's rules before
|
|
8
|
+
hashing, so `" User@Example.com"` and `"user@example.com"` produce the same
|
|
9
|
+
hash. The earlier `user_data` hint showed `email` and `phone`, which were sent
|
|
10
|
+
to Meta unhashed: rename them to `em` and `ph`. Unknown keys in
|
|
11
|
+
`settings.user_data` are now rejected by `walkeros validate` and TypeScript.
|
|
12
|
+
Unknown keys from any source, mappings included, are dropped with a warning at
|
|
13
|
+
runtime. A `url` without a trailing slash also builds a valid endpoint.
|
|
14
|
+
- Updated dependencies [57788bc]
|
|
15
|
+
- Updated dependencies [f5a1cfd]
|
|
16
|
+
- Updated dependencies [ef02916]
|
|
17
|
+
- Updated dependencies [ef02916]
|
|
18
|
+
- Updated dependencies [2aebc53]
|
|
19
|
+
- Updated dependencies [f5a1cfd]
|
|
20
|
+
- Updated dependencies [f5a1cfd]
|
|
21
|
+
- Updated dependencies [2aebc53]
|
|
22
|
+
- Updated dependencies [8f8aea6]
|
|
23
|
+
- Updated dependencies [2aebc53]
|
|
24
|
+
- Updated dependencies [2aebc53]
|
|
25
|
+
- @walkeros/core@4.7.0-next-1790187973605
|
|
26
|
+
- @walkeros/server-core@4.7.0-next-1790187973605
|
|
27
|
+
|
|
3
28
|
## 4.6.1
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -30,7 +30,15 @@ npm install @walkeros/server-destination-meta
|
|
|
30
30
|
"default": {
|
|
31
31
|
"config": { "platform": "server" },
|
|
32
32
|
"destinations": {
|
|
33
|
-
"meta": {
|
|
33
|
+
"meta": {
|
|
34
|
+
"package": "@walkeros/server-destination-meta",
|
|
35
|
+
"config": {
|
|
36
|
+
"settings": {
|
|
37
|
+
"accessToken": "YOUR_ACCESS_TOKEN",
|
|
38
|
+
"pixelId": "1234567890"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
44
|
}
|
package/dist/browser-schemas.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,browser_schemas_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(browser_schemas_exports,{schemas:()=>
|
|
1
|
+
"use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,browser_schemas_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(browser_schemas_exports,{schemas:()=>schemas2}),module.exports=(mod=browser_schemas_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var import_dev4=require("@walkeros/core/dev"),import_dev2=require("@walkeros/core/dev"),import_dev=require("@walkeros/core/dev"),ActionSourceSchema=import_dev.z.enum(["email","website","app","phone_call","chat","physical_store","system_generated","business_messaging","other"]),SettingsSchema=(import_dev.z.union([import_dev.z.enum(["AddPaymentInfo","AddToCart","AddToWishlist","CompleteRegistration","Contact","CustomizeProduct","Donate","FindLocation","InitiateCheckout","Lead","Purchase","Schedule","Search","StartTrial","SubmitApplication","Subscribe","ViewContent"]),import_dev.z.string()]),import_dev2.z.object({accessToken:import_dev2.z.string().min(1).describe("Meta access token for Conversions API authentication (like your_access_token)"),pixelId:import_dev2.z.string().regex(/^[0-9]+$/,"Pixel ID must contain only digits").describe("Meta Pixel ID from your Facebook Business account (like 1234567890)"),action_source:ActionSourceSchema.describe("Source of the event (website, app, phone_call, etc.) (like website)").optional(),doNotHash:import_dev2.z.array(import_dev2.z.string()).describe("user_data keys to send without normalizing and hashing, for values that are already hashed. Only em, ph, fn, ln, db, ge, ct, st, zp, country and external_id are hashed (like ['external_id'])").optional(),test_event_code:import_dev2.z.string().describe("Test event code for debugging Meta Conversions API events (like TEST12345)").optional(),url:import_dev2.z.string().url().describe("Custom URL for Meta Conversions API endpoint (like https://graph.facebook.com/v22.0)").optional(),user_data:import_dev2.z.partialRecord(import_dev2.z.enum(["em","ph","fn","ln","db","ge","ct","st","zp","country","external_id","client_ip_address","client_user_agent","fbc","fbp","subscription_id","fb_login_id","lead_id","anon_id","madid","page_id","page_scoped_user_id","ctwa_clid","ig_account_id","ig_sid","fbclid"]),import_dev2.schemas.MappingSchemas.ValueSchema).describe("Mapping of Meta customer information parameters to event values, applied to every event. Keys must be Meta's short names such as em and ph (like { em: 'user.email', ph: 'user.phone' })").optional()})),MappingSchema=require("@walkeros/core/dev").z.object({}),schemas2={settings:(0,import_dev4.zodToSchema)(SettingsSchema),mapping:(0,import_dev4.zodToSchema)(MappingSchema)};//# sourceMappingURL=browser-schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/browser-schemas.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/primitives.ts","../src/schemas/mapping.ts"],"sourcesContent":["// Browser-safe schema-only exports\n// This file exports ONLY schemas without any Node.js dependencies\nimport { settings, mapping } from './schemas';\n\nexport const schemas = {\n settings,\n mapping,\n};\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport * from './primitives';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\nimport { ActionSourceSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n accessToken: z\n .string()\n .min(1)\n .describe(\n 'Meta access token for Conversions API authentication (like your_access_token)',\n ),\n pixelId: z\n .string()\n .regex(/^[0-9]+$/, 'Pixel ID must contain only digits')\n .describe(\n 'Meta Pixel ID from your Facebook Business account (like 1234567890)',\n ),\n action_source: ActionSourceSchema.describe(\n 'Source of the event (website, app, phone_call, etc.) (like website)',\n ).optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"
|
|
1
|
+
{"version":3,"sources":["../src/browser-schemas.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/userData.ts","../src/schemas/primitives.ts","../src/schemas/mapping.ts"],"sourcesContent":["// Browser-safe schema-only exports\n// This file exports ONLY schemas without any Node.js dependencies\nimport { settings, mapping } from './schemas';\n\nexport const schemas = {\n settings,\n mapping,\n};\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport * from './primitives';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { schemas, z } from '@walkeros/core/dev';\nimport { userDataKeys } from '../userData';\nimport { ActionSourceSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n accessToken: z\n .string()\n .min(1)\n .describe(\n 'Meta access token for Conversions API authentication (like your_access_token)',\n ),\n pixelId: z\n .string()\n .regex(/^[0-9]+$/, 'Pixel ID must contain only digits')\n .describe(\n 'Meta Pixel ID from your Facebook Business account (like 1234567890)',\n ),\n action_source: ActionSourceSchema.describe(\n 'Source of the event (website, app, phone_call, etc.) (like website)',\n ).optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"user_data keys to send without normalizing and hashing, for values that are already hashed. Only em, ph, fn, ln, db, ge, ct, st, zp, country and external_id are hashed (like ['external_id'])\",\n )\n .optional(),\n test_event_code: z\n .string()\n .describe(\n 'Test event code for debugging Meta Conversions API events (like TEST12345)',\n )\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Custom URL for Meta Conversions API endpoint (like https://graph.facebook.com/v22.0)',\n )\n .optional(),\n user_data: z\n .partialRecord(z.enum(userDataKeys), schemas.MappingSchemas.ValueSchema)\n .describe(\n \"Mapping of Meta customer information parameters to event values, applied to every event. Keys must be Meta's short names such as em and ph (like { em: 'user.email', ph: 'user.phone' })\",\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","// Customer information parameters accepted in user_data:\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters\n// fbclid is not sent; the destination turns it into fbc.\nexport const userDataKeys = [\n 'em',\n 'ph',\n 'fn',\n 'ln',\n 'db',\n 'ge',\n 'ct',\n 'st',\n 'zp',\n 'country',\n 'external_id',\n 'client_ip_address',\n 'client_user_agent',\n 'fbc',\n 'fbp',\n 'subscription_id',\n 'fb_login_id',\n 'lead_id',\n 'anon_id',\n 'madid',\n 'page_id',\n 'page_scoped_user_id',\n 'ctwa_clid',\n 'ig_account_id',\n 'ig_sid',\n 'fbclid',\n] as const;\n\nexport function getUnknownUserDataKeys(userData: object): string[] {\n const known: readonly string[] = userDataKeys;\n return Object.keys(userData).filter((key) => !known.includes(key));\n}\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Action Source Enum\n * Where the conversion event took place\n * https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/server-event\n */\nexport const ActionSourceSchema = z.enum([\n 'email',\n 'website',\n 'app',\n 'phone_call',\n 'chat',\n 'physical_store',\n 'system_generated',\n 'business_messaging',\n 'other',\n]);\n\n/**\n * Event Name\n * Standard Meta event names or custom event identifiers\n */\nexport const EventNameSchema = z.union([\n z.enum([\n 'AddPaymentInfo',\n 'AddToCart',\n 'AddToWishlist',\n 'CompleteRegistration',\n 'Contact',\n 'CustomizeProduct',\n 'Donate',\n 'FindLocation',\n 'InitiateCheckout',\n 'Lead',\n 'Purchase',\n 'Schedule',\n 'Search',\n 'StartTrial',\n 'SubmitApplication',\n 'Subscribe',\n 'ViewContent',\n ]),\n z.string(), // Allow custom event names\n]);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Meta Conversions API Mapping Schema\n * Meta CAPI has no event-level mapping configuration\n */\nexport const MappingSchema = z.object({});\n\n/**\n * Type inference from MappingSchema\n */\nexport type Mapping = z.infer<typeof MappingSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,iBAAAA;AAAA;AAAA;;;ACAA,IAAAC,cAA4B;;;ACA5B,IAAAC,cAA2B;;;ACGpB,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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CD,IAAAC,cAAkB;AAMX,IAAM,gBAAgB,cAAE,OAAO,CAAC,CAAC;;;AJIjC,IAAM,eAAW,yBAAY,cAAc;AAC3C,IAAM,cAAU,yBAAY,aAAa;;;ADPzC,IAAMC,WAAU;AAAA,EACrB;AAAA,EACA;AACF;","names":["schemas","import_dev","import_dev","import_dev","schemas"]}
|
package/dist/browser-schemas.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{zodToSchema}from"@walkeros/core/dev";import{z as z2}from"@walkeros/core/dev";import{z}from"@walkeros/core/dev";var ActionSourceSchema=z.enum(["email","website","app","phone_call","chat","physical_store","system_generated","business_messaging","other"]),SettingsSchema=(z.union([z.enum(["AddPaymentInfo","AddToCart","AddToWishlist","CompleteRegistration","Contact","CustomizeProduct","Donate","FindLocation","InitiateCheckout","Lead","Purchase","Schedule","Search","StartTrial","SubmitApplication","Subscribe","ViewContent"]),z.string()]),z2.object({accessToken:z2.string().min(1).describe("Meta access token for Conversions API authentication (like your_access_token)"),pixelId:z2.string().regex(/^[0-9]+$/,"Pixel ID must contain only digits").describe("Meta Pixel ID from your Facebook Business account (like 1234567890)"),action_source:ActionSourceSchema.describe("Source of the event (website, app, phone_call, etc.) (like website)").optional(),doNotHash:z2.array(z2.string()).describe("
|
|
1
|
+
import{zodToSchema}from"@walkeros/core/dev";import{schemas,z as z2}from"@walkeros/core/dev";import{z}from"@walkeros/core/dev";var ActionSourceSchema=z.enum(["email","website","app","phone_call","chat","physical_store","system_generated","business_messaging","other"]),SettingsSchema=(z.union([z.enum(["AddPaymentInfo","AddToCart","AddToWishlist","CompleteRegistration","Contact","CustomizeProduct","Donate","FindLocation","InitiateCheckout","Lead","Purchase","Schedule","Search","StartTrial","SubmitApplication","Subscribe","ViewContent"]),z.string()]),z2.object({accessToken:z2.string().min(1).describe("Meta access token for Conversions API authentication (like your_access_token)"),pixelId:z2.string().regex(/^[0-9]+$/,"Pixel ID must contain only digits").describe("Meta Pixel ID from your Facebook Business account (like 1234567890)"),action_source:ActionSourceSchema.describe("Source of the event (website, app, phone_call, etc.) (like website)").optional(),doNotHash:z2.array(z2.string()).describe("user_data keys to send without normalizing and hashing, for values that are already hashed. Only em, ph, fn, ln, db, ge, ct, st, zp, country and external_id are hashed (like ['external_id'])").optional(),test_event_code:z2.string().describe("Test event code for debugging Meta Conversions API events (like TEST12345)").optional(),url:z2.string().url().describe("Custom URL for Meta Conversions API endpoint (like https://graph.facebook.com/v22.0)").optional(),user_data:z2.partialRecord(z2.enum(["em","ph","fn","ln","db","ge","ct","st","zp","country","external_id","client_ip_address","client_user_agent","fbc","fbp","subscription_id","fb_login_id","lead_id","anon_id","madid","page_id","page_scoped_user_id","ctwa_clid","ig_account_id","ig_sid","fbclid"]),schemas.MappingSchemas.ValueSchema).describe("Mapping of Meta customer information parameters to event values, applied to every event. Keys must be Meta's short names such as em and ph (like { em: 'user.email', ph: 'user.phone' })").optional()}));import{z as z3}from"@walkeros/core/dev";var MappingSchema=z3.object({}),schemas2={settings:zodToSchema(SettingsSchema),mapping:zodToSchema(MappingSchema)};export{schemas2 as schemas};//# sourceMappingURL=browser-schemas.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/primitives.ts","../src/schemas/mapping.ts","../src/browser-schemas.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport * from './primitives';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\nimport { ActionSourceSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n accessToken: z\n .string()\n .min(1)\n .describe(\n 'Meta access token for Conversions API authentication (like your_access_token)',\n ),\n pixelId: z\n .string()\n .regex(/^[0-9]+$/, 'Pixel ID must contain only digits')\n .describe(\n 'Meta Pixel ID from your Facebook Business account (like 1234567890)',\n ),\n action_source: ActionSourceSchema.describe(\n 'Source of the event (website, app, phone_call, etc.) (like website)',\n ).optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"
|
|
1
|
+
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/userData.ts","../src/schemas/primitives.ts","../src/schemas/mapping.ts","../src/browser-schemas.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport * from './primitives';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { schemas, z } from '@walkeros/core/dev';\nimport { userDataKeys } from '../userData';\nimport { ActionSourceSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n accessToken: z\n .string()\n .min(1)\n .describe(\n 'Meta access token for Conversions API authentication (like your_access_token)',\n ),\n pixelId: z\n .string()\n .regex(/^[0-9]+$/, 'Pixel ID must contain only digits')\n .describe(\n 'Meta Pixel ID from your Facebook Business account (like 1234567890)',\n ),\n action_source: ActionSourceSchema.describe(\n 'Source of the event (website, app, phone_call, etc.) (like website)',\n ).optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"user_data keys to send without normalizing and hashing, for values that are already hashed. Only em, ph, fn, ln, db, ge, ct, st, zp, country and external_id are hashed (like ['external_id'])\",\n )\n .optional(),\n test_event_code: z\n .string()\n .describe(\n 'Test event code for debugging Meta Conversions API events (like TEST12345)',\n )\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Custom URL for Meta Conversions API endpoint (like https://graph.facebook.com/v22.0)',\n )\n .optional(),\n user_data: z\n .partialRecord(z.enum(userDataKeys), schemas.MappingSchemas.ValueSchema)\n .describe(\n \"Mapping of Meta customer information parameters to event values, applied to every event. Keys must be Meta's short names such as em and ph (like { em: 'user.email', ph: 'user.phone' })\",\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","// Customer information parameters accepted in user_data:\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters\n// fbclid is not sent; the destination turns it into fbc.\nexport const userDataKeys = [\n 'em',\n 'ph',\n 'fn',\n 'ln',\n 'db',\n 'ge',\n 'ct',\n 'st',\n 'zp',\n 'country',\n 'external_id',\n 'client_ip_address',\n 'client_user_agent',\n 'fbc',\n 'fbp',\n 'subscription_id',\n 'fb_login_id',\n 'lead_id',\n 'anon_id',\n 'madid',\n 'page_id',\n 'page_scoped_user_id',\n 'ctwa_clid',\n 'ig_account_id',\n 'ig_sid',\n 'fbclid',\n] as const;\n\nexport function getUnknownUserDataKeys(userData: object): string[] {\n const known: readonly string[] = userDataKeys;\n return Object.keys(userData).filter((key) => !known.includes(key));\n}\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Action Source Enum\n * Where the conversion event took place\n * https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/server-event\n */\nexport const ActionSourceSchema = z.enum([\n 'email',\n 'website',\n 'app',\n 'phone_call',\n 'chat',\n 'physical_store',\n 'system_generated',\n 'business_messaging',\n 'other',\n]);\n\n/**\n * Event Name\n * Standard Meta event names or custom event identifiers\n */\nexport const EventNameSchema = z.union([\n z.enum([\n 'AddPaymentInfo',\n 'AddToCart',\n 'AddToWishlist',\n 'CompleteRegistration',\n 'Contact',\n 'CustomizeProduct',\n 'Donate',\n 'FindLocation',\n 'InitiateCheckout',\n 'Lead',\n 'Purchase',\n 'Schedule',\n 'Search',\n 'StartTrial',\n 'SubmitApplication',\n 'Subscribe',\n 'ViewContent',\n ]),\n z.string(), // Allow custom event names\n]);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Meta Conversions API Mapping Schema\n * Meta CAPI has no event-level mapping configuration\n */\nexport const MappingSchema = z.object({});\n\n/**\n * Type inference from MappingSchema\n */\nexport type Mapping = z.infer<typeof MappingSchema>;\n","// Browser-safe schema-only exports\n// This file exports ONLY schemas without any Node.js dependencies\nimport { settings, mapping } from './schemas';\n\nexport const schemas = {\n settings,\n mapping,\n};\n"],"mappings":";AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS,KAAAA,UAAS;;;ACGpB,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;AC9BA,SAAS,SAAS;AAOX,IAAM,qBAAqB,EAAE,KAAK;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,kBAAkB,EAAE,MAAM;AAAA,EACrC,EAAE,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAAA,EACD,EAAE,OAAO;AAAA;AACX,CAAC;;;AFxCM,IAAM,iBAAiBC,GAAE,OAAO;AAAA,EACrC,aAAaA,GACV,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,SAASA,GACN,OAAO,EACP,MAAM,YAAY,mCAAmC,EACrD;AAAA,IACC;AAAA,EACF;AAAA,EACF,eAAe,mBAAmB;AAAA,IAChC;AAAA,EACF,EAAE,SAAS;AAAA,EACX,WAAWA,GACR,MAAMA,GAAE,OAAO,CAAC,EAChB;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,iBAAiBA,GACd,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,KAAKA,GACF,OAAO,EACP,IAAI,EACJ;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,WAAWA,GACR,cAAcA,GAAE,KAAK,YAAY,GAAG,QAAQ,eAAe,WAAW,EACtE;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC;;;AG7CD,SAAS,KAAAC,UAAS;AAMX,IAAM,gBAAgBA,GAAE,OAAO,CAAC,CAAC;;;AJIjC,IAAM,WAAW,YAAY,cAAc;AAC3C,IAAM,UAAU,YAAY,aAAa;;;AKPzC,IAAMC,WAAU;AAAA,EACrB;AAAA,EACA;AACF;","names":["z","z","z","schemas"]}
|
package/dist/dev.d.mts
CHANGED
|
@@ -60,7 +60,34 @@ declare const SettingsSchema: z.ZodObject<{
|
|
|
60
60
|
doNotHash: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
61
61
|
test_event_code: z.ZodOptional<z.ZodString>;
|
|
62
62
|
url: z.ZodOptional<z.ZodString>;
|
|
63
|
-
user_data: z.ZodOptional<z.ZodRecord<z.
|
|
63
|
+
user_data: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
64
|
+
em: "em";
|
|
65
|
+
ph: "ph";
|
|
66
|
+
fn: "fn";
|
|
67
|
+
ln: "ln";
|
|
68
|
+
db: "db";
|
|
69
|
+
ge: "ge";
|
|
70
|
+
ct: "ct";
|
|
71
|
+
st: "st";
|
|
72
|
+
zp: "zp";
|
|
73
|
+
country: "country";
|
|
74
|
+
external_id: "external_id";
|
|
75
|
+
client_ip_address: "client_ip_address";
|
|
76
|
+
client_user_agent: "client_user_agent";
|
|
77
|
+
fbc: "fbc";
|
|
78
|
+
fbp: "fbp";
|
|
79
|
+
subscription_id: "subscription_id";
|
|
80
|
+
fb_login_id: "fb_login_id";
|
|
81
|
+
lead_id: "lead_id";
|
|
82
|
+
anon_id: "anon_id";
|
|
83
|
+
madid: "madid";
|
|
84
|
+
page_id: "page_id";
|
|
85
|
+
page_scoped_user_id: "page_scoped_user_id";
|
|
86
|
+
ctwa_clid: "ctwa_clid";
|
|
87
|
+
ig_account_id: "ig_account_id";
|
|
88
|
+
ig_sid: "ig_sid";
|
|
89
|
+
fbclid: "fbclid";
|
|
90
|
+
}> & z.core.$partial, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
64
91
|
}, z.core.$strip>;
|
|
65
92
|
type Settings = z.infer<typeof SettingsSchema>;
|
|
66
93
|
|
package/dist/dev.d.ts
CHANGED
|
@@ -60,7 +60,34 @@ declare const SettingsSchema: z.ZodObject<{
|
|
|
60
60
|
doNotHash: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
61
61
|
test_event_code: z.ZodOptional<z.ZodString>;
|
|
62
62
|
url: z.ZodOptional<z.ZodString>;
|
|
63
|
-
user_data: z.ZodOptional<z.ZodRecord<z.
|
|
63
|
+
user_data: z.ZodOptional<z.ZodRecord<z.ZodEnum<{
|
|
64
|
+
em: "em";
|
|
65
|
+
ph: "ph";
|
|
66
|
+
fn: "fn";
|
|
67
|
+
ln: "ln";
|
|
68
|
+
db: "db";
|
|
69
|
+
ge: "ge";
|
|
70
|
+
ct: "ct";
|
|
71
|
+
st: "st";
|
|
72
|
+
zp: "zp";
|
|
73
|
+
country: "country";
|
|
74
|
+
external_id: "external_id";
|
|
75
|
+
client_ip_address: "client_ip_address";
|
|
76
|
+
client_user_agent: "client_user_agent";
|
|
77
|
+
fbc: "fbc";
|
|
78
|
+
fbp: "fbp";
|
|
79
|
+
subscription_id: "subscription_id";
|
|
80
|
+
fb_login_id: "fb_login_id";
|
|
81
|
+
lead_id: "lead_id";
|
|
82
|
+
anon_id: "anon_id";
|
|
83
|
+
madid: "madid";
|
|
84
|
+
page_id: "page_id";
|
|
85
|
+
page_scoped_user_id: "page_scoped_user_id";
|
|
86
|
+
ctwa_clid: "ctwa_clid";
|
|
87
|
+
ig_account_id: "ig_account_id";
|
|
88
|
+
ig_sid: "ig_sid";
|
|
89
|
+
fbclid: "fbclid";
|
|
90
|
+
}> & z.core.$partial, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
64
91
|
}, z.core.$strip>;
|
|
65
92
|
type Settings = z.infer<typeof SettingsSchema>;
|
|
66
93
|
|
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,n=(e,a)=>{for(var r in a)t(e,r,{get:a[r],enumerable:!0})},o={};n(o,{examples:()=>v,schemas:()=>s}),module.exports=(e=o,((e,n,o,s)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let c of r(n))i.call(e,c)||c===o||t(e,c,{get:()=>n[c],enumerable:!(s=a(n,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={};n(s,{ActionSourceSchema:()=>l,EventNameSchema:()=>p,MappingSchema:()=>h,SettingsSchema:()=>m,mapping:()=>_,settings:()=>b});var c=require("@walkeros/core/dev"),d=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),l=u.z.enum(["email","website","app","phone_call","chat","physical_store","system_generated","business_messaging","other"]),p=u.z.union([u.z.enum(["AddPaymentInfo","AddToCart","AddToWishlist","CompleteRegistration","Contact","CustomizeProduct","Donate","FindLocation","InitiateCheckout","Lead","Purchase","Schedule","Search","StartTrial","SubmitApplication","Subscribe","ViewContent"]),u.z.string()]),m=d.z.object({accessToken:d.z.string().min(1).describe("Meta access token for Conversions API authentication (like your_access_token)"),pixelId:d.z.string().regex(/^[0-9]+$/,"Pixel ID must contain only digits").describe("Meta Pixel ID from your Facebook Business account (like 1234567890)"),action_source:l.describe("Source of the event (website, app, phone_call, etc.) (like website)").optional(),doNotHash:d.z.array(d.z.string()).describe("user_data keys to send without normalizing and hashing, for values that are already hashed. Only em, ph, fn, ln, db, ge, ct, st, zp, country and external_id are hashed (like ['external_id'])").optional(),test_event_code:d.z.string().describe("Test event code for debugging Meta Conversions API events (like TEST12345)").optional(),url:d.z.string().url().describe("Custom URL for Meta Conversions API endpoint (like https://graph.facebook.com/v22.0)").optional(),user_data:d.z.partialRecord(d.z.enum(["em","ph","fn","ln","db","ge","ct","st","zp","country","external_id","client_ip_address","client_user_agent","fbc","fbp","subscription_id","fb_login_id","lead_id","anon_id","madid","page_id","page_scoped_user_id","ctwa_clid","ig_account_id","ig_sid","fbclid"]),d.schemas.MappingSchemas.ValueSchema).describe("Mapping of Meta customer information parameters to event values, applied to every event. Keys must be Meta's short names such as em and ph (like { em: 'user.email', ph: 'user.phone' })").optional()}),h=require("@walkeros/core/dev").z.object({}),b=(0,c.zodToSchema)(m),_=(0,c.zodToSchema)(h),v={};n(v,{env:()=>f,step:()=>w});var f={};n(f,{push:()=>y,simulation:()=>g});var y={sendServer:async function(e,t,a){return{ok:!0,data:{events_received:1,messages:[],fbtrace_id:"mock-trace-id"}}}},g=["sendServer"],w={};n(w,{lead:()=>P,purchase:()=>z,purchaseWithClickAttribution:()=>A});var S=require("@walkeros/core"),k="https://graph.facebook.com/v22.0/1234567890/events",x={headers:{Authorization:"Bearer s3cr3t"}},z={title:"Purchase",description:"A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.",in:(0,S.getEvent)("order complete",{id:"c1d2e3f4a5b60001",timestamp:17000009e5,data:{id:"ORD-300",total:249.99,currency:"EUR"},nested:[{entity:"product",data:{id:"SKU-A1",price:129.99,quantity:2}}],user:{id:"user-123",device:"device-456"},source:{type:"browser",platform:"web",url:"https://shop.example.com"}}),mapping:{name:"Purchase",data:{map:{order_id:"data.id",currency:{key:"data.currency",value:"EUR"},value:"data.total",contents:{loop:["nested",{condition:e=>"object"==typeof e&&null!==e&&"entity"in e&&"product"===e.entity,map:{id:"data.id",item_price:"data.price",quantity:{key:"data.quantity",value:1}}}]},num_items:{fn:e=>e.nested.filter(e=>"product"===e.entity).length}}}},out:[["sendServer",k,JSON.stringify({data:[{event_name:"Purchase",event_id:"c1d2e3f4a5b60001",event_time:1700000900,action_source:"website",order_id:"ORD-300",currency:"EUR",value:249.99,contents:[{id:"SKU-A1",item_price:129.99,quantity:2}],num_items:1,user_data:{},event_source_url:"https://shop.example.com"}]}),x]]},P={title:"Form submit",description:"A form submission is forwarded to Meta CAPI as a custom event with the event source URL.",in:(0,S.getEvent)("form submit",{id:"c1d2e3f4a5b60002",timestamp:1700000901e3,data:{type:"newsletter"},user:{email:"user@example.com"},source:{type:"browser",platform:"web",url:"https://example.com"}}),mapping:void 0,out:[["sendServer",k,JSON.stringify({data:[{event_name:"form submit",event_id:"c1d2e3f4a5b60002",event_time:1700000901,action_source:"website",user_data:{},event_source_url:"https://example.com"}]}),x]]},A={title:"Purchase with fbclid",description:"A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.",in:(0,S.getEvent)("order complete",{id:"c1d2e3f4a5b60003",timestamp:1700000902e3,data:{id:"ORD-700",total:89.99,currency:"USD"},user:{id:"cust-42"},context:{fbclid:["abc123xyz",0]},source:{type:"browser",platform:"web",url:"https://shop.example.com"}}),mapping:{name:"Purchase",data:{map:{currency:{key:"data.currency",value:"EUR"},value:"data.total",order_id:"data.id",user_data:{map:{external_id:"user.id",fbclid:"context.fbclid.0"}}}}},out:[["sendServer",k,JSON.stringify({data:[{event_name:"Purchase",event_id:"c1d2e3f4a5b60003",event_time:1700000902,action_source:"website",currency:"USD",value:89.99,order_id:"ORD-700",user_data:{external_id:"8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa",fbc:"fb.1.1700000902000.abc123xyz"},event_source_url:"https://shop.example.com"}]}),x]]};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/primitives.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport * from './primitives';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\nimport { ActionSourceSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n accessToken: z\n .string()\n .min(1)\n .describe(\n 'Meta access token for Conversions API authentication (like your_access_token)',\n ),\n pixelId: z\n .string()\n .regex(/^[0-9]+$/, 'Pixel ID must contain only digits')\n .describe(\n 'Meta Pixel ID from your Facebook Business account (like 1234567890)',\n ),\n action_source: ActionSourceSchema.describe(\n 'Source of the event (website, app, phone_call, etc.) (like website)',\n ).optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"Array of user_data fields that should not be hashed (like ['client_ip_address', 'client_user_agent'])\",\n )\n .optional(),\n test_event_code: z\n .string()\n .describe(\n 'Test event code for debugging Meta Conversions API events (like TEST12345)',\n )\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Custom URL for Meta Conversions API endpoint (like https://graph.facebook.com/v17.0)',\n )\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\n \"Mapping configuration for user data fields (like { email: 'user.email', phone: 'user.phone' })\",\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Action Source Enum\n * Where the conversion event took place\n * https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/server-event\n */\nexport const ActionSourceSchema = z.enum([\n 'email',\n 'website',\n 'app',\n 'phone_call',\n 'chat',\n 'physical_store',\n 'system_generated',\n 'business_messaging',\n 'other',\n]);\n\n/**\n * Event Name\n * Standard Meta event names or custom event identifiers\n */\nexport const EventNameSchema = z.union([\n z.enum([\n 'AddPaymentInfo',\n 'AddToCart',\n 'AddToWishlist',\n 'CompleteRegistration',\n 'Contact',\n 'CustomizeProduct',\n 'Donate',\n 'FindLocation',\n 'InitiateCheckout',\n 'Lead',\n 'Purchase',\n 'Schedule',\n 'Search',\n 'StartTrial',\n 'SubmitApplication',\n 'Subscribe',\n 'ViewContent',\n ]),\n z.string(), // Allow custom event names\n]);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Meta Conversions API Mapping Schema\n * Meta CAPI has no event-level mapping configuration\n */\nexport const MappingSchema = z.object({});\n\n/**\n * Type inference from MappingSchema\n */\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { SendDataValue, SendResponse } from '@walkeros/core';\nimport type { SendServerOptions } from '@walkeros/server-core';\nimport type { Env } from '../types';\n\n/**\n * Example environment configurations for Meta Conversions API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\n/**\n * Mock sendServer function that simulates successful HTTP responses\n */\nasync function mockSendServer(\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n): Promise<SendResponse> {\n // Simulate successful Meta API response\n return {\n ok: true,\n data: {\n events_received: 1,\n messages: [],\n fbtrace_id: 'mock-trace-id',\n },\n };\n}\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing Meta Conversions API events without making\n * actual HTTP requests to Facebook's servers.\n */\nexport const push: Env = {\n sendServer: mockSendServer,\n};\n\nexport const simulation = ['sendServer'];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent, isObject } from '@walkeros/core';\n\n/**\n * Meta Conversions API step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is `${settings.url}${settings.pixelId}/events`, `body` is the\n * JSON-stringified `{ data: [serverEvent] }` payload, and `options` carries the\n * access token in an `Authorization: Bearer` header (never in the URL).\n *\n * The public name users see when inspecting the destination is `sendServer`,\n * so each `out` tuple is `['sendServer', url, body, options]` with `body` as\n * the already-stringified JSON payload (mirroring the actual call signature).\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelId = 'p1x3l1d'`,\n * so every endpoint resolves to:\n * https://graph.facebook.com/v22.0/p1x3l1d/events\n * with header `Authorization: Bearer s3cr3t`.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * 1. event_name\n * 2. event_id\n * 3. event_time (unix seconds; `Math.round(event.timestamp / 1000)`)\n * 4. action_source\n * 5. ...mapped event data (currency, value, etc.)\n * 6. user_data (hashed per Meta's PII requirements)\n * 7. event_source_url (appended after hash when action_source === 'website')\n */\nconst ENDPOINT = 'https://graph.facebook.com/v22.0/p1x3l1d/events';\n\nconst OPTIONS = { headers: { Authorization: 'Bearer s3cr3t' } };\n\nexport const purchase: Flow.StepExample = {\n title: 'Purchase',\n description:\n 'A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.',\n in: getEvent('order complete', {\n id: 'c1d2e3f4a5b60001',\n timestamp: 1700000900,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n nested: [\n { entity: 'product', data: { id: 'SKU-A1', price: 129.99, quantity: 2 } },\n ],\n user: { id: 'user-123', device: 'device-456' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://shop.example.com',\n },\n }),\n mapping: {\n name: 'Purchase',\n data: {\n map: {\n order_id: 'data.id',\n currency: { key: 'data.currency', value: 'EUR' },\n value: 'data.total',\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity: unknown) =>\n isObject(entity) && entity.entity === 'product',\n map: {\n id: 'data.id',\n item_price: 'data.price',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n num_items: {\n fn: (event: unknown) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.entity === 'product',\n ).length,\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'Purchase',\n event_id: 'c1d2e3f4a5b60001',\n event_time: 1700001,\n action_source: 'website',\n order_id: 'ORD-300',\n currency: 'EUR',\n value: 249.99,\n contents: [{ id: 'SKU-A1', item_price: 129.99, quantity: 2 }],\n num_items: 1,\n user_data: {},\n event_source_url: 'https://shop.example.com',\n },\n ],\n }),\n OPTIONS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Form submit',\n description:\n 'A form submission is forwarded to Meta CAPI as a custom event with the event source URL.',\n in: getEvent('form submit', {\n id: 'c1d2e3f4a5b60002',\n timestamp: 1700000901,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://example.com',\n },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'form submit',\n event_id: 'c1d2e3f4a5b60002',\n event_time: 1700001,\n action_source: 'website',\n user_data: {},\n event_source_url: 'https://example.com',\n },\n ],\n }),\n OPTIONS,\n ],\n ],\n};\n\nexport const purchaseWithClickAttribution: Flow.StepExample = {\n title: 'Purchase with fbclid',\n description:\n 'A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.',\n in: getEvent('order complete', {\n id: 'c1d2e3f4a5b60003',\n timestamp: 1700000902,\n data: { id: 'ORD-700', total: 89.99, currency: 'USD' },\n user: { id: 'cust-42' },\n context: { fbclid: ['abc123xyz', 0] },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://shop.example.com',\n },\n }),\n mapping: {\n name: 'Purchase',\n data: {\n map: {\n currency: { key: 'data.currency', value: 'EUR' },\n value: 'data.total',\n order_id: 'data.id',\n user_data: {\n map: {\n external_id: 'user.id',\n fbclid: 'context.fbclid',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'Purchase',\n event_id: 'c1d2e3f4a5b60003',\n event_time: 1700001,\n action_source: 'website',\n currency: 'USD',\n value: 89.99,\n order_id: 'ORD-700',\n user_data: {\n // sha256('cust-42')\n external_id:\n '8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa',\n // formatClickId(['abc123xyz', 0], event.timestamp) - array joins\n // to 'abc123xyz,0' when coerced to string inside the template.\n fbc: 'fb.1.1700000902.abc123xyz,0',\n },\n event_source_url: 'https://shop.example.com',\n },\n ],\n }),\n OPTIONS,\n ],\n ],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,IAAAC,cAAkB;;;ACAlB,iBAAkB;AAOX,IAAM,qBAAqB,aAAE,KAAK;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,kBAAkB,aAAE,MAAM;AAAA,EACrC,aAAE,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAAA,EACD,aAAE,OAAO;AAAA;AACX,CAAC;;;ADzCM,IAAM,iBAAiB,cAAE,OAAO;AAAA,EACrC,aAAa,cACV,OAAO,EACP,IAAI,CAAC,EACL;AAAA,I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K;AAAA,YACH,aAAa;AAAA,YACb,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,MAAM;AAAA,UACJ;AAAA,YACE,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,YAAY;AAAA,YACZ,eAAe;AAAA,YACf,UAAU;AAAA,YACV,OAAO;AAAA,YACP,UAAU;AAAA,YACV,WAAW;AAAA;AAAA,cAET,aACE;AAAA;AAAA;AAAA,cAGF,KAAK;AAAA,YACP;AAAA,YACA,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;","names":["import_dev","import_dev","import_dev"]}
|
|
1
|
+
{"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/userData.ts","../src/schemas/primitives.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport * from './primitives';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { schemas, z } from '@walkeros/core/dev';\nimport { userDataKeys } from '../userData';\nimport { ActionSourceSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n accessToken: z\n .string()\n .min(1)\n .describe(\n 'Meta access token for Conversions API authentication (like your_access_token)',\n ),\n pixelId: z\n .string()\n .regex(/^[0-9]+$/, 'Pixel ID must contain only digits')\n .describe(\n 'Meta Pixel ID from your Facebook Business account (like 1234567890)',\n ),\n action_source: ActionSourceSchema.describe(\n 'Source of the event (website, app, phone_call, etc.) (like website)',\n ).optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"user_data keys to send without normalizing and hashing, for values that are already hashed. Only em, ph, fn, ln, db, ge, ct, st, zp, country and external_id are hashed (like ['external_id'])\",\n )\n .optional(),\n test_event_code: z\n .string()\n .describe(\n 'Test event code for debugging Meta Conversions API events (like TEST12345)',\n )\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Custom URL for Meta Conversions API endpoint (like https://graph.facebook.com/v22.0)',\n )\n .optional(),\n user_data: z\n .partialRecord(z.enum(userDataKeys), schemas.MappingSchemas.ValueSchema)\n .describe(\n \"Mapping of Meta customer information parameters to event values, applied to every event. Keys must be Meta's short names such as em and ph (like { em: 'user.email', ph: 'user.phone' })\",\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","// Customer information parameters accepted in user_data:\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters\n// fbclid is not sent; the destination turns it into fbc.\nexport const userDataKeys = [\n 'em',\n 'ph',\n 'fn',\n 'ln',\n 'db',\n 'ge',\n 'ct',\n 'st',\n 'zp',\n 'country',\n 'external_id',\n 'client_ip_address',\n 'client_user_agent',\n 'fbc',\n 'fbp',\n 'subscription_id',\n 'fb_login_id',\n 'lead_id',\n 'anon_id',\n 'madid',\n 'page_id',\n 'page_scoped_user_id',\n 'ctwa_clid',\n 'ig_account_id',\n 'ig_sid',\n 'fbclid',\n] as const;\n\nexport function getUnknownUserDataKeys(userData: object): string[] {\n const known: readonly string[] = userDataKeys;\n return Object.keys(userData).filter((key) => !known.includes(key));\n}\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Action Source Enum\n * Where the conversion event took place\n * https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/server-event\n */\nexport const ActionSourceSchema = z.enum([\n 'email',\n 'website',\n 'app',\n 'phone_call',\n 'chat',\n 'physical_store',\n 'system_generated',\n 'business_messaging',\n 'other',\n]);\n\n/**\n * Event Name\n * Standard Meta event names or custom event identifiers\n */\nexport const EventNameSchema = z.union([\n z.enum([\n 'AddPaymentInfo',\n 'AddToCart',\n 'AddToWishlist',\n 'CompleteRegistration',\n 'Contact',\n 'CustomizeProduct',\n 'Donate',\n 'FindLocation',\n 'InitiateCheckout',\n 'Lead',\n 'Purchase',\n 'Schedule',\n 'Search',\n 'StartTrial',\n 'SubmitApplication',\n 'Subscribe',\n 'ViewContent',\n ]),\n z.string(), // Allow custom event names\n]);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Meta Conversions API Mapping Schema\n * Meta CAPI has no event-level mapping configuration\n */\nexport const MappingSchema = z.object({});\n\n/**\n * Type inference from MappingSchema\n */\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { SendDataValue, SendResponse } from '@walkeros/core';\nimport type { SendServerOptions } from '@walkeros/server-core';\nimport type { Env } from '../types';\n\n/**\n * Example environment configurations for Meta Conversions API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\n/**\n * Mock sendServer function that simulates successful HTTP responses\n */\nasync function mockSendServer(\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n): Promise<SendResponse> {\n // Simulate successful Meta API response\n return {\n ok: true,\n data: {\n events_received: 1,\n messages: [],\n fbtrace_id: 'mock-trace-id',\n },\n };\n}\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing Meta Conversions API events without making\n * actual HTTP requests to Facebook's servers.\n */\nexport const push: Env = {\n sendServer: mockSendServer,\n};\n\nexport const simulation = ['sendServer'];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\n\n/**\n * Meta Conversions API step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is `${settings.url}/${settings.pixelId}/events`, `body` is the\n * JSON-stringified `{ data: [serverEvent] }` payload, and `options` carries the\n * access token in an `Authorization: Bearer` header (never in the URL).\n *\n * The public name users see when inspecting the destination is `sendServer`,\n * so each `out` tuple is `['sendServer', url, body, options]` with `body` as\n * the already-stringified JSON payload (mirroring the actual call signature).\n *\n * Functions in mappings are published as source code, so they must not use\n * imported helpers.\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelId = '1234567890'`,\n * so every endpoint resolves to:\n * https://graph.facebook.com/v22.0/1234567890/events\n * with header `Authorization: Bearer s3cr3t`.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * 1. event_name\n * 2. event_id\n * 3. event_time (unix seconds; `Math.round(event.timestamp / 1000)`)\n * 4. action_source\n * 5. ...mapped event data (currency, value, etc.)\n * 6. user_data (hashed per Meta's PII requirements)\n * 7. event_source_url (appended after hash when action_source === 'website')\n */\nconst ENDPOINT = 'https://graph.facebook.com/v22.0/1234567890/events';\n\nconst OPTIONS = { headers: { Authorization: 'Bearer s3cr3t' } };\n\nexport const purchase: Flow.StepExample = {\n title: 'Purchase',\n description:\n 'A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.',\n in: getEvent('order complete', {\n id: 'c1d2e3f4a5b60001',\n timestamp: 1700000900000,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n nested: [\n { entity: 'product', data: { id: 'SKU-A1', price: 129.99, quantity: 2 } },\n ],\n user: { id: 'user-123', device: 'device-456' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://shop.example.com',\n },\n }),\n mapping: {\n name: 'Purchase',\n data: {\n map: {\n order_id: 'data.id',\n currency: { key: 'data.currency', value: 'EUR' },\n value: 'data.total',\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity: unknown) =>\n typeof entity === 'object' &&\n entity !== null &&\n 'entity' in entity &&\n entity.entity === 'product',\n map: {\n id: 'data.id',\n item_price: 'data.price',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n num_items: {\n fn: (event: unknown) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.entity === 'product',\n ).length,\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'Purchase',\n event_id: 'c1d2e3f4a5b60001',\n event_time: 1700000900,\n action_source: 'website',\n order_id: 'ORD-300',\n currency: 'EUR',\n value: 249.99,\n contents: [{ id: 'SKU-A1', item_price: 129.99, quantity: 2 }],\n num_items: 1,\n user_data: {},\n event_source_url: 'https://shop.example.com',\n },\n ],\n }),\n OPTIONS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Form submit',\n description:\n 'A form submission is forwarded to Meta CAPI as a custom event with the event source URL.',\n in: getEvent('form submit', {\n id: 'c1d2e3f4a5b60002',\n timestamp: 1700000901000,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://example.com',\n },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'form submit',\n event_id: 'c1d2e3f4a5b60002',\n event_time: 1700000901,\n action_source: 'website',\n user_data: {},\n event_source_url: 'https://example.com',\n },\n ],\n }),\n OPTIONS,\n ],\n ],\n};\n\nexport const purchaseWithClickAttribution: Flow.StepExample = {\n title: 'Purchase with fbclid',\n description:\n 'A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.',\n in: getEvent('order complete', {\n id: 'c1d2e3f4a5b60003',\n timestamp: 1700000902000,\n data: { id: 'ORD-700', total: 89.99, currency: 'USD' },\n user: { id: 'cust-42' },\n context: { fbclid: ['abc123xyz', 0] },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://shop.example.com',\n },\n }),\n mapping: {\n name: 'Purchase',\n data: {\n map: {\n currency: { key: 'data.currency', value: 'EUR' },\n value: 'data.total',\n order_id: 'data.id',\n user_data: {\n map: {\n external_id: 'user.id',\n fbclid: 'context.fbclid.0',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'Purchase',\n event_id: 'c1d2e3f4a5b60003',\n event_time: 1700000902,\n action_source: 'website',\n currency: 'USD',\n value: 89.99,\n order_id: 'ORD-700',\n user_data: {\n // sha256('cust-42')\n external_id:\n '8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa',\n // fb.subdomainIndex.creationTime.fbclid, creationTime in milliseconds\n fbc: 'fb.1.1700000902000.abc123xyz',\n },\n event_source_url: 'https://shop.example.com',\n },\n ],\n }),\n OPTIONS,\n ],\n ],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,IAAAC,cAA2B;;;ACGpB,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;AC9BA,iBAAkB;AAOX,IAAM,qBAAqB,aAAE,KAAK;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,kBAAkB,aAAE,MAAM;AAAA,EACrC,aAAE,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AA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D,SAAS;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,MACJ,KAAK;AAAA,QACH,UAAU,EAAE,KAAK,iBAAiB,OAAO,MAAM;AAAA,QAC/C,OAAO;AAAA,QACP,UAAU;AAAA,QACV,WAAW;AAAA,UACT,KAAK;AAAA,YACH,aAAa;AAAA,YACb,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,MAAM;AAAA,UACJ;AAAA,YACE,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,YAAY;AAAA,YACZ,eAAe;AAAA,YACf,UAAU;AAAA,YACV,OAAO;AAAA,YACP,UAAU;AAAA,YACV,WAAW;AAAA;AAAA,cAET,aACE;AAAA;AAAA,cAEF,KAAK;AAAA,YACP;AAAA,YACA,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;","names":["import_dev","import_dev","import_dev"]}
|
package/dist/dev.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.defineProperty,t=(t,a)=>{for(var r in a)e(t,r,{get:a[r],enumerable:!0})},a={};t(a,{ActionSourceSchema:()=>
|
|
1
|
+
var e=Object.defineProperty,t=(t,a)=>{for(var r in a)e(t,r,{get:a[r],enumerable:!0})},a={};t(a,{ActionSourceSchema:()=>n,EventNameSchema:()=>c,MappingSchema:()=>p,SettingsSchema:()=>d,mapping:()=>l,settings:()=>m});import{zodToSchema as r}from"@walkeros/core/dev";import{schemas as i,z as o}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";var n=s.enum(["email","website","app","phone_call","chat","physical_store","system_generated","business_messaging","other"]),c=s.union([s.enum(["AddPaymentInfo","AddToCart","AddToWishlist","CompleteRegistration","Contact","CustomizeProduct","Donate","FindLocation","InitiateCheckout","Lead","Purchase","Schedule","Search","StartTrial","SubmitApplication","Subscribe","ViewContent"]),s.string()]),d=o.object({accessToken:o.string().min(1).describe("Meta access token for Conversions API authentication (like your_access_token)"),pixelId:o.string().regex(/^[0-9]+$/,"Pixel ID must contain only digits").describe("Meta Pixel ID from your Facebook Business account (like 1234567890)"),action_source:n.describe("Source of the event (website, app, phone_call, etc.) (like website)").optional(),doNotHash:o.array(o.string()).describe("user_data keys to send without normalizing and hashing, for values that are already hashed. Only em, ph, fn, ln, db, ge, ct, st, zp, country and external_id are hashed (like ['external_id'])").optional(),test_event_code:o.string().describe("Test event code for debugging Meta Conversions API events (like TEST12345)").optional(),url:o.string().url().describe("Custom URL for Meta Conversions API endpoint (like https://graph.facebook.com/v22.0)").optional(),user_data:o.partialRecord(o.enum(["em","ph","fn","ln","db","ge","ct","st","zp","country","external_id","client_ip_address","client_user_agent","fbc","fbp","subscription_id","fb_login_id","lead_id","anon_id","madid","page_id","page_scoped_user_id","ctwa_clid","ig_account_id","ig_sid","fbclid"]),i.MappingSchemas.ValueSchema).describe("Mapping of Meta customer information parameters to event values, applied to every event. Keys must be Meta's short names such as em and ph (like { em: 'user.email', ph: 'user.phone' })").optional()});import{z as u}from"@walkeros/core/dev";var p=u.object({}),m=r(d),l=r(p),h={};t(h,{env:()=>_,step:()=>f});var _={};t(_,{push:()=>b,simulation:()=>v});var b={sendServer:async function(e,t,a){return{ok:!0,data:{events_received:1,messages:[],fbtrace_id:"mock-trace-id"}}}},v=["sendServer"],f={};t(f,{lead:()=>w,purchase:()=>S,purchaseWithClickAttribution:()=>x});import{getEvent as y}from"@walkeros/core";var g="https://graph.facebook.com/v22.0/1234567890/events",k={headers:{Authorization:"Bearer s3cr3t"}},S={title:"Purchase",description:"A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.",in:y("order complete",{id:"c1d2e3f4a5b60001",timestamp:17000009e5,data:{id:"ORD-300",total:249.99,currency:"EUR"},nested:[{entity:"product",data:{id:"SKU-A1",price:129.99,quantity:2}}],user:{id:"user-123",device:"device-456"},source:{type:"browser",platform:"web",url:"https://shop.example.com"}}),mapping:{name:"Purchase",data:{map:{order_id:"data.id",currency:{key:"data.currency",value:"EUR"},value:"data.total",contents:{loop:["nested",{condition:e=>"object"==typeof e&&null!==e&&"entity"in e&&"product"===e.entity,map:{id:"data.id",item_price:"data.price",quantity:{key:"data.quantity",value:1}}}]},num_items:{fn:e=>e.nested.filter(e=>"product"===e.entity).length}}}},out:[["sendServer",g,JSON.stringify({data:[{event_name:"Purchase",event_id:"c1d2e3f4a5b60001",event_time:1700000900,action_source:"website",order_id:"ORD-300",currency:"EUR",value:249.99,contents:[{id:"SKU-A1",item_price:129.99,quantity:2}],num_items:1,user_data:{},event_source_url:"https://shop.example.com"}]}),k]]},w={title:"Form submit",description:"A form submission is forwarded to Meta CAPI as a custom event with the event source URL.",in:y("form submit",{id:"c1d2e3f4a5b60002",timestamp:1700000901e3,data:{type:"newsletter"},user:{email:"user@example.com"},source:{type:"browser",platform:"web",url:"https://example.com"}}),mapping:void 0,out:[["sendServer",g,JSON.stringify({data:[{event_name:"form submit",event_id:"c1d2e3f4a5b60002",event_time:1700000901,action_source:"website",user_data:{},event_source_url:"https://example.com"}]}),k]]},x={title:"Purchase with fbclid",description:"A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.",in:y("order complete",{id:"c1d2e3f4a5b60003",timestamp:1700000902e3,data:{id:"ORD-700",total:89.99,currency:"USD"},user:{id:"cust-42"},context:{fbclid:["abc123xyz",0]},source:{type:"browser",platform:"web",url:"https://shop.example.com"}}),mapping:{name:"Purchase",data:{map:{currency:{key:"data.currency",value:"EUR"},value:"data.total",order_id:"data.id",user_data:{map:{external_id:"user.id",fbclid:"context.fbclid.0"}}}}},out:[["sendServer",g,JSON.stringify({data:[{event_name:"Purchase",event_id:"c1d2e3f4a5b60003",event_time:1700000902,action_source:"website",currency:"USD",value:89.99,order_id:"ORD-700",user_data:{external_id:"8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa",fbc:"fb.1.1700000902000.abc123xyz"},event_source_url:"https://shop.example.com"}]}),k]]};export{h as examples,a as schemas};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/primitives.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport * from './primitives';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\nimport { ActionSourceSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n accessToken: z\n .string()\n .min(1)\n .describe(\n 'Meta access token for Conversions API authentication (like your_access_token)',\n ),\n pixelId: z\n .string()\n .regex(/^[0-9]+$/, 'Pixel ID must contain only digits')\n .describe(\n 'Meta Pixel ID from your Facebook Business account (like 1234567890)',\n ),\n action_source: ActionSourceSchema.describe(\n 'Source of the event (website, app, phone_call, etc.) (like website)',\n ).optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"Array of user_data fields that should not be hashed (like ['client_ip_address', 'client_user_agent'])\",\n )\n .optional(),\n test_event_code: z\n .string()\n .describe(\n 'Test event code for debugging Meta Conversions API events (like TEST12345)',\n )\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Custom URL for Meta Conversions API endpoint (like https://graph.facebook.com/v17.0)',\n )\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\n \"Mapping configuration for user data fields (like { email: 'user.email', phone: 'user.phone' })\",\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Action Source Enum\n * Where the conversion event took place\n * https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/server-event\n */\nexport const ActionSourceSchema = z.enum([\n 'email',\n 'website',\n 'app',\n 'phone_call',\n 'chat',\n 'physical_store',\n 'system_generated',\n 'business_messaging',\n 'other',\n]);\n\n/**\n * Event Name\n * Standard Meta event names or custom event identifiers\n */\nexport const EventNameSchema = z.union([\n z.enum([\n 'AddPaymentInfo',\n 'AddToCart',\n 'AddToWishlist',\n 'CompleteRegistration',\n 'Contact',\n 'CustomizeProduct',\n 'Donate',\n 'FindLocation',\n 'InitiateCheckout',\n 'Lead',\n 'Purchase',\n 'Schedule',\n 'Search',\n 'StartTrial',\n 'SubmitApplication',\n 'Subscribe',\n 'ViewContent',\n ]),\n z.string(), // Allow custom event names\n]);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Meta Conversions API Mapping Schema\n * Meta CAPI has no event-level mapping configuration\n */\nexport const MappingSchema = z.object({});\n\n/**\n * Type inference from MappingSchema\n */\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { SendDataValue, SendResponse } from '@walkeros/core';\nimport type { SendServerOptions } from '@walkeros/server-core';\nimport type { Env } from '../types';\n\n/**\n * Example environment configurations for Meta Conversions API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\n/**\n * Mock sendServer function that simulates successful HTTP responses\n */\nasync function mockSendServer(\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n): Promise<SendResponse> {\n // Simulate successful Meta API response\n return {\n ok: true,\n data: {\n events_received: 1,\n messages: [],\n fbtrace_id: 'mock-trace-id',\n },\n };\n}\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing Meta Conversions API events without making\n * actual HTTP requests to Facebook's servers.\n */\nexport const push: Env = {\n sendServer: mockSendServer,\n};\n\nexport const simulation = ['sendServer'];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent, isObject } from '@walkeros/core';\n\n/**\n * Meta Conversions API step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is `${settings.url}${settings.pixelId}/events`, `body` is the\n * JSON-stringified `{ data: [serverEvent] }` payload, and `options` carries the\n * access token in an `Authorization: Bearer` header (never in the URL).\n *\n * The public name users see when inspecting the destination is `sendServer`,\n * so each `out` tuple is `['sendServer', url, body, options]` with `body` as\n * the already-stringified JSON payload (mirroring the actual call signature).\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelId = 'p1x3l1d'`,\n * so every endpoint resolves to:\n * https://graph.facebook.com/v22.0/p1x3l1d/events\n * with header `Authorization: Bearer s3cr3t`.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * 1. event_name\n * 2. event_id\n * 3. event_time (unix seconds; `Math.round(event.timestamp / 1000)`)\n * 4. action_source\n * 5. ...mapped event data (currency, value, etc.)\n * 6. user_data (hashed per Meta's PII requirements)\n * 7. event_source_url (appended after hash when action_source === 'website')\n */\nconst ENDPOINT = 'https://graph.facebook.com/v22.0/p1x3l1d/events';\n\nconst OPTIONS = { headers: { Authorization: 'Bearer s3cr3t' } };\n\nexport const purchase: Flow.StepExample = {\n title: 'Purchase',\n description:\n 'A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.',\n in: getEvent('order complete', {\n id: 'c1d2e3f4a5b60001',\n timestamp: 1700000900,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n nested: [\n { entity: 'product', data: { id: 'SKU-A1', price: 129.99, quantity: 2 } },\n ],\n user: { id: 'user-123', device: 'device-456' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://shop.example.com',\n },\n }),\n mapping: {\n name: 'Purchase',\n data: {\n map: {\n order_id: 'data.id',\n currency: { key: 'data.currency', value: 'EUR' },\n value: 'data.total',\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity: unknown) =>\n isObject(entity) && entity.entity === 'product',\n map: {\n id: 'data.id',\n item_price: 'data.price',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n num_items: {\n fn: (event: unknown) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.entity === 'product',\n ).length,\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'Purchase',\n event_id: 'c1d2e3f4a5b60001',\n event_time: 1700001,\n action_source: 'website',\n order_id: 'ORD-300',\n currency: 'EUR',\n value: 249.99,\n contents: [{ id: 'SKU-A1', item_price: 129.99, quantity: 2 }],\n num_items: 1,\n user_data: {},\n event_source_url: 'https://shop.example.com',\n },\n ],\n }),\n OPTIONS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Form submit',\n description:\n 'A form submission is forwarded to Meta CAPI as a custom event with the event source URL.',\n in: getEvent('form submit', {\n id: 'c1d2e3f4a5b60002',\n timestamp: 1700000901,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://example.com',\n },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'form submit',\n event_id: 'c1d2e3f4a5b60002',\n event_time: 1700001,\n action_source: 'website',\n user_data: {},\n event_source_url: 'https://example.com',\n },\n ],\n }),\n OPTIONS,\n ],\n ],\n};\n\nexport const purchaseWithClickAttribution: Flow.StepExample = {\n title: 'Purchase with fbclid',\n description:\n 'A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.',\n in: getEvent('order complete', {\n id: 'c1d2e3f4a5b60003',\n timestamp: 1700000902,\n data: { id: 'ORD-700', total: 89.99, currency: 'USD' },\n user: { id: 'cust-42' },\n context: { fbclid: ['abc123xyz', 0] },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://shop.example.com',\n },\n }),\n mapping: {\n name: 'Purchase',\n data: {\n map: {\n currency: { key: 'data.currency', value: 'EUR' },\n value: 'data.total',\n order_id: 'data.id',\n user_data: {\n map: {\n external_id: 'user.id',\n fbclid: 'context.fbclid',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'Purchase',\n event_id: 'c1d2e3f4a5b60003',\n event_time: 1700001,\n action_source: 'website',\n currency: 'USD',\n value: 89.99,\n order_id: 'ORD-700',\n user_data: {\n // sha256('cust-42')\n external_id:\n '8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa',\n // formatClickId(['abc123xyz', 0], event.timestamp) - array joins\n // to 'abc123xyz,0' when coerced to string inside the template.\n fbc: 'fb.1.1700000902.abc123xyz,0',\n },\n event_source_url: 'https://shop.example.com',\n },\n ],\n }),\n OPTIONS,\n ],\n ],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAOX,IAAM,qBAAqB,EAAE,KAAK;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,kBAAkB,EAAE,MAAM;AAAA,EACrC,EAAE,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAAA,EACD,EAAE,OAAO;AAAA;AACX,CAAC;;;ADzCM,IAAM,iBAAiBC,GAAE,OAAO;AAAA,EACrC,aAAaA,GACV,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,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A,YACH,aAAa;AAAA,YACb,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,MAAM;AAAA,UACJ;AAAA,YACE,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,YAAY;AAAA,YACZ,eAAe;AAAA,YACf,UAAU;AAAA,YACV,OAAO;AAAA,YACP,UAAU;AAAA,YACV,WAAW;AAAA;AAAA,cAET,aACE;AAAA;AAAA;AAAA,cAGF,KAAK;AAAA,YACP;AAAA,YACA,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;","names":["z","z","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/userData.ts","../src/schemas/primitives.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport * from './primitives';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { schemas, z } from '@walkeros/core/dev';\nimport { userDataKeys } from '../userData';\nimport { ActionSourceSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n accessToken: z\n .string()\n .min(1)\n .describe(\n 'Meta access token for Conversions API authentication (like your_access_token)',\n ),\n pixelId: z\n .string()\n .regex(/^[0-9]+$/, 'Pixel ID must contain only digits')\n .describe(\n 'Meta Pixel ID from your Facebook Business account (like 1234567890)',\n ),\n action_source: ActionSourceSchema.describe(\n 'Source of the event (website, app, phone_call, etc.) (like website)',\n ).optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"user_data keys to send without normalizing and hashing, for values that are already hashed. Only em, ph, fn, ln, db, ge, ct, st, zp, country and external_id are hashed (like ['external_id'])\",\n )\n .optional(),\n test_event_code: z\n .string()\n .describe(\n 'Test event code for debugging Meta Conversions API events (like TEST12345)',\n )\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Custom URL for Meta Conversions API endpoint (like https://graph.facebook.com/v22.0)',\n )\n .optional(),\n user_data: z\n .partialRecord(z.enum(userDataKeys), schemas.MappingSchemas.ValueSchema)\n .describe(\n \"Mapping of Meta customer information parameters to event values, applied to every event. Keys must be Meta's short names such as em and ph (like { em: 'user.email', ph: 'user.phone' })\",\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","// Customer information parameters accepted in user_data:\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters\n// fbclid is not sent; the destination turns it into fbc.\nexport const userDataKeys = [\n 'em',\n 'ph',\n 'fn',\n 'ln',\n 'db',\n 'ge',\n 'ct',\n 'st',\n 'zp',\n 'country',\n 'external_id',\n 'client_ip_address',\n 'client_user_agent',\n 'fbc',\n 'fbp',\n 'subscription_id',\n 'fb_login_id',\n 'lead_id',\n 'anon_id',\n 'madid',\n 'page_id',\n 'page_scoped_user_id',\n 'ctwa_clid',\n 'ig_account_id',\n 'ig_sid',\n 'fbclid',\n] as const;\n\nexport function getUnknownUserDataKeys(userData: object): string[] {\n const known: readonly string[] = userDataKeys;\n return Object.keys(userData).filter((key) => !known.includes(key));\n}\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Action Source Enum\n * Where the conversion event took place\n * https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/server-event\n */\nexport const ActionSourceSchema = z.enum([\n 'email',\n 'website',\n 'app',\n 'phone_call',\n 'chat',\n 'physical_store',\n 'system_generated',\n 'business_messaging',\n 'other',\n]);\n\n/**\n * Event Name\n * Standard Meta event names or custom event identifiers\n */\nexport const EventNameSchema = z.union([\n z.enum([\n 'AddPaymentInfo',\n 'AddToCart',\n 'AddToWishlist',\n 'CompleteRegistration',\n 'Contact',\n 'CustomizeProduct',\n 'Donate',\n 'FindLocation',\n 'InitiateCheckout',\n 'Lead',\n 'Purchase',\n 'Schedule',\n 'Search',\n 'StartTrial',\n 'SubmitApplication',\n 'Subscribe',\n 'ViewContent',\n ]),\n z.string(), // Allow custom event names\n]);\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Meta Conversions API Mapping Schema\n * Meta CAPI has no event-level mapping configuration\n */\nexport const MappingSchema = z.object({});\n\n/**\n * Type inference from MappingSchema\n */\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { SendDataValue, SendResponse } from '@walkeros/core';\nimport type { SendServerOptions } from '@walkeros/server-core';\nimport type { Env } from '../types';\n\n/**\n * Example environment configurations for Meta Conversions API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\n/**\n * Mock sendServer function that simulates successful HTTP responses\n */\nasync function mockSendServer(\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n): Promise<SendResponse> {\n // Simulate successful Meta API response\n return {\n ok: true,\n data: {\n events_received: 1,\n messages: [],\n fbtrace_id: 'mock-trace-id',\n },\n };\n}\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing Meta Conversions API events without making\n * actual HTTP requests to Facebook's servers.\n */\nexport const push: Env = {\n sendServer: mockSendServer,\n};\n\nexport const simulation = ['sendServer'];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\n\n/**\n * Meta Conversions API step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body, options)`\n * where `url` is `${settings.url}/${settings.pixelId}/events`, `body` is the\n * JSON-stringified `{ data: [serverEvent] }` payload, and `options` carries the\n * access token in an `Authorization: Bearer` header (never in the URL).\n *\n * The public name users see when inspecting the destination is `sendServer`,\n * so each `out` tuple is `['sendServer', url, body, options]` with `body` as\n * the already-stringified JSON payload (mirroring the actual call signature).\n *\n * Functions in mappings are published as source code, so they must not use\n * imported helpers.\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelId = '1234567890'`,\n * so every endpoint resolves to:\n * https://graph.facebook.com/v22.0/1234567890/events\n * with header `Authorization: Bearer s3cr3t`.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * 1. event_name\n * 2. event_id\n * 3. event_time (unix seconds; `Math.round(event.timestamp / 1000)`)\n * 4. action_source\n * 5. ...mapped event data (currency, value, etc.)\n * 6. user_data (hashed per Meta's PII requirements)\n * 7. event_source_url (appended after hash when action_source === 'website')\n */\nconst ENDPOINT = 'https://graph.facebook.com/v22.0/1234567890/events';\n\nconst OPTIONS = { headers: { Authorization: 'Bearer s3cr3t' } };\n\nexport const purchase: Flow.StepExample = {\n title: 'Purchase',\n description:\n 'A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.',\n in: getEvent('order complete', {\n id: 'c1d2e3f4a5b60001',\n timestamp: 1700000900000,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n nested: [\n { entity: 'product', data: { id: 'SKU-A1', price: 129.99, quantity: 2 } },\n ],\n user: { id: 'user-123', device: 'device-456' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://shop.example.com',\n },\n }),\n mapping: {\n name: 'Purchase',\n data: {\n map: {\n order_id: 'data.id',\n currency: { key: 'data.currency', value: 'EUR' },\n value: 'data.total',\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity: unknown) =>\n typeof entity === 'object' &&\n entity !== null &&\n 'entity' in entity &&\n entity.entity === 'product',\n map: {\n id: 'data.id',\n item_price: 'data.price',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n num_items: {\n fn: (event: unknown) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.entity === 'product',\n ).length,\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'Purchase',\n event_id: 'c1d2e3f4a5b60001',\n event_time: 1700000900,\n action_source: 'website',\n order_id: 'ORD-300',\n currency: 'EUR',\n value: 249.99,\n contents: [{ id: 'SKU-A1', item_price: 129.99, quantity: 2 }],\n num_items: 1,\n user_data: {},\n event_source_url: 'https://shop.example.com',\n },\n ],\n }),\n OPTIONS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Form submit',\n description:\n 'A form submission is forwarded to Meta CAPI as a custom event with the event source URL.',\n in: getEvent('form submit', {\n id: 'c1d2e3f4a5b60002',\n timestamp: 1700000901000,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://example.com',\n },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'form submit',\n event_id: 'c1d2e3f4a5b60002',\n event_time: 1700000901,\n action_source: 'website',\n user_data: {},\n event_source_url: 'https://example.com',\n },\n ],\n }),\n OPTIONS,\n ],\n ],\n};\n\nexport const purchaseWithClickAttribution: Flow.StepExample = {\n title: 'Purchase with fbclid',\n description:\n 'A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.',\n in: getEvent('order complete', {\n id: 'c1d2e3f4a5b60003',\n timestamp: 1700000902000,\n data: { id: 'ORD-700', total: 89.99, currency: 'USD' },\n user: { id: 'cust-42' },\n context: { fbclid: ['abc123xyz', 0] },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://shop.example.com',\n },\n }),\n mapping: {\n name: 'Purchase',\n data: {\n map: {\n currency: { key: 'data.currency', value: 'EUR' },\n value: 'data.total',\n order_id: 'data.id',\n user_data: {\n map: {\n external_id: 'user.id',\n fbclid: 'context.fbclid.0',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'Purchase',\n event_id: 'c1d2e3f4a5b60003',\n event_time: 1700000902,\n action_source: 'website',\n currency: 'USD',\n value: 89.99,\n order_id: 'ORD-700',\n user_data: {\n // sha256('cust-42')\n external_id:\n '8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa',\n // fb.subdomainIndex.creationTime.fbclid, creationTime in milliseconds\n fbc: 'fb.1.1700000902000.abc123xyz',\n },\n event_source_url: 'https://shop.example.com',\n },\n ],\n }),\n OPTIONS,\n ],\n ],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS,KAAAA,UAAS;;;ACGpB,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;AC9BA,SAAS,SAAS;AAOX,IAAM,qBAAqB,EAAE,KAAK;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,kBAAkB,EAAE,MAAM;AAAA,EACrC,EAAE,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAAA,EACD,EAAE,OAAO;AAAA;AACX,CAAC;;;AFxCM,IAAM,iBAAiBC,GAAE,OAAO;AAAA,EACr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K,iBAAiB,OAAO,MAAM;AAAA,QAC/C,OAAO;AAAA,QACP,UAAU;AAAA,QACV,WAAW;AAAA,UACT,KAAK;AAAA,YACH,aAAa;AAAA,YACb,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,MAAM;AAAA,UACJ;AAAA,YACE,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,YAAY;AAAA,YACZ,eAAe;AAAA,YACf,UAAU;AAAA,YACV,OAAO;AAAA,YACP,UAAU;AAAA,YACV,WAAW;AAAA;AAAA,cAET,aACE;AAAA;AAAA,cAEF,KAAK;AAAA,YACP;AAAA,YACA,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;","names":["z","z","z"]}
|
package/dist/examples/index.js
CHANGED
|
@@ -54,14 +54,14 @@ __export(step_exports, {
|
|
|
54
54
|
purchaseWithClickAttribution: () => purchaseWithClickAttribution
|
|
55
55
|
});
|
|
56
56
|
var import_core = require("@walkeros/core");
|
|
57
|
-
var ENDPOINT = "https://graph.facebook.com/v22.0/
|
|
57
|
+
var ENDPOINT = "https://graph.facebook.com/v22.0/1234567890/events";
|
|
58
58
|
var OPTIONS = { headers: { Authorization: "Bearer s3cr3t" } };
|
|
59
59
|
var purchase = {
|
|
60
60
|
title: "Purchase",
|
|
61
61
|
description: "A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.",
|
|
62
62
|
in: (0, import_core.getEvent)("order complete", {
|
|
63
63
|
id: "c1d2e3f4a5b60001",
|
|
64
|
-
timestamp:
|
|
64
|
+
timestamp: 17000009e5,
|
|
65
65
|
data: { id: "ORD-300", total: 249.99, currency: "EUR" },
|
|
66
66
|
nested: [
|
|
67
67
|
{ entity: "product", data: { id: "SKU-A1", price: 129.99, quantity: 2 } }
|
|
@@ -84,7 +84,7 @@ var purchase = {
|
|
|
84
84
|
loop: [
|
|
85
85
|
"nested",
|
|
86
86
|
{
|
|
87
|
-
condition: (entity) =>
|
|
87
|
+
condition: (entity) => typeof entity === "object" && entity !== null && "entity" in entity && entity.entity === "product",
|
|
88
88
|
map: {
|
|
89
89
|
id: "data.id",
|
|
90
90
|
item_price: "data.price",
|
|
@@ -110,7 +110,7 @@ var purchase = {
|
|
|
110
110
|
{
|
|
111
111
|
event_name: "Purchase",
|
|
112
112
|
event_id: "c1d2e3f4a5b60001",
|
|
113
|
-
event_time:
|
|
113
|
+
event_time: 1700000900,
|
|
114
114
|
action_source: "website",
|
|
115
115
|
order_id: "ORD-300",
|
|
116
116
|
currency: "EUR",
|
|
@@ -131,7 +131,7 @@ var lead = {
|
|
|
131
131
|
description: "A form submission is forwarded to Meta CAPI as a custom event with the event source URL.",
|
|
132
132
|
in: (0, import_core.getEvent)("form submit", {
|
|
133
133
|
id: "c1d2e3f4a5b60002",
|
|
134
|
-
timestamp:
|
|
134
|
+
timestamp: 1700000901e3,
|
|
135
135
|
data: { type: "newsletter" },
|
|
136
136
|
user: { email: "user@example.com" },
|
|
137
137
|
source: {
|
|
@@ -150,7 +150,7 @@ var lead = {
|
|
|
150
150
|
{
|
|
151
151
|
event_name: "form submit",
|
|
152
152
|
event_id: "c1d2e3f4a5b60002",
|
|
153
|
-
event_time:
|
|
153
|
+
event_time: 1700000901,
|
|
154
154
|
action_source: "website",
|
|
155
155
|
user_data: {},
|
|
156
156
|
event_source_url: "https://example.com"
|
|
@@ -166,7 +166,7 @@ var purchaseWithClickAttribution = {
|
|
|
166
166
|
description: "A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.",
|
|
167
167
|
in: (0, import_core.getEvent)("order complete", {
|
|
168
168
|
id: "c1d2e3f4a5b60003",
|
|
169
|
-
timestamp:
|
|
169
|
+
timestamp: 1700000902e3,
|
|
170
170
|
data: { id: "ORD-700", total: 89.99, currency: "USD" },
|
|
171
171
|
user: { id: "cust-42" },
|
|
172
172
|
context: { fbclid: ["abc123xyz", 0] },
|
|
@@ -186,7 +186,7 @@ var purchaseWithClickAttribution = {
|
|
|
186
186
|
user_data: {
|
|
187
187
|
map: {
|
|
188
188
|
external_id: "user.id",
|
|
189
|
-
fbclid: "context.fbclid"
|
|
189
|
+
fbclid: "context.fbclid.0"
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -201,7 +201,7 @@ var purchaseWithClickAttribution = {
|
|
|
201
201
|
{
|
|
202
202
|
event_name: "Purchase",
|
|
203
203
|
event_id: "c1d2e3f4a5b60003",
|
|
204
|
-
event_time:
|
|
204
|
+
event_time: 1700000902,
|
|
205
205
|
action_source: "website",
|
|
206
206
|
currency: "USD",
|
|
207
207
|
value: 89.99,
|
|
@@ -209,9 +209,8 @@ var purchaseWithClickAttribution = {
|
|
|
209
209
|
user_data: {
|
|
210
210
|
// sha256('cust-42')
|
|
211
211
|
external_id: "8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa",
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
fbc: "fb.1.1700000902.abc123xyz,0"
|
|
212
|
+
// fb.subdomainIndex.creationTime.fbclid, creationTime in milliseconds
|
|
213
|
+
fbc: "fb.1.1700000902000.abc123xyz"
|
|
215
214
|
},
|
|
216
215
|
event_source_url: "https://shop.example.com"
|
|
217
216
|
}
|