@walkeros/server-destination-meta 3.4.2 → 4.0.0-next-1777463920154

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,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
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})},s={};o(s,{examples:()=>f,schemas:()=>n}),module.exports=(e=s,((e,o,s,n)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let c of r(o))i.call(e,c)||c===s||t(e,c,{get:()=>o[c],enumerable:!(n=a(o,c))||n.enumerable});return e})(t({},"__esModule",{value:!0}),e));var n={};o(n,{ActionSourceSchema:()=>l,EventNameSchema:()=>p,MappingSchema:()=>b,SettingsSchema:()=>m,mapping:()=>h,settings:()=>v});var c=require("@walkeros/core/dev"),d=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),l=u.z.enum(["email","website","app","phone_call","chat","physical_store","system_generated","business_messaging","other"]),p=u.z.union([u.z.enum(["AddPaymentInfo","AddToCart","AddToWishlist","CompleteRegistration","Contact","CustomizeProduct","Donate","FindLocation","InitiateCheckout","Lead","Purchase","Schedule","Search","StartTrial","SubmitApplication","Subscribe","ViewContent"]),u.z.string()]),m=d.z.object({accessToken:d.z.string().min(1).describe("Meta access token for Conversions API authentication (like your_access_token)"),pixelId:d.z.string().regex(/^[0-9]+$/,"Pixel ID must contain only digits").describe("Meta Pixel ID from your Facebook Business account (like 1234567890)"),action_source:l.describe("Source of the event (website, app, phone_call, etc.) (like website)").optional(),doNotHash:d.z.array(d.z.string()).describe("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()}),b=require("@walkeros/core/dev").z.object({}),v=(0,c.zodToSchema)(m),h=(0,c.zodToSchema)(b),f={};o(f,{env:()=>_,step:()=>k});var _={};o(_,{push:()=>y,simulation:()=>g});var y={sendServer:async function(e,t,a){return{ok:!0,data:{events_received:1,messages:[],fbtrace_id:"mock-trace-id"}}}},g=["sendServer"],k={};o(k,{lead:()=>x,purchase:()=>P,purchaseWithClickAttribution:()=>z});var w=require("@walkeros/core"),S="https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t",P={title:"Purchase",description:"A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.",in:(0,w.getEvent)("order complete",{id:"c1d2e3f4a5b60001",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:"browser",platform:"web",url:"https://shop.example.com"}}),mapping:{name:"Purchase",data:{map:{order_id:"data.id",currency:{key:"data.currency",value:"EUR"},value:"data.total",contents:{loop:["nested",{condition:e=>(0,w.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",S,JSON.stringify({data:[{event_name:"Purchase",event_id:"c1d2e3f4a5b60001",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,w.getEvent)("form submit",{id:"c1d2e3f4a5b60002",timestamp:1700000901,data:{type:"newsletter"},user:{email:"user@example.com"},source:{type:"browser",platform:"web",url:"https://example.com"}}),mapping:void 0,out:[["sendServer",S,JSON.stringify({data:[{event_name:"form submit",event_id:"c1d2e3f4a5b60002",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,w.getEvent)("order complete",{id:"c1d2e3f4a5b60003",timestamp:1700000902,data:{id:"ORD-700",total:89.99,currency:"USD"},user:{id:"cust-42"},context:{fbclid:["abc123xyz",0]},source:{type:"browser",platform:"web",url:"https://shop.example.com"}}),mapping:{name:"Purchase",data:{map:{currency:{key:"data.currency",value:"EUR"},value:"data.total",order_id:"data.id",user_data:{map:{external_id:"user.id",fbclid:"context.fbclid"}}}}},out:[["sendServer",S,JSON.stringify({data:[{event_name:"Purchase",event_id:"c1d2e3f4a5b60003",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 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;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,IAAI,EACJ;AAAA,IACC;AAAA,EACF,EACC,SAA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AAA,YACV,YAAY;AAAA,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,OAAO;AAAA,EACP,aACE;AAAA,EACF,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"]}
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 id: 'c1d2e3f4a5b60001',\n timestamp: 1700000900,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n nested: [\n { entity: 'product', data: { id: 'SKU-A1', price: 129.99, quantity: 2 } },\n ],\n user: { id: 'user-123', device: 'device-456' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://shop.example.com',\n },\n }),\n mapping: {\n name: 'Purchase',\n data: {\n map: {\n order_id: 'data.id',\n currency: { key: 'data.currency', value: 'EUR' },\n value: 'data.total',\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity: unknown) =>\n isObject(entity) && entity.entity === 'product',\n map: {\n id: 'data.id',\n item_price: 'data.price',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n num_items: {\n fn: (event: unknown) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.entity === 'product',\n ).length,\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'Purchase',\n event_id: 'c1d2e3f4a5b60001',\n event_time: 1700001,\n action_source: 'website',\n order_id: 'ORD-300',\n currency: 'EUR',\n value: 249.99,\n contents: [{ id: 'SKU-A1', item_price: 129.99, quantity: 2 }],\n num_items: 1,\n user_data: {},\n event_source_url: 'https://shop.example.com',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Form submit',\n description:\n 'A form submission is forwarded to Meta CAPI as a custom event with the event source URL.',\n in: getEvent('form submit', {\n id: 'c1d2e3f4a5b60002',\n timestamp: 1700000901,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://example.com',\n },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'form submit',\n event_id: 'c1d2e3f4a5b60002',\n event_time: 1700001,\n action_source: 'website',\n user_data: {},\n event_source_url: 'https://example.com',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const purchaseWithClickAttribution: Flow.StepExample = {\n title: 'Purchase with fbclid',\n description:\n 'A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.',\n in: getEvent('order complete', {\n id: 'c1d2e3f4a5b60003',\n timestamp: 1700000902,\n data: { id: 'ORD-700', total: 89.99, currency: 'USD' },\n user: { id: 'cust-42' },\n context: { fbclid: ['abc123xyz', 0] },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://shop.example.com',\n },\n }),\n mapping: {\n name: 'Purchase',\n data: {\n map: {\n currency: { key: 'data.currency', value: 'EUR' },\n value: 'data.total',\n order_id: 'data.id',\n user_data: {\n map: {\n external_id: 'user.id',\n fbclid: 'context.fbclid',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'Purchase',\n event_id: 'c1d2e3f4a5b60003',\n event_time: 1700001,\n action_source: 'website',\n currency: 'USD',\n value: 89.99,\n order_id: 'ORD-700',\n user_data: {\n // sha256('cust-42')\n external_id:\n '8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa',\n // formatClickId(['abc123xyz', 0], event.timestamp) - array joins\n // to 'abc123xyz,0' when coerced to string inside the template.\n fbc: 'fb.1.1700000902.abc123xyz,0',\n },\n event_source_url: 'https://shop.example.com',\n },\n ],\n }),\n ],\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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A;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:()=>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
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:()=>p,settings:()=>m});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({}),m=r(c),p=r(u),l={};t(l,{env:()=>b,step:()=>f});var b={};t(b,{push:()=>h,simulation:()=>v});var h={sendServer:async function(e,t,a){return{ok:!0,data:{events_received:1,messages:[],fbtrace_id:"mock-trace-id"}}}},v=["sendServer"],f={};t(f,{lead:()=>S,purchase:()=>k,purchaseWithClickAttribution:()=>w});import{getEvent as _,isObject as y}from"@walkeros/core";var g="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:_("order complete",{id:"c1d2e3f4a5b60001",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:"browser",platform:"web",url:"https://shop.example.com"}}),mapping:{name:"Purchase",data:{map:{order_id:"data.id",currency:{key:"data.currency",value:"EUR"},value:"data.total",contents:{loop:["nested",{condition:e=>y(e)&&"product"===e.entity,map:{id:"data.id",item_price:"data.price",quantity:{key:"data.quantity",value:1}}}]},num_items:{fn:e=>e.nested.filter(e=>"product"===e.entity).length}}}},out:[["sendServer",g,JSON.stringify({data:[{event_name:"Purchase",event_id:"c1d2e3f4a5b60001",event_time: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:_("form submit",{id:"c1d2e3f4a5b60002",timestamp:1700000901,data:{type:"newsletter"},user:{email:"user@example.com"},source:{type:"browser",platform:"web",url:"https://example.com"}}),mapping:void 0,out:[["sendServer",g,JSON.stringify({data:[{event_name:"form submit",event_id:"c1d2e3f4a5b60002",event_time:1700001,action_source:"website",user_data:{},event_source_url:"https://example.com"}]})]]},w={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:_("order complete",{id:"c1d2e3f4a5b60003",timestamp:1700000902,data:{id:"ORD-700",total:89.99,currency:"USD"},user:{id:"cust-42"},context:{fbclid:["abc123xyz",0]},source:{type:"browser",platform:"web",url:"https://shop.example.com"}}),mapping:{name:"Purchase",data:{map:{currency:{key:"data.currency",value:"EUR"},value:"data.total",order_id:"data.id",user_data:{map:{external_id:"user.id",fbclid:"context.fbclid"}}}}},out:[["sendServer",g,JSON.stringify({data:[{event_name:"Purchase",event_id:"c1d2e3f4a5b60003",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 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;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;A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AAA,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 id: 'c1d2e3f4a5b60001',\n timestamp: 1700000900,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n nested: [\n { entity: 'product', data: { id: 'SKU-A1', price: 129.99, quantity: 2 } },\n ],\n user: { id: 'user-123', device: 'device-456' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://shop.example.com',\n },\n }),\n mapping: {\n name: 'Purchase',\n data: {\n map: {\n order_id: 'data.id',\n currency: { key: 'data.currency', value: 'EUR' },\n value: 'data.total',\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity: unknown) =>\n isObject(entity) && entity.entity === 'product',\n map: {\n id: 'data.id',\n item_price: 'data.price',\n quantity: { key: 'data.quantity', value: 1 },\n },\n },\n ],\n },\n num_items: {\n fn: (event: unknown) =>\n (event as WalkerOS.Event).nested.filter(\n (item) => item.entity === 'product',\n ).length,\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'Purchase',\n event_id: 'c1d2e3f4a5b60001',\n event_time: 1700001,\n action_source: 'website',\n order_id: 'ORD-300',\n currency: 'EUR',\n value: 249.99,\n contents: [{ id: 'SKU-A1', item_price: 129.99, quantity: 2 }],\n num_items: 1,\n user_data: {},\n event_source_url: 'https://shop.example.com',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Form submit',\n description:\n 'A form submission is forwarded to Meta CAPI as a custom event with the event source URL.',\n in: getEvent('form submit', {\n id: 'c1d2e3f4a5b60002',\n timestamp: 1700000901,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://example.com',\n },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'form submit',\n event_id: 'c1d2e3f4a5b60002',\n event_time: 1700001,\n action_source: 'website',\n user_data: {},\n event_source_url: 'https://example.com',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const purchaseWithClickAttribution: Flow.StepExample = {\n title: 'Purchase with fbclid',\n description:\n 'A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.',\n in: getEvent('order complete', {\n id: 'c1d2e3f4a5b60003',\n timestamp: 1700000902,\n data: { id: 'ORD-700', total: 89.99, currency: 'USD' },\n user: { id: 'cust-42' },\n context: { fbclid: ['abc123xyz', 0] },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://shop.example.com',\n },\n }),\n mapping: {\n name: 'Purchase',\n data: {\n map: {\n currency: { key: 'data.currency', value: 'EUR' },\n value: 'data.total',\n order_id: 'data.id',\n user_data: {\n map: {\n external_id: 'user.id',\n fbclid: 'context.fbclid',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'Purchase',\n event_id: 'c1d2e3f4a5b60003',\n event_time: 1700001,\n action_source: 'website',\n currency: 'USD',\n value: 89.99,\n order_id: 'ORD-700',\n user_data: {\n // sha256('cust-42')\n external_id:\n '8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa',\n // formatClickId(['abc123xyz', 0], event.timestamp) - array joins\n // to 'abc123xyz,0' when coerced to string inside the template.\n fbc: 'fb.1.1700000902.abc123xyz,0',\n },\n event_source_url: 'https://shop.example.com',\n },\n ],\n }),\n ],\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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;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"]}
@@ -59,13 +59,18 @@ var purchase = {
59
59
  title: "Purchase",
60
60
  description: "A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.",
61
61
  in: (0, import_core.getEvent)("order complete", {
62
+ id: "c1d2e3f4a5b60001",
62
63
  timestamp: 1700000900,
63
64
  data: { id: "ORD-300", total: 249.99, currency: "EUR" },
64
65
  nested: [
65
66
  { entity: "product", data: { id: "SKU-A1", price: 129.99, quantity: 2 } }
66
67
  ],
67
68
  user: { id: "user-123", device: "device-456" },
68
- source: { type: "server", id: "https://shop.example.com", previous_id: "" }
69
+ source: {
70
+ type: "browser",
71
+ platform: "web",
72
+ url: "https://shop.example.com"
73
+ }
69
74
  }),
70
75
  mapping: {
71
76
  name: "Purchase",
@@ -103,7 +108,7 @@ var purchase = {
103
108
  data: [
104
109
  {
105
110
  event_name: "Purchase",
106
- event_id: "1700000900-gr0up-1",
111
+ event_id: "c1d2e3f4a5b60001",
107
112
  event_time: 1700001,
108
113
  action_source: "website",
109
114
  order_id: "ORD-300",
@@ -123,10 +128,15 @@ var lead = {
123
128
  title: "Form submit",
124
129
  description: "A form submission is forwarded to Meta CAPI as a custom event with the event source URL.",
125
130
  in: (0, import_core.getEvent)("form submit", {
131
+ id: "c1d2e3f4a5b60002",
126
132
  timestamp: 1700000901,
127
133
  data: { type: "newsletter" },
128
134
  user: { email: "user@example.com" },
129
- source: { type: "server", id: "https://example.com", previous_id: "" }
135
+ source: {
136
+ type: "browser",
137
+ platform: "web",
138
+ url: "https://example.com"
139
+ }
130
140
  }),
131
141
  mapping: void 0,
132
142
  out: [
@@ -137,7 +147,7 @@ var lead = {
137
147
  data: [
138
148
  {
139
149
  event_name: "form submit",
140
- event_id: "1700000901-gr0up-1",
150
+ event_id: "c1d2e3f4a5b60002",
141
151
  event_time: 1700001,
142
152
  action_source: "website",
143
153
  user_data: {},
@@ -152,11 +162,16 @@ var purchaseWithClickAttribution = {
152
162
  title: "Purchase with fbclid",
153
163
  description: "A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.",
154
164
  in: (0, import_core.getEvent)("order complete", {
165
+ id: "c1d2e3f4a5b60003",
155
166
  timestamp: 1700000902,
156
167
  data: { id: "ORD-700", total: 89.99, currency: "USD" },
157
168
  user: { id: "cust-42" },
158
169
  context: { fbclid: ["abc123xyz", 0] },
159
- source: { type: "server", id: "https://shop.example.com", previous_id: "" }
170
+ source: {
171
+ type: "browser",
172
+ platform: "web",
173
+ url: "https://shop.example.com"
174
+ }
160
175
  }),
161
176
  mapping: {
162
177
  name: "Purchase",
@@ -182,7 +197,7 @@ var purchaseWithClickAttribution = {
182
197
  data: [
183
198
  {
184
199
  event_name: "Purchase",
185
- event_id: "1700000902-gr0up-1",
200
+ event_id: "c1d2e3f4a5b60003",
186
201
  event_time: 1700001,
187
202
  action_source: "website",
188
203
  currency: "USD",
@@ -191,7 +206,7 @@ var purchaseWithClickAttribution = {
191
206
  user_data: {
192
207
  // sha256('cust-42')
193
208
  external_id: "8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa",
194
- // formatClickId(['abc123xyz', 0], event.timestamp) array joins
209
+ // formatClickId(['abc123xyz', 0], event.timestamp) - array joins
195
210
  // to 'abc123xyz,0' when coerced to string inside the template.
196
211
  fbc: "fb.1.1700000902.abc123xyz,0"
197
212
  },
@@ -38,13 +38,18 @@ var purchase = {
38
38
  title: "Purchase",
39
39
  description: "A completed order is sent to the Meta Conversions API as a Purchase event with value, currency, and contents.",
40
40
  in: getEvent("order complete", {
41
+ id: "c1d2e3f4a5b60001",
41
42
  timestamp: 1700000900,
42
43
  data: { id: "ORD-300", total: 249.99, currency: "EUR" },
43
44
  nested: [
44
45
  { entity: "product", data: { id: "SKU-A1", price: 129.99, quantity: 2 } }
45
46
  ],
46
47
  user: { id: "user-123", device: "device-456" },
47
- source: { type: "server", id: "https://shop.example.com", previous_id: "" }
48
+ source: {
49
+ type: "browser",
50
+ platform: "web",
51
+ url: "https://shop.example.com"
52
+ }
48
53
  }),
49
54
  mapping: {
50
55
  name: "Purchase",
@@ -82,7 +87,7 @@ var purchase = {
82
87
  data: [
83
88
  {
84
89
  event_name: "Purchase",
85
- event_id: "1700000900-gr0up-1",
90
+ event_id: "c1d2e3f4a5b60001",
86
91
  event_time: 1700001,
87
92
  action_source: "website",
88
93
  order_id: "ORD-300",
@@ -102,10 +107,15 @@ var lead = {
102
107
  title: "Form submit",
103
108
  description: "A form submission is forwarded to Meta CAPI as a custom event with the event source URL.",
104
109
  in: getEvent("form submit", {
110
+ id: "c1d2e3f4a5b60002",
105
111
  timestamp: 1700000901,
106
112
  data: { type: "newsletter" },
107
113
  user: { email: "user@example.com" },
108
- source: { type: "server", id: "https://example.com", previous_id: "" }
114
+ source: {
115
+ type: "browser",
116
+ platform: "web",
117
+ url: "https://example.com"
118
+ }
109
119
  }),
110
120
  mapping: void 0,
111
121
  out: [
@@ -116,7 +126,7 @@ var lead = {
116
126
  data: [
117
127
  {
118
128
  event_name: "form submit",
119
- event_id: "1700000901-gr0up-1",
129
+ event_id: "c1d2e3f4a5b60002",
120
130
  event_time: 1700001,
121
131
  action_source: "website",
122
132
  user_data: {},
@@ -131,11 +141,16 @@ var purchaseWithClickAttribution = {
131
141
  title: "Purchase with fbclid",
132
142
  description: "A purchase is sent to Meta CAPI with an external_id and a formatted fbc click id for ads attribution.",
133
143
  in: getEvent("order complete", {
144
+ id: "c1d2e3f4a5b60003",
134
145
  timestamp: 1700000902,
135
146
  data: { id: "ORD-700", total: 89.99, currency: "USD" },
136
147
  user: { id: "cust-42" },
137
148
  context: { fbclid: ["abc123xyz", 0] },
138
- source: { type: "server", id: "https://shop.example.com", previous_id: "" }
149
+ source: {
150
+ type: "browser",
151
+ platform: "web",
152
+ url: "https://shop.example.com"
153
+ }
139
154
  }),
140
155
  mapping: {
141
156
  name: "Purchase",
@@ -161,7 +176,7 @@ var purchaseWithClickAttribution = {
161
176
  data: [
162
177
  {
163
178
  event_name: "Purchase",
164
- event_id: "1700000902-gr0up-1",
179
+ event_id: "c1d2e3f4a5b60003",
165
180
  event_time: 1700001,
166
181
  action_source: "website",
167
182
  currency: "USD",
@@ -170,7 +185,7 @@ var purchaseWithClickAttribution = {
170
185
  user_data: {
171
186
  // sha256('cust-42')
172
187
  external_id: "8a3c5a67cad508582b5edf6b8352cea3ffbad7f44812c1a736b4444c0f5746aa",
173
- // formatClickId(['abc123xyz', 0], event.timestamp) array joins
188
+ // formatClickId(['abc123xyz', 0], event.timestamp) - array joins
174
189
  // to 'abc123xyz,0' when coerced to string inside the template.
175
190
  fbc: "fb.1.1700000902.abc123xyz,0"
176
191
  },
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,index_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(index_exports,{DestinationMeta:()=>types_exports,default:()=>index_default,destinationMeta:()=>destinationMeta}),module.exports=(mod=index_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var import_core2=require("@walkeros/core"),import_server_core2=require("@walkeros/server-core"),import_core=require("@walkeros/core"),import_server_core=require("@walkeros/server-core"),keysToHash=["em","ph","fn","ln","db","ge","ct","st","zp","country","external_id"];function shouldBeHashed(key,doNotHash=[]){return keysToHash.includes(key)&&!doNotHash.includes(key)}async function processValue(value,shouldHash){return shouldHash?(0,import_core.isArray)(value)?Promise.all(value.map(item=>(0,import_server_core.getHashServer)(String(item)))):(0,import_server_core.getHashServer)(String(value)):value}var push=async function(event,{config:config,rule:rule,data:data,collector:collector,env:env,logger:logger}){var _a;const{accessToken:accessToken,pixelId:pixelId,action_source:action_source="website",doNotHash:doNotHash,test_event_code:test_event_code,url:url="https://graph.facebook.com/v22.0/",user_data:user_data}=config.settings,eventData=(0,import_core2.isObject)(data)?data:{},configData=config.data?await(0,import_core2.getMappingValue)(event,config.data):{},userDataCustom=user_data?await(0,import_core2.getMappingValue)(event,{map:user_data}):{},userData={...(0,import_core2.isObject)(configData)&&(0,import_core2.isObject)(configData.user_data)?configData.user_data:{},...(0,import_core2.isObject)(userDataCustom)?userDataCustom:{},...(0,import_core2.isObject)(eventData.user_data)?eventData.user_data:{}};userData.fbclid&&(userData.fbc=function(clickId,time){if(!clickId)return;const version="fb",subdomainIndex="1",creationTime=time||Date.now();return`${version}.${subdomainIndex}.${creationTime}.${clickId}`}(userData.fbclid,(null==(_a=null==collector?void 0:collector.session)?void 0:_a.start)||event.timestamp),delete userData.fbclid);const serverEvent={event_name:event.name,event_id:event.id,event_time:Math.round((event.timestamp||Date.now())/1e3),action_source:action_source,...eventData,user_data:userData};"website"===action_source&&(serverEvent.event_source_url=event.source.id);const hashedServerEvent=await async function(value,doNotHash=[]){if(!(0,import_core.isObject)(value))return value;const isUserData="user_data"in value,target=isUserData?value.user_data:value,result=(await Promise.all(Object.entries(target).map(async([k,v])=>[k,await processValue(v,isUserData&&shouldBeHashed(k,doNotHash))]))).reduce((acc,[k,v])=>((0,import_core.isString)(k)&&(acc[k]=v),acc),{});return isUserData?{...value,user_data:result}:result}(serverEvent,doNotHash),body={data:[hashedServerEvent]};test_event_code&&(body.test_event_code=test_event_code);const endpoint=`${url}${pixelId}/events`;logger.debug("Calling Meta API",{endpoint:endpoint,method:"POST",eventName:serverEvent.event_name,eventId:serverEvent.event_id});const sendServerFn=(null==env?void 0:env.sendServer)||import_server_core2.sendServer,result=await sendServerFn(`${endpoint}?access_token=${accessToken}`,JSON.stringify(body));logger.debug("Meta API response",{ok:!(0,import_core2.isObject)(result)||result.ok}),(0,import_core2.isObject)(result)&&!1===result.ok&&logger.throw(`Meta API error: ${JSON.stringify(result)}`)};var types_exports={},destinationMeta={type:"meta",config:{},async init({config:partialConfig,logger:logger}){const config=function(partialConfig={},logger){const settings=partialConfig.settings||{},{accessToken:accessToken,pixelId:pixelId}=settings;accessToken||logger.throw("Config settings accessToken missing"),pixelId||logger.throw("Config settings pixelId missing");const settingsConfig={...settings,accessToken:accessToken,pixelId:pixelId};return{...partialConfig,settings:settingsConfig}}(partialConfig,logger);return config},push:async(event,context)=>await push(event,context)},index_default=destinationMeta;//# sourceMappingURL=index.js.map
1
+ "use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,index_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(index_exports,{DestinationMeta:()=>types_exports,default:()=>index_default,destinationMeta:()=>destinationMeta}),module.exports=(mod=index_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var import_core2=require("@walkeros/core"),import_server_core2=require("@walkeros/server-core"),import_core=require("@walkeros/core"),import_server_core=require("@walkeros/server-core"),keysToHash=["em","ph","fn","ln","db","ge","ct","st","zp","country","external_id"];function shouldBeHashed(key,doNotHash=[]){return keysToHash.includes(key)&&!doNotHash.includes(key)}async function processValue(value,shouldHash){return shouldHash?(0,import_core.isArray)(value)?Promise.all(value.map(item=>(0,import_server_core.getHashServer)(String(item)))):(0,import_server_core.getHashServer)(String(value)):value}var push=async function(event,{config:config,rule:rule,data:data,collector:collector,env:env,logger:logger}){const{accessToken:accessToken,pixelId:pixelId,action_source:action_source="website",doNotHash:doNotHash,test_event_code:test_event_code,url:url="https://graph.facebook.com/v22.0/",user_data:user_data}=config.settings,eventData=(0,import_core2.isObject)(data)?data:{},configData=config.data?await(0,import_core2.getMappingValue)(event,config.data):{},userDataCustom=user_data?await(0,import_core2.getMappingValue)(event,{map:user_data}):{},userData={...(0,import_core2.isObject)(configData)&&(0,import_core2.isObject)(configData.user_data)?configData.user_data:{},...(0,import_core2.isObject)(userDataCustom)?userDataCustom:{},...(0,import_core2.isObject)(eventData.user_data)?eventData.user_data:{}};userData.fbclid&&(userData.fbc=function(clickId,time){if(!clickId)return;const version="fb",subdomainIndex="1",creationTime=time||Date.now();return`${version}.${subdomainIndex}.${creationTime}.${clickId}`}(userData.fbclid,collector?.session?.start||event.timestamp),delete userData.fbclid);const serverEvent={event_name:event.name,event_id:event.id,event_time:Math.round((event.timestamp||Date.now())/1e3),action_source:action_source,...eventData,user_data:userData};"website"===action_source&&event.source?.url&&(serverEvent.event_source_url=event.source.url);const hashedServerEvent=await async function(value,doNotHash=[]){if(!(0,import_core.isObject)(value))return value;const isUserData="user_data"in value,target=isUserData?value.user_data:value,result=(await Promise.all(Object.entries(target).map(async([k,v])=>[k,await processValue(v,isUserData&&shouldBeHashed(k,doNotHash))]))).reduce((acc,[k,v])=>((0,import_core.isString)(k)&&(acc[k]=v),acc),{});return isUserData?{...value,user_data:result}:result}(serverEvent,doNotHash),body={data:[hashedServerEvent]};test_event_code&&(body.test_event_code=test_event_code);const endpoint=`${url}${pixelId}/events`;logger.debug("Calling Meta API",{endpoint:endpoint,method:"POST",eventName:serverEvent.event_name,eventId:serverEvent.event_id});const sendServerFn=env?.sendServer||import_server_core2.sendServer,result=await sendServerFn(`${endpoint}?access_token=${accessToken}`,JSON.stringify(body));logger.debug("Meta API response",{ok:!(0,import_core2.isObject)(result)||result.ok}),(0,import_core2.isObject)(result)&&!1===result.ok&&logger.throw(`Meta API error: ${JSON.stringify(result)}`)};var types_exports={},destinationMeta={type:"meta",config:{},async init({config:partialConfig,logger:logger}){const config=function(partialConfig={},logger){const settings=partialConfig.settings||{},{accessToken:accessToken,pixelId:pixelId}=settings;accessToken||logger.throw("Config settings accessToken missing"),pixelId||logger.throw("Config settings pixelId missing");const settingsConfig={...settings,accessToken:accessToken,pixelId:pixelId};return{...partialConfig,settings:settingsConfig}}(partialConfig,logger);return config},push:async(event,context)=>await push(event,context)},index_default=destinationMeta;//# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/push.ts","../src/hash.ts","../src/types/index.ts"],"sourcesContent":["import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationMeta from './types';\n\nexport const destinationMeta: Destination = {\n type: 'meta',\n\n config: {},\n\n async init({ config: partialConfig, logger }) {\n const config = getConfig(partialConfig, logger);\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n};\n\nexport default destinationMeta;\n","import type { Config, Settings, PartialConfig } from './types';\nimport type { Logger } from '@walkeros/core';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n logger: Logger.Instance,\n): Config {\n const settings = (partialConfig.settings || {}) as Partial<Settings>;\n const { accessToken, pixelId } = settings;\n\n if (!accessToken) logger.throw('Config settings accessToken missing');\n if (!pixelId) logger.throw('Config settings pixelId missing');\n\n const settingsConfig: Settings = {\n ...settings,\n accessToken,\n pixelId,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type {\n BodyParameters,\n CustomerInformationParameters,\n PushFn,\n ServerEventParameters,\n Env,\n} from './types';\nimport { getMappingValue, isObject } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport { hashEvent } from './hash';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, collector, env, logger },\n) {\n const {\n accessToken,\n pixelId,\n action_source = 'website',\n doNotHash,\n test_event_code,\n url = 'https://graph.facebook.com/v22.0/',\n user_data,\n } = config.settings!;\n\n const eventData = isObject(data) ? data : {};\n const configData = config.data\n ? await getMappingValue(event, config.data)\n : {};\n const userDataCustom = user_data\n ? await getMappingValue(event, { map: user_data })\n : {};\n\n const userData: CustomerInformationParameters = {\n // Destination config\n ...(isObject(configData) && isObject(configData.user_data)\n ? configData.user_data\n : {}),\n // Custom user_data\n ...(isObject(userDataCustom) ? userDataCustom : {}),\n // Event mapping\n ...(isObject(eventData.user_data) ? eventData.user_data : {}),\n };\n\n if (userData.fbclid) {\n userData.fbc = formatClickId(\n userData.fbclid,\n collector?.session?.start || event.timestamp,\n );\n delete userData.fbclid;\n }\n const serverEvent: ServerEventParameters = {\n event_name: event.name,\n event_id: event.id,\n event_time: Math.round((event.timestamp || Date.now()) / 1000),\n action_source,\n ...eventData,\n user_data: userData,\n };\n\n if (action_source === 'website')\n serverEvent.event_source_url = event.source.id;\n\n const hashedServerEvent = await hashEvent(serverEvent, doNotHash);\n\n const body: BodyParameters = { data: [hashedServerEvent] };\n\n // Test event code\n if (test_event_code) body.test_event_code = test_event_code;\n\n const endpoint = `${url}${pixelId}/events`;\n logger.debug('Calling Meta API', {\n endpoint,\n method: 'POST',\n eventName: serverEvent.event_name,\n eventId: serverEvent.event_id,\n });\n\n const sendServerFn = env?.sendServer || sendServer;\n const result = await sendServerFn(\n `${endpoint}?access_token=${accessToken}`,\n JSON.stringify(body),\n );\n\n logger.debug('Meta API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`Meta API error: ${JSON.stringify(result)}`);\n }\n};\n\nfunction formatClickId(clickId: unknown, time?: number): string | undefined {\n // https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc#2--format-clickid\n\n if (!clickId) return;\n\n // Version is always \"fb\"\n const version = 'fb';\n\n // Subdomain ('com' = 0, 'example.com' = 1, 'www.example.com' = 2)\n const subdomainIndex = '1';\n\n // Get the current timestamp in milliseconds (or when the fbclid was observed)\n const creationTime = time || Date.now();\n\n return `${version}.${subdomainIndex}.${creationTime}.${clickId}`;\n}\n\nfunction lower(str: WalkerOS.Property): string {\n return String(str).toLocaleLowerCase();\n}\n","import { WalkerOS } from '@walkeros/core';\nimport { isArray, isObject, isString } from '@walkeros/core';\nimport { getHashServer } from '@walkeros/server-core';\n\nconst keysToHash = [\n 'em',\n 'ph',\n 'fn',\n 'ln',\n 'db',\n 'ge',\n 'ct',\n 'st',\n 'zp',\n 'country',\n 'external_id',\n];\n\nfunction shouldBeHashed(key: string, doNotHash: string[] = []): boolean {\n return keysToHash.includes(key) && !doNotHash.includes(key);\n}\n\ntype HashableValue = WalkerOS.AnyObject | unknown | unknown[];\n\nasync function processValue(\n value: unknown,\n shouldHash: boolean,\n): Promise<unknown> {\n if (!shouldHash) return value;\n if (isArray(value)) {\n return Promise.all(value.map((item) => getHashServer(String(item))));\n }\n return getHashServer(String(value));\n}\n\nexport async function hashEvent<T extends HashableValue>(\n value: T,\n doNotHash: string[] = [],\n): Promise<T> {\n if (!isObject(value)) return value;\n\n const isUserData = 'user_data' in value;\n const target = (isUserData ? value.user_data : value) as WalkerOS.AnyObject;\n\n const entries = await Promise.all(\n Object.entries(target).map(async ([k, v]) => [\n k,\n await processValue(v, isUserData && shouldBeHashed(k, doNotHash)),\n ]),\n );\n\n const result = entries.reduce((acc, [k, v]) => {\n if (isString(k)) acc[k] = v;\n return acc;\n }, {} as WalkerOS.AnyObject);\n\n return isUserData ? { ...value, user_data: result } : (result as T);\n}\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer, sendServer } from '@walkeros/server-core';\n\nexport interface Settings {\n accessToken: string;\n pixelId: string;\n action_source?: ActionSource;\n doNotHash?: string[];\n test_event_code?: string;\n url?: string;\n user_data?: WalkerOSMapping.Map;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n sendServer?: typeof sendServer;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/main-body\nexport interface BodyParameters {\n data: Array<ServerEventParameters>;\n test_event_code?: string;\n}\n\n/**\n * Represents the top‑level parameters for a server event sent via Meta's Conversions API.\n * https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/server-event\n */\nexport interface ServerEventParameters extends StandardParameters {\n /** The event name or custom event identifier. Required for deduplication. */\n event_name: EventName;\n\n /** Unix timestamp (in seconds) when the event actually occurred. GMT timezone. */\n event_time: number;\n\n /** Map of customer information for matching (emails, phone, etc.). */\n user_data: CustomerInformationParameters;\n\n /** Additional business data about the event. */\n custom_data?: Record<string, unknown>;\n\n /** URL of the page where the event occurred. */\n event_source_url?: string;\n\n /** If true, exclude this event from ads optimization (only attribution). */\n opt_out?: boolean;\n\n /** Unique ID for deduplication across Pixel and CAPI. */\n event_id?: string;\n\n /** Source of the event (e.g., website, app). */\n action_source: ActionSource;\n\n /** Processing options (e.g., ['LDU'] for CCPA limited data use). */\n data_processing_options?: DataProcessingOption[];\n\n /** Country code for data processing option (1 = USA, 0 = auto‑geolocate). */\n data_processing_options_country?: number;\n\n /** State code for data processing option (1000 = California, 0 = auto). */\n data_processing_options_state?: number;\n\n /** App‑specific data (required if action_source is 'app'). */\n app_data?: AppData;\n\n /** HTTP referrer header of the event. */\n referrer_url?: string;\n\n /** Metadata to link delayed events to past acquisition events. */\n original_event_data?: OriginalEventDataParameters;\n\n /** User segment for more context about the customer's relationship. */\n customer_segmentation?: CustomerSegmentation;\n}\n\nexport type EventName =\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 | string;\n\nexport type ActionSource =\n | 'email'\n | 'website'\n | 'app'\n | 'phone_call'\n | 'chat'\n | 'physical_store'\n | 'system_generated'\n | 'business_messaging'\n | 'other';\n\nexport type DataProcessingOption = 'LDU';\n\nexport type CustomerSegmentation =\n | 'new_customer_to_business'\n | 'new_customer_to_business_line'\n | 'new_customer_to_product_area'\n | 'new_customer_to_medium'\n | 'existing_customer_to_business'\n | 'existing_customer_to_business_line'\n | 'existing_customer_to_product_area'\n | 'existing_customer_to_medium'\n | 'customer_in_loyalty_program';\n\n/** Extended device info for app events (Android version 'a2', iOS 'i2') */\nexport interface AppData {\n /**\n * Comma-separated array of strings with fixed order:\n * [sdk_version, os_version, device_model, device_brand,\n * screen_width, screen_height, ...]\n */\n extinfo: string[];\n}\n\n// Customer Information Parameters\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters\nexport interface CustomerInformationParameters {\n /** Email(s), SHA-256 hashed, lowercase and trimmed */\n em?: string | string[];\n\n /** Phone number(s), SHA-256 hashed, E.164 format (no leading 0s or symbols) */\n ph?: string | string[];\n\n /** First name(s), SHA-256 hashed, lowercase */\n fn?: string | string[];\n\n /** Last name(s), SHA-256 hashed, lowercase */\n ln?: string | string[];\n\n /** Date(s) of birth in YYYYMMDD, SHA-256 hashed */\n db?: string | string[];\n\n /** Gender(s) in lowercase single letter (\"m\", \"f\", etc.), SHA-256 hashed */\n ge?: string | string[];\n\n /** City name(s), SHA-256 hashed, lowercase */\n ct?: string | string[];\n\n /** State abbreviation(s), SHA-256 hashed, lowercase (e.g., \"ca\", \"ny\") */\n st?: string | string[];\n\n /** ZIP or postal code(s), SHA-256 hashed, lowercase */\n zp?: string | string[];\n\n /** Country code(s), SHA-256 hashed, lowercase (ISO 3166-1 alpha-2) */\n country?: string | string[];\n\n /** External IDs, unique per user. SHA-256 hash recommended */\n external_id?: string | string[];\n\n /** IPv4 or IPv6 address of client. Do NOT hash. */\n client_ip_address?: string;\n\n /** User agent string from browser. Do NOT hash. */\n client_user_agent?: string;\n\n /** fbclid parameter value from the URL. Do NOT hash. */\n fbclid?: string;\n\n /** Facebook click ID (_fbc cookie). Do NOT hash. */\n fbc?: string;\n\n /** Facebook browser ID (_fbp cookie). Do NOT hash. */\n fbp?: string;\n\n /** Subscription ID for the transaction. Do NOT hash. */\n subscription_id?: string;\n\n /** Facebook login ID (App-Scoped ID). Do NOT hash. */\n fb_login_id?: number;\n\n /** Meta Lead Ad lead ID. Do NOT hash. */\n lead_id?: number;\n\n /** Anonymous install ID. App events only. Do NOT hash. */\n anon_id?: string;\n\n /** Mobile advertiser ID (GAID/IDFA). Do NOT hash. */\n madid?: string;\n\n /** Facebook Page ID. Do NOT hash. */\n page_id?: string;\n\n /** Messenger Page-scoped user ID. Do NOT hash. */\n page_scoped_user_id?: string;\n\n /** Click to WhatsApp ad click ID. Do NOT hash. */\n ctwa_clid?: string;\n\n /** Instagram business account ID. Do NOT hash. */\n ig_account_id?: string;\n\n /** Instagram-scoped user ID. Do NOT hash. */\n ig_sid?: string;\n}\n\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/custom-data\nexport interface StandardParameters {\n // Web and Offline parameters\n availability?: string;\n body_style?: string;\n checkin_date?: string;\n city?: string;\n condition_of_vehicle?: string;\n content_ids?: string[];\n content_type?: 'product' | 'product_group' | string;\n contents?: Array<{\n id: string;\n quantity?: number;\n item_price?: number;\n delivery_category?: string;\n }>;\n country?: string;\n currency?: string;\n delivery_category?: 'in_store' | 'curbside' | 'home_delivery' | string;\n departing_arrival_date?: string;\n departing_departure_date?: string;\n destination_airport?: string;\n destination_ids?: string[];\n dma_code?: string;\n drivetrain?: string;\n exterior_color?: string;\n fuel_type?: string;\n hotel_score?: number;\n interior_color?: string;\n lead_event_source?: string;\n lease_end_date?: string;\n lease_start_date?: string;\n listing_type?: string;\n make?: string;\n // @TODO is mileage an object?\n 'mileage.unit'?: string;\n 'mileage.value'?: number;\n model?: string;\n neighborhood?: string;\n net_revenue?: number;\n num_adults?: number;\n num_children?: number;\n num_infants?: number;\n num_items?: number;\n order_id?: string;\n origin_airport?: string;\n postal_code?: string;\n predicted_ltv?: number;\n preferred_baths_range?: string;\n preferred_beds_range?: string;\n preferred_neighborhoods?: string[];\n preferred_num_stops?: number;\n preferred_price_range?: string;\n preferred_star_ratings?: [number, number];\n price?: string;\n product_catalog_id?: string;\n property_type?: string;\n region?: string;\n returning_arrival_date?: string;\n returning_departure_date?: string;\n search_string?: string;\n state_of_vehicle?: string;\n suggested_destinations?: string[];\n suggested_home_listings?: string[];\n suggested_hotels?: string[];\n suggested_jobs?: string[];\n suggested_local_service_businesses?: string[];\n suggested_location_based_items?: string[];\n suggested_vehicles?: string[];\n transmission?: string;\n travel_class?: string;\n travel_end?: string;\n travel_start?: string;\n trim?: string;\n\n // App-specific parameters (with fb_ prefix)\n fb_availability?: string;\n fb_body_style?: string;\n fb_checkin_date?: string;\n fb_city?: string;\n fb_condition_of_vehicle?: string;\n fb_content_ids?: string[];\n fb_content_type?: string;\n fb_contents?: Array<{ id: string; quantity?: number; item_price?: number }>;\n fb_country?: string;\n fb_currency?: string;\n fb_delivery_category?: string;\n fb_departing_arrival_date?: string;\n fb_departing_departure_date?: string;\n fb_destination_airport?: string;\n fb_destination_ids?: string[];\n fb_dma_code?: string;\n fb_drivetrain?: string;\n fb_exterior_color?: string;\n fb_fuel_type?: string;\n fb_hotel_score?: number;\n fb_interior_color?: string;\n fb_lease_end_date?: string;\n fb_lease_start_date?: string;\n fb_listing_type?: string;\n fb_make?: string;\n // @TODO is fb_mileage an object?\n 'fb_mileage.unit'?: string;\n 'fb_mileage.value'?: number;\n fb_model?: string;\n fb_neighborhood?: string;\n fb_num_adults?: number;\n fb_num_children?: number;\n fb_num_infants?: number;\n fb_num_items?: number;\n fb_order_id?: string;\n fb_origin_airport?: string;\n fb_postal_code?: string;\n fb_predicted_ltv?: number;\n fb_preferred_baths_range?: string;\n fb_preferred_beds_range?: string;\n fb_preferred_neighborhoods?: string[];\n fb_preferred_num_stops?: number;\n fb_preferred_price_range?: string;\n fb_preferred_star_ratings?: [number, number];\n fb_price?: string;\n fb_product_catalog_id?: string;\n fb_property_type?: string;\n fb_region?: string;\n fb_returning_arrival_date?: string;\n fb_returning_departure_date?: string;\n fb_search_string?: string;\n fb_state_of_vehicle?: string;\n fb_suggested_destinations?: string[];\n fb_suggested_home_listings?: string[];\n fb_suggested_hotels?: string[];\n fb_suggested_jobs?: string[];\n fb_suggested_local_service_businesses?: string[];\n fb_suggested_location_based_items?: string[];\n fb_suggested_vehicles?: string[];\n fb_transmission?: string;\n fb_travel_class?: string;\n fb_travel_end?: string;\n fb_travel_start?: string;\n\n // Offline-specific parameters\n user_bucket?: string;\n value?: number;\n vin?: string;\n year?: number;\n item_number?: string;\n}\n\nexport interface OriginalEventDataParameters {\n event_name?: EventName;\n event_time?: number;\n order_id?: number;\n event_id?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,SAAS,UACd,gBAA+B,CAAC,GAChC,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,aAAa,QAAQ,IAAI;AAEjC,MAAI,CAAC,YAAa,QAAO,MAAM,qCAAqC;AACpE,MAAI,CAAC,QAAS,QAAO,MAAM,iCAAiC;AAE5D,QAAM,iBAA2B;AAAA,IAC/B,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,eAAe,UAAU,eAAe;AACtD;;;ACZA,IAAAA,eAA0C;AAC1C,IAAAC,sBAA2B;;;ACR3B,kBAA4C;AAC5C,yBAA8B;AAE9B,IAAM,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,eAAe,KAAa,YAAsB,CAAC,GAAY;AACtE,SAAO,WAAW,SAAS,GAAG,KAAK,CAAC,UAAU,SAAS,GAAG;AAC5D;AAIA,eAAe,aACb,OACA,YACkB;AAClB,MAAI,CAAC,WAAY,QAAO;AACxB,UAAI,qBAAQ,KAAK,GAAG;AAClB,WAAO,QAAQ,IAAI,MAAM,IAAI,CAAC,aAAS,kCAAc,OAAO,IAAI,CAAC,CAAC,CAAC;AAAA,EACrE;AACA,aAAO,kCAAc,OAAO,KAAK,CAAC;AACpC;AAEA,eAAsB,UACpB,OACA,YAAsB,CAAC,GACX;AACZ,MAAI,KAAC,sBAAS,KAAK,EAAG,QAA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AAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,MAAM,KAAK,EAAE,QAAQ,eAAe,OAAO,GAAG;AAC5C,UAAM,SAAS,UAAU,eAAe,MAAM;AAC9C,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,SAAS;AACzB,WAAO,MAAM,KAAK,OAAO,OAAO;AAAA,EAClC;AACF;AAEA,IAAO,gBAAQ;","names":["import_core","import_server_core"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/push.ts","../src/hash.ts","../src/types/index.ts"],"sourcesContent":["import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationMeta from './types';\n\nexport const destinationMeta: Destination = {\n type: 'meta',\n\n config: {},\n\n async init({ config: partialConfig, logger }) {\n const config = getConfig(partialConfig, logger);\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n};\n\nexport default destinationMeta;\n","import type { Config, Settings, PartialConfig } from './types';\nimport type { Logger } from '@walkeros/core';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n logger: Logger.Instance,\n): Config {\n const settings = (partialConfig.settings || {}) as Partial<Settings>;\n const { accessToken, pixelId } = settings;\n\n if (!accessToken) logger.throw('Config settings accessToken missing');\n if (!pixelId) logger.throw('Config settings pixelId missing');\n\n const settingsConfig: Settings = {\n ...settings,\n accessToken,\n pixelId,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type {\n BodyParameters,\n CustomerInformationParameters,\n PushFn,\n ServerEventParameters,\n Env,\n} from './types';\nimport { getMappingValue, isObject } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport { hashEvent } from './hash';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, collector, env, logger },\n) {\n const {\n accessToken,\n pixelId,\n action_source = 'website',\n doNotHash,\n test_event_code,\n url = 'https://graph.facebook.com/v22.0/',\n user_data,\n } = config.settings!;\n\n const eventData = isObject(data) ? data : {};\n const configData = config.data\n ? await getMappingValue(event, config.data)\n : {};\n const userDataCustom = user_data\n ? await getMappingValue(event, { map: user_data })\n : {};\n\n const userData: CustomerInformationParameters = {\n // Destination config\n ...(isObject(configData) && isObject(configData.user_data)\n ? configData.user_data\n : {}),\n // Custom user_data\n ...(isObject(userDataCustom) ? userDataCustom : {}),\n // Event mapping\n ...(isObject(eventData.user_data) ? eventData.user_data : {}),\n };\n\n if (userData.fbclid) {\n userData.fbc = formatClickId(\n userData.fbclid,\n collector?.session?.start || event.timestamp,\n );\n delete userData.fbclid;\n }\n const serverEvent: ServerEventParameters = {\n event_name: event.name,\n event_id: event.id,\n event_time: Math.round((event.timestamp || Date.now()) / 1000),\n action_source,\n ...eventData,\n user_data: userData,\n };\n\n if (action_source === 'website' && event.source?.url)\n serverEvent.event_source_url = event.source.url;\n\n const hashedServerEvent = await hashEvent(serverEvent, doNotHash);\n\n const body: BodyParameters = { data: [hashedServerEvent] };\n\n // Test event code\n if (test_event_code) body.test_event_code = test_event_code;\n\n const endpoint = `${url}${pixelId}/events`;\n logger.debug('Calling Meta API', {\n endpoint,\n method: 'POST',\n eventName: serverEvent.event_name,\n eventId: serverEvent.event_id,\n });\n\n const sendServerFn = env?.sendServer || sendServer;\n const result = await sendServerFn(\n `${endpoint}?access_token=${accessToken}`,\n JSON.stringify(body),\n );\n\n logger.debug('Meta API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`Meta API error: ${JSON.stringify(result)}`);\n }\n};\n\nfunction formatClickId(clickId: unknown, time?: number): string | undefined {\n // https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc#2--format-clickid\n\n if (!clickId) return;\n\n // Version is always \"fb\"\n const version = 'fb';\n\n // Subdomain ('com' = 0, 'example.com' = 1, 'www.example.com' = 2)\n const subdomainIndex = '1';\n\n // Get the current timestamp in milliseconds (or when the fbclid was observed)\n const creationTime = time || Date.now();\n\n return `${version}.${subdomainIndex}.${creationTime}.${clickId}`;\n}\n\nfunction lower(str: WalkerOS.Property): string {\n return String(str).toLocaleLowerCase();\n}\n","import { WalkerOS } from '@walkeros/core';\nimport { isArray, isObject, isString } from '@walkeros/core';\nimport { getHashServer } from '@walkeros/server-core';\n\nconst keysToHash = [\n 'em',\n 'ph',\n 'fn',\n 'ln',\n 'db',\n 'ge',\n 'ct',\n 'st',\n 'zp',\n 'country',\n 'external_id',\n];\n\nfunction shouldBeHashed(key: string, doNotHash: string[] = []): boolean {\n return keysToHash.includes(key) && !doNotHash.includes(key);\n}\n\ntype HashableValue = WalkerOS.AnyObject | unknown | unknown[];\n\nasync function processValue(\n value: unknown,\n shouldHash: boolean,\n): Promise<unknown> {\n if (!shouldHash) return value;\n if (isArray(value)) {\n return Promise.all(value.map((item) => getHashServer(String(item))));\n }\n return getHashServer(String(value));\n}\n\nexport async function hashEvent<T extends HashableValue>(\n value: T,\n doNotHash: string[] = [],\n): Promise<T> {\n if (!isObject(value)) return value;\n\n const isUserData = 'user_data' in value;\n const target = (isUserData ? value.user_data : value) as WalkerOS.AnyObject;\n\n const entries = await Promise.all(\n Object.entries(target).map(async ([k, v]) => [\n k,\n await processValue(v, isUserData && shouldBeHashed(k, doNotHash)),\n ]),\n );\n\n const result = entries.reduce((acc, [k, v]) => {\n if (isString(k)) acc[k] = v;\n return acc;\n }, {} as WalkerOS.AnyObject);\n\n return isUserData ? { ...value, user_data: result } : (result as T);\n}\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer, sendServer } from '@walkeros/server-core';\n\nexport interface Settings {\n accessToken: string;\n pixelId: string;\n action_source?: ActionSource;\n doNotHash?: string[];\n test_event_code?: string;\n url?: string;\n user_data?: WalkerOSMapping.Map;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n sendServer?: typeof sendServer;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/main-body\nexport interface BodyParameters {\n data: Array<ServerEventParameters>;\n test_event_code?: string;\n}\n\n/**\n * Represents the top‑level parameters for a server event sent via Meta's Conversions API.\n * https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/server-event\n */\nexport interface ServerEventParameters extends StandardParameters {\n /** The event name or custom event identifier. Required for deduplication. */\n event_name: EventName;\n\n /** Unix timestamp (in seconds) when the event actually occurred. GMT timezone. */\n event_time: number;\n\n /** Map of customer information for matching (emails, phone, etc.). */\n user_data: CustomerInformationParameters;\n\n /** Additional business data about the event. */\n custom_data?: Record<string, unknown>;\n\n /** URL of the page where the event occurred. */\n event_source_url?: string;\n\n /** If true, exclude this event from ads optimization (only attribution). */\n opt_out?: boolean;\n\n /** Unique ID for deduplication across Pixel and CAPI. */\n event_id?: string;\n\n /** Source of the event (e.g., website, app). */\n action_source: ActionSource;\n\n /** Processing options (e.g., ['LDU'] for CCPA limited data use). */\n data_processing_options?: DataProcessingOption[];\n\n /** Country code for data processing option (1 = USA, 0 = auto‑geolocate). */\n data_processing_options_country?: number;\n\n /** State code for data processing option (1000 = California, 0 = auto). */\n data_processing_options_state?: number;\n\n /** App‑specific data (required if action_source is 'app'). */\n app_data?: AppData;\n\n /** HTTP referrer header of the event. */\n referrer_url?: string;\n\n /** Metadata to link delayed events to past acquisition events. */\n original_event_data?: OriginalEventDataParameters;\n\n /** User segment for more context about the customer's relationship. */\n customer_segmentation?: CustomerSegmentation;\n}\n\nexport type EventName =\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 | string;\n\nexport type ActionSource =\n | 'email'\n | 'website'\n | 'app'\n | 'phone_call'\n | 'chat'\n | 'physical_store'\n | 'system_generated'\n | 'business_messaging'\n | 'other';\n\nexport type DataProcessingOption = 'LDU';\n\nexport type CustomerSegmentation =\n | 'new_customer_to_business'\n | 'new_customer_to_business_line'\n | 'new_customer_to_product_area'\n | 'new_customer_to_medium'\n | 'existing_customer_to_business'\n | 'existing_customer_to_business_line'\n | 'existing_customer_to_product_area'\n | 'existing_customer_to_medium'\n | 'customer_in_loyalty_program';\n\n/** Extended device info for app events (Android version 'a2', iOS 'i2') */\nexport interface AppData {\n /**\n * Comma-separated array of strings with fixed order:\n * [sdk_version, os_version, device_model, device_brand,\n * screen_width, screen_height, ...]\n */\n extinfo: string[];\n}\n\n// Customer Information Parameters\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters\nexport interface CustomerInformationParameters {\n /** Email(s), SHA-256 hashed, lowercase and trimmed */\n em?: string | string[];\n\n /** Phone number(s), SHA-256 hashed, E.164 format (no leading 0s or symbols) */\n ph?: string | string[];\n\n /** First name(s), SHA-256 hashed, lowercase */\n fn?: string | string[];\n\n /** Last name(s), SHA-256 hashed, lowercase */\n ln?: string | string[];\n\n /** Date(s) of birth in YYYYMMDD, SHA-256 hashed */\n db?: string | string[];\n\n /** Gender(s) in lowercase single letter (\"m\", \"f\", etc.), SHA-256 hashed */\n ge?: string | string[];\n\n /** City name(s), SHA-256 hashed, lowercase */\n ct?: string | string[];\n\n /** State abbreviation(s), SHA-256 hashed, lowercase (e.g., \"ca\", \"ny\") */\n st?: string | string[];\n\n /** ZIP or postal code(s), SHA-256 hashed, lowercase */\n zp?: string | string[];\n\n /** Country code(s), SHA-256 hashed, lowercase (ISO 3166-1 alpha-2) */\n country?: string | string[];\n\n /** External IDs, unique per user. SHA-256 hash recommended */\n external_id?: string | string[];\n\n /** IPv4 or IPv6 address of client. Do NOT hash. */\n client_ip_address?: string;\n\n /** User agent string from browser. Do NOT hash. */\n client_user_agent?: string;\n\n /** fbclid parameter value from the URL. Do NOT hash. */\n fbclid?: string;\n\n /** Facebook click ID (_fbc cookie). Do NOT hash. */\n fbc?: string;\n\n /** Facebook browser ID (_fbp cookie). Do NOT hash. */\n fbp?: string;\n\n /** Subscription ID for the transaction. Do NOT hash. */\n subscription_id?: string;\n\n /** Facebook login ID (App-Scoped ID). Do NOT hash. */\n fb_login_id?: number;\n\n /** Meta Lead Ad lead ID. Do NOT hash. */\n lead_id?: number;\n\n /** Anonymous install ID. App events only. Do NOT hash. */\n anon_id?: string;\n\n /** Mobile advertiser ID (GAID/IDFA). Do NOT hash. */\n madid?: string;\n\n /** Facebook Page ID. Do NOT hash. */\n page_id?: string;\n\n /** Messenger Page-scoped user ID. Do NOT hash. */\n page_scoped_user_id?: string;\n\n /** Click to WhatsApp ad click ID. Do NOT hash. */\n ctwa_clid?: string;\n\n /** Instagram business account ID. Do NOT hash. */\n ig_account_id?: string;\n\n /** Instagram-scoped user ID. Do NOT hash. */\n ig_sid?: string;\n}\n\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/custom-data\nexport interface StandardParameters {\n // Web and Offline parameters\n availability?: string;\n body_style?: string;\n checkin_date?: string;\n city?: string;\n condition_of_vehicle?: string;\n content_ids?: string[];\n content_type?: 'product' | 'product_group' | string;\n contents?: Array<{\n id: string;\n quantity?: number;\n item_price?: number;\n delivery_category?: string;\n }>;\n country?: string;\n currency?: string;\n delivery_category?: 'in_store' | 'curbside' | 'home_delivery' | string;\n departing_arrival_date?: string;\n departing_departure_date?: string;\n destination_airport?: string;\n destination_ids?: string[];\n dma_code?: string;\n drivetrain?: string;\n exterior_color?: string;\n fuel_type?: string;\n hotel_score?: number;\n interior_color?: string;\n lead_event_source?: string;\n lease_end_date?: string;\n lease_start_date?: string;\n listing_type?: string;\n make?: string;\n // @TODO is mileage an object?\n 'mileage.unit'?: string;\n 'mileage.value'?: number;\n model?: string;\n neighborhood?: string;\n net_revenue?: number;\n num_adults?: number;\n num_children?: number;\n num_infants?: number;\n num_items?: number;\n order_id?: string;\n origin_airport?: string;\n postal_code?: string;\n predicted_ltv?: number;\n preferred_baths_range?: string;\n preferred_beds_range?: string;\n preferred_neighborhoods?: string[];\n preferred_num_stops?: number;\n preferred_price_range?: string;\n preferred_star_ratings?: [number, number];\n price?: string;\n product_catalog_id?: string;\n property_type?: string;\n region?: string;\n returning_arrival_date?: string;\n returning_departure_date?: string;\n search_string?: string;\n state_of_vehicle?: string;\n suggested_destinations?: string[];\n suggested_home_listings?: string[];\n suggested_hotels?: string[];\n suggested_jobs?: string[];\n suggested_local_service_businesses?: string[];\n suggested_location_based_items?: string[];\n suggested_vehicles?: string[];\n transmission?: string;\n travel_class?: string;\n travel_end?: string;\n travel_start?: string;\n trim?: string;\n\n // App-specific parameters (with fb_ prefix)\n fb_availability?: string;\n fb_body_style?: string;\n fb_checkin_date?: string;\n fb_city?: string;\n fb_condition_of_vehicle?: string;\n fb_content_ids?: string[];\n fb_content_type?: string;\n fb_contents?: Array<{ id: string; quantity?: number; item_price?: number }>;\n fb_country?: string;\n fb_currency?: string;\n fb_delivery_category?: string;\n fb_departing_arrival_date?: string;\n fb_departing_departure_date?: string;\n fb_destination_airport?: string;\n fb_destination_ids?: string[];\n fb_dma_code?: string;\n fb_drivetrain?: string;\n fb_exterior_color?: string;\n fb_fuel_type?: string;\n fb_hotel_score?: number;\n fb_interior_color?: string;\n fb_lease_end_date?: string;\n fb_lease_start_date?: string;\n fb_listing_type?: string;\n fb_make?: string;\n // @TODO is fb_mileage an object?\n 'fb_mileage.unit'?: string;\n 'fb_mileage.value'?: number;\n fb_model?: string;\n fb_neighborhood?: string;\n fb_num_adults?: number;\n fb_num_children?: number;\n fb_num_infants?: number;\n fb_num_items?: number;\n fb_order_id?: string;\n fb_origin_airport?: string;\n fb_postal_code?: string;\n fb_predicted_ltv?: number;\n fb_preferred_baths_range?: string;\n fb_preferred_beds_range?: string;\n fb_preferred_neighborhoods?: string[];\n fb_preferred_num_stops?: number;\n fb_preferred_price_range?: string;\n fb_preferred_star_ratings?: [number, number];\n fb_price?: string;\n fb_product_catalog_id?: string;\n fb_property_type?: string;\n fb_region?: string;\n fb_returning_arrival_date?: string;\n fb_returning_departure_date?: string;\n fb_search_string?: string;\n fb_state_of_vehicle?: string;\n fb_suggested_destinations?: string[];\n fb_suggested_home_listings?: string[];\n fb_suggested_hotels?: string[];\n fb_suggested_jobs?: string[];\n fb_suggested_local_service_businesses?: string[];\n fb_suggested_location_based_items?: string[];\n fb_suggested_vehicles?: string[];\n fb_transmission?: string;\n fb_travel_class?: string;\n fb_travel_end?: string;\n fb_travel_start?: string;\n\n // Offline-specific parameters\n user_bucket?: string;\n value?: number;\n vin?: string;\n year?: number;\n item_number?: string;\n}\n\nexport interface OriginalEventDataParameters {\n event_name?: EventName;\n event_time?: number;\n order_id?: number;\n event_id?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,SAAS,UACd,gBAA+B,CAAC,GAChC,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,aAAa,QAAQ,IAAI;AAEjC,MAAI,CAAC,YAAa,QAAO,MAAM,qCAAqC;AACpE,MAAI,CAAC,QAAS,QAAO,MAAM,iCAAiC;AAE5D,QAAM,iBAA2B;AAAA,IAC/B,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,GAAG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AAQ;AAAA,IACR,WAAW,YAAY;AAAA,IACvB,SAAS,YAAY;AAAA,EACvB,CAAC;AAED,QAAM,eAAe,KAAK,cAAc;AACxC,QAAM,SAAS,MAAM;AAAA,IACnB,GAAG,QAAQ,iBAAiB,WAAW;AAAA,IACvC,KAAK,UAAU,IAAI;AAAA,EACrB;AAEA,SAAO,MAAM,qBAAqB;AAAA,IAChC,QAAI,uBAAS,MAAM,IAAI,OAAO,KAAK;AAAA,EACrC,CAAC;AAED,UAAI,uBAAS,MAAM,KAAK,OAAO,OAAO,OAAO;AAC3C,WAAO,MAAM,mBAAmB,KAAK,UAAU,MAAM,CAAC,EAAE;AAAA,EAC1D;AACF;AAEA,SAAS,cAAc,SAAkB,MAAmC;AAG1E,MAAI,CAAC,QAAS;AAGd,QAAM,UAAU;AAGhB,QAAM,iBAAiB;AAGvB,QAAM,eAAe,QAAQ,KAAK,IAAI;AAEtC,SAAO,GAAG,OAAO,IAAI,cAAc,IAAI,YAAY,IAAI,OAAO;AAChE;;;AE7GA;;;AJOO,IAAM,kBAA+B;AAAA,EAC1C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,MAAM,KAAK,EAAE,QAAQ,eAAe,OAAO,GAAG;AAC5C,UAAM,SAAS,UAAU,eAAe,MAAM;AAC9C,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,SAAS;AACzB,WAAO,MAAM,KAAK,OAAO,OAAO;AAAA,EAClC;AACF;AAEA,IAAO,gBAAQ;","names":["import_core","import_server_core"]}
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{getMappingValue,isObject as isObject2}from"@walkeros/core";import{sendServer}from"@walkeros/server-core";import{isArray,isObject,isString}from"@walkeros/core";import{getHashServer}from"@walkeros/server-core";var keysToHash=["em","ph","fn","ln","db","ge","ct","st","zp","country","external_id"];function shouldBeHashed(key,doNotHash=[]){return keysToHash.includes(key)&&!doNotHash.includes(key)}async function processValue(value,shouldHash){return shouldHash?isArray(value)?Promise.all(value.map(item=>getHashServer(String(item)))):getHashServer(String(value)):value}var push=async function(event,{config:config,rule:rule,data:data,collector:collector,env:env,logger:logger}){var _a;const{accessToken:accessToken,pixelId:pixelId,action_source:action_source="website",doNotHash:doNotHash,test_event_code:test_event_code,url:url="https://graph.facebook.com/v22.0/",user_data:user_data}=config.settings,eventData=isObject2(data)?data:{},configData=config.data?await getMappingValue(event,config.data):{},userDataCustom=user_data?await getMappingValue(event,{map:user_data}):{},userData={...isObject2(configData)&&isObject2(configData.user_data)?configData.user_data:{},...isObject2(userDataCustom)?userDataCustom:{},...isObject2(eventData.user_data)?eventData.user_data:{}};userData.fbclid&&(userData.fbc=function(clickId,time){if(!clickId)return;const version="fb",subdomainIndex="1",creationTime=time||Date.now();return`${version}.${subdomainIndex}.${creationTime}.${clickId}`}(userData.fbclid,(null==(_a=null==collector?void 0:collector.session)?void 0:_a.start)||event.timestamp),delete userData.fbclid);const serverEvent={event_name:event.name,event_id:event.id,event_time:Math.round((event.timestamp||Date.now())/1e3),action_source:action_source,...eventData,user_data:userData};"website"===action_source&&(serverEvent.event_source_url=event.source.id);const hashedServerEvent=await async function(value,doNotHash=[]){if(!isObject(value))return value;const isUserData="user_data"in value,target=isUserData?value.user_data:value,result=(await Promise.all(Object.entries(target).map(async([k,v])=>[k,await processValue(v,isUserData&&shouldBeHashed(k,doNotHash))]))).reduce((acc,[k,v])=>(isString(k)&&(acc[k]=v),acc),{});return isUserData?{...value,user_data:result}:result}(serverEvent,doNotHash),body={data:[hashedServerEvent]};test_event_code&&(body.test_event_code=test_event_code);const endpoint=`${url}${pixelId}/events`;logger.debug("Calling Meta API",{endpoint:endpoint,method:"POST",eventName:serverEvent.event_name,eventId:serverEvent.event_id});const sendServerFn=(null==env?void 0:env.sendServer)||sendServer,result=await sendServerFn(`${endpoint}?access_token=${accessToken}`,JSON.stringify(body));logger.debug("Meta API response",{ok:!isObject2(result)||result.ok}),isObject2(result)&&!1===result.ok&&logger.throw(`Meta API error: ${JSON.stringify(result)}`)};var types_exports={},destinationMeta={type:"meta",config:{},async init({config:partialConfig,logger:logger}){const config=function(partialConfig={},logger){const settings=partialConfig.settings||{},{accessToken:accessToken,pixelId:pixelId}=settings;accessToken||logger.throw("Config settings accessToken missing"),pixelId||logger.throw("Config settings pixelId missing");const settingsConfig={...settings,accessToken:accessToken,pixelId:pixelId};return{...partialConfig,settings:settingsConfig}}(partialConfig,logger);return config},push:async(event,context)=>await push(event,context)},index_default=destinationMeta;export{types_exports as DestinationMeta,index_default as default,destinationMeta};//# sourceMappingURL=index.mjs.map
1
+ import{getMappingValue,isObject as isObject2}from"@walkeros/core";import{sendServer}from"@walkeros/server-core";import{isArray,isObject,isString}from"@walkeros/core";import{getHashServer}from"@walkeros/server-core";var keysToHash=["em","ph","fn","ln","db","ge","ct","st","zp","country","external_id"];function shouldBeHashed(key,doNotHash=[]){return keysToHash.includes(key)&&!doNotHash.includes(key)}async function processValue(value,shouldHash){return shouldHash?isArray(value)?Promise.all(value.map(item=>getHashServer(String(item)))):getHashServer(String(value)):value}var push=async function(event,{config:config,rule:rule,data:data,collector:collector,env:env,logger:logger}){const{accessToken:accessToken,pixelId:pixelId,action_source:action_source="website",doNotHash:doNotHash,test_event_code:test_event_code,url:url="https://graph.facebook.com/v22.0/",user_data:user_data}=config.settings,eventData=isObject2(data)?data:{},configData=config.data?await getMappingValue(event,config.data):{},userDataCustom=user_data?await getMappingValue(event,{map:user_data}):{},userData={...isObject2(configData)&&isObject2(configData.user_data)?configData.user_data:{},...isObject2(userDataCustom)?userDataCustom:{},...isObject2(eventData.user_data)?eventData.user_data:{}};userData.fbclid&&(userData.fbc=function(clickId,time){if(!clickId)return;const version="fb",subdomainIndex="1",creationTime=time||Date.now();return`${version}.${subdomainIndex}.${creationTime}.${clickId}`}(userData.fbclid,collector?.session?.start||event.timestamp),delete userData.fbclid);const serverEvent={event_name:event.name,event_id:event.id,event_time:Math.round((event.timestamp||Date.now())/1e3),action_source:action_source,...eventData,user_data:userData};"website"===action_source&&event.source?.url&&(serverEvent.event_source_url=event.source.url);const hashedServerEvent=await async function(value,doNotHash=[]){if(!isObject(value))return value;const isUserData="user_data"in value,target=isUserData?value.user_data:value,result=(await Promise.all(Object.entries(target).map(async([k,v])=>[k,await processValue(v,isUserData&&shouldBeHashed(k,doNotHash))]))).reduce((acc,[k,v])=>(isString(k)&&(acc[k]=v),acc),{});return isUserData?{...value,user_data:result}:result}(serverEvent,doNotHash),body={data:[hashedServerEvent]};test_event_code&&(body.test_event_code=test_event_code);const endpoint=`${url}${pixelId}/events`;logger.debug("Calling Meta API",{endpoint:endpoint,method:"POST",eventName:serverEvent.event_name,eventId:serverEvent.event_id});const sendServerFn=env?.sendServer||sendServer,result=await sendServerFn(`${endpoint}?access_token=${accessToken}`,JSON.stringify(body));logger.debug("Meta API response",{ok:!isObject2(result)||result.ok}),isObject2(result)&&!1===result.ok&&logger.throw(`Meta API error: ${JSON.stringify(result)}`)};var types_exports={},destinationMeta={type:"meta",config:{},async init({config:partialConfig,logger:logger}){const config=function(partialConfig={},logger){const settings=partialConfig.settings||{},{accessToken:accessToken,pixelId:pixelId}=settings;accessToken||logger.throw("Config settings accessToken missing"),pixelId||logger.throw("Config settings pixelId missing");const settingsConfig={...settings,accessToken:accessToken,pixelId:pixelId};return{...partialConfig,settings:settingsConfig}}(partialConfig,logger);return config},push:async(event,context)=>await push(event,context)},index_default=destinationMeta;export{types_exports as DestinationMeta,index_default as default,destinationMeta};//# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts","../src/push.ts","../src/hash.ts","../src/types/index.ts","../src/index.ts"],"sourcesContent":["import type { Config, Settings, PartialConfig } from './types';\nimport type { Logger } from '@walkeros/core';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n logger: Logger.Instance,\n): Config {\n const settings = (partialConfig.settings || {}) as Partial<Settings>;\n const { accessToken, pixelId } = settings;\n\n if (!accessToken) logger.throw('Config settings accessToken missing');\n if (!pixelId) logger.throw('Config settings pixelId missing');\n\n const settingsConfig: Settings = {\n ...settings,\n accessToken,\n pixelId,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type {\n BodyParameters,\n CustomerInformationParameters,\n PushFn,\n ServerEventParameters,\n Env,\n} from './types';\nimport { getMappingValue, isObject } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport { hashEvent } from './hash';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, collector, env, logger },\n) {\n const {\n accessToken,\n pixelId,\n action_source = 'website',\n doNotHash,\n test_event_code,\n url = 'https://graph.facebook.com/v22.0/',\n user_data,\n } = config.settings!;\n\n const eventData = isObject(data) ? data : {};\n const configData = config.data\n ? await getMappingValue(event, config.data)\n : {};\n const userDataCustom = user_data\n ? await getMappingValue(event, { map: user_data })\n : {};\n\n const userData: CustomerInformationParameters = {\n // Destination config\n ...(isObject(configData) && isObject(configData.user_data)\n ? configData.user_data\n : {}),\n // Custom user_data\n ...(isObject(userDataCustom) ? userDataCustom : {}),\n // Event mapping\n ...(isObject(eventData.user_data) ? eventData.user_data : {}),\n };\n\n if (userData.fbclid) {\n userData.fbc = formatClickId(\n userData.fbclid,\n collector?.session?.start || event.timestamp,\n );\n delete userData.fbclid;\n }\n const serverEvent: ServerEventParameters = {\n event_name: event.name,\n event_id: event.id,\n event_time: Math.round((event.timestamp || Date.now()) / 1000),\n action_source,\n ...eventData,\n user_data: userData,\n };\n\n if (action_source === 'website')\n serverEvent.event_source_url = event.source.id;\n\n const hashedServerEvent = await hashEvent(serverEvent, doNotHash);\n\n const body: BodyParameters = { data: [hashedServerEvent] };\n\n // Test event code\n if (test_event_code) body.test_event_code = test_event_code;\n\n const endpoint = `${url}${pixelId}/events`;\n logger.debug('Calling Meta API', {\n endpoint,\n method: 'POST',\n eventName: serverEvent.event_name,\n eventId: serverEvent.event_id,\n });\n\n const sendServerFn = env?.sendServer || sendServer;\n const result = await sendServerFn(\n `${endpoint}?access_token=${accessToken}`,\n JSON.stringify(body),\n );\n\n logger.debug('Meta API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`Meta API error: ${JSON.stringify(result)}`);\n }\n};\n\nfunction formatClickId(clickId: unknown, time?: number): string | undefined {\n // https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc#2--format-clickid\n\n if (!clickId) return;\n\n // Version is always \"fb\"\n const version = 'fb';\n\n // Subdomain ('com' = 0, 'example.com' = 1, 'www.example.com' = 2)\n const subdomainIndex = '1';\n\n // Get the current timestamp in milliseconds (or when the fbclid was observed)\n const creationTime = time || Date.now();\n\n return `${version}.${subdomainIndex}.${creationTime}.${clickId}`;\n}\n\nfunction lower(str: WalkerOS.Property): string {\n return String(str).toLocaleLowerCase();\n}\n","import { WalkerOS } from '@walkeros/core';\nimport { isArray, isObject, isString } from '@walkeros/core';\nimport { getHashServer } from '@walkeros/server-core';\n\nconst keysToHash = [\n 'em',\n 'ph',\n 'fn',\n 'ln',\n 'db',\n 'ge',\n 'ct',\n 'st',\n 'zp',\n 'country',\n 'external_id',\n];\n\nfunction shouldBeHashed(key: string, doNotHash: string[] = []): boolean {\n return keysToHash.includes(key) && !doNotHash.includes(key);\n}\n\ntype HashableValue = WalkerOS.AnyObject | unknown | unknown[];\n\nasync function processValue(\n value: unknown,\n shouldHash: boolean,\n): Promise<unknown> {\n if (!shouldHash) return value;\n if (isArray(value)) {\n return Promise.all(value.map((item) => getHashServer(String(item))));\n }\n return getHashServer(String(value));\n}\n\nexport async function hashEvent<T extends HashableValue>(\n value: T,\n doNotHash: string[] = [],\n): Promise<T> {\n if (!isObject(value)) return value;\n\n const isUserData = 'user_data' in value;\n const target = (isUserData ? value.user_data : value) as WalkerOS.AnyObject;\n\n const entries = await Promise.all(\n Object.entries(target).map(async ([k, v]) => [\n k,\n await processValue(v, isUserData && shouldBeHashed(k, doNotHash)),\n ]),\n );\n\n const result = entries.reduce((acc, [k, v]) => {\n if (isString(k)) acc[k] = v;\n return acc;\n }, {} as WalkerOS.AnyObject);\n\n return isUserData ? { ...value, user_data: result } : (result as T);\n}\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer, sendServer } from '@walkeros/server-core';\n\nexport interface Settings {\n accessToken: string;\n pixelId: string;\n action_source?: ActionSource;\n doNotHash?: string[];\n test_event_code?: string;\n url?: string;\n user_data?: WalkerOSMapping.Map;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n sendServer?: typeof sendServer;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/main-body\nexport interface BodyParameters {\n data: Array<ServerEventParameters>;\n test_event_code?: string;\n}\n\n/**\n * Represents the top‑level parameters for a server event sent via Meta's Conversions API.\n * https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/server-event\n */\nexport interface ServerEventParameters extends StandardParameters {\n /** The event name or custom event identifier. Required for deduplication. */\n event_name: EventName;\n\n /** Unix timestamp (in seconds) when the event actually occurred. GMT timezone. */\n event_time: number;\n\n /** Map of customer information for matching (emails, phone, etc.). */\n user_data: CustomerInformationParameters;\n\n /** Additional business data about the event. */\n custom_data?: Record<string, unknown>;\n\n /** URL of the page where the event occurred. */\n event_source_url?: string;\n\n /** If true, exclude this event from ads optimization (only attribution). */\n opt_out?: boolean;\n\n /** Unique ID for deduplication across Pixel and CAPI. */\n event_id?: string;\n\n /** Source of the event (e.g., website, app). */\n action_source: ActionSource;\n\n /** Processing options (e.g., ['LDU'] for CCPA limited data use). */\n data_processing_options?: DataProcessingOption[];\n\n /** Country code for data processing option (1 = USA, 0 = auto‑geolocate). */\n data_processing_options_country?: number;\n\n /** State code for data processing option (1000 = California, 0 = auto). */\n data_processing_options_state?: number;\n\n /** App‑specific data (required if action_source is 'app'). */\n app_data?: AppData;\n\n /** HTTP referrer header of the event. */\n referrer_url?: string;\n\n /** Metadata to link delayed events to past acquisition events. */\n original_event_data?: OriginalEventDataParameters;\n\n /** User segment for more context about the customer's relationship. */\n customer_segmentation?: CustomerSegmentation;\n}\n\nexport type EventName =\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 | string;\n\nexport type ActionSource =\n | 'email'\n | 'website'\n | 'app'\n | 'phone_call'\n | 'chat'\n | 'physical_store'\n | 'system_generated'\n | 'business_messaging'\n | 'other';\n\nexport type DataProcessingOption = 'LDU';\n\nexport type CustomerSegmentation =\n | 'new_customer_to_business'\n | 'new_customer_to_business_line'\n | 'new_customer_to_product_area'\n | 'new_customer_to_medium'\n | 'existing_customer_to_business'\n | 'existing_customer_to_business_line'\n | 'existing_customer_to_product_area'\n | 'existing_customer_to_medium'\n | 'customer_in_loyalty_program';\n\n/** Extended device info for app events (Android version 'a2', iOS 'i2') */\nexport interface AppData {\n /**\n * Comma-separated array of strings with fixed order:\n * [sdk_version, os_version, device_model, device_brand,\n * screen_width, screen_height, ...]\n */\n extinfo: string[];\n}\n\n// Customer Information Parameters\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters\nexport interface CustomerInformationParameters {\n /** Email(s), SHA-256 hashed, lowercase and trimmed */\n em?: string | string[];\n\n /** Phone number(s), SHA-256 hashed, E.164 format (no leading 0s or symbols) */\n ph?: string | string[];\n\n /** First name(s), SHA-256 hashed, lowercase */\n fn?: string | string[];\n\n /** Last name(s), SHA-256 hashed, lowercase */\n ln?: string | string[];\n\n /** Date(s) of birth in YYYYMMDD, SHA-256 hashed */\n db?: string | string[];\n\n /** Gender(s) in lowercase single letter (\"m\", \"f\", etc.), SHA-256 hashed */\n ge?: string | string[];\n\n /** City name(s), SHA-256 hashed, lowercase */\n ct?: string | string[];\n\n /** State abbreviation(s), SHA-256 hashed, lowercase (e.g., \"ca\", \"ny\") */\n st?: string | string[];\n\n /** ZIP or postal code(s), SHA-256 hashed, lowercase */\n zp?: string | string[];\n\n /** Country code(s), SHA-256 hashed, lowercase (ISO 3166-1 alpha-2) */\n country?: string | string[];\n\n /** External IDs, unique per user. SHA-256 hash recommended */\n external_id?: string | string[];\n\n /** IPv4 or IPv6 address of client. Do NOT hash. */\n client_ip_address?: string;\n\n /** User agent string from browser. Do NOT hash. */\n client_user_agent?: string;\n\n /** fbclid parameter value from the URL. Do NOT hash. */\n fbclid?: string;\n\n /** Facebook click ID (_fbc cookie). Do NOT hash. */\n fbc?: string;\n\n /** Facebook browser ID (_fbp cookie). Do NOT hash. */\n fbp?: string;\n\n /** Subscription ID for the transaction. Do NOT hash. */\n subscription_id?: string;\n\n /** Facebook login ID (App-Scoped ID). Do NOT hash. */\n fb_login_id?: number;\n\n /** Meta Lead Ad lead ID. Do NOT hash. */\n lead_id?: number;\n\n /** Anonymous install ID. App events only. Do NOT hash. */\n anon_id?: string;\n\n /** Mobile advertiser ID (GAID/IDFA). Do NOT hash. */\n madid?: string;\n\n /** Facebook Page ID. Do NOT hash. */\n page_id?: string;\n\n /** Messenger Page-scoped user ID. Do NOT hash. */\n page_scoped_user_id?: string;\n\n /** Click to WhatsApp ad click ID. Do NOT hash. */\n ctwa_clid?: string;\n\n /** Instagram business account ID. Do NOT hash. */\n ig_account_id?: string;\n\n /** Instagram-scoped user ID. Do NOT hash. */\n ig_sid?: string;\n}\n\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/custom-data\nexport interface StandardParameters {\n // Web and Offline parameters\n availability?: string;\n body_style?: string;\n checkin_date?: string;\n city?: string;\n condition_of_vehicle?: string;\n content_ids?: string[];\n content_type?: 'product' | 'product_group' | string;\n contents?: Array<{\n id: string;\n quantity?: number;\n item_price?: number;\n delivery_category?: string;\n }>;\n country?: string;\n currency?: string;\n delivery_category?: 'in_store' | 'curbside' | 'home_delivery' | string;\n departing_arrival_date?: string;\n departing_departure_date?: string;\n destination_airport?: string;\n destination_ids?: string[];\n dma_code?: string;\n drivetrain?: string;\n exterior_color?: string;\n fuel_type?: string;\n hotel_score?: number;\n interior_color?: string;\n lead_event_source?: string;\n lease_end_date?: string;\n lease_start_date?: string;\n listing_type?: string;\n make?: string;\n // @TODO is mileage an object?\n 'mileage.unit'?: string;\n 'mileage.value'?: number;\n model?: string;\n neighborhood?: string;\n net_revenue?: number;\n num_adults?: number;\n num_children?: number;\n num_infants?: number;\n num_items?: number;\n order_id?: string;\n origin_airport?: string;\n postal_code?: string;\n predicted_ltv?: number;\n preferred_baths_range?: string;\n preferred_beds_range?: string;\n preferred_neighborhoods?: string[];\n preferred_num_stops?: number;\n preferred_price_range?: string;\n preferred_star_ratings?: [number, number];\n price?: string;\n product_catalog_id?: string;\n property_type?: string;\n region?: string;\n returning_arrival_date?: string;\n returning_departure_date?: string;\n search_string?: string;\n state_of_vehicle?: string;\n suggested_destinations?: string[];\n suggested_home_listings?: string[];\n suggested_hotels?: string[];\n suggested_jobs?: string[];\n suggested_local_service_businesses?: string[];\n suggested_location_based_items?: string[];\n suggested_vehicles?: string[];\n transmission?: string;\n travel_class?: string;\n travel_end?: string;\n travel_start?: string;\n trim?: string;\n\n // App-specific parameters (with fb_ prefix)\n fb_availability?: string;\n fb_body_style?: string;\n fb_checkin_date?: string;\n fb_city?: string;\n fb_condition_of_vehicle?: string;\n fb_content_ids?: string[];\n fb_content_type?: string;\n fb_contents?: Array<{ id: string; quantity?: number; item_price?: number }>;\n fb_country?: string;\n fb_currency?: string;\n fb_delivery_category?: string;\n fb_departing_arrival_date?: string;\n fb_departing_departure_date?: string;\n fb_destination_airport?: string;\n fb_destination_ids?: string[];\n fb_dma_code?: string;\n fb_drivetrain?: string;\n fb_exterior_color?: string;\n fb_fuel_type?: string;\n fb_hotel_score?: number;\n fb_interior_color?: string;\n fb_lease_end_date?: string;\n fb_lease_start_date?: string;\n fb_listing_type?: string;\n fb_make?: string;\n // @TODO is fb_mileage an object?\n 'fb_mileage.unit'?: string;\n 'fb_mileage.value'?: number;\n fb_model?: string;\n fb_neighborhood?: string;\n fb_num_adults?: number;\n fb_num_children?: number;\n fb_num_infants?: number;\n fb_num_items?: number;\n fb_order_id?: string;\n fb_origin_airport?: string;\n fb_postal_code?: string;\n fb_predicted_ltv?: number;\n fb_preferred_baths_range?: string;\n fb_preferred_beds_range?: string;\n fb_preferred_neighborhoods?: string[];\n fb_preferred_num_stops?: number;\n fb_preferred_price_range?: string;\n fb_preferred_star_ratings?: [number, number];\n fb_price?: string;\n fb_product_catalog_id?: string;\n fb_property_type?: string;\n fb_region?: string;\n fb_returning_arrival_date?: string;\n fb_returning_departure_date?: string;\n fb_search_string?: string;\n fb_state_of_vehicle?: string;\n fb_suggested_destinations?: string[];\n fb_suggested_home_listings?: string[];\n fb_suggested_hotels?: string[];\n fb_suggested_jobs?: string[];\n fb_suggested_local_service_businesses?: string[];\n fb_suggested_location_based_items?: string[];\n fb_suggested_vehicles?: string[];\n fb_transmission?: string;\n fb_travel_class?: string;\n fb_travel_end?: string;\n fb_travel_start?: string;\n\n // Offline-specific parameters\n user_bucket?: string;\n value?: number;\n vin?: string;\n year?: number;\n item_number?: string;\n}\n\nexport interface OriginalEventDataParameters {\n event_name?: EventName;\n event_time?: number;\n order_id?: number;\n event_id?: string;\n}\n","import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationMeta from './types';\n\nexport const destinationMeta: Destination = {\n type: 'meta',\n\n config: {},\n\n async init({ config: partialConfig, logger }) {\n const config = getConfig(partialConfig, logger);\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n};\n\nexport default destinationMeta;\n"],"mappings":";AAGO,SAAS,UACd,gBAA+B,CAAC,GAChC,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,aAAa,QAAQ,IAAI;AAEjC,MAAI,CAAC,YAAa,QAAO,MAAM,qCAAqC;AACpE,MAAI,CAAC,QAAS,QAAO,MAAM,iCAAiC;AAE5D,QAAM,iBAA2B;AAAA,IAC/B,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,eAAe,UAAU,eAAe;AACtD;;;ACZA,SAAS,iBAAiB,YAAAA,iBAAgB;AAC1C,SAAS,kBAAkB;;;ACR3B,SAAS,SAAS,UAAU,gBAAgB;AAC5C,SAAS,qBAAqB;AAE9B,IAAM,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,eAAe,KAAa,YAAsB,CAAC,GAAY;AACtE,SAAO,WAAW,SAAS,GAAG,KAAK,CAAC,UAAU,SAAS,GAAG;AAC5D;AAIA,eAAe,aACb,OACA,YACkB;AAClB,MAAI,CAAC,WAAY,QAAO;AACxB,MAAI,QAAQ,KAAK,GAAG;AAClB,WAAO,QAAQ,IAAI,MAAM,IAAI,CAAC,SAAS,cAAc,OAAO,IAAI,CAAC,CAAC,CAAC;AAAA,EACrE;AACA,SAAO,cAAc,OAAO,KAAK,CAAC;AACpC;AAEA,eAAsB,UACp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AI,OAAO;AAChE;;;AE7GA;;;ACOO,IAAM,kBAA+B;AAAA,EAC1C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,MAAM,KAAK,EAAE,QAAQ,eAAe,OAAO,GAAG;AAC5C,UAAM,SAAS,UAAU,eAAe,MAAM;AAC9C,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,SAAS;AACzB,WAAO,MAAM,KAAK,OAAO,OAAO;AAAA,EAClC;AACF;AAEA,IAAO,gBAAQ;","names":["isObject","isObject"]}
1
+ {"version":3,"sources":["../src/config.ts","../src/push.ts","../src/hash.ts","../src/types/index.ts","../src/index.ts"],"sourcesContent":["import type { Config, Settings, PartialConfig } from './types';\nimport type { Logger } from '@walkeros/core';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n logger: Logger.Instance,\n): Config {\n const settings = (partialConfig.settings || {}) as Partial<Settings>;\n const { accessToken, pixelId } = settings;\n\n if (!accessToken) logger.throw('Config settings accessToken missing');\n if (!pixelId) logger.throw('Config settings pixelId missing');\n\n const settingsConfig: Settings = {\n ...settings,\n accessToken,\n pixelId,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { WalkerOS } from '@walkeros/core';\nimport type {\n BodyParameters,\n CustomerInformationParameters,\n PushFn,\n ServerEventParameters,\n Env,\n} from './types';\nimport { getMappingValue, isObject } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport { hashEvent } from './hash';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, collector, env, logger },\n) {\n const {\n accessToken,\n pixelId,\n action_source = 'website',\n doNotHash,\n test_event_code,\n url = 'https://graph.facebook.com/v22.0/',\n user_data,\n } = config.settings!;\n\n const eventData = isObject(data) ? data : {};\n const configData = config.data\n ? await getMappingValue(event, config.data)\n : {};\n const userDataCustom = user_data\n ? await getMappingValue(event, { map: user_data })\n : {};\n\n const userData: CustomerInformationParameters = {\n // Destination config\n ...(isObject(configData) && isObject(configData.user_data)\n ? configData.user_data\n : {}),\n // Custom user_data\n ...(isObject(userDataCustom) ? userDataCustom : {}),\n // Event mapping\n ...(isObject(eventData.user_data) ? eventData.user_data : {}),\n };\n\n if (userData.fbclid) {\n userData.fbc = formatClickId(\n userData.fbclid,\n collector?.session?.start || event.timestamp,\n );\n delete userData.fbclid;\n }\n const serverEvent: ServerEventParameters = {\n event_name: event.name,\n event_id: event.id,\n event_time: Math.round((event.timestamp || Date.now()) / 1000),\n action_source,\n ...eventData,\n user_data: userData,\n };\n\n if (action_source === 'website' && event.source?.url)\n serverEvent.event_source_url = event.source.url;\n\n const hashedServerEvent = await hashEvent(serverEvent, doNotHash);\n\n const body: BodyParameters = { data: [hashedServerEvent] };\n\n // Test event code\n if (test_event_code) body.test_event_code = test_event_code;\n\n const endpoint = `${url}${pixelId}/events`;\n logger.debug('Calling Meta API', {\n endpoint,\n method: 'POST',\n eventName: serverEvent.event_name,\n eventId: serverEvent.event_id,\n });\n\n const sendServerFn = env?.sendServer || sendServer;\n const result = await sendServerFn(\n `${endpoint}?access_token=${accessToken}`,\n JSON.stringify(body),\n );\n\n logger.debug('Meta API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`Meta API error: ${JSON.stringify(result)}`);\n }\n};\n\nfunction formatClickId(clickId: unknown, time?: number): string | undefined {\n // https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc#2--format-clickid\n\n if (!clickId) return;\n\n // Version is always \"fb\"\n const version = 'fb';\n\n // Subdomain ('com' = 0, 'example.com' = 1, 'www.example.com' = 2)\n const subdomainIndex = '1';\n\n // Get the current timestamp in milliseconds (or when the fbclid was observed)\n const creationTime = time || Date.now();\n\n return `${version}.${subdomainIndex}.${creationTime}.${clickId}`;\n}\n\nfunction lower(str: WalkerOS.Property): string {\n return String(str).toLocaleLowerCase();\n}\n","import { WalkerOS } from '@walkeros/core';\nimport { isArray, isObject, isString } from '@walkeros/core';\nimport { getHashServer } from '@walkeros/server-core';\n\nconst keysToHash = [\n 'em',\n 'ph',\n 'fn',\n 'ln',\n 'db',\n 'ge',\n 'ct',\n 'st',\n 'zp',\n 'country',\n 'external_id',\n];\n\nfunction shouldBeHashed(key: string, doNotHash: string[] = []): boolean {\n return keysToHash.includes(key) && !doNotHash.includes(key);\n}\n\ntype HashableValue = WalkerOS.AnyObject | unknown | unknown[];\n\nasync function processValue(\n value: unknown,\n shouldHash: boolean,\n): Promise<unknown> {\n if (!shouldHash) return value;\n if (isArray(value)) {\n return Promise.all(value.map((item) => getHashServer(String(item))));\n }\n return getHashServer(String(value));\n}\n\nexport async function hashEvent<T extends HashableValue>(\n value: T,\n doNotHash: string[] = [],\n): Promise<T> {\n if (!isObject(value)) return value;\n\n const isUserData = 'user_data' in value;\n const target = (isUserData ? value.user_data : value) as WalkerOS.AnyObject;\n\n const entries = await Promise.all(\n Object.entries(target).map(async ([k, v]) => [\n k,\n await processValue(v, isUserData && shouldBeHashed(k, doNotHash)),\n ]),\n );\n\n const result = entries.reduce((acc, [k, v]) => {\n if (isString(k)) acc[k] = v;\n return acc;\n }, {} as WalkerOS.AnyObject);\n\n return isUserData ? { ...value, user_data: result } : (result as T);\n}\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer, sendServer } from '@walkeros/server-core';\n\nexport interface Settings {\n accessToken: string;\n pixelId: string;\n action_source?: ActionSource;\n doNotHash?: string[];\n test_event_code?: string;\n url?: string;\n user_data?: WalkerOSMapping.Map;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {}\n\nexport interface Env extends DestinationServer.Env {\n sendServer?: typeof sendServer;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/main-body\nexport interface BodyParameters {\n data: Array<ServerEventParameters>;\n test_event_code?: string;\n}\n\n/**\n * Represents the top‑level parameters for a server event sent via Meta's Conversions API.\n * https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/server-event\n */\nexport interface ServerEventParameters extends StandardParameters {\n /** The event name or custom event identifier. Required for deduplication. */\n event_name: EventName;\n\n /** Unix timestamp (in seconds) when the event actually occurred. GMT timezone. */\n event_time: number;\n\n /** Map of customer information for matching (emails, phone, etc.). */\n user_data: CustomerInformationParameters;\n\n /** Additional business data about the event. */\n custom_data?: Record<string, unknown>;\n\n /** URL of the page where the event occurred. */\n event_source_url?: string;\n\n /** If true, exclude this event from ads optimization (only attribution). */\n opt_out?: boolean;\n\n /** Unique ID for deduplication across Pixel and CAPI. */\n event_id?: string;\n\n /** Source of the event (e.g., website, app). */\n action_source: ActionSource;\n\n /** Processing options (e.g., ['LDU'] for CCPA limited data use). */\n data_processing_options?: DataProcessingOption[];\n\n /** Country code for data processing option (1 = USA, 0 = auto‑geolocate). */\n data_processing_options_country?: number;\n\n /** State code for data processing option (1000 = California, 0 = auto). */\n data_processing_options_state?: number;\n\n /** App‑specific data (required if action_source is 'app'). */\n app_data?: AppData;\n\n /** HTTP referrer header of the event. */\n referrer_url?: string;\n\n /** Metadata to link delayed events to past acquisition events. */\n original_event_data?: OriginalEventDataParameters;\n\n /** User segment for more context about the customer's relationship. */\n customer_segmentation?: CustomerSegmentation;\n}\n\nexport type EventName =\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 | string;\n\nexport type ActionSource =\n | 'email'\n | 'website'\n | 'app'\n | 'phone_call'\n | 'chat'\n | 'physical_store'\n | 'system_generated'\n | 'business_messaging'\n | 'other';\n\nexport type DataProcessingOption = 'LDU';\n\nexport type CustomerSegmentation =\n | 'new_customer_to_business'\n | 'new_customer_to_business_line'\n | 'new_customer_to_product_area'\n | 'new_customer_to_medium'\n | 'existing_customer_to_business'\n | 'existing_customer_to_business_line'\n | 'existing_customer_to_product_area'\n | 'existing_customer_to_medium'\n | 'customer_in_loyalty_program';\n\n/** Extended device info for app events (Android version 'a2', iOS 'i2') */\nexport interface AppData {\n /**\n * Comma-separated array of strings with fixed order:\n * [sdk_version, os_version, device_model, device_brand,\n * screen_width, screen_height, ...]\n */\n extinfo: string[];\n}\n\n// Customer Information Parameters\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters\nexport interface CustomerInformationParameters {\n /** Email(s), SHA-256 hashed, lowercase and trimmed */\n em?: string | string[];\n\n /** Phone number(s), SHA-256 hashed, E.164 format (no leading 0s or symbols) */\n ph?: string | string[];\n\n /** First name(s), SHA-256 hashed, lowercase */\n fn?: string | string[];\n\n /** Last name(s), SHA-256 hashed, lowercase */\n ln?: string | string[];\n\n /** Date(s) of birth in YYYYMMDD, SHA-256 hashed */\n db?: string | string[];\n\n /** Gender(s) in lowercase single letter (\"m\", \"f\", etc.), SHA-256 hashed */\n ge?: string | string[];\n\n /** City name(s), SHA-256 hashed, lowercase */\n ct?: string | string[];\n\n /** State abbreviation(s), SHA-256 hashed, lowercase (e.g., \"ca\", \"ny\") */\n st?: string | string[];\n\n /** ZIP or postal code(s), SHA-256 hashed, lowercase */\n zp?: string | string[];\n\n /** Country code(s), SHA-256 hashed, lowercase (ISO 3166-1 alpha-2) */\n country?: string | string[];\n\n /** External IDs, unique per user. SHA-256 hash recommended */\n external_id?: string | string[];\n\n /** IPv4 or IPv6 address of client. Do NOT hash. */\n client_ip_address?: string;\n\n /** User agent string from browser. Do NOT hash. */\n client_user_agent?: string;\n\n /** fbclid parameter value from the URL. Do NOT hash. */\n fbclid?: string;\n\n /** Facebook click ID (_fbc cookie). Do NOT hash. */\n fbc?: string;\n\n /** Facebook browser ID (_fbp cookie). Do NOT hash. */\n fbp?: string;\n\n /** Subscription ID for the transaction. Do NOT hash. */\n subscription_id?: string;\n\n /** Facebook login ID (App-Scoped ID). Do NOT hash. */\n fb_login_id?: number;\n\n /** Meta Lead Ad lead ID. Do NOT hash. */\n lead_id?: number;\n\n /** Anonymous install ID. App events only. Do NOT hash. */\n anon_id?: string;\n\n /** Mobile advertiser ID (GAID/IDFA). Do NOT hash. */\n madid?: string;\n\n /** Facebook Page ID. Do NOT hash. */\n page_id?: string;\n\n /** Messenger Page-scoped user ID. Do NOT hash. */\n page_scoped_user_id?: string;\n\n /** Click to WhatsApp ad click ID. Do NOT hash. */\n ctwa_clid?: string;\n\n /** Instagram business account ID. Do NOT hash. */\n ig_account_id?: string;\n\n /** Instagram-scoped user ID. Do NOT hash. */\n ig_sid?: string;\n}\n\n// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/custom-data\nexport interface StandardParameters {\n // Web and Offline parameters\n availability?: string;\n body_style?: string;\n checkin_date?: string;\n city?: string;\n condition_of_vehicle?: string;\n content_ids?: string[];\n content_type?: 'product' | 'product_group' | string;\n contents?: Array<{\n id: string;\n quantity?: number;\n item_price?: number;\n delivery_category?: string;\n }>;\n country?: string;\n currency?: string;\n delivery_category?: 'in_store' | 'curbside' | 'home_delivery' | string;\n departing_arrival_date?: string;\n departing_departure_date?: string;\n destination_airport?: string;\n destination_ids?: string[];\n dma_code?: string;\n drivetrain?: string;\n exterior_color?: string;\n fuel_type?: string;\n hotel_score?: number;\n interior_color?: string;\n lead_event_source?: string;\n lease_end_date?: string;\n lease_start_date?: string;\n listing_type?: string;\n make?: string;\n // @TODO is mileage an object?\n 'mileage.unit'?: string;\n 'mileage.value'?: number;\n model?: string;\n neighborhood?: string;\n net_revenue?: number;\n num_adults?: number;\n num_children?: number;\n num_infants?: number;\n num_items?: number;\n order_id?: string;\n origin_airport?: string;\n postal_code?: string;\n predicted_ltv?: number;\n preferred_baths_range?: string;\n preferred_beds_range?: string;\n preferred_neighborhoods?: string[];\n preferred_num_stops?: number;\n preferred_price_range?: string;\n preferred_star_ratings?: [number, number];\n price?: string;\n product_catalog_id?: string;\n property_type?: string;\n region?: string;\n returning_arrival_date?: string;\n returning_departure_date?: string;\n search_string?: string;\n state_of_vehicle?: string;\n suggested_destinations?: string[];\n suggested_home_listings?: string[];\n suggested_hotels?: string[];\n suggested_jobs?: string[];\n suggested_local_service_businesses?: string[];\n suggested_location_based_items?: string[];\n suggested_vehicles?: string[];\n transmission?: string;\n travel_class?: string;\n travel_end?: string;\n travel_start?: string;\n trim?: string;\n\n // App-specific parameters (with fb_ prefix)\n fb_availability?: string;\n fb_body_style?: string;\n fb_checkin_date?: string;\n fb_city?: string;\n fb_condition_of_vehicle?: string;\n fb_content_ids?: string[];\n fb_content_type?: string;\n fb_contents?: Array<{ id: string; quantity?: number; item_price?: number }>;\n fb_country?: string;\n fb_currency?: string;\n fb_delivery_category?: string;\n fb_departing_arrival_date?: string;\n fb_departing_departure_date?: string;\n fb_destination_airport?: string;\n fb_destination_ids?: string[];\n fb_dma_code?: string;\n fb_drivetrain?: string;\n fb_exterior_color?: string;\n fb_fuel_type?: string;\n fb_hotel_score?: number;\n fb_interior_color?: string;\n fb_lease_end_date?: string;\n fb_lease_start_date?: string;\n fb_listing_type?: string;\n fb_make?: string;\n // @TODO is fb_mileage an object?\n 'fb_mileage.unit'?: string;\n 'fb_mileage.value'?: number;\n fb_model?: string;\n fb_neighborhood?: string;\n fb_num_adults?: number;\n fb_num_children?: number;\n fb_num_infants?: number;\n fb_num_items?: number;\n fb_order_id?: string;\n fb_origin_airport?: string;\n fb_postal_code?: string;\n fb_predicted_ltv?: number;\n fb_preferred_baths_range?: string;\n fb_preferred_beds_range?: string;\n fb_preferred_neighborhoods?: string[];\n fb_preferred_num_stops?: number;\n fb_preferred_price_range?: string;\n fb_preferred_star_ratings?: [number, number];\n fb_price?: string;\n fb_product_catalog_id?: string;\n fb_property_type?: string;\n fb_region?: string;\n fb_returning_arrival_date?: string;\n fb_returning_departure_date?: string;\n fb_search_string?: string;\n fb_state_of_vehicle?: string;\n fb_suggested_destinations?: string[];\n fb_suggested_home_listings?: string[];\n fb_suggested_hotels?: string[];\n fb_suggested_jobs?: string[];\n fb_suggested_local_service_businesses?: string[];\n fb_suggested_location_based_items?: string[];\n fb_suggested_vehicles?: string[];\n fb_transmission?: string;\n fb_travel_class?: string;\n fb_travel_end?: string;\n fb_travel_start?: string;\n\n // Offline-specific parameters\n user_bucket?: string;\n value?: number;\n vin?: string;\n year?: number;\n item_number?: string;\n}\n\nexport interface OriginalEventDataParameters {\n event_name?: EventName;\n event_time?: number;\n order_id?: number;\n event_id?: string;\n}\n","import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationMeta from './types';\n\nexport const destinationMeta: Destination = {\n type: 'meta',\n\n config: {},\n\n async init({ config: partialConfig, logger }) {\n const config = getConfig(partialConfig, logger);\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n};\n\nexport default destinationMeta;\n"],"mappings":";AAGO,SAAS,UACd,gBAA+B,CAAC,GAChC,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,aAAa,QAAQ,IAAI;AAEjC,MAAI,CAAC,YAAa,QAAO,MAAM,qCAAqC;AACpE,MAAI,CAAC,QAAS,QAAO,MAAM,iCAAiC;AAE5D,QAAM,iBAA2B;AAAA,IAC/B,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,eAAe,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AAA,IAC/B;AAAA,IACA,QAAQ;AAAA,IACR,WAAW,YAAY;AAAA,IACvB,SAAS,YAAY;AAAA,EACvB,CAAC;AAED,QAAM,eAAe,KAAK,cAAc;AACxC,QAAM,SAAS,MAAM;AAAA,IACnB,GAAG,QAAQ,iBAAiB,WAAW;AAAA,IACvC,KAAK,UAAU,IAAI;AAAA,EACrB;AAEA,SAAO,MAAM,qBAAqB;AAAA,IAChC,IAAIA,UAAS,MAAM,IAAI,OAAO,KAAK;AAAA,EACrC,CAAC;AAED,MAAIA,UAAS,MAAM,KAAK,OAAO,OAAO,OAAO;AAC3C,WAAO,MAAM,mBAAmB,KAAK,UAAU,MAAM,CAAC,EAAE;AAAA,EAC1D;AACF;AAEA,SAAS,cAAc,SAAkB,MAAmC;AAG1E,MAAI,CAAC,QAAS;AAGd,QAAM,UAAU;AAGhB,QAAM,iBAAiB;AAGvB,QAAM,eAAe,QAAQ,KAAK,IAAI;AAEtC,SAAO,GAAG,OAAO,IAAI,cAAc,IAAI,YAAY,IAAI,OAAO;AAChE;;;AE7GA;;;ACOO,IAAM,kBAA+B;AAAA,EAC1C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,MAAM,KAAK,EAAE,QAAQ,eAAe,OAAO,GAAG;AAC5C,UAAM,SAAS,UAAU,eAAe,MAAM;AAC9C,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,SAAS;AACzB,WAAO,MAAM,KAAK,OAAO,OAAO;AAAA,EAClC;AACF;AAEA,IAAO,gBAAQ;","names":["isObject","isObject"]}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$meta": {
3
3
  "package": "@walkeros/server-destination-meta",
4
- "version": "3.4.2",
4
+ "version": "4.0.0-next-1777463920154",
5
5
  "type": "destination",
6
6
  "platform": [
7
7
  "server"
@@ -119,42 +119,29 @@
119
119
  "entity": "child",
120
120
  "data": {
121
121
  "is": "subordinated"
122
- },
123
- "nested": [],
124
- "context": {
125
- "element": [
126
- "child",
127
- 0
128
- ]
129
122
  }
130
123
  }
131
124
  ],
132
125
  "consent": {
133
126
  "functional": true
134
127
  },
135
- "id": "1700000901-gr0up-1",
128
+ "id": "c1d2e3f4a5b60002",
136
129
  "trigger": "test",
137
130
  "entity": "form",
138
131
  "action": "submit",
139
132
  "timestamp": 1700000901,
140
133
  "timing": 3.14,
141
- "group": "gr0up",
142
- "count": 1,
143
- "version": {
144
- "source": "3.4.2",
145
- "tagging": 1
146
- },
147
134
  "source": {
148
- "type": "server",
149
- "id": "https://example.com",
150
- "previous_id": ""
135
+ "type": "browser",
136
+ "platform": "web",
137
+ "url": "https://example.com"
151
138
  }
152
139
  },
153
140
  "out": [
154
141
  [
155
142
  "sendServer",
156
143
  "https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t",
157
- "{\"data\":[{\"event_name\":\"form submit\",\"event_id\":\"1700000901-gr0up-1\",\"event_time\":1700001,\"action_source\":\"website\",\"user_data\":{},\"event_source_url\":\"https://example.com\"}]}"
144
+ "{\"data\":[{\"event_name\":\"form submit\",\"event_id\":\"c1d2e3f4a5b60002\",\"event_time\":1700001,\"action_source\":\"website\",\"user_data\":{},\"event_source_url\":\"https://example.com\"}]}"
158
145
  ]
159
146
  ]
160
147
  },
@@ -197,22 +184,16 @@
197
184
  "consent": {
198
185
  "functional": true
199
186
  },
200
- "id": "1700000900-gr0up-1",
187
+ "id": "c1d2e3f4a5b60001",
201
188
  "trigger": "load",
202
189
  "entity": "order",
203
190
  "action": "complete",
204
191
  "timestamp": 1700000900,
205
192
  "timing": 3.14,
206
- "group": "gr0up",
207
- "count": 1,
208
- "version": {
209
- "source": "3.4.2",
210
- "tagging": 1
211
- },
212
193
  "source": {
213
- "type": "server",
214
- "id": "https://shop.example.com",
215
- "previous_id": ""
194
+ "type": "browser",
195
+ "platform": "web",
196
+ "url": "https://shop.example.com"
216
197
  }
217
198
  },
218
199
  "mapping": {
@@ -230,7 +211,7 @@
230
211
  "nested",
231
212
  {
232
213
  "condition": {
233
- "$code": "e=>g(e)&&\"product\"===e.entity"
214
+ "$code": "e=>y(e)&&\"product\"===e.entity"
234
215
  },
235
216
  "map": {
236
217
  "id": "data.id",
@@ -255,7 +236,7 @@
255
236
  [
256
237
  "sendServer",
257
238
  "https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t",
258
- "{\"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\"}]}"
239
+ "{\"data\":[{\"event_name\":\"Purchase\",\"event_id\":\"c1d2e3f4a5b60001\",\"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\"}]}"
259
240
  ]
260
241
  ]
261
242
  },
@@ -335,22 +316,16 @@
335
316
  "consent": {
336
317
  "functional": true
337
318
  },
338
- "id": "1700000902-gr0up-1",
319
+ "id": "c1d2e3f4a5b60003",
339
320
  "trigger": "load",
340
321
  "entity": "order",
341
322
  "action": "complete",
342
323
  "timestamp": 1700000902,
343
324
  "timing": 3.14,
344
- "group": "gr0up",
345
- "count": 1,
346
- "version": {
347
- "source": "3.4.2",
348
- "tagging": 1
349
- },
350
325
  "source": {
351
- "type": "server",
352
- "id": "https://shop.example.com",
353
- "previous_id": ""
326
+ "type": "browser",
327
+ "platform": "web",
328
+ "url": "https://shop.example.com"
354
329
  }
355
330
  },
356
331
  "mapping": {
@@ -376,7 +351,7 @@
376
351
  [
377
352
  "sendServer",
378
353
  "https://graph.facebook.com/v22.0/p1x3l1d/events?access_token=s3cr3t",
379
- "{\"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\"}]}"
354
+ "{\"data\":[{\"event_name\":\"Purchase\",\"event_id\":\"c1d2e3f4a5b60003\",\"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\"}]}"
380
355
  ]
381
356
  ]
382
357
  }
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.2",
4
+ "version": "4.0.0-next-1777463920154",
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.2",
38
- "@walkeros/server-core": "3.4.2"
37
+ "@walkeros/core": "4.0.0-next-1777463920154",
38
+ "@walkeros/server-core": "4.0.0-next-1777463920154"
39
39
  },
40
40
  "devDependencies": {
41
- "@walkeros/collector": "3.4.2"
41
+ "@walkeros/collector": "4.0.0-next-1777463920154"
42
42
  },
43
43
  "repository": {
44
44
  "url": "git+https://github.com/elbwalker/walkerOS.git",