@walkeros/server-destination-meta 3.3.1 → 3.4.0

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 CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,o=(e,a)=>{for(var r in a)t(e,r,{get:a[r],enumerable:!0})},n={};o(n,{examples:()=>g,schemas:()=>s}),module.exports=(e=n,((e,o,n,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let c of r(o))i.call(e,c)||c===n||t(e,c,{get:()=>o[c],enumerable:!(s=a(o,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={};o(s,{ActionSourceSchema:()=>p,EventNameSchema:()=>l,MappingSchema:()=>v,SettingsSchema:()=>m,mapping:()=>h,settings:()=>_});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({}),_=(0,c.zodToSchema)(m),h=(0,c.zodToSchema)(v),g={};o(g,{env:()=>b,step:()=>k});var b={};o(b,{push:()=>y,simulation:()=>f});var y={sendServer:async function(e,t,a){return{ok:!0,data:{events_received:1,messages:[],fbtrace_id:"mock-trace-id"}}}},f=["sendServer"],k={};o(k,{lead:()=>z,purchase:()=>x,purchaseWithClickAttribution:()=>w});var S=require("@walkeros/core"),x={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:{data:[{event_name:"Purchase",event_time:1700000900,event_id:"1700000900-gr0up-1",event_source_url:"https://shop.example.com",action_source:"website",user_data:{external_id:["user-123"]},currency:"EUR",value:249.99,contents:[{id:"SKU-A1",quantity:2,item_price:129.99}]}]}},z={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:{data:[{event_name:"Lead",event_time:1700000901,event_id:"1700000901-gr0up-1",event_source_url:"https://example.com",action_source:"website",user_data:{email:["user@example.com"]}}]}},w={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:{data:[{event_name:"Purchase",event_time:1700000902,event_id:"1700000902-gr0up-1",event_source_url:"https://shop.example.com",action_source:"website",currency:"USD",value:89.99,order_id:"ORD-700"}]}};//# sourceMappingURL=dev.js.map
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:()=>h,settings:()=>_});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({}),_=(0,c.zodToSchema)(m),h=(0,c.zodToSchema)(v),b={};o(b,{env:()=>g,step:()=>S});var g={};o(g,{push:()=>y,simulation:()=>f});var y={sendServer:async function(e,t,r){return{ok:!0,data:{events_received:1,messages:[],fbtrace_id:"mock-trace-id"}}}},f=["sendServer"],S={};o(S,{lead:()=>w,purchase:()=>z,purchaseWithClickAttribution:()=>P});var k=require("@walkeros/core"),x="https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t",z={in:(0,k.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,k.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",x,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"}]})]]},w={in:(0,k.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",x,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"}]})]]},P={in:(0,k.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",x,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\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 data: [\n {\n event_name: 'Purchase',\n event_time: 1700000900,\n event_id: '1700000900-gr0up-1',\n event_source_url: 'https://shop.example.com',\n action_source: 'website',\n user_data: {\n external_id: ['user-123'],\n },\n currency: 'EUR',\n value: 249.99,\n contents: [{ id: 'SKU-A1', quantity: 2, item_price: 129.99 }],\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 data: [\n {\n event_name: 'Lead',\n event_time: 1700000901,\n event_id: '1700000901-gr0up-1',\n event_source_url: 'https://example.com',\n action_source: 'website',\n user_data: {\n email: ['user@example.com'],\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 data: [\n {\n event_name: 'Purchase',\n event_time: 1700000902,\n event_id: '1700000902-gr0up-1',\n event_source_url: 'https://shop.example.com',\n action_source: 'website',\n currency: 'USD',\n value: 89.99,\n order_id: 'ORD-700',\n },\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;AAA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YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,kBAAkB;AAAA,QAClB,eAAe;AAAA,QACf,UAAU;AAAA,QACV,OAAO;AAAA,QACP,UAAU;AAAA,MACZ;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/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};\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,IACC;AAAA,EACF;AAAA,EACF,SAAS,cACN,OAAO,EACP,MAAM,YAAY,mCAAmC,EACrD;AAAA,IACC;AAAA,EACF;AAAA,EACF,eAAe,mBAAmB;AAAA,IAChC;AAAA,EACF,EAAE,SAAS;AAAA,EACX,WAAW,cACR,MAAM,cAAE,OAAO,CAAC,EAChB;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,iBAAiB,cACd,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,KAAK,cACF,OAAO,EACP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YACZ,eAAe;AAAA,YACf,WAAW,CAAC;AAAA,YACZ,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,IAAM,+BAAiD;AAAA,EAC5D,QAAI,sBAAS,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"]}
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:()=>s,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 o}from"@walkeros/core/dev";var s=o.enum(["email","website","app","phone_call","chat","physical_store","system_generated","business_messaging","other"]),n=o.union([o.enum(["AddPaymentInfo","AddToCart","AddToWishlist","CompleteRegistration","Contact","CustomizeProduct","Donate","FindLocation","InitiateCheckout","Lead","Purchase","Schedule","Search","StartTrial","SubmitApplication","Subscribe","ViewContent"]),o.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:s.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:()=>g});var v={};t(v,{push:()=>_,simulation:()=>h});var _={sendServer:async function(e,t,a){return{ok:!0,data:{events_received:1,messages:[],fbtrace_id:"mock-trace-id"}}}},h=["sendServer"],g={};t(g,{lead:()=>k,purchase:()=>f,purchaseWithClickAttribution:()=>x});import{getEvent as y,isObject as b}from"@walkeros/core";var f={in:y("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=>b(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:{data:[{event_name:"Purchase",event_time:1700000900,event_id:"1700000900-gr0up-1",event_source_url:"https://shop.example.com",action_source:"website",user_data:{external_id:["user-123"]},currency:"EUR",value:249.99,contents:[{id:"SKU-A1",quantity:2,item_price:129.99}]}]}},k={in:y("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:{data:[{event_name:"Lead",event_time:1700000901,event_id:"1700000901-gr0up-1",event_source_url:"https://example.com",action_source:"website",user_data:{email:["user@example.com"]}}]}},x={in:y("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:{data:[{event_name:"Purchase",event_time:1700000902,event_id:"1700000902-gr0up-1",event_source_url:"https://shop.example.com",action_source:"website",currency:"USD",value:89.99,order_id:"ORD-700"}]}};export{l as examples,a as schemas};//# sourceMappingURL=dev.mjs.map
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:()=>s,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 o}from"@walkeros/core/dev";var s=o.enum(["email","website","app","phone_call","chat","physical_store","system_generated","business_messaging","other"]),n=o.union([o.enum(["AddPaymentInfo","AddToCart","AddToWishlist","CompleteRegistration","Contact","CustomizeProduct","Donate","FindLocation","InitiateCheckout","Lead","Purchase","Schedule","Search","StartTrial","SubmitApplication","Subscribe","ViewContent"]),o.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:s.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:()=>_,simulation:()=>h});var _={sendServer:async function(e,t,a){return{ok:!0,data:{events_received:1,messages:[],fbtrace_id:"mock-trace-id"}}}},h=["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={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={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={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\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 data: [\n {\n event_name: 'Purchase',\n event_time: 1700000900,\n event_id: '1700000900-gr0up-1',\n event_source_url: 'https://shop.example.com',\n action_source: 'website',\n user_data: {\n external_id: ['user-123'],\n },\n currency: 'EUR',\n value: 249.99,\n contents: [{ id: 'SKU-A1', quantity: 2, item_price: 129.99 }],\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 data: [\n {\n event_name: 'Lead',\n event_time: 1700000901,\n event_id: '1700000901-gr0up-1',\n event_source_url: 'https://example.com',\n action_source: 'website',\n user_data: {\n email: ['user@example.com'],\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 data: [\n {\n event_name: 'Purchase',\n event_time: 1700000902,\n event_id: '1700000902-gr0up-1',\n event_source_url: 'https://shop.example.com',\n action_source: 'website',\n currency: 'USD',\n value: 89.99,\n order_id: 'ORD-700',\n },\n ],\n },\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB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A,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,MAAM;AAAA,MACJ;AAAA,QACE,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,UAAU;AAAA,QACV,kBAAkB;AAAA,QAClB,eAAe;AAAA,QACf,UAAU;AAAA,QACV,OAAO;AAAA,QACP,UAAU;AAAA,MACZ;AAAA,IACF;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 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};\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,SAASA,GACN,OAAO,EACP,MAAM,YAAY,mCAAmC,EACrD;AAAA,IACC;AAAA,EACF;AAAA,EACF,eAA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A,cAGF,KAAK;AAAA,YACP;AAAA,YACA,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["z","z","z"]}
@@ -54,6 +54,7 @@ __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/p1x3l1d/events?access_token=s3cr3t";
57
58
  var purchase = {
58
59
  in: (0, import_core.getEvent)("order complete", {
59
60
  timestamp: 1700000900,
@@ -92,23 +93,29 @@ var purchase = {
92
93
  }
93
94
  }
94
95
  },
95
- out: {
96
- data: [
97
- {
98
- event_name: "Purchase",
99
- event_time: 1700000900,
100
- event_id: "1700000900-gr0up-1",
101
- event_source_url: "https://shop.example.com",
102
- action_source: "website",
103
- user_data: {
104
- external_id: ["user-123"]
105
- },
106
- currency: "EUR",
107
- value: 249.99,
108
- contents: [{ id: "SKU-A1", quantity: 2, item_price: 129.99 }]
109
- }
96
+ out: [
97
+ [
98
+ "sendServer",
99
+ ENDPOINT,
100
+ JSON.stringify({
101
+ data: [
102
+ {
103
+ event_name: "Purchase",
104
+ event_id: "1700000900-gr0up-1",
105
+ event_time: 1700001,
106
+ action_source: "website",
107
+ order_id: "ORD-300",
108
+ currency: "EUR",
109
+ value: 249.99,
110
+ contents: [{ id: "SKU-A1", item_price: 129.99, quantity: 2 }],
111
+ num_items: 1,
112
+ user_data: {},
113
+ event_source_url: "https://shop.example.com"
114
+ }
115
+ ]
116
+ })
110
117
  ]
111
- }
118
+ ]
112
119
  };
113
120
  var lead = {
114
121
  in: (0, import_core.getEvent)("form submit", {
@@ -118,20 +125,24 @@ var lead = {
118
125
  source: { type: "server", id: "https://example.com", previous_id: "" }
119
126
  }),
120
127
  mapping: void 0,
121
- out: {
122
- data: [
123
- {
124
- event_name: "Lead",
125
- event_time: 1700000901,
126
- event_id: "1700000901-gr0up-1",
127
- event_source_url: "https://example.com",
128
- action_source: "website",
129
- user_data: {
130
- email: ["user@example.com"]
131
- }
132
- }
128
+ out: [
129
+ [
130
+ "sendServer",
131
+ ENDPOINT,
132
+ JSON.stringify({
133
+ data: [
134
+ {
135
+ event_name: "form submit",
136
+ event_id: "1700000901-gr0up-1",
137
+ event_time: 1700001,
138
+ action_source: "website",
139
+ user_data: {},
140
+ event_source_url: "https://example.com"
141
+ }
142
+ ]
143
+ })
133
144
  ]
134
- }
145
+ ]
135
146
  };
136
147
  var purchaseWithClickAttribution = {
137
148
  in: (0, import_core.getEvent)("order complete", {
@@ -157,20 +168,33 @@ var purchaseWithClickAttribution = {
157
168
  }
158
169
  }
159
170
  },
160
- out: {
161
- data: [
162
- {
163
- event_name: "Purchase",
164
- event_time: 1700000902,
165
- event_id: "1700000902-gr0up-1",
166
- event_source_url: "https://shop.example.com",
167
- action_source: "website",
168
- currency: "USD",
169
- value: 89.99,
170
- order_id: "ORD-700"
171
- }
171
+ out: [
172
+ [
173
+ "sendServer",
174
+ ENDPOINT,
175
+ JSON.stringify({
176
+ data: [
177
+ {
178
+ event_name: "Purchase",
179
+ event_id: "1700000902-gr0up-1",
180
+ event_time: 1700001,
181
+ action_source: "website",
182
+ currency: "USD",
183
+ value: 89.99,
184
+ order_id: "ORD-700",
185
+ user_data: {
186
+ // sha256('cust-42')
187
+ external_id: "8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa",
188
+ // formatClickId(['abc123xyz', 0], event.timestamp) — array joins
189
+ // to 'abc123xyz,0' when coerced to string inside the template.
190
+ fbc: "fb.1.1700000902.abc123xyz,0"
191
+ },
192
+ event_source_url: "https://shop.example.com"
193
+ }
194
+ ]
195
+ })
172
196
  ]
173
- }
197
+ ]
174
198
  };
175
199
  // Annotate the CommonJS export names for ESM import in node:
176
200
  0 && (module.exports = {
@@ -33,6 +33,7 @@ __export(step_exports, {
33
33
  purchaseWithClickAttribution: () => purchaseWithClickAttribution
34
34
  });
35
35
  import { getEvent, isObject } from "@walkeros/core";
36
+ var ENDPOINT = "https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t";
36
37
  var purchase = {
37
38
  in: getEvent("order complete", {
38
39
  timestamp: 1700000900,
@@ -71,23 +72,29 @@ var purchase = {
71
72
  }
72
73
  }
73
74
  },
74
- out: {
75
- data: [
76
- {
77
- event_name: "Purchase",
78
- event_time: 1700000900,
79
- event_id: "1700000900-gr0up-1",
80
- event_source_url: "https://shop.example.com",
81
- action_source: "website",
82
- user_data: {
83
- external_id: ["user-123"]
84
- },
85
- currency: "EUR",
86
- value: 249.99,
87
- contents: [{ id: "SKU-A1", quantity: 2, item_price: 129.99 }]
88
- }
75
+ out: [
76
+ [
77
+ "sendServer",
78
+ ENDPOINT,
79
+ JSON.stringify({
80
+ data: [
81
+ {
82
+ event_name: "Purchase",
83
+ event_id: "1700000900-gr0up-1",
84
+ event_time: 1700001,
85
+ action_source: "website",
86
+ order_id: "ORD-300",
87
+ currency: "EUR",
88
+ value: 249.99,
89
+ contents: [{ id: "SKU-A1", item_price: 129.99, quantity: 2 }],
90
+ num_items: 1,
91
+ user_data: {},
92
+ event_source_url: "https://shop.example.com"
93
+ }
94
+ ]
95
+ })
89
96
  ]
90
- }
97
+ ]
91
98
  };
92
99
  var lead = {
93
100
  in: getEvent("form submit", {
@@ -97,20 +104,24 @@ var lead = {
97
104
  source: { type: "server", id: "https://example.com", previous_id: "" }
98
105
  }),
99
106
  mapping: void 0,
100
- out: {
101
- data: [
102
- {
103
- event_name: "Lead",
104
- event_time: 1700000901,
105
- event_id: "1700000901-gr0up-1",
106
- event_source_url: "https://example.com",
107
- action_source: "website",
108
- user_data: {
109
- email: ["user@example.com"]
110
- }
111
- }
107
+ out: [
108
+ [
109
+ "sendServer",
110
+ ENDPOINT,
111
+ JSON.stringify({
112
+ data: [
113
+ {
114
+ event_name: "form submit",
115
+ event_id: "1700000901-gr0up-1",
116
+ event_time: 1700001,
117
+ action_source: "website",
118
+ user_data: {},
119
+ event_source_url: "https://example.com"
120
+ }
121
+ ]
122
+ })
112
123
  ]
113
- }
124
+ ]
114
125
  };
115
126
  var purchaseWithClickAttribution = {
116
127
  in: getEvent("order complete", {
@@ -136,20 +147,33 @@ var purchaseWithClickAttribution = {
136
147
  }
137
148
  }
138
149
  },
139
- out: {
140
- data: [
141
- {
142
- event_name: "Purchase",
143
- event_time: 1700000902,
144
- event_id: "1700000902-gr0up-1",
145
- event_source_url: "https://shop.example.com",
146
- action_source: "website",
147
- currency: "USD",
148
- value: 89.99,
149
- order_id: "ORD-700"
150
- }
150
+ out: [
151
+ [
152
+ "sendServer",
153
+ ENDPOINT,
154
+ JSON.stringify({
155
+ data: [
156
+ {
157
+ event_name: "Purchase",
158
+ event_id: "1700000902-gr0up-1",
159
+ event_time: 1700001,
160
+ action_source: "website",
161
+ currency: "USD",
162
+ value: 89.99,
163
+ order_id: "ORD-700",
164
+ user_data: {
165
+ // sha256('cust-42')
166
+ external_id: "8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa",
167
+ // formatClickId(['abc123xyz', 0], event.timestamp) — array joins
168
+ // to 'abc123xyz,0' when coerced to string inside the template.
169
+ fbc: "fb.1.1700000902.abc123xyz,0"
170
+ },
171
+ event_source_url: "https://shop.example.com"
172
+ }
173
+ ]
174
+ })
151
175
  ]
152
- }
176
+ ]
153
177
  };
154
178
  export {
155
179
  env_exports as env,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$meta": {
3
3
  "package": "@walkeros/server-destination-meta",
4
- "version": "3.3.1",
4
+ "version": "3.4.0",
5
5
  "type": "destination",
6
6
  "platform": [
7
7
  "server"
@@ -139,7 +139,7 @@
139
139
  "group": "gr0up",
140
140
  "count": 1,
141
141
  "version": {
142
- "source": "3.3.1",
142
+ "source": "3.4.0",
143
143
  "tagging": 1
144
144
  },
145
145
  "source": {
@@ -148,22 +148,13 @@
148
148
  "previous_id": ""
149
149
  }
150
150
  },
151
- "out": {
152
- "data": [
153
- {
154
- "event_name": "Lead",
155
- "event_time": 1700000901,
156
- "event_id": "1700000901-gr0up-1",
157
- "event_source_url": "https://example.com",
158
- "action_source": "website",
159
- "user_data": {
160
- "email": [
161
- "user@example.com"
162
- ]
163
- }
164
- }
151
+ "out": [
152
+ [
153
+ "sendServer",
154
+ "https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t",
155
+ "{\"data\":[{\"event_name\":\"form submit\",\"event_id\":\"1700000901-gr0up-1\",\"event_time\":1700001,\"action_source\":\"website\",\"user_data\":{},\"event_source_url\":\"https://example.com\"}]}"
165
156
  ]
166
- }
157
+ ]
167
158
  },
168
159
  "purchase": {
169
160
  "in": {
@@ -211,7 +202,7 @@
211
202
  "group": "gr0up",
212
203
  "count": 1,
213
204
  "version": {
214
- "source": "3.3.1",
205
+ "source": "3.4.0",
215
206
  "tagging": 1
216
207
  },
217
208
  "source": {
@@ -235,7 +226,7 @@
235
226
  "nested",
236
227
  {
237
228
  "condition": {
238
- "$code": "e=>b(e)&&\"product\"===e.entity"
229
+ "$code": "e=>g(e)&&\"product\"===e.entity"
239
230
  },
240
231
  "map": {
241
232
  "id": "data.id",
@@ -256,31 +247,13 @@
256
247
  }
257
248
  }
258
249
  },
259
- "out": {
260
- "data": [
261
- {
262
- "event_name": "Purchase",
263
- "event_time": 1700000900,
264
- "event_id": "1700000900-gr0up-1",
265
- "event_source_url": "https://shop.example.com",
266
- "action_source": "website",
267
- "user_data": {
268
- "external_id": [
269
- "user-123"
270
- ]
271
- },
272
- "currency": "EUR",
273
- "value": 249.99,
274
- "contents": [
275
- {
276
- "id": "SKU-A1",
277
- "quantity": 2,
278
- "item_price": 129.99
279
- }
280
- ]
281
- }
250
+ "out": [
251
+ [
252
+ "sendServer",
253
+ "https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t",
254
+ "{\"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\"}]}"
282
255
  ]
283
- }
256
+ ]
284
257
  },
285
258
  "purchaseWithClickAttribution": {
286
259
  "in": {
@@ -365,7 +338,7 @@
365
338
  "group": "gr0up",
366
339
  "count": 1,
367
340
  "version": {
368
- "source": "3.3.1",
341
+ "source": "3.4.0",
369
342
  "tagging": 1
370
343
  },
371
344
  "source": {
@@ -393,20 +366,13 @@
393
366
  }
394
367
  }
395
368
  },
396
- "out": {
397
- "data": [
398
- {
399
- "event_name": "Purchase",
400
- "event_time": 1700000902,
401
- "event_id": "1700000902-gr0up-1",
402
- "event_source_url": "https://shop.example.com",
403
- "action_source": "website",
404
- "currency": "USD",
405
- "value": 89.99,
406
- "order_id": "ORD-700"
407
- }
369
+ "out": [
370
+ [
371
+ "sendServer",
372
+ "https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t",
373
+ "{\"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\"}]}"
408
374
  ]
409
- }
375
+ ]
410
376
  }
411
377
  }
412
378
  }
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.3.1",
4
+ "version": "3.4.0",
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.3.1",
38
- "@walkeros/server-core": "3.3.1"
37
+ "@walkeros/core": "3.4.0",
38
+ "@walkeros/server-core": "3.4.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@walkeros/collector": "3.3.1"
41
+ "@walkeros/collector": "3.4.0"
42
42
  },
43
43
  "repository": {
44
44
  "url": "git+https://github.com/elbwalker/walkerOS.git",