@walkeros/server-destination-meta 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +6 -0
- package/dist/examples/index.mjs +6 -0
- package/dist/walkerOS.json +10 -4
- package/package.json +4 -4
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o=(e,r)=>{for(var a in r)t(e,a,{get:r[a],enumerable:!0})},s={};o(s,{examples:()=>b,schemas:()=>n}),module.exports=(e=s,((e,o,s,n)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let c of a(o))i.call(e,c)||c===s||t(e,c,{get:()=>o[c],enumerable:!(n=r(o,c))||n.enumerable});return e})(t({},"__esModule",{value:!0}),e));var n={};o(n,{ActionSourceSchema:()=>p,EventNameSchema:()=>l,MappingSchema:()=>v,SettingsSchema:()=>m,mapping:()=>
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o=(e,r)=>{for(var a in r)t(e,a,{get:r[a],enumerable:!0})},s={};o(s,{examples:()=>b,schemas:()=>n}),module.exports=(e=s,((e,o,s,n)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let c of a(o))i.call(e,c)||c===s||t(e,c,{get:()=>o[c],enumerable:!(n=r(o,c))||n.enumerable});return e})(t({},"__esModule",{value:!0}),e));var n={};o(n,{ActionSourceSchema:()=>p,EventNameSchema:()=>l,MappingSchema:()=>v,SettingsSchema:()=>m,mapping:()=>_,settings:()=>h});var c=require("@walkeros/core/dev"),d=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),p=u.z.enum(["email","website","app","phone_call","chat","physical_store","system_generated","business_messaging","other"]),l=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:p.describe("Source of the event (website, app, phone_call, etc.) (like website)").optional(),doNotHash:d.z.array(d.z.string()).describe("Array of user_data fields that should not be hashed (like ['client_ip_address', 'client_user_agent'])").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/v17.0)").optional(),user_data:d.z.record(d.z.string(),d.z.string()).describe("Mapping configuration for user data fields (like { email: 'user.email', phone: 'user.phone' })").optional()}),v=require("@walkeros/core/dev").z.object({}),h=(0,c.zodToSchema)(m),_=(0,c.zodToSchema)(v),b={};o(b,{env:()=>f,step:()=>k});var f={};o(f,{push:()=>g,simulation:()=>y});var g={sendServer:async function(e,t,r){return{ok:!0,data:{events_received:1,messages:[],fbtrace_id:"mock-trace-id"}}}},y=["sendServer"],k={};o(k,{lead:()=>x,purchase:()=>w,purchaseWithClickAttribution:()=>z});var S=require("@walkeros/core"),P="https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t",w={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",{timestamp:1700000900,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:"server",id:"https://shop.example.com",previous_id:""}}),mapping:{name:"Purchase",data:{map:{order_id:"data.id",currency:{key:"data.currency",value:"EUR"},value:"data.total",contents:{loop:["nested",{condition:e=>(0,S.isObject)(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",P,JSON.stringify({data:[{event_name:"Purchase",event_id:"1700000900-gr0up-1",event_time:1700001,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={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",{timestamp:1700000901,data:{type:"newsletter"},user:{email:"user@example.com"},source:{type:"server",id:"https://example.com",previous_id:""}}),mapping:void 0,out:[["sendServer",P,JSON.stringify({data:[{event_name:"form submit",event_id:"1700000901-gr0up-1",event_time:1700001,action_source:"website",user_data:{},event_source_url:"https://example.com"}]})]]},z={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",{timestamp:1700000902,data:{id:"ORD-700",total:89.99,currency:"USD"},user:{id:"cust-42"},context:{fbclid:["abc123xyz",0]},source:{type:"server",id:"https://shop.example.com",previous_id:""}}),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"}}}}},out:[["sendServer",P,JSON.stringify({data:[{event_name:"Purchase",event_id:"1700000902-gr0up-1",event_time:1700001,action_source:"website",currency:"USD",value:89.99,order_id:"ORD-700",user_data:{external_id:"8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa",fbc:"fb.1.1700000902.abc123xyz,0"},event_source_url:"https://shop.example.com"}]})]]};//# 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)` where\n * `url` is `${settings.url}${settings.pixelId}/events?access_token=${settings.accessToken}`\n * and `body` is the JSON-stringified `{ data: [serverEvent] }` payload.\n *\n * The public name users see when inspecting the destination is `sendServer`,\n * so each `out` tuple is `['sendServer', url, body]` with `body` as the\n * 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?access_token=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 =\n 'https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t';\n\nexport const purchase: Flow.StepExample = {\n in: getEvent('order complete', {\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: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\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: '1700000900-gr0up-1',\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 ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n in: getEvent('form submit', {\n timestamp: 1700000901,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: { type: 'server', id: 'https://example.com', previous_id: '' },\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: '1700000901-gr0up-1',\n event_time: 1700001,\n action_source: 'website',\n user_data: {},\n event_source_url: 'https://example.com',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const purchaseWithClickAttribution: Flow.StepExample = {\n in: getEvent('order complete', {\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: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\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: '1700000902-gr0up-1',\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 ],\n ],\n};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kBAAkB;AAAA,IAC7B,WAAW;AAAA,IACX,MAAM,EAAE,IAAI,WAAW,OAAO,OAAO,UAAU,MAAM;AAAA,IACrD,MAAM,EAAE,IAAI,UAAU;AAAA,IACtB,SAAS,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAE;AAAA,IACpC,QAAQ,EAAE,MAAM,UAAU,IAAI,4BAA4B,aAAa,GAAG;AAAA,EAC5E,CAAC;AAAA,EACD,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;AAAA,cAGF,KAAK;AAAA,YACP;AAAA,YACA,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;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/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)` where\n * `url` is `${settings.url}${settings.pixelId}/events?access_token=${settings.accessToken}`\n * and `body` is the JSON-stringified `{ data: [serverEvent] }` payload.\n *\n * The public name users see when inspecting the destination is `sendServer`,\n * so each `out` tuple is `['sendServer', url, body]` with `body` as the\n * 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?access_token=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 =\n 'https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=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 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: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\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: '1700000900-gr0up-1',\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 ],\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 timestamp: 1700000901,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: { type: 'server', id: 'https://example.com', previous_id: '' },\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: '1700000901-gr0up-1',\n event_time: 1700001,\n action_source: 'website',\n user_data: {},\n event_source_url: 'https://example.com',\n },\n ],\n }),\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 timestamp: 1700000902,\n data: { id: 'ORD-700', total: 89.99, currency: 'USD' },\n user: { id: 'cust-42' },\n context: { fbclid: ['abc123xyz', 0] },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\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: '1700000902-gr0up-1',\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 ],\n ],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA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kB;AAAA,IAC7B,WAAW;AAAA,IACX,MAAM,EAAE,IAAI,WAAW,OAAO,OAAO,UAAU,MAAM;AAAA,IACrD,MAAM,EAAE,IAAI,UAAU;AAAA,IACtB,SAAS,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAE;AAAA,IACpC,QAAQ,EAAE,MAAM,UAAU,IAAI,4BAA4B,aAAa,GAAG;AAAA,EAC5E,CAAC;AAAA,EACD,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;AAAA,cAGF,KAAK;AAAA,YACP;AAAA,YACA,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;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:()=>o,EventNameSchema:()=>n,MappingSchema:()=>u,SettingsSchema:()=>c,mapping:()=>m,settings:()=>p});import{zodToSchema as r}from"@walkeros/core/dev";import{z as i}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";var o=s.enum(["email","website","app","phone_call","chat","physical_store","system_generated","business_messaging","other"]),n=s.union([s.enum(["AddPaymentInfo","AddToCart","AddToWishlist","CompleteRegistration","Contact","CustomizeProduct","Donate","FindLocation","InitiateCheckout","Lead","Purchase","Schedule","Search","StartTrial","SubmitApplication","Subscribe","ViewContent"]),s.string()]),c=i.object({accessToken:i.string().min(1).describe("Meta access token for Conversions API authentication (like your_access_token)"),pixelId:i.string().regex(/^[0-9]+$/,"Pixel ID must contain only digits").describe("Meta Pixel ID from your Facebook Business account (like 1234567890)"),action_source:o.describe("Source of the event (website, app, phone_call, etc.) (like website)").optional(),doNotHash:i.array(i.string()).describe("Array of user_data fields that should not be hashed (like ['client_ip_address', 'client_user_agent'])").optional(),test_event_code:i.string().describe("Test event code for debugging Meta Conversions API events (like TEST12345)").optional(),url:i.string().url().describe("Custom URL for Meta Conversions API endpoint (like https://graph.facebook.com/v17.0)").optional(),user_data:i.record(i.string(),i.string()).describe("Mapping configuration for user data fields (like { email: 'user.email', phone: 'user.phone' })").optional()});import{z as d}from"@walkeros/core/dev";var u=d.object({}),p=r(c),m=r(u),l={};t(l,{env:()=>v,step:()=>b});var v={};t(v,{push:()=>h,simulation:()=>_});var h={sendServer:async function(e,t,a){return{ok:!0,data:{events_received:1,messages:[],fbtrace_id:"mock-trace-id"}}}},_=["sendServer"],b={};t(b,{lead:()=>S,purchase:()=>k,purchaseWithClickAttribution:()=>x});import{getEvent as f,isObject as g}from"@walkeros/core";var y="https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t",k={title:"Purchase",description:"A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.",in:f("order complete",{timestamp:1700000900,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:"server",id:"https://shop.example.com",previous_id:""}}),mapping:{name:"Purchase",data:{map:{order_id:"data.id",currency:{key:"data.currency",value:"EUR"},value:"data.total",contents:{loop:["nested",{condition:e=>g(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",y,JSON.stringify({data:[{event_name:"Purchase",event_id:"1700000900-gr0up-1",event_time:1700001,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"}]})]]},S={title:"Form submit",description:"A form submission is forwarded to Meta CAPI as a custom event with the event source URL.",in:f("form submit",{timestamp:1700000901,data:{type:"newsletter"},user:{email:"user@example.com"},source:{type:"server",id:"https://example.com",previous_id:""}}),mapping:void 0,out:[["sendServer",y,JSON.stringify({data:[{event_name:"form submit",event_id:"1700000901-gr0up-1",event_time:1700001,action_source:"website",user_data:{},event_source_url:"https://example.com"}]})]]},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:f("order complete",{timestamp:1700000902,data:{id:"ORD-700",total:89.99,currency:"USD"},user:{id:"cust-42"},context:{fbclid:["abc123xyz",0]},source:{type:"server",id:"https://shop.example.com",previous_id:""}}),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"}}}}},out:[["sendServer",y,JSON.stringify({data:[{event_name:"Purchase",event_id:"1700000902-gr0up-1",event_time:1700001,action_source:"website",currency:"USD",value:89.99,order_id:"ORD-700",user_data:{external_id:"8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa",fbc:"fb.1.1700000902.abc123xyz,0"},event_source_url:"https://shop.example.com"}]})]]};export{l 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)` where\n * `url` is `${settings.url}${settings.pixelId}/events?access_token=${settings.accessToken}`\n * and `body` is the JSON-stringified `{ data: [serverEvent] }` payload.\n *\n * The public name users see when inspecting the destination is `sendServer`,\n * so each `out` tuple is `['sendServer', url, body]` with `body` as the\n * 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?access_token=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 =\n 'https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t';\n\nexport const purchase: Flow.StepExample = {\n in: getEvent('order complete', {\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: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\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: '1700000900-gr0up-1',\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 ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n in: getEvent('form submit', {\n timestamp: 1700000901,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: { type: 'server', id: 'https://example.com', previous_id: '' },\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: '1700000901-gr0up-1',\n event_time: 1700001,\n action_source: 'website',\n user_data: {},\n event_source_url: 'https://example.com',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const purchaseWithClickAttribution: Flow.StepExample = {\n in: getEvent('order complete', {\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: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\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: '1700000902-gr0up-1',\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 ],\n ],\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WAAW;AAAA,IACX,MAAM,EAAE,IAAI,WAAW,OAAO,OAAO,UAAU,MAAM;AAAA,IACrD,MAAM,EAAE,IAAI,UAAU;AAAA,IACtB,SAAS,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAE;AAAA,IACpC,QAAQ,EAAE,MAAM,UAAU,IAAI,4BAA4B,aAAa,GAAG;AAAA,EAC5E,CAAC;AAAA,EACD,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;AAAA,cAGF,KAAK;AAAA,YACP;AAAA,YACA,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["z","z","z"]}
|
|
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)` where\n * `url` is `${settings.url}${settings.pixelId}/events?access_token=${settings.accessToken}`\n * and `body` is the JSON-stringified `{ data: [serverEvent] }` payload.\n *\n * The public name users see when inspecting the destination is `sendServer`,\n * so each `out` tuple is `['sendServer', url, body]` with `body` as the\n * 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?access_token=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 =\n 'https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=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 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: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\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: '1700000900-gr0up-1',\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 ],\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 timestamp: 1700000901,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: { type: 'server', id: 'https://example.com', previous_id: '' },\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: '1700000901-gr0up-1',\n event_time: 1700001,\n action_source: 'website',\n user_data: {},\n event_source_url: 'https://example.com',\n },\n ],\n }),\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 timestamp: 1700000902,\n data: { id: 'ORD-700', total: 89.99, currency: 'USD' },\n user: { id: 'cust-42' },\n context: { fbclid: ['abc123xyz', 0] },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\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: '1700000902-gr0up-1',\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 ],\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;AA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AAE,IAAI,UAAU;AAAA,IACtB,SAAS,EAAE,QAAQ,CAAC,aAAa,CAAC,EAAE;AAAA,IACpC,QAAQ,EAAE,MAAM,UAAU,IAAI,4BAA4B,aAAa,GAAG;AAAA,EAC5E,CAAC;AAAA,EACD,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;AAAA,cAGF,KAAK;AAAA,YACP;AAAA,YACA,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["z","z","z"]}
|
package/dist/examples/index.js
CHANGED
|
@@ -56,6 +56,8 @@ __export(step_exports, {
|
|
|
56
56
|
var import_core = require("@walkeros/core");
|
|
57
57
|
var ENDPOINT = "https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t";
|
|
58
58
|
var purchase = {
|
|
59
|
+
title: "Purchase",
|
|
60
|
+
description: "A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.",
|
|
59
61
|
in: (0, import_core.getEvent)("order complete", {
|
|
60
62
|
timestamp: 1700000900,
|
|
61
63
|
data: { id: "ORD-300", total: 249.99, currency: "EUR" },
|
|
@@ -118,6 +120,8 @@ var purchase = {
|
|
|
118
120
|
]
|
|
119
121
|
};
|
|
120
122
|
var lead = {
|
|
123
|
+
title: "Form submit",
|
|
124
|
+
description: "A form submission is forwarded to Meta CAPI as a custom event with the event source URL.",
|
|
121
125
|
in: (0, import_core.getEvent)("form submit", {
|
|
122
126
|
timestamp: 1700000901,
|
|
123
127
|
data: { type: "newsletter" },
|
|
@@ -145,6 +149,8 @@ var lead = {
|
|
|
145
149
|
]
|
|
146
150
|
};
|
|
147
151
|
var purchaseWithClickAttribution = {
|
|
152
|
+
title: "Purchase with fbclid",
|
|
153
|
+
description: "A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.",
|
|
148
154
|
in: (0, import_core.getEvent)("order complete", {
|
|
149
155
|
timestamp: 1700000902,
|
|
150
156
|
data: { id: "ORD-700", total: 89.99, currency: "USD" },
|
package/dist/examples/index.mjs
CHANGED
|
@@ -35,6 +35,8 @@ __export(step_exports, {
|
|
|
35
35
|
import { getEvent, isObject } from "@walkeros/core";
|
|
36
36
|
var ENDPOINT = "https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t";
|
|
37
37
|
var purchase = {
|
|
38
|
+
title: "Purchase",
|
|
39
|
+
description: "A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.",
|
|
38
40
|
in: getEvent("order complete", {
|
|
39
41
|
timestamp: 1700000900,
|
|
40
42
|
data: { id: "ORD-300", total: 249.99, currency: "EUR" },
|
|
@@ -97,6 +99,8 @@ var purchase = {
|
|
|
97
99
|
]
|
|
98
100
|
};
|
|
99
101
|
var lead = {
|
|
102
|
+
title: "Form submit",
|
|
103
|
+
description: "A form submission is forwarded to Meta CAPI as a custom event with the event source URL.",
|
|
100
104
|
in: getEvent("form submit", {
|
|
101
105
|
timestamp: 1700000901,
|
|
102
106
|
data: { type: "newsletter" },
|
|
@@ -124,6 +128,8 @@ var lead = {
|
|
|
124
128
|
]
|
|
125
129
|
};
|
|
126
130
|
var purchaseWithClickAttribution = {
|
|
131
|
+
title: "Purchase with fbclid",
|
|
132
|
+
description: "A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.",
|
|
127
133
|
in: getEvent("order complete", {
|
|
128
134
|
timestamp: 1700000902,
|
|
129
135
|
data: { id: "ORD-700", total: 89.99, currency: "USD" },
|
package/dist/walkerOS.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$meta": {
|
|
3
3
|
"package": "@walkeros/server-destination-meta",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.1",
|
|
5
5
|
"type": "destination",
|
|
6
6
|
"platform": [
|
|
7
7
|
"server"
|
|
@@ -92,6 +92,8 @@
|
|
|
92
92
|
},
|
|
93
93
|
"step": {
|
|
94
94
|
"lead": {
|
|
95
|
+
"title": "Form submit",
|
|
96
|
+
"description": "A form submission is forwarded to Meta CAPI as a custom event with the event source URL.",
|
|
95
97
|
"in": {
|
|
96
98
|
"name": "form submit",
|
|
97
99
|
"data": {
|
|
@@ -139,7 +141,7 @@
|
|
|
139
141
|
"group": "gr0up",
|
|
140
142
|
"count": 1,
|
|
141
143
|
"version": {
|
|
142
|
-
"source": "3.4.
|
|
144
|
+
"source": "3.4.1",
|
|
143
145
|
"tagging": 1
|
|
144
146
|
},
|
|
145
147
|
"source": {
|
|
@@ -157,6 +159,8 @@
|
|
|
157
159
|
]
|
|
158
160
|
},
|
|
159
161
|
"purchase": {
|
|
162
|
+
"title": "Purchase",
|
|
163
|
+
"description": "A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.",
|
|
160
164
|
"in": {
|
|
161
165
|
"name": "order complete",
|
|
162
166
|
"data": {
|
|
@@ -202,7 +206,7 @@
|
|
|
202
206
|
"group": "gr0up",
|
|
203
207
|
"count": 1,
|
|
204
208
|
"version": {
|
|
205
|
-
"source": "3.4.
|
|
209
|
+
"source": "3.4.1",
|
|
206
210
|
"tagging": 1
|
|
207
211
|
},
|
|
208
212
|
"source": {
|
|
@@ -256,6 +260,8 @@
|
|
|
256
260
|
]
|
|
257
261
|
},
|
|
258
262
|
"purchaseWithClickAttribution": {
|
|
263
|
+
"title": "Purchase with fbclid",
|
|
264
|
+
"description": "A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.",
|
|
259
265
|
"in": {
|
|
260
266
|
"name": "order complete",
|
|
261
267
|
"data": {
|
|
@@ -338,7 +344,7 @@
|
|
|
338
344
|
"group": "gr0up",
|
|
339
345
|
"count": 1,
|
|
340
346
|
"version": {
|
|
341
|
-
"source": "3.4.
|
|
347
|
+
"source": "3.4.1",
|
|
342
348
|
"tagging": 1
|
|
343
349
|
},
|
|
344
350
|
"source": {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/server-destination-meta",
|
|
3
3
|
"description": "Meta server destination for walkerOS",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"update": "npx npm-check-updates -u && npm update"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@walkeros/core": "3.4.
|
|
38
|
-
"@walkeros/server-core": "3.4.
|
|
37
|
+
"@walkeros/core": "3.4.1",
|
|
38
|
+
"@walkeros/server-core": "3.4.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@walkeros/collector": "3.4.
|
|
41
|
+
"@walkeros/collector": "3.4.1"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|