@walkeros/server-destination-snapchat 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.js +8 -0
- package/dist/examples/index.mjs +8 -0
- package/dist/walkerOS.json +15 -7
- package/package.json +4 -4
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i=(e,a)=>{for(var r in a)t(e,r,{get:a[r],enumerable:!0})},s={};i(s,{examples:()=>E,schemas:()=>o}),module.exports=(e=s,((e,i,s,o)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of r(i))n.call(e,c)||c===s||t(e,c,{get:()=>i[c],enumerable:!(o=a(i,c))||o.enumerable});return e})(t({},"__esModule",{value:!0}),e));var o={};i(o,{MappingSchema:()=>u,SettingsSchema:()=>p,StandardEventNameSchema:()=>_,mapping:()=>v,settings:()=>l});var c=require("@walkeros/core/dev"),d=require("@walkeros/core/dev"),p=d.z.object({accessToken:d.z.string().min(1).describe("Long-lived Conversions API access token from Snapchat Ads Manager"),pixelId:d.z.string().min(1).describe("Snap Pixel ID"),url:d.z.string().url().describe("Custom Conversions API base URL (default https://tr.snapchat.com/v3/)").optional(),action_source:d.z.enum(["WEB","MOBILE_APP","OFFLINE"]).describe("Event action source (default WEB)").optional(),doNotHash:d.z.array(d.z.string()).describe("User data fields to skip hashing (like ['em', 'ph'])").optional(),user_data:d.z.record(d.z.string(),d.z.string()).describe("Mapping for user data fields (like { em: 'user.email' })").optional(),testMode:d.z.boolean().describe("When true, sends events to /events/validate instead of /events for testing").optional()}),u=require("@walkeros/core/dev").z.object({}),m=require("@walkeros/core/dev"),_=m.z.union([m.z.enum(["PAGE_VIEW","VIEW_CONTENT","ADD_CART","ADD_TO_WISHLIST","START_CHECKOUT","ADD_BILLING","PURCHASE","SIGN_UP","SEARCH","SAVE","SUBSCRIBE","COMPLETE_TUTORIAL","START_TRIAL","AD_CLICK","AD_VIEW","APP_OPEN","LEVEL_COMPLETE","INVITE","LOGIN","SHARE","RESERVE","ACHIEVEMENT_UNLOCKED","SPENT_CREDITS","RATE","LIST_VIEW","CUSTOM_EVENT_1","CUSTOM_EVENT_2","CUSTOM_EVENT_3","CUSTOM_EVENT_4","CUSTOM_EVENT_5"]),m.z.string()]),l=(0,c.zodToSchema)(p),v=(0,c.zodToSchema)(u),E={};i(E,{env:()=>S,step:()=>y});var S={};i(S,{push:()=>h,simulation:()=>g});var h={sendServer:async()=>({ok:!0,data:{status:"OK",request_id:"mock-123"}})},g=["sendServer"],y={};i(y,{addToCart:()=>f,lead:()=>C,pageView:()=>O,purchase:()=>b});var A=require("@walkeros/core"),T="https://tr.snapchat.com/v3/p1x3l1d/events?access_token=s3cr3t",b={title:"Purchase",description:"A completed order is sent to the Snapchat Conversions API as a PURCHASE with value, currency, and contents.",in:(0,A.getEvent)("order complete",{timestamp:17000009e5,data:{id:"ORD-300",total:249.99,currency:"EUR"},nested:[{entity:"product",data:{id:"SKU-A1",name:"Widget Pro",price:124.99,quantity:2}}],user:{id:"user-123",device:"device-456"},source:{type:"server",id:"https://shop.example.com/checkout/complete",previous_id:""}}),mapping:{name:"PURCHASE",data:{map:{custom_data:{map:{value:"data.total",currency:{key:"data.currency",value:"EUR"},transaction_id:"data.id",contents:{loop:["nested",{condition:e=>(0,A.isObject)(e)&&"product"===e.entity,map:{id:"data.id",item_price:"data.price",quantity:{key:"data.quantity",value:1}}}]}}},user_data:{map:{external_id:"user.id"}}}}},out:[["sendServer",T,JSON.stringify({data:[{event_name:"PURCHASE",event_time:1700000900,action_source:"WEB",event_id:"1700000900000-gr0up-1",user_data:{external_id:"fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8"},custom_data:{value:249.99,currency:"EUR",transaction_id:"ORD-300",contents:[{id:"SKU-A1",item_price:124.99,quantity:2}]},event_source_url:"https://shop.example.com/checkout/complete"}]})]]},f={title:"Add to cart",description:"A product add is sent to Snapchat as an ADD_CART conversion with value and product details.",in:(0,A.getEvent)("product add",{timestamp:1700000901e3,data:{id:"SKU-B2",name:"Running Shoes",price:89.99,color:"blue"},nested:[{entity:"product",data:{id:"SKU-B2",name:"Running Shoes",price:89.99,quantity:1}}],source:{type:"server",id:"https://shop.example.com/products/running-shoes",previous_id:""}}),mapping:{name:"ADD_CART",data:{map:{custom_data:{map:{value:"data.price",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>(0,A.isObject)(e)&&"product"===e.entity,map:{id:"data.id",item_price:"data.price",quantity:{key:"data.quantity",value:1}}}]}}}}}},out:[["sendServer",T,JSON.stringify({data:[{event_name:"ADD_CART",event_time:1700000901,action_source:"WEB",event_id:"1700000901000-gr0up-1",user_data:{},custom_data:{value:89.99,currency:"EUR",contents:[{id:"SKU-B2",item_price:89.99,quantity:1}]},event_source_url:"https://shop.example.com/products/running-shoes"}]})]]},O={title:"Page view",description:"A page view is forwarded to Snapchat with the event source URL and no extra custom data.",in:(0,A.getEvent)("page view",{timestamp:1700000902e3,source:{type:"server",id:"https://example.com/docs/",previous_id:""}}),mapping:void 0,out:[["sendServer",T,JSON.stringify({data:[{event_name:"page view",event_time:1700000902,action_source:"WEB",event_id:"1700000902000-gr0up-1",user_data:{},custom_data:{},event_source_url:"https://example.com/docs/"}]})]]},C={title:"Sign up",description:"A newsletter form submission is sent to Snapchat as a SIGN_UP conversion with a hashed email.",in:(0,A.getEvent)("form submit",{timestamp:1700000903e3,data:{type:"newsletter"},user:{email:"user@example.com"},source:{type:"server",id:"https://example.com/contact",previous_id:""}}),mapping:{name:"SIGN_UP",data:{map:{user_data:{map:{em:"user.email"}},custom_data:{map:{sign_up_method:{value:"newsletter"}}}}}},out:[["sendServer",T,JSON.stringify({data:[{event_name:"SIGN_UP",event_time:1700000903,action_source:"WEB",event_id:"1700000903000-gr0up-1",user_data:{em:"b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"},custom_data:{sign_up_method:"newsletter"},event_source_url:"https://example.com/contact"}]})]]};//# 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/mapping.ts","../src/schemas/primitives.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';\n\nexport const SettingsSchema = z.object({\n accessToken: z\n .string()\n .min(1)\n .describe(\n 'Long-lived Conversions API access token from Snapchat Ads Manager',\n ),\n pixelId: z.string().min(1).describe('Snap Pixel ID'),\n url: z\n .string()\n .url()\n .describe(\n 'Custom Conversions API base URL (default https://tr.snapchat.com/v3/)',\n )\n .optional(),\n action_source: z\n .enum(['WEB', 'MOBILE_APP', 'OFFLINE'])\n .describe('Event action source (default WEB)')\n .optional(),\n doNotHash: z\n .array(z.string())\n .describe(\"User data fields to skip hashing (like ['em', 'ph'])\")\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\"Mapping for user data fields (like { em: 'user.email' })\")\n .optional(),\n testMode: z\n .boolean()\n .describe(\n 'When true, sends events to /events/validate instead of /events for testing',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Snapchat Conversions API Mapping Schema\n * Snapchat 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","import { z } from '@walkeros/core/dev';\n\n/**\n * Standard Snapchat Conversions API event names (UPPERCASE).\n * https://businesshelp.snapchat.com/s/article/capi-parameters\n */\nexport const StandardEventNameSchema = z.union([\n z.enum([\n 'PAGE_VIEW',\n 'VIEW_CONTENT',\n 'ADD_CART',\n 'ADD_TO_WISHLIST',\n 'START_CHECKOUT',\n 'ADD_BILLING',\n 'PURCHASE',\n 'SIGN_UP',\n 'SEARCH',\n 'SAVE',\n 'SUBSCRIBE',\n 'COMPLETE_TUTORIAL',\n 'START_TRIAL',\n 'AD_CLICK',\n 'AD_VIEW',\n 'APP_OPEN',\n 'LEVEL_COMPLETE',\n 'INVITE',\n 'LOGIN',\n 'SHARE',\n 'RESERVE',\n 'ACHIEVEMENT_UNLOCKED',\n 'SPENT_CREDITS',\n 'RATE',\n 'LIST_VIEW',\n 'CUSTOM_EVENT_1',\n 'CUSTOM_EVENT_2',\n 'CUSTOM_EVENT_3',\n 'CUSTOM_EVENT_4',\n 'CUSTOM_EVENT_5',\n ]),\n z.string(), // Allow custom event names\n]);\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 Snapchat Conversions API destination.\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\ntype MockSendServer = (\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n) => Promise<SendResponse>;\n\nconst mockSendServer: MockSendServer = async () => ({\n ok: true,\n data: {\n status: 'OK',\n request_id: 'mock-123',\n },\n});\n\n/**\n * Standard mock environment for push operations.\n *\n * Use this for testing Snapchat Conversions API events without making\n * actual HTTP requests to Snapchat's servers.\n */\nexport const push: Env = {\n sendServer: mockSendServer,\n};\n\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent, isObject } from '@walkeros/core';\n\n/**\n * Snapchat Conversions API step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body)` where\n * `url` is `${settings.url}${settings.pixelId}/${path}?access_token=${settings.accessToken}`\n * with `path` = `events` (or `events/validate` when `testMode` is set),\n * and `body` is the JSON-stringified `{ data: [snapchatEvent] }` payload.\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelId = 'p1x3l1d'`,\n * so every endpoint resolves to:\n * https://tr.snapchat.com/v3/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_time (unix seconds; `Math.round(event.timestamp / 1000)`)\n * 3. action_source (default 'WEB')\n * 4. event_id\n * 5. user_data (hashed per Snapchat's PII requirements)\n * 6. custom_data (mapped event data, excluding user_data/custom_data keys)\n * 7. event_source_url (appended last when action_source === 'WEB')\n */\nconst ENDPOINT =\n 'https://tr.snapchat.com/v3/p1x3l1d/events?access_token=s3cr3t';\n\nexport const purchase: Flow.StepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000900000,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n nested: [\n {\n entity: 'product',\n data: { id: 'SKU-A1', name: 'Widget Pro', price: 124.99, quantity: 2 },\n },\n ],\n user: { id: 'user-123', device: 'device-456' },\n source: {\n type: 'server',\n id: 'https://shop.example.com/checkout/complete',\n previous_id: '',\n },\n }),\n mapping: {\n name: 'PURCHASE',\n data: {\n map: {\n custom_data: {\n map: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'EUR' },\n transaction_id: 'data.id',\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 },\n },\n user_data: {\n map: {\n external_id: 'user.id',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'PURCHASE',\n event_time: 1700000900,\n action_source: 'WEB',\n event_id: '1700000900000-gr0up-1',\n user_data: {\n external_id:\n 'fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8',\n },\n custom_data: {\n value: 249.99,\n currency: 'EUR',\n transaction_id: 'ORD-300',\n contents: [{ id: 'SKU-A1', item_price: 124.99, quantity: 2 }],\n },\n event_source_url: 'https://shop.example.com/checkout/complete',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const addToCart: Flow.StepExample = {\n in: getEvent('product add', {\n timestamp: 1700000901000,\n data: {\n id: 'SKU-B2',\n name: 'Running Shoes',\n price: 89.99,\n color: 'blue',\n },\n nested: [\n {\n entity: 'product',\n data: {\n id: 'SKU-B2',\n name: 'Running Shoes',\n price: 89.99,\n quantity: 1,\n },\n },\n ],\n source: {\n type: 'server',\n id: 'https://shop.example.com/products/running-shoes',\n previous_id: '',\n },\n }),\n mapping: {\n name: 'ADD_CART',\n data: {\n map: {\n custom_data: {\n map: {\n value: 'data.price',\n currency: { value: 'EUR' },\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 },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'ADD_CART',\n event_time: 1700000901,\n action_source: 'WEB',\n event_id: '1700000901000-gr0up-1',\n user_data: {},\n custom_data: {\n value: 89.99,\n currency: 'EUR',\n contents: [{ id: 'SKU-B2', item_price: 89.99, quantity: 1 }],\n },\n event_source_url: 'https://shop.example.com/products/running-shoes',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const pageView: Flow.StepExample = {\n in: getEvent('page view', {\n timestamp: 1700000902000,\n source: {\n type: 'server',\n id: 'https://example.com/docs/',\n previous_id: '',\n },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'page view',\n event_time: 1700000902,\n action_source: 'WEB',\n event_id: '1700000902000-gr0up-1',\n user_data: {},\n custom_data: {},\n event_source_url: 'https://example.com/docs/',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n in: getEvent('form submit', {\n timestamp: 1700000903000,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: {\n type: 'server',\n id: 'https://example.com/contact',\n previous_id: '',\n },\n }),\n mapping: {\n name: 'SIGN_UP',\n data: {\n map: {\n user_data: {\n map: {\n em: 'user.email',\n },\n },\n custom_data: {\n map: {\n sign_up_method: { value: 'newsletter' },\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'SIGN_UP',\n event_time: 1700000903,\n action_source: 'WEB',\n event_id: '1700000903000-gr0up-1',\n user_data: {\n // sha256('user@example.com')\n em: 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514',\n },\n custom_data: {\n sign_up_method: 'newsletter',\n },\n event_source_url: 'https://example.com/contact',\n },\n ],\n }),\n ],\n ],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACrC,aAAa,aACV,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;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aAAa;AAAA,IACf;AAAA,EACF,CAAC;AAAA,EACD,SAAS;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,MACJ,KAAK;AAAA,QACH,WAAW;AAAA,UACT,KAAK;AAAA,YACH,IAAI;AAAA,UACN;AAAA,QACF;AAAA,QACA,aAAa;AAAA,UACX,KAAK;AAAA,YACH,gBAAgB,EAAE,OAAO,aAAa;AAAA,UACxC;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,YAAY;AAAA,YACZ,eAAe;AAAA,YACf,UAAU;AAAA,YACV,WAAW;AAAA;AAAA,cAET,IAAI;AAAA,YACN;AAAA,YACA,aAAa;AAAA,cACX,gBAAgB;AAAA,YAClB;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/mapping.ts","../src/schemas/primitives.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';\n\nexport const SettingsSchema = z.object({\n accessToken: z\n .string()\n .min(1)\n .describe(\n 'Long-lived Conversions API access token from Snapchat Ads Manager',\n ),\n pixelId: z.string().min(1).describe('Snap Pixel ID'),\n url: z\n .string()\n .url()\n .describe(\n 'Custom Conversions API base URL (default https://tr.snapchat.com/v3/)',\n )\n .optional(),\n action_source: z\n .enum(['WEB', 'MOBILE_APP', 'OFFLINE'])\n .describe('Event action source (default WEB)')\n .optional(),\n doNotHash: z\n .array(z.string())\n .describe(\"User data fields to skip hashing (like ['em', 'ph'])\")\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\"Mapping for user data fields (like { em: 'user.email' })\")\n .optional(),\n testMode: z\n .boolean()\n .describe(\n 'When true, sends events to /events/validate instead of /events for testing',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Snapchat Conversions API Mapping Schema\n * Snapchat 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","import { z } from '@walkeros/core/dev';\n\n/**\n * Standard Snapchat Conversions API event names (UPPERCASE).\n * https://businesshelp.snapchat.com/s/article/capi-parameters\n */\nexport const StandardEventNameSchema = z.union([\n z.enum([\n 'PAGE_VIEW',\n 'VIEW_CONTENT',\n 'ADD_CART',\n 'ADD_TO_WISHLIST',\n 'START_CHECKOUT',\n 'ADD_BILLING',\n 'PURCHASE',\n 'SIGN_UP',\n 'SEARCH',\n 'SAVE',\n 'SUBSCRIBE',\n 'COMPLETE_TUTORIAL',\n 'START_TRIAL',\n 'AD_CLICK',\n 'AD_VIEW',\n 'APP_OPEN',\n 'LEVEL_COMPLETE',\n 'INVITE',\n 'LOGIN',\n 'SHARE',\n 'RESERVE',\n 'ACHIEVEMENT_UNLOCKED',\n 'SPENT_CREDITS',\n 'RATE',\n 'LIST_VIEW',\n 'CUSTOM_EVENT_1',\n 'CUSTOM_EVENT_2',\n 'CUSTOM_EVENT_3',\n 'CUSTOM_EVENT_4',\n 'CUSTOM_EVENT_5',\n ]),\n z.string(), // Allow custom event names\n]);\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 Snapchat Conversions API destination.\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\ntype MockSendServer = (\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n) => Promise<SendResponse>;\n\nconst mockSendServer: MockSendServer = async () => ({\n ok: true,\n data: {\n status: 'OK',\n request_id: 'mock-123',\n },\n});\n\n/**\n * Standard mock environment for push operations.\n *\n * Use this for testing Snapchat Conversions API events without making\n * actual HTTP requests to Snapchat's servers.\n */\nexport const push: Env = {\n sendServer: mockSendServer,\n};\n\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent, isObject } from '@walkeros/core';\n\n/**\n * Snapchat Conversions API step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body)` where\n * `url` is `${settings.url}${settings.pixelId}/${path}?access_token=${settings.accessToken}`\n * with `path` = `events` (or `events/validate` when `testMode` is set),\n * and `body` is the JSON-stringified `{ data: [snapchatEvent] }` payload.\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelId = 'p1x3l1d'`,\n * so every endpoint resolves to:\n * https://tr.snapchat.com/v3/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_time (unix seconds; `Math.round(event.timestamp / 1000)`)\n * 3. action_source (default 'WEB')\n * 4. event_id\n * 5. user_data (hashed per Snapchat's PII requirements)\n * 6. custom_data (mapped event data, excluding user_data/custom_data keys)\n * 7. event_source_url (appended last when action_source === 'WEB')\n */\nconst ENDPOINT =\n 'https://tr.snapchat.com/v3/p1x3l1d/events?access_token=s3cr3t';\n\nexport const purchase: Flow.StepExample = {\n title: 'Purchase',\n description:\n 'A completed order is sent to the Snapchat Conversions API as a PURCHASE with value, currency, and contents.',\n in: getEvent('order complete', {\n timestamp: 1700000900000,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n nested: [\n {\n entity: 'product',\n data: { id: 'SKU-A1', name: 'Widget Pro', price: 124.99, quantity: 2 },\n },\n ],\n user: { id: 'user-123', device: 'device-456' },\n source: {\n type: 'server',\n id: 'https://shop.example.com/checkout/complete',\n previous_id: '',\n },\n }),\n mapping: {\n name: 'PURCHASE',\n data: {\n map: {\n custom_data: {\n map: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'EUR' },\n transaction_id: 'data.id',\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 },\n },\n user_data: {\n map: {\n external_id: 'user.id',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'PURCHASE',\n event_time: 1700000900,\n action_source: 'WEB',\n event_id: '1700000900000-gr0up-1',\n user_data: {\n external_id:\n 'fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8',\n },\n custom_data: {\n value: 249.99,\n currency: 'EUR',\n transaction_id: 'ORD-300',\n contents: [{ id: 'SKU-A1', item_price: 124.99, quantity: 2 }],\n },\n event_source_url: 'https://shop.example.com/checkout/complete',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const addToCart: Flow.StepExample = {\n title: 'Add to cart',\n description:\n 'A product add is sent to Snapchat as an ADD_CART conversion with value and product details.',\n in: getEvent('product add', {\n timestamp: 1700000901000,\n data: {\n id: 'SKU-B2',\n name: 'Running Shoes',\n price: 89.99,\n color: 'blue',\n },\n nested: [\n {\n entity: 'product',\n data: {\n id: 'SKU-B2',\n name: 'Running Shoes',\n price: 89.99,\n quantity: 1,\n },\n },\n ],\n source: {\n type: 'server',\n id: 'https://shop.example.com/products/running-shoes',\n previous_id: '',\n },\n }),\n mapping: {\n name: 'ADD_CART',\n data: {\n map: {\n custom_data: {\n map: {\n value: 'data.price',\n currency: { value: 'EUR' },\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 },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'ADD_CART',\n event_time: 1700000901,\n action_source: 'WEB',\n event_id: '1700000901000-gr0up-1',\n user_data: {},\n custom_data: {\n value: 89.99,\n currency: 'EUR',\n contents: [{ id: 'SKU-B2', item_price: 89.99, quantity: 1 }],\n },\n event_source_url: 'https://shop.example.com/products/running-shoes',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const pageView: Flow.StepExample = {\n title: 'Page view',\n description:\n 'A page view is forwarded to Snapchat with the event source URL and no extra custom data.',\n in: getEvent('page view', {\n timestamp: 1700000902000,\n source: {\n type: 'server',\n id: 'https://example.com/docs/',\n previous_id: '',\n },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'page view',\n event_time: 1700000902,\n action_source: 'WEB',\n event_id: '1700000902000-gr0up-1',\n user_data: {},\n custom_data: {},\n event_source_url: 'https://example.com/docs/',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Sign up',\n description:\n 'A newsletter form submission is sent to Snapchat as a SIGN_UP conversion with a hashed email.',\n in: getEvent('form submit', {\n timestamp: 1700000903000,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: {\n type: 'server',\n id: 'https://example.com/contact',\n previous_id: '',\n },\n }),\n mapping: {\n name: 'SIGN_UP',\n data: {\n map: {\n user_data: {\n map: {\n em: 'user.email',\n },\n },\n custom_data: {\n map: {\n sign_up_method: { value: 'newsletter' },\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'SIGN_UP',\n event_time: 1700000903,\n action_source: 'WEB',\n event_id: '1700000903000-gr0up-1',\n user_data: {\n // sha256('user@example.com')\n em: 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514',\n },\n custom_data: {\n sign_up_method: 'newsletter',\n },\n event_source_url: 'https://example.com/contact',\n },\n ],\n }),\n ],\n ],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACrC,aAAa,aACV,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,SAAS,aAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,eAAe;AAAA,EACnD,KAAK,aACF,OAAO,EACP,IAAI,EACJ;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,eAAe,aACZ,KAAK,CAAC,OAAO,cAAc,SAAS,CAAC,EACrC,SAAS,mCAAmC,EAC5C,SAAS;AAAA,EACZ,WAAW,aACR,MAAM,aAAE,OAAO,CAAC,EAChB,SAAS,sDAAsD,EAC/D,SAAS;AAAA,EACZ,WAAW,aACR,OAAO,aAAE,OAAO,GAAG,aAAE,OAAO,CAAC,EAC7B,SAAS,0DAA0D,EACnE,SAAS;AAAA,EACZ,UAAU,aACP,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC;;;ACnCD,IAAAC,cAAkB;AAMX,IAAM,gBAAgB,cAAE,OAAO,CAAC,CAAC;;;ACNxC,IAAAC,cAAkB;AAMX,IAAM,0BAA0B,cAAE,MAAM;AAAA,EAC7C,cAAE,KAAK;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A,YACN;AAAA,YACA,aAAa;AAAA,cACX,gBAAgB;AAAA,YAClB;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,{MappingSchema:()=>o,SettingsSchema:()=>
|
|
1
|
+
var e=Object.defineProperty,t=(t,a)=>{for(var r in a)e(t,r,{get:a[r],enumerable:!0})},a={};t(a,{MappingSchema:()=>o,SettingsSchema:()=>i,StandardEventNameSchema:()=>c,mapping:()=>u,settings:()=>p});import{zodToSchema as r}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";var i=s.object({accessToken:s.string().min(1).describe("Long-lived Conversions API access token from Snapchat Ads Manager"),pixelId:s.string().min(1).describe("Snap Pixel ID"),url:s.string().url().describe("Custom Conversions API base URL (default https://tr.snapchat.com/v3/)").optional(),action_source:s.enum(["WEB","MOBILE_APP","OFFLINE"]).describe("Event action source (default WEB)").optional(),doNotHash:s.array(s.string()).describe("User data fields to skip hashing (like ['em', 'ph'])").optional(),user_data:s.record(s.string(),s.string()).describe("Mapping for user data fields (like { em: 'user.email' })").optional(),testMode:s.boolean().describe("When true, sends events to /events/validate instead of /events for testing").optional()});import{z as n}from"@walkeros/core/dev";var o=n.object({});import{z as d}from"@walkeros/core/dev";var c=d.union([d.enum(["PAGE_VIEW","VIEW_CONTENT","ADD_CART","ADD_TO_WISHLIST","START_CHECKOUT","ADD_BILLING","PURCHASE","SIGN_UP","SEARCH","SAVE","SUBSCRIBE","COMPLETE_TUTORIAL","START_TRIAL","AD_CLICK","AD_VIEW","APP_OPEN","LEVEL_COMPLETE","INVITE","LOGIN","SHARE","RESERVE","ACHIEVEMENT_UNLOCKED","SPENT_CREDITS","RATE","LIST_VIEW","CUSTOM_EVENT_1","CUSTOM_EVENT_2","CUSTOM_EVENT_3","CUSTOM_EVENT_4","CUSTOM_EVENT_5"]),d.string()]),p=r(i),u=r(o),m={};t(m,{env:()=>_,step:()=>E});var _={};t(_,{push:()=>l,simulation:()=>v});var l={sendServer:async()=>({ok:!0,data:{status:"OK",request_id:"mock-123"}})},v=["sendServer"],E={};t(E,{addToCart:()=>T,lead:()=>f,pageView:()=>y,purchase:()=>A});import{getEvent as S,isObject as h}from"@walkeros/core";var g="https://tr.snapchat.com/v3/p1x3l1d/events?access_token=s3cr3t",A={title:"Purchase",description:"A completed order is sent to the Snapchat Conversions API as a PURCHASE with value, currency, and contents.",in:S("order complete",{timestamp:17000009e5,data:{id:"ORD-300",total:249.99,currency:"EUR"},nested:[{entity:"product",data:{id:"SKU-A1",name:"Widget Pro",price:124.99,quantity:2}}],user:{id:"user-123",device:"device-456"},source:{type:"server",id:"https://shop.example.com/checkout/complete",previous_id:""}}),mapping:{name:"PURCHASE",data:{map:{custom_data:{map:{value:"data.total",currency:{key:"data.currency",value:"EUR"},transaction_id:"data.id",contents:{loop:["nested",{condition:e=>h(e)&&"product"===e.entity,map:{id:"data.id",item_price:"data.price",quantity:{key:"data.quantity",value:1}}}]}}},user_data:{map:{external_id:"user.id"}}}}},out:[["sendServer",g,JSON.stringify({data:[{event_name:"PURCHASE",event_time:1700000900,action_source:"WEB",event_id:"1700000900000-gr0up-1",user_data:{external_id:"fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8"},custom_data:{value:249.99,currency:"EUR",transaction_id:"ORD-300",contents:[{id:"SKU-A1",item_price:124.99,quantity:2}]},event_source_url:"https://shop.example.com/checkout/complete"}]})]]},T={title:"Add to cart",description:"A product add is sent to Snapchat as an ADD_CART conversion with value and product details.",in:S("product add",{timestamp:1700000901e3,data:{id:"SKU-B2",name:"Running Shoes",price:89.99,color:"blue"},nested:[{entity:"product",data:{id:"SKU-B2",name:"Running Shoes",price:89.99,quantity:1}}],source:{type:"server",id:"https://shop.example.com/products/running-shoes",previous_id:""}}),mapping:{name:"ADD_CART",data:{map:{custom_data:{map:{value:"data.price",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>h(e)&&"product"===e.entity,map:{id:"data.id",item_price:"data.price",quantity:{key:"data.quantity",value:1}}}]}}}}}},out:[["sendServer",g,JSON.stringify({data:[{event_name:"ADD_CART",event_time:1700000901,action_source:"WEB",event_id:"1700000901000-gr0up-1",user_data:{},custom_data:{value:89.99,currency:"EUR",contents:[{id:"SKU-B2",item_price:89.99,quantity:1}]},event_source_url:"https://shop.example.com/products/running-shoes"}]})]]},y={title:"Page view",description:"A page view is forwarded to Snapchat with the event source URL and no extra custom data.",in:S("page view",{timestamp:1700000902e3,source:{type:"server",id:"https://example.com/docs/",previous_id:""}}),mapping:void 0,out:[["sendServer",g,JSON.stringify({data:[{event_name:"page view",event_time:1700000902,action_source:"WEB",event_id:"1700000902000-gr0up-1",user_data:{},custom_data:{},event_source_url:"https://example.com/docs/"}]})]]},f={title:"Sign up",description:"A newsletter form submission is sent to Snapchat as a SIGN_UP conversion with a hashed email.",in:S("form submit",{timestamp:1700000903e3,data:{type:"newsletter"},user:{email:"user@example.com"},source:{type:"server",id:"https://example.com/contact",previous_id:""}}),mapping:{name:"SIGN_UP",data:{map:{user_data:{map:{em:"user.email"}},custom_data:{map:{sign_up_method:{value:"newsletter"}}}}}},out:[["sendServer",g,JSON.stringify({data:[{event_name:"SIGN_UP",event_time:1700000903,action_source:"WEB",event_id:"1700000903000-gr0up-1",user_data:{em:"b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"},custom_data:{sign_up_method:"newsletter"},event_source_url:"https://example.com/contact"}]})]]};export{m 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/mapping.ts","../src/schemas/primitives.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';\n\nexport const SettingsSchema = z.object({\n accessToken: z\n .string()\n .min(1)\n .describe(\n 'Long-lived Conversions API access token from Snapchat Ads Manager',\n ),\n pixelId: z.string().min(1).describe('Snap Pixel ID'),\n url: z\n .string()\n .url()\n .describe(\n 'Custom Conversions API base URL (default https://tr.snapchat.com/v3/)',\n )\n .optional(),\n action_source: z\n .enum(['WEB', 'MOBILE_APP', 'OFFLINE'])\n .describe('Event action source (default WEB)')\n .optional(),\n doNotHash: z\n .array(z.string())\n .describe(\"User data fields to skip hashing (like ['em', 'ph'])\")\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\"Mapping for user data fields (like { em: 'user.email' })\")\n .optional(),\n testMode: z\n .boolean()\n .describe(\n 'When true, sends events to /events/validate instead of /events for testing',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Snapchat Conversions API Mapping Schema\n * Snapchat 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","import { z } from '@walkeros/core/dev';\n\n/**\n * Standard Snapchat Conversions API event names (UPPERCASE).\n * https://businesshelp.snapchat.com/s/article/capi-parameters\n */\nexport const StandardEventNameSchema = z.union([\n z.enum([\n 'PAGE_VIEW',\n 'VIEW_CONTENT',\n 'ADD_CART',\n 'ADD_TO_WISHLIST',\n 'START_CHECKOUT',\n 'ADD_BILLING',\n 'PURCHASE',\n 'SIGN_UP',\n 'SEARCH',\n 'SAVE',\n 'SUBSCRIBE',\n 'COMPLETE_TUTORIAL',\n 'START_TRIAL',\n 'AD_CLICK',\n 'AD_VIEW',\n 'APP_OPEN',\n 'LEVEL_COMPLETE',\n 'INVITE',\n 'LOGIN',\n 'SHARE',\n 'RESERVE',\n 'ACHIEVEMENT_UNLOCKED',\n 'SPENT_CREDITS',\n 'RATE',\n 'LIST_VIEW',\n 'CUSTOM_EVENT_1',\n 'CUSTOM_EVENT_2',\n 'CUSTOM_EVENT_3',\n 'CUSTOM_EVENT_4',\n 'CUSTOM_EVENT_5',\n ]),\n z.string(), // Allow custom event names\n]);\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 Snapchat Conversions API destination.\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\ntype MockSendServer = (\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n) => Promise<SendResponse>;\n\nconst mockSendServer: MockSendServer = async () => ({\n ok: true,\n data: {\n status: 'OK',\n request_id: 'mock-123',\n },\n});\n\n/**\n * Standard mock environment for push operations.\n *\n * Use this for testing Snapchat Conversions API events without making\n * actual HTTP requests to Snapchat's servers.\n */\nexport const push: Env = {\n sendServer: mockSendServer,\n};\n\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent, isObject } from '@walkeros/core';\n\n/**\n * Snapchat Conversions API step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body)` where\n * `url` is `${settings.url}${settings.pixelId}/${path}?access_token=${settings.accessToken}`\n * with `path` = `events` (or `events/validate` when `testMode` is set),\n * and `body` is the JSON-stringified `{ data: [snapchatEvent] }` payload.\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelId = 'p1x3l1d'`,\n * so every endpoint resolves to:\n * https://tr.snapchat.com/v3/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_time (unix seconds; `Math.round(event.timestamp / 1000)`)\n * 3. action_source (default 'WEB')\n * 4. event_id\n * 5. user_data (hashed per Snapchat's PII requirements)\n * 6. custom_data (mapped event data, excluding user_data/custom_data keys)\n * 7. event_source_url (appended last when action_source === 'WEB')\n */\nconst ENDPOINT =\n 'https://tr.snapchat.com/v3/p1x3l1d/events?access_token=s3cr3t';\n\nexport const purchase: Flow.StepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000900000,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n nested: [\n {\n entity: 'product',\n data: { id: 'SKU-A1', name: 'Widget Pro', price: 124.99, quantity: 2 },\n },\n ],\n user: { id: 'user-123', device: 'device-456' },\n source: {\n type: 'server',\n id: 'https://shop.example.com/checkout/complete',\n previous_id: '',\n },\n }),\n mapping: {\n name: 'PURCHASE',\n data: {\n map: {\n custom_data: {\n map: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'EUR' },\n transaction_id: 'data.id',\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 },\n },\n user_data: {\n map: {\n external_id: 'user.id',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'PURCHASE',\n event_time: 1700000900,\n action_source: 'WEB',\n event_id: '1700000900000-gr0up-1',\n user_data: {\n external_id:\n 'fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8',\n },\n custom_data: {\n value: 249.99,\n currency: 'EUR',\n transaction_id: 'ORD-300',\n contents: [{ id: 'SKU-A1', item_price: 124.99, quantity: 2 }],\n },\n event_source_url: 'https://shop.example.com/checkout/complete',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const addToCart: Flow.StepExample = {\n in: getEvent('product add', {\n timestamp: 1700000901000,\n data: {\n id: 'SKU-B2',\n name: 'Running Shoes',\n price: 89.99,\n color: 'blue',\n },\n nested: [\n {\n entity: 'product',\n data: {\n id: 'SKU-B2',\n name: 'Running Shoes',\n price: 89.99,\n quantity: 1,\n },\n },\n ],\n source: {\n type: 'server',\n id: 'https://shop.example.com/products/running-shoes',\n previous_id: '',\n },\n }),\n mapping: {\n name: 'ADD_CART',\n data: {\n map: {\n custom_data: {\n map: {\n value: 'data.price',\n currency: { value: 'EUR' },\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 },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'ADD_CART',\n event_time: 1700000901,\n action_source: 'WEB',\n event_id: '1700000901000-gr0up-1',\n user_data: {},\n custom_data: {\n value: 89.99,\n currency: 'EUR',\n contents: [{ id: 'SKU-B2', item_price: 89.99, quantity: 1 }],\n },\n event_source_url: 'https://shop.example.com/products/running-shoes',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const pageView: Flow.StepExample = {\n in: getEvent('page view', {\n timestamp: 1700000902000,\n source: {\n type: 'server',\n id: 'https://example.com/docs/',\n previous_id: '',\n },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'page view',\n event_time: 1700000902,\n action_source: 'WEB',\n event_id: '1700000902000-gr0up-1',\n user_data: {},\n custom_data: {},\n event_source_url: 'https://example.com/docs/',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n in: getEvent('form submit', {\n timestamp: 1700000903000,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: {\n type: 'server',\n id: 'https://example.com/contact',\n previous_id: '',\n },\n }),\n mapping: {\n name: 'SIGN_UP',\n data: {\n map: {\n user_data: {\n map: {\n em: 'user.email',\n },\n },\n custom_data: {\n map: {\n sign_up_method: { value: 'newsletter' },\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'SIGN_UP',\n event_time: 1700000903,\n action_source: 'WEB',\n event_id: '1700000903000-gr0up-1',\n user_data: {\n // sha256('user@example.com')\n em: 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514',\n },\n custom_data: {\n sign_up_method: 'newsletter',\n },\n event_source_url: 'https://example.com/contact',\n },\n ],\n }),\n ],\n ],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,aAAa,EACV,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,eAAe;AAAA,EACnD,KAAK,EACF,OAAO,EACP,IAAI,EACJ;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,eAAe,EACZ,KAAK,CAAC,OAAO,cAAc,SAAS,CAAC,EACrC,SAAS,mCAAmC,EAC5C,SAAS;AAAA,EACZ,WAAW,EACR,MAAM,EAAE,OAAO,CAAC,EAChB,SAAS,sDAAsD,EAC/D,SAAS;AAAA,EACZ,WAAW,EACR,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAC7B,SAAS,0DAA0D,EACnE,SAAS;AAAA,EACZ,UAAU,EACP,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AACd,CAAC;;;ACnCD,SAAS,KAAAA,UAAS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IAAI;AAAA,YACN;AAAA,YACA,aAAa;AAAA,cACX,gBAAgB;AAAA,YAClB;AAAA,YACA,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["z","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/schemas/primitives.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';\n\nexport const SettingsSchema = z.object({\n accessToken: z\n .string()\n .min(1)\n .describe(\n 'Long-lived Conversions API access token from Snapchat Ads Manager',\n ),\n pixelId: z.string().min(1).describe('Snap Pixel ID'),\n url: z\n .string()\n .url()\n .describe(\n 'Custom Conversions API base URL (default https://tr.snapchat.com/v3/)',\n )\n .optional(),\n action_source: z\n .enum(['WEB', 'MOBILE_APP', 'OFFLINE'])\n .describe('Event action source (default WEB)')\n .optional(),\n doNotHash: z\n .array(z.string())\n .describe(\"User data fields to skip hashing (like ['em', 'ph'])\")\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\"Mapping for user data fields (like { em: 'user.email' })\")\n .optional(),\n testMode: z\n .boolean()\n .describe(\n 'When true, sends events to /events/validate instead of /events for testing',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * Snapchat Conversions API Mapping Schema\n * Snapchat 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","import { z } from '@walkeros/core/dev';\n\n/**\n * Standard Snapchat Conversions API event names (UPPERCASE).\n * https://businesshelp.snapchat.com/s/article/capi-parameters\n */\nexport const StandardEventNameSchema = z.union([\n z.enum([\n 'PAGE_VIEW',\n 'VIEW_CONTENT',\n 'ADD_CART',\n 'ADD_TO_WISHLIST',\n 'START_CHECKOUT',\n 'ADD_BILLING',\n 'PURCHASE',\n 'SIGN_UP',\n 'SEARCH',\n 'SAVE',\n 'SUBSCRIBE',\n 'COMPLETE_TUTORIAL',\n 'START_TRIAL',\n 'AD_CLICK',\n 'AD_VIEW',\n 'APP_OPEN',\n 'LEVEL_COMPLETE',\n 'INVITE',\n 'LOGIN',\n 'SHARE',\n 'RESERVE',\n 'ACHIEVEMENT_UNLOCKED',\n 'SPENT_CREDITS',\n 'RATE',\n 'LIST_VIEW',\n 'CUSTOM_EVENT_1',\n 'CUSTOM_EVENT_2',\n 'CUSTOM_EVENT_3',\n 'CUSTOM_EVENT_4',\n 'CUSTOM_EVENT_5',\n ]),\n z.string(), // Allow custom event names\n]);\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 Snapchat Conversions API destination.\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\ntype MockSendServer = (\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n) => Promise<SendResponse>;\n\nconst mockSendServer: MockSendServer = async () => ({\n ok: true,\n data: {\n status: 'OK',\n request_id: 'mock-123',\n },\n});\n\n/**\n * Standard mock environment for push operations.\n *\n * Use this for testing Snapchat Conversions API events without making\n * actual HTTP requests to Snapchat's servers.\n */\nexport const push: Env = {\n sendServer: mockSendServer,\n};\n\nexport const simulation = ['sendServer'];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent, isObject } from '@walkeros/core';\n\n/**\n * Snapchat Conversions API step examples.\n *\n * At push time, the destination calls `env.sendServer(url, body)` where\n * `url` is `${settings.url}${settings.pixelId}/${path}?access_token=${settings.accessToken}`\n * with `path` = `events` (or `events/validate` when `testMode` is set),\n * and `body` is the JSON-stringified `{ data: [snapchatEvent] }` payload.\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelId = 'p1x3l1d'`,\n * so every endpoint resolves to:\n * https://tr.snapchat.com/v3/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_time (unix seconds; `Math.round(event.timestamp / 1000)`)\n * 3. action_source (default 'WEB')\n * 4. event_id\n * 5. user_data (hashed per Snapchat's PII requirements)\n * 6. custom_data (mapped event data, excluding user_data/custom_data keys)\n * 7. event_source_url (appended last when action_source === 'WEB')\n */\nconst ENDPOINT =\n 'https://tr.snapchat.com/v3/p1x3l1d/events?access_token=s3cr3t';\n\nexport const purchase: Flow.StepExample = {\n title: 'Purchase',\n description:\n 'A completed order is sent to the Snapchat Conversions API as a PURCHASE with value, currency, and contents.',\n in: getEvent('order complete', {\n timestamp: 1700000900000,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n nested: [\n {\n entity: 'product',\n data: { id: 'SKU-A1', name: 'Widget Pro', price: 124.99, quantity: 2 },\n },\n ],\n user: { id: 'user-123', device: 'device-456' },\n source: {\n type: 'server',\n id: 'https://shop.example.com/checkout/complete',\n previous_id: '',\n },\n }),\n mapping: {\n name: 'PURCHASE',\n data: {\n map: {\n custom_data: {\n map: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'EUR' },\n transaction_id: 'data.id',\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 },\n },\n user_data: {\n map: {\n external_id: 'user.id',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'PURCHASE',\n event_time: 1700000900,\n action_source: 'WEB',\n event_id: '1700000900000-gr0up-1',\n user_data: {\n external_id:\n 'fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8',\n },\n custom_data: {\n value: 249.99,\n currency: 'EUR',\n transaction_id: 'ORD-300',\n contents: [{ id: 'SKU-A1', item_price: 124.99, quantity: 2 }],\n },\n event_source_url: 'https://shop.example.com/checkout/complete',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const addToCart: Flow.StepExample = {\n title: 'Add to cart',\n description:\n 'A product add is sent to Snapchat as an ADD_CART conversion with value and product details.',\n in: getEvent('product add', {\n timestamp: 1700000901000,\n data: {\n id: 'SKU-B2',\n name: 'Running Shoes',\n price: 89.99,\n color: 'blue',\n },\n nested: [\n {\n entity: 'product',\n data: {\n id: 'SKU-B2',\n name: 'Running Shoes',\n price: 89.99,\n quantity: 1,\n },\n },\n ],\n source: {\n type: 'server',\n id: 'https://shop.example.com/products/running-shoes',\n previous_id: '',\n },\n }),\n mapping: {\n name: 'ADD_CART',\n data: {\n map: {\n custom_data: {\n map: {\n value: 'data.price',\n currency: { value: 'EUR' },\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 },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'ADD_CART',\n event_time: 1700000901,\n action_source: 'WEB',\n event_id: '1700000901000-gr0up-1',\n user_data: {},\n custom_data: {\n value: 89.99,\n currency: 'EUR',\n contents: [{ id: 'SKU-B2', item_price: 89.99, quantity: 1 }],\n },\n event_source_url: 'https://shop.example.com/products/running-shoes',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const pageView: Flow.StepExample = {\n title: 'Page view',\n description:\n 'A page view is forwarded to Snapchat with the event source URL and no extra custom data.',\n in: getEvent('page view', {\n timestamp: 1700000902000,\n source: {\n type: 'server',\n id: 'https://example.com/docs/',\n previous_id: '',\n },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'page view',\n event_time: 1700000902,\n action_source: 'WEB',\n event_id: '1700000902000-gr0up-1',\n user_data: {},\n custom_data: {},\n event_source_url: 'https://example.com/docs/',\n },\n ],\n }),\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Sign up',\n description:\n 'A newsletter form submission is sent to Snapchat as a SIGN_UP conversion with a hashed email.',\n in: getEvent('form submit', {\n timestamp: 1700000903000,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: {\n type: 'server',\n id: 'https://example.com/contact',\n previous_id: '',\n },\n }),\n mapping: {\n name: 'SIGN_UP',\n data: {\n map: {\n user_data: {\n map: {\n em: 'user.email',\n },\n },\n custom_data: {\n map: {\n sign_up_method: { value: 'newsletter' },\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n data: [\n {\n event_name: 'SIGN_UP',\n event_time: 1700000903,\n action_source: 'WEB',\n event_id: '1700000903000-gr0up-1',\n user_data: {\n // sha256('user@example.com')\n em: 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514',\n },\n custom_data: {\n sign_up_method: 'newsletter',\n },\n event_source_url: 'https://example.com/contact',\n },\n ],\n }),\n ],\n ],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,aAAa,EACV,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,SAAS,EAAE,OAA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AE,MAAM,aAAa;AAAA,IAC3B,MAAM,EAAE,OAAO,mBAAmB;AAAA,IAClC,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,aAAa;AAAA,IACf;AAAA,EACF,CAAC;AAAA,EACD,SAAS;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,MACJ,KAAK;AAAA,QACH,WAAW;AAAA,UACT,KAAK;AAAA,YACH,IAAI;AAAA,UACN;AAAA,QACF;AAAA,QACA,aAAa;AAAA,UACX,KAAK;AAAA,YACH,gBAAgB,EAAE,OAAO,aAAa;AAAA,UACxC;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,YAAY;AAAA,YACZ,eAAe;AAAA,YACf,UAAU;AAAA,YACV,WAAW;AAAA;AAAA,cAET,IAAI;AAAA,YACN;AAAA,YACA,aAAa;AAAA,cACX,gBAAgB;AAAA,YAClB;AAAA,YACA,kBAAkB;AAAA,UACpB;AAAA,QACF;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["z","z"]}
|
package/dist/examples/index.js
CHANGED
|
@@ -54,6 +54,8 @@ __export(step_exports, {
|
|
|
54
54
|
var import_core = require("@walkeros/core");
|
|
55
55
|
var ENDPOINT = "https://tr.snapchat.com/v3/p1x3l1d/events?access_token=s3cr3t";
|
|
56
56
|
var purchase = {
|
|
57
|
+
title: "Purchase",
|
|
58
|
+
description: "A completed order is sent to the Snapchat Conversions API as a PURCHASE with value, currency, and contents.",
|
|
57
59
|
in: (0, import_core.getEvent)("order complete", {
|
|
58
60
|
timestamp: 17000009e5,
|
|
59
61
|
data: { id: "ORD-300", total: 249.99, currency: "EUR" },
|
|
@@ -130,6 +132,8 @@ var purchase = {
|
|
|
130
132
|
]
|
|
131
133
|
};
|
|
132
134
|
var addToCart = {
|
|
135
|
+
title: "Add to cart",
|
|
136
|
+
description: "A product add is sent to Snapchat as an ADD_CART conversion with value and product details.",
|
|
133
137
|
in: (0, import_core.getEvent)("product add", {
|
|
134
138
|
timestamp: 1700000901e3,
|
|
135
139
|
data: {
|
|
@@ -206,6 +210,8 @@ var addToCart = {
|
|
|
206
210
|
]
|
|
207
211
|
};
|
|
208
212
|
var pageView = {
|
|
213
|
+
title: "Page view",
|
|
214
|
+
description: "A page view is forwarded to Snapchat with the event source URL and no extra custom data.",
|
|
209
215
|
in: (0, import_core.getEvent)("page view", {
|
|
210
216
|
timestamp: 1700000902e3,
|
|
211
217
|
source: {
|
|
@@ -236,6 +242,8 @@ var pageView = {
|
|
|
236
242
|
]
|
|
237
243
|
};
|
|
238
244
|
var lead = {
|
|
245
|
+
title: "Sign up",
|
|
246
|
+
description: "A newsletter form submission is sent to Snapchat as a SIGN_UP conversion with a hashed email.",
|
|
239
247
|
in: (0, import_core.getEvent)("form submit", {
|
|
240
248
|
timestamp: 1700000903e3,
|
|
241
249
|
data: { type: "newsletter" },
|
package/dist/examples/index.mjs
CHANGED
|
@@ -33,6 +33,8 @@ __export(step_exports, {
|
|
|
33
33
|
import { getEvent, isObject } from "@walkeros/core";
|
|
34
34
|
var ENDPOINT = "https://tr.snapchat.com/v3/p1x3l1d/events?access_token=s3cr3t";
|
|
35
35
|
var purchase = {
|
|
36
|
+
title: "Purchase",
|
|
37
|
+
description: "A completed order is sent to the Snapchat Conversions API as a PURCHASE with value, currency, and contents.",
|
|
36
38
|
in: getEvent("order complete", {
|
|
37
39
|
timestamp: 17000009e5,
|
|
38
40
|
data: { id: "ORD-300", total: 249.99, currency: "EUR" },
|
|
@@ -109,6 +111,8 @@ var purchase = {
|
|
|
109
111
|
]
|
|
110
112
|
};
|
|
111
113
|
var addToCart = {
|
|
114
|
+
title: "Add to cart",
|
|
115
|
+
description: "A product add is sent to Snapchat as an ADD_CART conversion with value and product details.",
|
|
112
116
|
in: getEvent("product add", {
|
|
113
117
|
timestamp: 1700000901e3,
|
|
114
118
|
data: {
|
|
@@ -185,6 +189,8 @@ var addToCart = {
|
|
|
185
189
|
]
|
|
186
190
|
};
|
|
187
191
|
var pageView = {
|
|
192
|
+
title: "Page view",
|
|
193
|
+
description: "A page view is forwarded to Snapchat with the event source URL and no extra custom data.",
|
|
188
194
|
in: getEvent("page view", {
|
|
189
195
|
timestamp: 1700000902e3,
|
|
190
196
|
source: {
|
|
@@ -215,6 +221,8 @@ var pageView = {
|
|
|
215
221
|
]
|
|
216
222
|
};
|
|
217
223
|
var lead = {
|
|
224
|
+
title: "Sign up",
|
|
225
|
+
description: "A newsletter form submission is sent to Snapchat as a SIGN_UP conversion with a hashed email.",
|
|
218
226
|
in: getEvent("form submit", {
|
|
219
227
|
timestamp: 1700000903e3,
|
|
220
228
|
data: { type: "newsletter" },
|
package/dist/walkerOS.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$meta": {
|
|
3
3
|
"package": "@walkeros/server-destination-snapchat",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.1",
|
|
5
5
|
"type": "destination",
|
|
6
6
|
"platform": [
|
|
7
7
|
"server"
|
|
@@ -86,6 +86,8 @@
|
|
|
86
86
|
},
|
|
87
87
|
"step": {
|
|
88
88
|
"addToCart": {
|
|
89
|
+
"title": "Add to cart",
|
|
90
|
+
"description": "A product add is sent to Snapchat as an ADD_CART conversion with value and product details.",
|
|
89
91
|
"in": {
|
|
90
92
|
"name": "product add",
|
|
91
93
|
"data": {
|
|
@@ -134,7 +136,7 @@
|
|
|
134
136
|
"group": "gr0up",
|
|
135
137
|
"count": 1,
|
|
136
138
|
"version": {
|
|
137
|
-
"source": "3.4.
|
|
139
|
+
"source": "3.4.1",
|
|
138
140
|
"tagging": 1
|
|
139
141
|
},
|
|
140
142
|
"source": {
|
|
@@ -158,7 +160,7 @@
|
|
|
158
160
|
"nested",
|
|
159
161
|
{
|
|
160
162
|
"condition": {
|
|
161
|
-
"$code": "e=>
|
|
163
|
+
"$code": "e=>h(e)&&\"product\"===e.entity"
|
|
162
164
|
},
|
|
163
165
|
"map": {
|
|
164
166
|
"id": "data.id",
|
|
@@ -185,6 +187,8 @@
|
|
|
185
187
|
]
|
|
186
188
|
},
|
|
187
189
|
"lead": {
|
|
190
|
+
"title": "Sign up",
|
|
191
|
+
"description": "A newsletter form submission is sent to Snapchat as a SIGN_UP conversion with a hashed email.",
|
|
188
192
|
"in": {
|
|
189
193
|
"name": "form submit",
|
|
190
194
|
"data": {
|
|
@@ -232,7 +236,7 @@
|
|
|
232
236
|
"group": "gr0up",
|
|
233
237
|
"count": 1,
|
|
234
238
|
"version": {
|
|
235
|
-
"source": "3.4.
|
|
239
|
+
"source": "3.4.1",
|
|
236
240
|
"tagging": 1
|
|
237
241
|
},
|
|
238
242
|
"source": {
|
|
@@ -269,6 +273,8 @@
|
|
|
269
273
|
]
|
|
270
274
|
},
|
|
271
275
|
"pageView": {
|
|
276
|
+
"title": "Page view",
|
|
277
|
+
"description": "A page view is forwarded to Snapchat with the event source URL and no extra custom data.",
|
|
272
278
|
"in": {
|
|
273
279
|
"name": "page view",
|
|
274
280
|
"data": {
|
|
@@ -323,7 +329,7 @@
|
|
|
323
329
|
"group": "gr0up",
|
|
324
330
|
"count": 1,
|
|
325
331
|
"version": {
|
|
326
|
-
"source": "3.4.
|
|
332
|
+
"source": "3.4.1",
|
|
327
333
|
"tagging": 1
|
|
328
334
|
},
|
|
329
335
|
"source": {
|
|
@@ -341,6 +347,8 @@
|
|
|
341
347
|
]
|
|
342
348
|
},
|
|
343
349
|
"purchase": {
|
|
350
|
+
"title": "Purchase",
|
|
351
|
+
"description": "A completed order is sent to the Snapchat Conversions API as a PURCHASE with value, currency, and contents.",
|
|
344
352
|
"in": {
|
|
345
353
|
"name": "order complete",
|
|
346
354
|
"data": {
|
|
@@ -387,7 +395,7 @@
|
|
|
387
395
|
"group": "gr0up",
|
|
388
396
|
"count": 1,
|
|
389
397
|
"version": {
|
|
390
|
-
"source": "3.4.
|
|
398
|
+
"source": "3.4.1",
|
|
391
399
|
"tagging": 1
|
|
392
400
|
},
|
|
393
401
|
"source": {
|
|
@@ -413,7 +421,7 @@
|
|
|
413
421
|
"nested",
|
|
414
422
|
{
|
|
415
423
|
"condition": {
|
|
416
|
-
"$code": "e=>
|
|
424
|
+
"$code": "e=>h(e)&&\"product\"===e.entity"
|
|
417
425
|
},
|
|
418
426
|
"map": {
|
|
419
427
|
"id": "data.id",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/server-destination-snapchat",
|
|
3
3
|
"description": "Snapchat Conversions API server destination for walkerOS",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"update": "npx npm-check-updates -u && npm update"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@walkeros/core": "3.4.
|
|
38
|
-
"@walkeros/server-core": "3.4.
|
|
37
|
+
"@walkeros/core": "3.4.1",
|
|
38
|
+
"@walkeros/server-core": "3.4.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@walkeros/collector": "3.4.
|
|
41
|
+
"@walkeros/collector": "3.4.1"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|