@walkeros/server-destination-tiktok 3.4.2 → 4.0.0-next-1777882869103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dev.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,i=(e,a)=>{for(var n in a)t(e,n,{get:a[n],enumerable:!0})},o={};i(o,{examples:()=>y,schemas:()=>s}),module.exports=(e=o,((e,i,o,s)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of n(i))r.call(e,c)||c===o||t(e,c,{get:()=>i[c],enumerable:!(s=a(i,c))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={};i(s,{MappingSchema:()=>m,SettingsSchema:()=>p,StandardEventNameSchema:()=>l,mapping:()=>g,settings:()=>v});var c=require("@walkeros/core/dev"),d=require("@walkeros/core/dev"),p=d.z.object({pixelCode:d.z.string().min(1).describe("TikTok Pixel Code from Events Manager (like C0ABCDEF12345)"),accessToken:d.z.string().min(1).describe("Events API access token from TikTok Events Manager"),url:d.z.string().url().describe("Custom Events API endpoint URL").optional(),test_event_code:d.z.string().describe("Test event code for debugging in TikTok Events Manager (like TEST12345)").optional(),doNotHash:d.z.array(d.z.string()).describe("User data fields to skip hashing (like ['email', 'phone_number'])").optional(),user_data:d.z.record(d.z.string(),d.z.string()).describe("Mapping for user data fields (like { email: 'user.email' })").optional(),partner_name:d.z.string().describe("Partner name for TikTok attribution").optional()}),m=require("@walkeros/core/dev").z.object({}),u=require("@walkeros/core/dev"),l=u.z.union([u.z.enum(["ViewContent","ClickButton","Search","AddToWishlist","AddToCart","InitiateCheckout","AddPaymentInfo","CompletePayment","PlaceAnOrder","Contact","Download","SubmitForm","CompleteRegistration","Subscribe"]),u.z.string()]),v=(0,c.zodToSchema)(p),g=(0,c.zodToSchema)(m),y={};i(y,{env:()=>h,step:()=>k});var h={};i(h,{push:()=>_,simulation:()=>b});var _={sendServer:async function(e,t,a){return{ok:!0,data:{code:0,message:"OK"}}}},b=["sendServer"],k={};i(k,{addToCart:()=>E,lead:()=>C,pageView:()=>x,purchase:()=>w});var S=require("@walkeros/core"),f="https://business-api.tiktok.com/open_api/v1.3/event/track/",T={headers:{"Access-Token":"s3cr3t","Content-Type":"application/json"}},w={title:"Complete payment",description:"A completed order is sent to the TikTok Events API as a CompletePayment with value, currency, and contents.",in:(0,S.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:"CompletePayment",data:{map:{value:"data.total",currency:{key:"data.currency",value:"EUR"},order_id:"data.id",content_type:{value:"product"},contents:{loop:["nested",{condition:e=>(0,S.isObject)(e)&&"product"===e.entity,map:{content_id:"data.id",content_name:"data.name",quantity:{key:"data.quantity",value:1},price:"data.price"}}]},user_data:{map:{external_id:"user.id"}}}}},out:[["sendServer",f,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"CompletePayment",event_id:"1700000900000-gr0up-1",timestamp:"2023-11-14T22:28:20.000Z",context:{user:{external_id:"fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8"},page:{url:"https://shop.example.com/checkout/complete"}},properties:{value:249.99,currency:"EUR",order_id:"ORD-300",content_type:"product",contents:[{content_id:"SKU-A1",content_name:"Widget Pro",quantity:2,price:124.99}]}}]}),T]]},E={title:"Add to cart",description:"A product add is sent to TikTok as an AddToCart event with value, currency, and product contents.",in:(0,S.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:"AddToCart",data:{map:{content_type:{value:"product"},value:"data.price",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>(0,S.isObject)(e)&&"product"===e.entity,map:{content_id:"data.id",content_name:"data.name",quantity:{key:"data.quantity",value:1},price:"data.price"}}]}}}},out:[["sendServer",f,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"AddToCart",event_id:"1700000901000-gr0up-1",timestamp:"2023-11-14T22:28:21.000Z",context:{page:{url:"https://shop.example.com/products/running-shoes"}},properties:{content_type:"product",value:89.99,currency:"EUR",contents:[{content_id:"SKU-B2",content_name:"Running Shoes",quantity:1,price:89.99}]}}]}),T]]},x={title:"Page view",description:"A page view is forwarded to TikTok as a page view event with the source URL in the page context.",in:(0,S.getEvent)("page view",{timestamp:1700000902e3,source:{type:"server",id:"https://example.com/docs/",previous_id:""}}),mapping:void 0,out:[["sendServer",f,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"page view",event_id:"1700000902000-gr0up-1",timestamp:"2023-11-14T22:28:22.000Z",context:{page:{url:"https://example.com/docs/"}},properties:{}}]}),T]]},C={title:"Submit form",description:"A newsletter form submission is sent to TikTok as a SubmitForm event with the hashed email in user context.",in:(0,S.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:"SubmitForm",data:{map:{user_data:{map:{email:"user.email"}}}}},out:[["sendServer",f,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"SubmitForm",event_id:"1700000903000-gr0up-1",timestamp:"2023-11-14T22:28:23.000Z",context:{user:{email:"b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"},page:{url:"https://example.com/contact"}},properties:{}}]}),T]]};//# sourceMappingURL=dev.js.map
1
+ "use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,o=(e,a)=>{for(var n in a)t(e,n,{get:a[n],enumerable:!0})},i={};o(i,{examples:()=>g,schemas:()=>c}),module.exports=(e=i,((e,o,i,c)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let s of n(o))r.call(e,s)||s===i||t(e,s,{get:()=>o[s],enumerable:!(c=a(o,s))||c.enumerable});return e})(t({},"__esModule",{value:!0}),e));var c={};o(c,{MappingSchema:()=>m,SettingsSchema:()=>p,StandardEventNameSchema:()=>l,mapping:()=>b,settings:()=>v});var s=require("@walkeros/core/dev"),d=require("@walkeros/core/dev"),p=d.z.object({pixelCode:d.z.string().min(1).describe("TikTok Pixel Code from Events Manager (like C0ABCDEF12345)"),accessToken:d.z.string().min(1).describe("Events API access token from TikTok Events Manager"),url:d.z.string().url().describe("Custom Events API endpoint URL").optional(),test_event_code:d.z.string().describe("Test event code for debugging in TikTok Events Manager (like TEST12345)").optional(),doNotHash:d.z.array(d.z.string()).describe("User data fields to skip hashing (like ['email', 'phone_number'])").optional(),user_data:d.z.record(d.z.string(),d.z.string()).describe("Mapping for user data fields (like { email: 'user.email' })").optional(),partner_name:d.z.string().describe("Partner name for TikTok attribution").optional()}),m=require("@walkeros/core/dev").z.object({}),u=require("@walkeros/core/dev"),l=u.z.union([u.z.enum(["ViewContent","ClickButton","Search","AddToWishlist","AddToCart","InitiateCheckout","AddPaymentInfo","CompletePayment","PlaceAnOrder","Contact","Download","SubmitForm","CompleteRegistration","Subscribe"]),u.z.string()]),v=(0,s.zodToSchema)(p),b=(0,s.zodToSchema)(m),g={};o(g,{env:()=>y,step:()=>k});var y={};o(y,{push:()=>f,simulation:()=>h});var f={sendServer:async function(e,t,a){return{ok:!0,data:{code:0,message:"OK"}}}},h=["sendServer"],k={};o(k,{addToCart:()=>E,lead:()=>C,pageView:()=>x,purchase:()=>T});var _=require("@walkeros/core"),S="https://business-api.tiktok.com/open_api/v1.3/event/track/",w={headers:{"Access-Token":"s3cr3t","Content-Type":"application/json"}},T={title:"Complete payment",description:"A completed order is sent to the TikTok Events API as a CompletePayment with value, currency, and contents.",in:(0,_.getEvent)("order complete",{id:"d1e2f3a4b5c60001",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:"browser",platform:"web",url:"https://shop.example.com/checkout/complete"}}),mapping:{name:"CompletePayment",data:{map:{value:"data.total",currency:{key:"data.currency",value:"EUR"},order_id:"data.id",content_type:{value:"product"},contents:{loop:["nested",{condition:e=>(0,_.isObject)(e)&&"product"===e.entity,map:{content_id:"data.id",content_name:"data.name",quantity:{key:"data.quantity",value:1},price:"data.price"}}]},user_data:{map:{external_id:"user.id"}}}}},out:[["sendServer",S,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"CompletePayment",event_id:"d1e2f3a4b5c60001",timestamp:"2023-11-14T22:28:20.000Z",context:{user:{external_id:"fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8"},page:{url:"https://shop.example.com/checkout/complete"}},properties:{value:249.99,currency:"EUR",order_id:"ORD-300",content_type:"product",contents:[{content_id:"SKU-A1",content_name:"Widget Pro",quantity:2,price:124.99}]}}]}),w]]},E={title:"Add to cart",description:"A product add is sent to TikTok as an AddToCart event with value, currency, and product contents.",in:(0,_.getEvent)("product add",{id:"d1e2f3a4b5c60002",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:"browser",platform:"web",url:"https://shop.example.com/products/running-shoes"}}),mapping:{name:"AddToCart",data:{map:{content_type:{value:"product"},value:"data.price",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>(0,_.isObject)(e)&&"product"===e.entity,map:{content_id:"data.id",content_name:"data.name",quantity:{key:"data.quantity",value:1},price:"data.price"}}]}}}},out:[["sendServer",S,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"AddToCart",event_id:"d1e2f3a4b5c60002",timestamp:"2023-11-14T22:28:21.000Z",context:{page:{url:"https://shop.example.com/products/running-shoes"}},properties:{content_type:"product",value:89.99,currency:"EUR",contents:[{content_id:"SKU-B2",content_name:"Running Shoes",quantity:1,price:89.99}]}}]}),w]]},x={title:"Page view",description:"A page view is forwarded to TikTok as a page view event with the source URL in the page context.",in:(0,_.getEvent)("page view",{id:"d1e2f3a4b5c60003",timestamp:1700000902e3,source:{type:"browser",platform:"web",url:"https://example.com/docs/"}}),mapping:void 0,out:[["sendServer",S,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"page view",event_id:"d1e2f3a4b5c60003",timestamp:"2023-11-14T22:28:22.000Z",context:{page:{url:"https://example.com/docs/"}},properties:{}}]}),w]]},C={title:"Submit form",description:"A newsletter form submission is sent to TikTok as a SubmitForm event with the hashed email in user context.",in:(0,_.getEvent)("form submit",{id:"d1e2f3a4b5c60004",timestamp:1700000903e3,data:{type:"newsletter"},user:{email:"user@example.com"},source:{type:"browser",platform:"web",url:"https://example.com/contact"}}),mapping:{name:"SubmitForm",data:{map:{user_data:{map:{email:"user.email"}}}}},out:[["sendServer",S,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"SubmitForm",event_id:"d1e2f3a4b5c60004",timestamp:"2023-11-14T22:28:23.000Z",context:{user:{email:"b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"},page:{url:"https://example.com/contact"}},properties:{}}]}),w]]};//# 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 pixelCode: z\n .string()\n .min(1)\n .describe('TikTok Pixel Code from Events Manager (like C0ABCDEF12345)'),\n accessToken: z\n .string()\n .min(1)\n .describe('Events API access token from TikTok Events Manager'),\n url: z.string().url().describe('Custom Events API endpoint URL').optional(),\n test_event_code: z\n .string()\n .describe(\n 'Test event code for debugging in TikTok Events Manager (like TEST12345)',\n )\n .optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"User data fields to skip hashing (like ['email', 'phone_number'])\",\n )\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\"Mapping for user data fields (like { email: 'user.email' })\")\n .optional(),\n partner_name: z\n .string()\n .describe('Partner name for TikTok attribution')\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * TikTok Events API Mapping Schema\n * TikTok Events API 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 TikTok Event Names\n * https://business-api.tiktok.com/portal/docs?id=1771100865818625\n */\nexport const StandardEventNameSchema = z.union([\n z.enum([\n 'ViewContent',\n 'ClickButton',\n 'Search',\n 'AddToWishlist',\n 'AddToCart',\n 'InitiateCheckout',\n 'AddPaymentInfo',\n 'CompletePayment',\n 'PlaceAnOrder',\n 'Contact',\n 'Download',\n 'SubmitForm',\n 'CompleteRegistration',\n 'Subscribe',\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 TikTok Events 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 TikTok API response\n return {\n ok: true,\n data: {\n code: 0,\n message: 'OK',\n },\n };\n}\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing TikTok Events API events without making\n * actual HTTP requests to TikTok'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 * TikTok Events API step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(url, body, { headers })` where `url` is the fixed\n * TikTok Events API endpoint and `body` is the JSON-stringified payload\n * `{ pixel_code, partner_name, data: [tiktokEvent] }`.\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelCode = 'PIXEL_CODE'`.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * pixel_code, partner_name, data[] with { event, event_id, timestamp,\n * context: { user?, page }, properties }.\n *\n * User identity fields (`email`, `phone_number`, `external_id`) are hashed\n * with SHA-256.\n */\nconst ENDPOINT = 'https://business-api.tiktok.com/open_api/v1.3/event/track/';\nconst HEADERS = {\n headers: {\n 'Access-Token': 's3cr3t',\n 'Content-Type': 'application/json',\n },\n};\n\nexport const purchase: Flow.StepExample = {\n title: 'Complete payment',\n description:\n 'A completed order is sent to the TikTok Events API as a CompletePayment 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: 'CompletePayment',\n data: {\n map: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'EUR' },\n order_id: 'data.id',\n content_type: { value: 'product' },\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity: unknown) =>\n isObject(entity) && entity.entity === 'product',\n map: {\n content_id: 'data.id',\n content_name: 'data.name',\n quantity: { key: 'data.quantity', value: 1 },\n price: 'data.price',\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 pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'CompletePayment',\n event_id: '1700000900000-gr0up-1',\n timestamp: '2023-11-14T22:28:20.000Z',\n context: {\n user: {\n external_id:\n 'fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8',\n },\n page: {\n url: 'https://shop.example.com/checkout/complete',\n },\n },\n properties: {\n value: 249.99,\n currency: 'EUR',\n order_id: 'ORD-300',\n content_type: 'product',\n contents: [\n {\n content_id: 'SKU-A1',\n content_name: 'Widget Pro',\n quantity: 2,\n price: 124.99,\n },\n ],\n },\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const addToCart: Flow.StepExample = {\n title: 'Add to cart',\n description:\n 'A product add is sent to TikTok as an AddToCart event with value, currency, and product contents.',\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: 'AddToCart',\n data: {\n map: {\n content_type: { value: 'product' },\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 content_id: 'data.id',\n content_name: 'data.name',\n quantity: { key: 'data.quantity', value: 1 },\n price: 'data.price',\n },\n },\n ],\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'AddToCart',\n event_id: '1700000901000-gr0up-1',\n timestamp: '2023-11-14T22:28:21.000Z',\n context: {\n page: {\n url: 'https://shop.example.com/products/running-shoes',\n },\n },\n properties: {\n content_type: 'product',\n value: 89.99,\n currency: 'EUR',\n contents: [\n {\n content_id: 'SKU-B2',\n content_name: 'Running Shoes',\n quantity: 1,\n price: 89.99,\n },\n ],\n },\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const pageView: Flow.StepExample = {\n title: 'Page view',\n description:\n 'A page view is forwarded to TikTok as a page view event with the source URL in the page context.',\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 pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'page view',\n event_id: '1700000902000-gr0up-1',\n timestamp: '2023-11-14T22:28:22.000Z',\n context: {\n page: {\n url: 'https://example.com/docs/',\n },\n },\n properties: {},\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Submit form',\n description:\n 'A newsletter form submission is sent to TikTok as a SubmitForm event with the hashed email in user context.',\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: 'SubmitForm',\n data: {\n map: {\n user_data: {\n map: {\n email: 'user.email',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'SubmitForm',\n event_id: '1700000903000-gr0up-1',\n timestamp: '2023-11-14T22:28:23.000Z',\n context: {\n user: {\n // sha256('user@example.com')\n email:\n 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514',\n },\n page: {\n url: 'https://example.com/contact',\n },\n },\n properties: {},\n },\n ],\n }),\n HEADERS,\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,WAAW,aACR,OAAO,EACP,IAAI,CAAC,EACL,SAAS,4DAA4D;AAAA,EACxE,aAAa,aACV,OAAO,EACP,IAAI,CAAC,EACL,SAAS,oDAAoD;AAAA,EAChE,KAAK,aAAE,OAAO,EAAE,IAAI,EAAE,SAAS,gCAAgC,EAAE,SAAS;AAAA,EAC1E,iBAAiB,aACd,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,WAAW,aACR,MAAM,aAAE,OAAO,CAAC,EAChB;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,WAAW,aACR,OAAO,aAAE,OAAO,GAAG,aAAE,OAAO,CAAC,EAC7B,SAAS,6DAA6D,EACtE,SAAS;AAAA,EACZ,cAAc,aACX,OAAO,EACP,SAAS,qCAAqC,EAC9C,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K;AAAA,QACH,WAAW;AAAA,UACT,KAAK;AAAA,YACH,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,MAAM;AAAA,UACJ;AAAA,YACE,OAAO;AAAA,YACP,UAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,cACP,MAAM;AAAA;AAAA,gBAEJ,OACE;AAAA,cACJ;AAAA,cACA,MAAM;AAAA,gBACJ,KAAK;AAAA,cACP;AAAA,YACF;AAAA,YACA,YAAY,CAAC;AAAA,UACf;AAAA,QACF;AAAA,MACF,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;","names":["import_dev","import_dev","import_dev"]}
1
+ {"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/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 pixelCode: z\n .string()\n .min(1)\n .describe('TikTok Pixel Code from Events Manager (like C0ABCDEF12345)'),\n accessToken: z\n .string()\n .min(1)\n .describe('Events API access token from TikTok Events Manager'),\n url: z.string().url().describe('Custom Events API endpoint URL').optional(),\n test_event_code: z\n .string()\n .describe(\n 'Test event code for debugging in TikTok Events Manager (like TEST12345)',\n )\n .optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"User data fields to skip hashing (like ['email', 'phone_number'])\",\n )\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\"Mapping for user data fields (like { email: 'user.email' })\")\n .optional(),\n partner_name: z\n .string()\n .describe('Partner name for TikTok attribution')\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * TikTok Events API Mapping Schema\n * TikTok Events API 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 TikTok Event Names\n * https://business-api.tiktok.com/portal/docs?id=1771100865818625\n */\nexport const StandardEventNameSchema = z.union([\n z.enum([\n 'ViewContent',\n 'ClickButton',\n 'Search',\n 'AddToWishlist',\n 'AddToCart',\n 'InitiateCheckout',\n 'AddPaymentInfo',\n 'CompletePayment',\n 'PlaceAnOrder',\n 'Contact',\n 'Download',\n 'SubmitForm',\n 'CompleteRegistration',\n 'Subscribe',\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 TikTok Events 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 TikTok API response\n return {\n ok: true,\n data: {\n code: 0,\n message: 'OK',\n },\n };\n}\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing TikTok Events API events without making\n * actual HTTP requests to TikTok'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 * TikTok Events API step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(url, body, { headers })` where `url` is the fixed\n * TikTok Events API endpoint and `body` is the JSON-stringified payload\n * `{ pixel_code, partner_name, data: [tiktokEvent] }`.\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelCode = 'PIXEL_CODE'`.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * pixel_code, partner_name, data[] with { event, event_id, timestamp,\n * context: { user?, page }, properties }.\n *\n * User identity fields (`email`, `phone_number`, `external_id`) are hashed\n * with SHA-256.\n */\nconst ENDPOINT = 'https://business-api.tiktok.com/open_api/v1.3/event/track/';\nconst HEADERS = {\n headers: {\n 'Access-Token': 's3cr3t',\n 'Content-Type': 'application/json',\n },\n};\n\nexport const purchase: Flow.StepExample = {\n title: 'Complete payment',\n description:\n 'A completed order is sent to the TikTok Events API as a CompletePayment with value, currency, and contents.',\n in: getEvent('order complete', {\n id: 'd1e2f3a4b5c60001',\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: 'browser',\n platform: 'web',\n url: 'https://shop.example.com/checkout/complete',\n },\n }),\n mapping: {\n name: 'CompletePayment',\n data: {\n map: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'EUR' },\n order_id: 'data.id',\n content_type: { value: 'product' },\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity: unknown) =>\n isObject(entity) && entity.entity === 'product',\n map: {\n content_id: 'data.id',\n content_name: 'data.name',\n quantity: { key: 'data.quantity', value: 1 },\n price: 'data.price',\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 pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'CompletePayment',\n event_id: 'd1e2f3a4b5c60001',\n timestamp: '2023-11-14T22:28:20.000Z',\n context: {\n user: {\n external_id:\n 'fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8',\n },\n page: {\n url: 'https://shop.example.com/checkout/complete',\n },\n },\n properties: {\n value: 249.99,\n currency: 'EUR',\n order_id: 'ORD-300',\n content_type: 'product',\n contents: [\n {\n content_id: 'SKU-A1',\n content_name: 'Widget Pro',\n quantity: 2,\n price: 124.99,\n },\n ],\n },\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const addToCart: Flow.StepExample = {\n title: 'Add to cart',\n description:\n 'A product add is sent to TikTok as an AddToCart event with value, currency, and product contents.',\n in: getEvent('product add', {\n id: 'd1e2f3a4b5c60002',\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: 'browser',\n platform: 'web',\n url: 'https://shop.example.com/products/running-shoes',\n },\n }),\n mapping: {\n name: 'AddToCart',\n data: {\n map: {\n content_type: { value: 'product' },\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 content_id: 'data.id',\n content_name: 'data.name',\n quantity: { key: 'data.quantity', value: 1 },\n price: 'data.price',\n },\n },\n ],\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'AddToCart',\n event_id: 'd1e2f3a4b5c60002',\n timestamp: '2023-11-14T22:28:21.000Z',\n context: {\n page: {\n url: 'https://shop.example.com/products/running-shoes',\n },\n },\n properties: {\n content_type: 'product',\n value: 89.99,\n currency: 'EUR',\n contents: [\n {\n content_id: 'SKU-B2',\n content_name: 'Running Shoes',\n quantity: 1,\n price: 89.99,\n },\n ],\n },\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const pageView: Flow.StepExample = {\n title: 'Page view',\n description:\n 'A page view is forwarded to TikTok as a page view event with the source URL in the page context.',\n in: getEvent('page view', {\n id: 'd1e2f3a4b5c60003',\n timestamp: 1700000902000,\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://example.com/docs/',\n },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'page view',\n event_id: 'd1e2f3a4b5c60003',\n timestamp: '2023-11-14T22:28:22.000Z',\n context: {\n page: {\n url: 'https://example.com/docs/',\n },\n },\n properties: {},\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Submit form',\n description:\n 'A newsletter form submission is sent to TikTok as a SubmitForm event with the hashed email in user context.',\n in: getEvent('form submit', {\n id: 'd1e2f3a4b5c60004',\n timestamp: 1700000903000,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://example.com/contact',\n },\n }),\n mapping: {\n name: 'SubmitForm',\n data: {\n map: {\n user_data: {\n map: {\n email: 'user.email',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'SubmitForm',\n event_id: 'd1e2f3a4b5c60004',\n timestamp: '2023-11-14T22:28:23.000Z',\n context: {\n user: {\n // sha256('user@example.com')\n email:\n 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514',\n },\n page: {\n url: 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KAAK;AAAA,cACP;AAAA,YACF;AAAA,YACA,YAAY,CAAC;AAAA,UACf;AAAA,QACF;AAAA,MACF,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;","names":["import_dev","import_dev","import_dev"]}
package/dist/dev.mjs CHANGED
@@ -1 +1 @@
1
- var e=Object.defineProperty,t=(t,a)=>{for(var n in a)e(t,n,{get:a[n],enumerable:!0})},a={};t(a,{MappingSchema:()=>s,SettingsSchema:()=>i,StandardEventNameSchema:()=>p,mapping:()=>m,settings:()=>c});import{zodToSchema as n}from"@walkeros/core/dev";import{z as r}from"@walkeros/core/dev";var i=r.object({pixelCode:r.string().min(1).describe("TikTok Pixel Code from Events Manager (like C0ABCDEF12345)"),accessToken:r.string().min(1).describe("Events API access token from TikTok Events Manager"),url:r.string().url().describe("Custom Events API endpoint URL").optional(),test_event_code:r.string().describe("Test event code for debugging in TikTok Events Manager (like TEST12345)").optional(),doNotHash:r.array(r.string()).describe("User data fields to skip hashing (like ['email', 'phone_number'])").optional(),user_data:r.record(r.string(),r.string()).describe("Mapping for user data fields (like { email: 'user.email' })").optional(),partner_name:r.string().describe("Partner name for TikTok attribution").optional()});import{z as o}from"@walkeros/core/dev";var s=o.object({});import{z as d}from"@walkeros/core/dev";var p=d.union([d.enum(["ViewContent","ClickButton","Search","AddToWishlist","AddToCart","InitiateCheckout","AddPaymentInfo","CompletePayment","PlaceAnOrder","Contact","Download","SubmitForm","CompleteRegistration","Subscribe"]),d.string()]),c=n(i),m=n(s),u={};t(u,{env:()=>l,step:()=>y});var l={};t(l,{push:()=>v,simulation:()=>g});var v={sendServer:async function(e,t,a){return{ok:!0,data:{code:0,message:"OK"}}}},g=["sendServer"],y={};t(y,{addToCart:()=>S,lead:()=>x,pageView:()=>T,purchase:()=>f});import{getEvent as h,isObject as k}from"@walkeros/core";var _="https://business-api.tiktok.com/open_api/v1.3/event/track/",b={headers:{"Access-Token":"s3cr3t","Content-Type":"application/json"}},f={title:"Complete payment",description:"A completed order is sent to the TikTok Events API as a CompletePayment with value, currency, and contents.",in:h("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:"CompletePayment",data:{map:{value:"data.total",currency:{key:"data.currency",value:"EUR"},order_id:"data.id",content_type:{value:"product"},contents:{loop:["nested",{condition:e=>k(e)&&"product"===e.entity,map:{content_id:"data.id",content_name:"data.name",quantity:{key:"data.quantity",value:1},price:"data.price"}}]},user_data:{map:{external_id:"user.id"}}}}},out:[["sendServer",_,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"CompletePayment",event_id:"1700000900000-gr0up-1",timestamp:"2023-11-14T22:28:20.000Z",context:{user:{external_id:"fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8"},page:{url:"https://shop.example.com/checkout/complete"}},properties:{value:249.99,currency:"EUR",order_id:"ORD-300",content_type:"product",contents:[{content_id:"SKU-A1",content_name:"Widget Pro",quantity:2,price:124.99}]}}]}),b]]},S={title:"Add to cart",description:"A product add is sent to TikTok as an AddToCart event with value, currency, and product contents.",in:h("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:"AddToCart",data:{map:{content_type:{value:"product"},value:"data.price",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>k(e)&&"product"===e.entity,map:{content_id:"data.id",content_name:"data.name",quantity:{key:"data.quantity",value:1},price:"data.price"}}]}}}},out:[["sendServer",_,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"AddToCart",event_id:"1700000901000-gr0up-1",timestamp:"2023-11-14T22:28:21.000Z",context:{page:{url:"https://shop.example.com/products/running-shoes"}},properties:{content_type:"product",value:89.99,currency:"EUR",contents:[{content_id:"SKU-B2",content_name:"Running Shoes",quantity:1,price:89.99}]}}]}),b]]},T={title:"Page view",description:"A page view is forwarded to TikTok as a page view event with the source URL in the page context.",in:h("page view",{timestamp:1700000902e3,source:{type:"server",id:"https://example.com/docs/",previous_id:""}}),mapping:void 0,out:[["sendServer",_,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"page view",event_id:"1700000902000-gr0up-1",timestamp:"2023-11-14T22:28:22.000Z",context:{page:{url:"https://example.com/docs/"}},properties:{}}]}),b]]},x={title:"Submit form",description:"A newsletter form submission is sent to TikTok as a SubmitForm event with the hashed email in user context.",in:h("form submit",{timestamp:1700000903e3,data:{type:"newsletter"},user:{email:"user@example.com"},source:{type:"server",id:"https://example.com/contact",previous_id:""}}),mapping:{name:"SubmitForm",data:{map:{user_data:{map:{email:"user.email"}}}}},out:[["sendServer",_,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"SubmitForm",event_id:"1700000903000-gr0up-1",timestamp:"2023-11-14T22:28:23.000Z",context:{user:{email:"b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"},page:{url:"https://example.com/contact"}},properties:{}}]}),b]]};export{u as examples,a as schemas};//# sourceMappingURL=dev.mjs.map
1
+ var e=Object.defineProperty,t=(t,a)=>{for(var n in a)e(t,n,{get:a[n],enumerable:!0})},a={};t(a,{MappingSchema:()=>s,SettingsSchema:()=>o,StandardEventNameSchema:()=>c,mapping:()=>m,settings:()=>p});import{zodToSchema as n}from"@walkeros/core/dev";import{z as r}from"@walkeros/core/dev";var o=r.object({pixelCode:r.string().min(1).describe("TikTok Pixel Code from Events Manager (like C0ABCDEF12345)"),accessToken:r.string().min(1).describe("Events API access token from TikTok Events Manager"),url:r.string().url().describe("Custom Events API endpoint URL").optional(),test_event_code:r.string().describe("Test event code for debugging in TikTok Events Manager (like TEST12345)").optional(),doNotHash:r.array(r.string()).describe("User data fields to skip hashing (like ['email', 'phone_number'])").optional(),user_data:r.record(r.string(),r.string()).describe("Mapping for user data fields (like { email: 'user.email' })").optional(),partner_name:r.string().describe("Partner name for TikTok attribution").optional()});import{z as i}from"@walkeros/core/dev";var s=i.object({});import{z as d}from"@walkeros/core/dev";var c=d.union([d.enum(["ViewContent","ClickButton","Search","AddToWishlist","AddToCart","InitiateCheckout","AddPaymentInfo","CompletePayment","PlaceAnOrder","Contact","Download","SubmitForm","CompleteRegistration","Subscribe"]),d.string()]),p=n(o),m=n(s),u={};t(u,{env:()=>l,step:()=>g});var l={};t(l,{push:()=>v,simulation:()=>b});var v={sendServer:async function(e,t,a){return{ok:!0,data:{code:0,message:"OK"}}}},b=["sendServer"],g={};t(g,{addToCart:()=>S,lead:()=>T,pageView:()=>w,purchase:()=>_});import{getEvent as f,isObject as y}from"@walkeros/core";var h="https://business-api.tiktok.com/open_api/v1.3/event/track/",k={headers:{"Access-Token":"s3cr3t","Content-Type":"application/json"}},_={title:"Complete payment",description:"A completed order is sent to the TikTok Events API as a CompletePayment with value, currency, and contents.",in:f("order complete",{id:"d1e2f3a4b5c60001",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:"browser",platform:"web",url:"https://shop.example.com/checkout/complete"}}),mapping:{name:"CompletePayment",data:{map:{value:"data.total",currency:{key:"data.currency",value:"EUR"},order_id:"data.id",content_type:{value:"product"},contents:{loop:["nested",{condition:e=>y(e)&&"product"===e.entity,map:{content_id:"data.id",content_name:"data.name",quantity:{key:"data.quantity",value:1},price:"data.price"}}]},user_data:{map:{external_id:"user.id"}}}}},out:[["sendServer",h,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"CompletePayment",event_id:"d1e2f3a4b5c60001",timestamp:"2023-11-14T22:28:20.000Z",context:{user:{external_id:"fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8"},page:{url:"https://shop.example.com/checkout/complete"}},properties:{value:249.99,currency:"EUR",order_id:"ORD-300",content_type:"product",contents:[{content_id:"SKU-A1",content_name:"Widget Pro",quantity:2,price:124.99}]}}]}),k]]},S={title:"Add to cart",description:"A product add is sent to TikTok as an AddToCart event with value, currency, and product contents.",in:f("product add",{id:"d1e2f3a4b5c60002",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:"browser",platform:"web",url:"https://shop.example.com/products/running-shoes"}}),mapping:{name:"AddToCart",data:{map:{content_type:{value:"product"},value:"data.price",currency:{value:"EUR"},contents:{loop:["nested",{condition:e=>y(e)&&"product"===e.entity,map:{content_id:"data.id",content_name:"data.name",quantity:{key:"data.quantity",value:1},price:"data.price"}}]}}}},out:[["sendServer",h,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"AddToCart",event_id:"d1e2f3a4b5c60002",timestamp:"2023-11-14T22:28:21.000Z",context:{page:{url:"https://shop.example.com/products/running-shoes"}},properties:{content_type:"product",value:89.99,currency:"EUR",contents:[{content_id:"SKU-B2",content_name:"Running Shoes",quantity:1,price:89.99}]}}]}),k]]},w={title:"Page view",description:"A page view is forwarded to TikTok as a page view event with the source URL in the page context.",in:f("page view",{id:"d1e2f3a4b5c60003",timestamp:1700000902e3,source:{type:"browser",platform:"web",url:"https://example.com/docs/"}}),mapping:void 0,out:[["sendServer",h,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"page view",event_id:"d1e2f3a4b5c60003",timestamp:"2023-11-14T22:28:22.000Z",context:{page:{url:"https://example.com/docs/"}},properties:{}}]}),k]]},T={title:"Submit form",description:"A newsletter form submission is sent to TikTok as a SubmitForm event with the hashed email in user context.",in:f("form submit",{id:"d1e2f3a4b5c60004",timestamp:1700000903e3,data:{type:"newsletter"},user:{email:"user@example.com"},source:{type:"browser",platform:"web",url:"https://example.com/contact"}}),mapping:{name:"SubmitForm",data:{map:{user_data:{map:{email:"user.email"}}}}},out:[["sendServer",h,JSON.stringify({pixel_code:"PIXEL_CODE",partner_name:"walkerOS",data:[{event:"SubmitForm",event_id:"d1e2f3a4b5c60004",timestamp:"2023-11-14T22:28:23.000Z",context:{user:{email:"b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"},page:{url:"https://example.com/contact"}},properties:{}}]}),k]]};export{u 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 pixelCode: z\n .string()\n .min(1)\n .describe('TikTok Pixel Code from Events Manager (like C0ABCDEF12345)'),\n accessToken: z\n .string()\n .min(1)\n .describe('Events API access token from TikTok Events Manager'),\n url: z.string().url().describe('Custom Events API endpoint URL').optional(),\n test_event_code: z\n .string()\n .describe(\n 'Test event code for debugging in TikTok Events Manager (like TEST12345)',\n )\n .optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"User data fields to skip hashing (like ['email', 'phone_number'])\",\n )\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\"Mapping for user data fields (like { email: 'user.email' })\")\n .optional(),\n partner_name: z\n .string()\n .describe('Partner name for TikTok attribution')\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * TikTok Events API Mapping Schema\n * TikTok Events API 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 TikTok Event Names\n * https://business-api.tiktok.com/portal/docs?id=1771100865818625\n */\nexport const StandardEventNameSchema = z.union([\n z.enum([\n 'ViewContent',\n 'ClickButton',\n 'Search',\n 'AddToWishlist',\n 'AddToCart',\n 'InitiateCheckout',\n 'AddPaymentInfo',\n 'CompletePayment',\n 'PlaceAnOrder',\n 'Contact',\n 'Download',\n 'SubmitForm',\n 'CompleteRegistration',\n 'Subscribe',\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 TikTok Events 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 TikTok API response\n return {\n ok: true,\n data: {\n code: 0,\n message: 'OK',\n },\n };\n}\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing TikTok Events API events without making\n * actual HTTP requests to TikTok'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 * TikTok Events API step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(url, body, { headers })` where `url` is the fixed\n * TikTok Events API endpoint and `body` is the JSON-stringified payload\n * `{ pixel_code, partner_name, data: [tiktokEvent] }`.\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelCode = 'PIXEL_CODE'`.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * pixel_code, partner_name, data[] with { event, event_id, timestamp,\n * context: { user?, page }, properties }.\n *\n * User identity fields (`email`, `phone_number`, `external_id`) are hashed\n * with SHA-256.\n */\nconst ENDPOINT = 'https://business-api.tiktok.com/open_api/v1.3/event/track/';\nconst HEADERS = {\n headers: {\n 'Access-Token': 's3cr3t',\n 'Content-Type': 'application/json',\n },\n};\n\nexport const purchase: Flow.StepExample = {\n title: 'Complete payment',\n description:\n 'A completed order is sent to the TikTok Events API as a CompletePayment 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: 'CompletePayment',\n data: {\n map: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'EUR' },\n order_id: 'data.id',\n content_type: { value: 'product' },\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity: unknown) =>\n isObject(entity) && entity.entity === 'product',\n map: {\n content_id: 'data.id',\n content_name: 'data.name',\n quantity: { key: 'data.quantity', value: 1 },\n price: 'data.price',\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 pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'CompletePayment',\n event_id: '1700000900000-gr0up-1',\n timestamp: '2023-11-14T22:28:20.000Z',\n context: {\n user: {\n external_id:\n 'fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8',\n },\n page: {\n url: 'https://shop.example.com/checkout/complete',\n },\n },\n properties: {\n value: 249.99,\n currency: 'EUR',\n order_id: 'ORD-300',\n content_type: 'product',\n contents: [\n {\n content_id: 'SKU-A1',\n content_name: 'Widget Pro',\n quantity: 2,\n price: 124.99,\n },\n ],\n },\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const addToCart: Flow.StepExample = {\n title: 'Add to cart',\n description:\n 'A product add is sent to TikTok as an AddToCart event with value, currency, and product contents.',\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: 'AddToCart',\n data: {\n map: {\n content_type: { value: 'product' },\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 content_id: 'data.id',\n content_name: 'data.name',\n quantity: { key: 'data.quantity', value: 1 },\n price: 'data.price',\n },\n },\n ],\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'AddToCart',\n event_id: '1700000901000-gr0up-1',\n timestamp: '2023-11-14T22:28:21.000Z',\n context: {\n page: {\n url: 'https://shop.example.com/products/running-shoes',\n },\n },\n properties: {\n content_type: 'product',\n value: 89.99,\n currency: 'EUR',\n contents: [\n {\n content_id: 'SKU-B2',\n content_name: 'Running Shoes',\n quantity: 1,\n price: 89.99,\n },\n ],\n },\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const pageView: Flow.StepExample = {\n title: 'Page view',\n description:\n 'A page view is forwarded to TikTok as a page view event with the source URL in the page context.',\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 pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'page view',\n event_id: '1700000902000-gr0up-1',\n timestamp: '2023-11-14T22:28:22.000Z',\n context: {\n page: {\n url: 'https://example.com/docs/',\n },\n },\n properties: {},\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Submit form',\n description:\n 'A newsletter form submission is sent to TikTok as a SubmitForm event with the hashed email in user context.',\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: 'SubmitForm',\n data: {\n map: {\n user_data: {\n map: {\n email: 'user.email',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'SubmitForm',\n event_id: '1700000903000-gr0up-1',\n timestamp: '2023-11-14T22:28:23.000Z',\n context: {\n user: {\n // sha256('user@example.com')\n email:\n 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514',\n },\n page: {\n url: 'https://example.com/contact',\n },\n },\n properties: {},\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAA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U;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,cACP,MAAM;AAAA,gBACJ,KAAK;AAAA,cACP;AAAA,YACF;AAAA,YACA,YAAY,CAAC;AAAA,UACf;AAAA,QACF;AAAA,MACF,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,OAAyB;AAAA,EACpC,OAAO;AAAA,EACP,aACE;AAAA,EACF,IAAI,SAAS,eAAe;AAAA,IAC1B,WAAW;AAAA,IACX,MAAM,EAAE,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,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,MAAM;AAAA,UACJ;AAAA,YACE,OAAO;AAAA,YACP,UAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,cACP,MAAM;AAAA;AAAA,gBAEJ,OACE;AAAA,cACJ;AAAA,cACA,MAAM;AAAA,gBACJ,KAAK;AAAA,cACP;AAAA,YACF;AAAA,YACA,YAAY,CAAC;AAAA,UACf;AAAA,QACF;AAAA,MACF,CAAC;AAAA,MACD;AAAA,IACF;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 pixelCode: z\n .string()\n .min(1)\n .describe('TikTok Pixel Code from Events Manager (like C0ABCDEF12345)'),\n accessToken: z\n .string()\n .min(1)\n .describe('Events API access token from TikTok Events Manager'),\n url: z.string().url().describe('Custom Events API endpoint URL').optional(),\n test_event_code: z\n .string()\n .describe(\n 'Test event code for debugging in TikTok Events Manager (like TEST12345)',\n )\n .optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"User data fields to skip hashing (like ['email', 'phone_number'])\",\n )\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\"Mapping for user data fields (like { email: 'user.email' })\")\n .optional(),\n partner_name: z\n .string()\n .describe('Partner name for TikTok attribution')\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * TikTok Events API Mapping Schema\n * TikTok Events API 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 TikTok Event Names\n * https://business-api.tiktok.com/portal/docs?id=1771100865818625\n */\nexport const StandardEventNameSchema = z.union([\n z.enum([\n 'ViewContent',\n 'ClickButton',\n 'Search',\n 'AddToWishlist',\n 'AddToCart',\n 'InitiateCheckout',\n 'AddPaymentInfo',\n 'CompletePayment',\n 'PlaceAnOrder',\n 'Contact',\n 'Download',\n 'SubmitForm',\n 'CompleteRegistration',\n 'Subscribe',\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 TikTok Events 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 TikTok API response\n return {\n ok: true,\n data: {\n code: 0,\n message: 'OK',\n },\n };\n}\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing TikTok Events API events without making\n * actual HTTP requests to TikTok'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 * TikTok Events API step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(url, body, { headers })` where `url` is the fixed\n * TikTok Events API endpoint and `body` is the JSON-stringified payload\n * `{ pixel_code, partner_name, data: [tiktokEvent] }`.\n *\n * The test fixture pins `accessToken = 's3cr3t'` and `pixelCode = 'PIXEL_CODE'`.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * pixel_code, partner_name, data[] with { event, event_id, timestamp,\n * context: { user?, page }, properties }.\n *\n * User identity fields (`email`, `phone_number`, `external_id`) are hashed\n * with SHA-256.\n */\nconst ENDPOINT = 'https://business-api.tiktok.com/open_api/v1.3/event/track/';\nconst HEADERS = {\n headers: {\n 'Access-Token': 's3cr3t',\n 'Content-Type': 'application/json',\n },\n};\n\nexport const purchase: Flow.StepExample = {\n title: 'Complete payment',\n description:\n 'A completed order is sent to the TikTok Events API as a CompletePayment with value, currency, and contents.',\n in: getEvent('order complete', {\n id: 'd1e2f3a4b5c60001',\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: 'browser',\n platform: 'web',\n url: 'https://shop.example.com/checkout/complete',\n },\n }),\n mapping: {\n name: 'CompletePayment',\n data: {\n map: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'EUR' },\n order_id: 'data.id',\n content_type: { value: 'product' },\n contents: {\n loop: [\n 'nested',\n {\n condition: (entity: unknown) =>\n isObject(entity) && entity.entity === 'product',\n map: {\n content_id: 'data.id',\n content_name: 'data.name',\n quantity: { key: 'data.quantity', value: 1 },\n price: 'data.price',\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 pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'CompletePayment',\n event_id: 'd1e2f3a4b5c60001',\n timestamp: '2023-11-14T22:28:20.000Z',\n context: {\n user: {\n external_id:\n 'fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8',\n },\n page: {\n url: 'https://shop.example.com/checkout/complete',\n },\n },\n properties: {\n value: 249.99,\n currency: 'EUR',\n order_id: 'ORD-300',\n content_type: 'product',\n contents: [\n {\n content_id: 'SKU-A1',\n content_name: 'Widget Pro',\n quantity: 2,\n price: 124.99,\n },\n ],\n },\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const addToCart: Flow.StepExample = {\n title: 'Add to cart',\n description:\n 'A product add is sent to TikTok as an AddToCart event with value, currency, and product contents.',\n in: getEvent('product add', {\n id: 'd1e2f3a4b5c60002',\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: 'browser',\n platform: 'web',\n url: 'https://shop.example.com/products/running-shoes',\n },\n }),\n mapping: {\n name: 'AddToCart',\n data: {\n map: {\n content_type: { value: 'product' },\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 content_id: 'data.id',\n content_name: 'data.name',\n quantity: { key: 'data.quantity', value: 1 },\n price: 'data.price',\n },\n },\n ],\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'AddToCart',\n event_id: 'd1e2f3a4b5c60002',\n timestamp: '2023-11-14T22:28:21.000Z',\n context: {\n page: {\n url: 'https://shop.example.com/products/running-shoes',\n },\n },\n properties: {\n content_type: 'product',\n value: 89.99,\n currency: 'EUR',\n contents: [\n {\n content_id: 'SKU-B2',\n content_name: 'Running Shoes',\n quantity: 1,\n price: 89.99,\n },\n ],\n },\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const pageView: Flow.StepExample = {\n title: 'Page view',\n description:\n 'A page view is forwarded to TikTok as a page view event with the source URL in the page context.',\n in: getEvent('page view', {\n id: 'd1e2f3a4b5c60003',\n timestamp: 1700000902000,\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://example.com/docs/',\n },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'page view',\n event_id: 'd1e2f3a4b5c60003',\n timestamp: '2023-11-14T22:28:22.000Z',\n context: {\n page: {\n url: 'https://example.com/docs/',\n },\n },\n properties: {},\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Submit form',\n description:\n 'A newsletter form submission is sent to TikTok as a SubmitForm event with the hashed email in user context.',\n in: getEvent('form submit', {\n id: 'd1e2f3a4b5c60004',\n timestamp: 1700000903000,\n data: { type: 'newsletter' },\n user: { email: 'user@example.com' },\n source: {\n type: 'browser',\n platform: 'web',\n url: 'https://example.com/contact',\n },\n }),\n mapping: {\n name: 'SubmitForm',\n data: {\n map: {\n user_data: {\n map: {\n email: 'user.email',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n pixel_code: 'PIXEL_CODE',\n partner_name: 'walkerOS',\n data: [\n {\n event: 'SubmitForm',\n event_id: 'd1e2f3a4b5c60004',\n timestamp: '2023-11-14T22:28:23.000Z',\n context: {\n user: {\n // sha256('user@example.com')\n email:\n 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514',\n },\n page: {\n url: 'https://example.com/contact',\n },\n },\n properties: {},\n },\n ],\n }),\n HEADERS,\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,WAAW,EACR,OAAO,EACP,IAAI,CAAC,EACL,SAAS,4DAA4D;AAAA,EACxE,aAAa,EACV,OAAO,EACP,IAAI,CAAC,EACL,SAAS,oDAAoD;AAAA,EAChE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,gCAAgC,EAAE,SAAS;AAAA,EAC1E,iBAAiB,EACd,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,WAAW,EACR,MAAM,EAAE,OAAO,CAAC,EAChB;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,WAAW,EACR,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAC7B,SAAS,6DAA6D,EACtE,SAAS;AAAA,EACZ,cAAc,EACX,OAAO,EACP,SAAS,qCAAqC,EAC9C,SAAS;AACd,CAAC;;;AChCD,SAAS,KAAAA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AA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,MACJ,KAAK;AAAA,QACH,WAAW;AAAA,UACT,KAAK;AAAA,YACH,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,MAAM;AAAA,UACJ;AAAA,YACE,OAAO;AAAA,YACP,UAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,cACP,MAAM;AAAA;AAAA,gBAEJ,OACE;AAAA,cACJ;AAAA,cACA,MAAM;AAAA,gBACJ,KAAK;AAAA,cACP;AAAA,YACF;AAAA,YACA,YAAY,CAAC;AAAA,UACf;AAAA,QACF;AAAA,MACF,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;","names":["z","z"]}
@@ -65,6 +65,7 @@ var purchase = {
65
65
  title: "Complete payment",
66
66
  description: "A completed order is sent to the TikTok Events API as a CompletePayment with value, currency, and contents.",
67
67
  in: (0, import_core.getEvent)("order complete", {
68
+ id: "d1e2f3a4b5c60001",
68
69
  timestamp: 17000009e5,
69
70
  data: { id: "ORD-300", total: 249.99, currency: "EUR" },
70
71
  nested: [
@@ -75,9 +76,9 @@ var purchase = {
75
76
  ],
76
77
  user: { id: "user-123", device: "device-456" },
77
78
  source: {
78
- type: "server",
79
- id: "https://shop.example.com/checkout/complete",
80
- previous_id: ""
79
+ type: "browser",
80
+ platform: "web",
81
+ url: "https://shop.example.com/checkout/complete"
81
82
  }
82
83
  }),
83
84
  mapping: {
@@ -120,7 +121,7 @@ var purchase = {
120
121
  data: [
121
122
  {
122
123
  event: "CompletePayment",
123
- event_id: "1700000900000-gr0up-1",
124
+ event_id: "d1e2f3a4b5c60001",
124
125
  timestamp: "2023-11-14T22:28:20.000Z",
125
126
  context: {
126
127
  user: {
@@ -155,6 +156,7 @@ var addToCart = {
155
156
  title: "Add to cart",
156
157
  description: "A product add is sent to TikTok as an AddToCart event with value, currency, and product contents.",
157
158
  in: (0, import_core.getEvent)("product add", {
159
+ id: "d1e2f3a4b5c60002",
158
160
  timestamp: 1700000901e3,
159
161
  data: {
160
162
  id: "SKU-B2",
@@ -174,9 +176,9 @@ var addToCart = {
174
176
  }
175
177
  ],
176
178
  source: {
177
- type: "server",
178
- id: "https://shop.example.com/products/running-shoes",
179
- previous_id: ""
179
+ type: "browser",
180
+ platform: "web",
181
+ url: "https://shop.example.com/products/running-shoes"
180
182
  }
181
183
  }),
182
184
  mapping: {
@@ -213,7 +215,7 @@ var addToCart = {
213
215
  data: [
214
216
  {
215
217
  event: "AddToCart",
216
- event_id: "1700000901000-gr0up-1",
218
+ event_id: "d1e2f3a4b5c60002",
217
219
  timestamp: "2023-11-14T22:28:21.000Z",
218
220
  context: {
219
221
  page: {
@@ -244,11 +246,12 @@ var pageView = {
244
246
  title: "Page view",
245
247
  description: "A page view is forwarded to TikTok as a page view event with the source URL in the page context.",
246
248
  in: (0, import_core.getEvent)("page view", {
249
+ id: "d1e2f3a4b5c60003",
247
250
  timestamp: 1700000902e3,
248
251
  source: {
249
- type: "server",
250
- id: "https://example.com/docs/",
251
- previous_id: ""
252
+ type: "browser",
253
+ platform: "web",
254
+ url: "https://example.com/docs/"
252
255
  }
253
256
  }),
254
257
  mapping: void 0,
@@ -262,7 +265,7 @@ var pageView = {
262
265
  data: [
263
266
  {
264
267
  event: "page view",
265
- event_id: "1700000902000-gr0up-1",
268
+ event_id: "d1e2f3a4b5c60003",
266
269
  timestamp: "2023-11-14T22:28:22.000Z",
267
270
  context: {
268
271
  page: {
@@ -281,13 +284,14 @@ var lead = {
281
284
  title: "Submit form",
282
285
  description: "A newsletter form submission is sent to TikTok as a SubmitForm event with the hashed email in user context.",
283
286
  in: (0, import_core.getEvent)("form submit", {
287
+ id: "d1e2f3a4b5c60004",
284
288
  timestamp: 1700000903e3,
285
289
  data: { type: "newsletter" },
286
290
  user: { email: "user@example.com" },
287
291
  source: {
288
- type: "server",
289
- id: "https://example.com/contact",
290
- previous_id: ""
292
+ type: "browser",
293
+ platform: "web",
294
+ url: "https://example.com/contact"
291
295
  }
292
296
  }),
293
297
  mapping: {
@@ -312,7 +316,7 @@ var lead = {
312
316
  data: [
313
317
  {
314
318
  event: "SubmitForm",
315
- event_id: "1700000903000-gr0up-1",
319
+ event_id: "d1e2f3a4b5c60004",
316
320
  timestamp: "2023-11-14T22:28:23.000Z",
317
321
  context: {
318
322
  user: {
@@ -44,6 +44,7 @@ var purchase = {
44
44
  title: "Complete payment",
45
45
  description: "A completed order is sent to the TikTok Events API as a CompletePayment with value, currency, and contents.",
46
46
  in: getEvent("order complete", {
47
+ id: "d1e2f3a4b5c60001",
47
48
  timestamp: 17000009e5,
48
49
  data: { id: "ORD-300", total: 249.99, currency: "EUR" },
49
50
  nested: [
@@ -54,9 +55,9 @@ var purchase = {
54
55
  ],
55
56
  user: { id: "user-123", device: "device-456" },
56
57
  source: {
57
- type: "server",
58
- id: "https://shop.example.com/checkout/complete",
59
- previous_id: ""
58
+ type: "browser",
59
+ platform: "web",
60
+ url: "https://shop.example.com/checkout/complete"
60
61
  }
61
62
  }),
62
63
  mapping: {
@@ -99,7 +100,7 @@ var purchase = {
99
100
  data: [
100
101
  {
101
102
  event: "CompletePayment",
102
- event_id: "1700000900000-gr0up-1",
103
+ event_id: "d1e2f3a4b5c60001",
103
104
  timestamp: "2023-11-14T22:28:20.000Z",
104
105
  context: {
105
106
  user: {
@@ -134,6 +135,7 @@ var addToCart = {
134
135
  title: "Add to cart",
135
136
  description: "A product add is sent to TikTok as an AddToCart event with value, currency, and product contents.",
136
137
  in: getEvent("product add", {
138
+ id: "d1e2f3a4b5c60002",
137
139
  timestamp: 1700000901e3,
138
140
  data: {
139
141
  id: "SKU-B2",
@@ -153,9 +155,9 @@ var addToCart = {
153
155
  }
154
156
  ],
155
157
  source: {
156
- type: "server",
157
- id: "https://shop.example.com/products/running-shoes",
158
- previous_id: ""
158
+ type: "browser",
159
+ platform: "web",
160
+ url: "https://shop.example.com/products/running-shoes"
159
161
  }
160
162
  }),
161
163
  mapping: {
@@ -192,7 +194,7 @@ var addToCart = {
192
194
  data: [
193
195
  {
194
196
  event: "AddToCart",
195
- event_id: "1700000901000-gr0up-1",
197
+ event_id: "d1e2f3a4b5c60002",
196
198
  timestamp: "2023-11-14T22:28:21.000Z",
197
199
  context: {
198
200
  page: {
@@ -223,11 +225,12 @@ var pageView = {
223
225
  title: "Page view",
224
226
  description: "A page view is forwarded to TikTok as a page view event with the source URL in the page context.",
225
227
  in: getEvent("page view", {
228
+ id: "d1e2f3a4b5c60003",
226
229
  timestamp: 1700000902e3,
227
230
  source: {
228
- type: "server",
229
- id: "https://example.com/docs/",
230
- previous_id: ""
231
+ type: "browser",
232
+ platform: "web",
233
+ url: "https://example.com/docs/"
231
234
  }
232
235
  }),
233
236
  mapping: void 0,
@@ -241,7 +244,7 @@ var pageView = {
241
244
  data: [
242
245
  {
243
246
  event: "page view",
244
- event_id: "1700000902000-gr0up-1",
247
+ event_id: "d1e2f3a4b5c60003",
245
248
  timestamp: "2023-11-14T22:28:22.000Z",
246
249
  context: {
247
250
  page: {
@@ -260,13 +263,14 @@ var lead = {
260
263
  title: "Submit form",
261
264
  description: "A newsletter form submission is sent to TikTok as a SubmitForm event with the hashed email in user context.",
262
265
  in: getEvent("form submit", {
266
+ id: "d1e2f3a4b5c60004",
263
267
  timestamp: 1700000903e3,
264
268
  data: { type: "newsletter" },
265
269
  user: { email: "user@example.com" },
266
270
  source: {
267
- type: "server",
268
- id: "https://example.com/contact",
269
- previous_id: ""
271
+ type: "browser",
272
+ platform: "web",
273
+ url: "https://example.com/contact"
270
274
  }
271
275
  }),
272
276
  mapping: {
@@ -291,7 +295,7 @@ var lead = {
291
295
  data: [
292
296
  {
293
297
  event: "SubmitForm",
294
- event_id: "1700000903000-gr0up-1",
298
+ event_id: "d1e2f3a4b5c60004",
295
299
  timestamp: "2023-11-14T22:28:23.000Z",
296
300
  context: {
297
301
  user: {
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,{DestinationTikTok:()=>types_exports,default:()=>index_default,destinationTikTok:()=>destinationTikTok}),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_core=require("@walkeros/core"),import_server_core2=require("@walkeros/server-core"),import_server_core=require("@walkeros/server-core"),keysToHash=["email","phone_number","external_id"];async function hashUserData(userData,doNotHash=[]){const entries=await Promise.all(Object.entries(userData).map(async([key,value])=>void 0===value?[key,value]:function(key,doNotHash=[]){return keysToHash.includes(key)&&!doNotHash.includes(key)}(key,doNotHash)?[key,await(0,import_server_core.getHashServer)(String(value))]:[key,value]));return Object.fromEntries(entries)}var types_exports={},destinationTikTok={type:"tiktok",config:{},async init({config:partialConfig,logger:logger}){const config=function(partialConfig={},logger){const settings=partialConfig.settings||{},{accessToken:accessToken,pixelCode:pixelCode}=settings;accessToken||logger.throw("Config settings accessToken missing"),pixelCode||logger.throw("Config settings pixelCode missing");const settingsConfig={partner_name:"walkerOS",...settings,accessToken:accessToken,pixelCode:pixelCode};return{...partialConfig,settings:settingsConfig}}(partialConfig,logger);return config},push:async(event,context)=>await async function(event,{config:config,rule:rule,data:data,collector:collector,env:env,logger:logger}){const{accessToken:accessToken,pixelCode:pixelCode,doNotHash:doNotHash,test_event_code:test_event_code,url:url="https://business-api.tiktok.com/open_api/v1.3/event/track/",user_data:user_data,partner_name:partner_name}=config.settings,eventData=(0,import_core.isObject)(data)?data:{},configData=config.data?await(0,import_core.getMappingValue)(event,config.data):{},userDataCustom=user_data?await(0,import_core.getMappingValue)(event,{map:user_data}):{},userData={...(0,import_core.isObject)(configData)&&(0,import_core.isObject)(configData.user_data)?configData.user_data:{},...(0,import_core.isObject)(userDataCustom)?userDataCustom:{},...(0,import_core.isObject)(eventData.user_data)?eventData.user_data:{}},properties={};if((0,import_core.isObject)(eventData))for(const[key,value]of Object.entries(eventData))"user_data"!==key&&(properties[key]=value);const hashedUserData=await hashUserData(userData,doNotHash),context={};Object.keys(hashedUserData).length>0&&(context.user=hashedUserData),context.page={url:event.source.id};const tiktokEvent={event:event.name,event_id:event.id,timestamp:new Date(event.timestamp).toISOString(),context:context,properties:properties},body={pixel_code:pixelCode,partner_name:partner_name,data:[tiktokEvent]};test_event_code&&(body.test_event_code=test_event_code),logger.debug("Calling TikTok Events API",{endpoint:url,method:"POST",eventName:tiktokEvent.event,eventId:tiktokEvent.event_id});const sendServerFn=(null==env?void 0:env.sendServer)||import_server_core2.sendServer,result=await sendServerFn(url,JSON.stringify(body),{headers:{"Access-Token":accessToken,"Content-Type":"application/json"}});logger.debug("TikTok API response",{ok:!(0,import_core.isObject)(result)||result.ok}),(0,import_core.isObject)(result)&&!1===result.ok&&logger.throw(`TikTok API error: ${JSON.stringify(result)}`)}(event,context)},index_default=destinationTikTok;//# 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,{DestinationTikTok:()=>types_exports,default:()=>index_default,destinationTikTok:()=>destinationTikTok}),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_core=require("@walkeros/core"),import_server_core2=require("@walkeros/server-core"),import_server_core=require("@walkeros/server-core"),keysToHash=["email","phone_number","external_id"];async function hashUserData(userData,doNotHash=[]){const entries=await Promise.all(Object.entries(userData).map(async([key,value])=>void 0===value?[key,value]:function(key,doNotHash=[]){return keysToHash.includes(key)&&!doNotHash.includes(key)}(key,doNotHash)?[key,await(0,import_server_core.getHashServer)(String(value))]:[key,value]));return Object.fromEntries(entries)}var types_exports={},destinationTikTok={type:"tiktok",config:{},async init({config:partialConfig,logger:logger}){const config=function(partialConfig={},logger){const settings=partialConfig.settings||{},{accessToken:accessToken,pixelCode:pixelCode}=settings;accessToken||logger.throw("Config settings accessToken missing"),pixelCode||logger.throw("Config settings pixelCode missing");const settingsConfig={partner_name:"walkerOS",...settings,accessToken:accessToken,pixelCode:pixelCode};return{...partialConfig,settings:settingsConfig}}(partialConfig,logger);return config},push:async(event,context)=>await async function(event,{config:config,rule:rule,data:data,collector:collector,env:env,logger:logger}){const{accessToken:accessToken,pixelCode:pixelCode,doNotHash:doNotHash,test_event_code:test_event_code,url:url="https://business-api.tiktok.com/open_api/v1.3/event/track/",user_data:user_data,partner_name:partner_name}=config.settings,eventData=(0,import_core.isObject)(data)?data:{},configData=config.data?await(0,import_core.getMappingValue)(event,config.data,{collector:collector}):{},userDataCustom=user_data?await(0,import_core.getMappingValue)(event,{map:user_data},{collector:collector}):{},userData={...(0,import_core.isObject)(configData)&&(0,import_core.isObject)(configData.user_data)?configData.user_data:{},...(0,import_core.isObject)(userDataCustom)?userDataCustom:{},...(0,import_core.isObject)(eventData.user_data)?eventData.user_data:{}},properties={};if((0,import_core.isObject)(eventData))for(const[key,value]of Object.entries(eventData))"user_data"!==key&&(properties[key]=value);const hashedUserData=await hashUserData(userData,doNotHash),context={};Object.keys(hashedUserData).length>0&&(context.user=hashedUserData),context.page={url:event.source?.url};const tiktokEvent={event:event.name,event_id:event.id,timestamp:new Date(event.timestamp).toISOString(),context:context,properties:properties},body={pixel_code:pixelCode,partner_name:partner_name,data:[tiktokEvent]};test_event_code&&(body.test_event_code=test_event_code),logger.debug("Calling TikTok Events API",{endpoint:url,method:"POST",eventName:tiktokEvent.event,eventId:tiktokEvent.event_id});const sendServerFn=env?.sendServer||import_server_core2.sendServer,result=await sendServerFn(url,JSON.stringify(body),{headers:{"Access-Token":accessToken,"Content-Type":"application/json"}});logger.debug("TikTok API response",{ok:!(0,import_core.isObject)(result)||result.ok}),(0,import_core.isObject)(result)&&!1===result.ok&&logger.throw(`TikTok API error: ${JSON.stringify(result)}`)}(event,context)},index_default=destinationTikTok;//# 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 DestinationTikTok from './types';\n\nexport const destinationTikTok: Destination = {\n type: 'tiktok',\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 destinationTikTok;\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, pixelCode } = settings;\n\n if (!accessToken) logger.throw('Config settings accessToken missing');\n if (!pixelCode) logger.throw('Config settings pixelCode missing');\n\n const settingsConfig: Settings = {\n partner_name: 'walkerOS',\n ...settings,\n accessToken,\n pixelCode,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type {\n EventData,\n EventContext,\n PushFn,\n RequestBody,\n UserData,\n Env,\n} from './types';\nimport { getMappingValue, isObject } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport { hashUserData } from './hash';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, collector, env, logger },\n) {\n const {\n accessToken,\n pixelCode,\n doNotHash,\n test_event_code,\n url = 'https://business-api.tiktok.com/open_api/v1.3/event/track/',\n user_data,\n partner_name,\n } = config.settings as import('./types').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 // Build user data from multiple sources\n const userData: UserData = {\n // Destination config data\n ...(isObject(configData) && isObject(configData.user_data)\n ? (configData.user_data as UserData)\n : {}),\n // Custom user_data from settings\n ...(isObject(userDataCustom) ? (userDataCustom as UserData) : {}),\n // Event mapping data\n ...(isObject(eventData.user_data) ? (eventData.user_data as UserData) : {}),\n };\n\n // Build properties from event data, excluding user_data\n const properties: Record<string, unknown> = {};\n if (isObject(eventData)) {\n for (const [key, value] of Object.entries(eventData)) {\n if (key !== 'user_data') {\n properties[key] = value;\n }\n }\n }\n\n // Hash identity fields\n const hashedUserData = await hashUserData(userData, doNotHash);\n\n // Build context\n const context: EventContext = {};\n\n // Add user data if non-empty\n if (Object.keys(hashedUserData).length > 0) {\n context.user = hashedUserData;\n }\n\n // Page context from event source\n context.page = {\n url: event.source.id,\n };\n\n // Build event data\n const tiktokEvent: EventData = {\n event: event.name,\n event_id: event.id,\n timestamp: new Date(event.timestamp).toISOString(),\n context,\n properties,\n };\n\n // Build request body\n const body: RequestBody = {\n pixel_code: pixelCode,\n partner_name,\n data: [tiktokEvent],\n };\n\n // Test event code\n if (test_event_code) body.test_event_code = test_event_code;\n\n logger.debug('Calling TikTok Events API', {\n endpoint: url,\n method: 'POST',\n eventName: tiktokEvent.event,\n eventId: tiktokEvent.event_id,\n });\n\n const sendServerFn = (env as Env)?.sendServer || sendServer;\n const result = await sendServerFn(url, JSON.stringify(body), {\n headers: {\n 'Access-Token': accessToken,\n 'Content-Type': 'application/json',\n },\n });\n\n logger.debug('TikTok API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`TikTok API error: ${JSON.stringify(result)}`);\n }\n};\n","import type { UserData } from './types';\nimport { getHashServer } from '@walkeros/server-core';\n\nconst keysToHash = ['email', 'phone_number', 'external_id'];\n\nfunction shouldBeHashed(key: string, doNotHash: string[] = []): boolean {\n return keysToHash.includes(key) && !doNotHash.includes(key);\n}\n\nexport async function hashUserData(\n userData: UserData,\n doNotHash: string[] = [],\n): Promise<UserData> {\n const entries = await Promise.all(\n Object.entries(userData).map(async ([key, value]) => {\n if (value === undefined) return [key, value];\n if (shouldBeHashed(key, doNotHash)) {\n return [key, await getHashServer(String(value))];\n }\n return [key, value];\n }),\n );\n\n return Object.fromEntries(entries) as UserData;\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 pixelCode: string;\n accessToken: string;\n url?: string;\n test_event_code?: string;\n doNotHash?: string[];\n user_data?: WalkerOSMapping.Map;\n partner_name?: string;\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// TikTok Events API Request Body\nexport interface RequestBody {\n pixel_code: string;\n partner_name?: string;\n test_event_code?: string;\n data: EventData[];\n}\n\n// Individual event in the data array\nexport interface EventData {\n event: string;\n event_id: string;\n timestamp: string;\n context?: EventContext;\n properties?: Record<string, unknown>;\n}\n\n// Context object within each event\nexport interface EventContext {\n ip?: string;\n user_agent?: string;\n user?: UserData;\n page?: PageContext;\n ad?: AdContext;\n}\n\n// User identity fields\nexport interface UserData {\n email?: string;\n phone_number?: string;\n external_id?: string;\n ttp?: string;\n ttclid?: string;\n locale?: string;\n}\n\n// Page context\nexport interface PageContext {\n url?: string;\n referrer?: string;\n}\n\n// Ad attribution context\nexport interface AdContext {\n callback?: string;\n}\n\n// TikTok API response\nexport interface ResponseBody {\n code: number;\n message: string;\n data?: Record<string, unknown>;\n}\n\n// Standard TikTok event names\nexport type StandardEventName =\n | 'ViewContent'\n | 'ClickButton'\n | 'Search'\n | 'AddToWishlist'\n | 'AddToCart'\n | 'InitiateCheckout'\n | 'AddPaymentInfo'\n | 'CompletePayment'\n | 'PlaceAnOrder'\n | 'Contact'\n | 'Download'\n | 'SubmitForm'\n | 'CompleteRegistration'\n | 'Subscribe'\n | (string & {});\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,UAAU,IAAI;AAEnC,MAAI,CAAC,YAAa,QAAO,MAAM,qCAAqC;AACpE,MAAI,CAAC,UAAW,QAAO,MAAM,mCAAmC;AAEhE,QAAM,iBAA2B;AAAA,IAC/B,cAAc;AAAA,IACd,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,eAAe,UAAU,eAAe;AACtD;;;ACbA,kBAA0C;AAC1C,IAAAA,sBAA2B;;;ACR3B,yBAA8B;AAE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AiC;AAAA,EAC5C,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_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 DestinationTikTok from './types';\n\nexport const destinationTikTok: Destination = {\n type: 'tiktok',\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 destinationTikTok;\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, pixelCode } = settings;\n\n if (!accessToken) logger.throw('Config settings accessToken missing');\n if (!pixelCode) logger.throw('Config settings pixelCode missing');\n\n const settingsConfig: Settings = {\n partner_name: 'walkerOS',\n ...settings,\n accessToken,\n pixelCode,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type {\n EventData,\n EventContext,\n PushFn,\n RequestBody,\n UserData,\n Env,\n} from './types';\nimport { getMappingValue, isObject } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport { hashUserData } from './hash';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, collector, env, logger },\n) {\n const {\n accessToken,\n pixelCode,\n doNotHash,\n test_event_code,\n url = 'https://business-api.tiktok.com/open_api/v1.3/event/track/',\n user_data,\n partner_name,\n } = config.settings as import('./types').Settings;\n\n const eventData = isObject(data) ? data : {};\n const configData = config.data\n ? await getMappingValue(event, config.data, { collector })\n : {};\n const userDataCustom = user_data\n ? await getMappingValue(event, { map: user_data }, { collector })\n : {};\n\n // Build user data from multiple sources\n const userData: UserData = {\n // Destination config data\n ...(isObject(configData) && isObject(configData.user_data)\n ? (configData.user_data as UserData)\n : {}),\n // Custom user_data from settings\n ...(isObject(userDataCustom) ? (userDataCustom as UserData) : {}),\n // Event mapping data\n ...(isObject(eventData.user_data) ? (eventData.user_data as UserData) : {}),\n };\n\n // Build properties from event data, excluding user_data\n const properties: Record<string, unknown> = {};\n if (isObject(eventData)) {\n for (const [key, value] of Object.entries(eventData)) {\n if (key !== 'user_data') {\n properties[key] = value;\n }\n }\n }\n\n // Hash identity fields\n const hashedUserData = await hashUserData(userData, doNotHash);\n\n // Build context\n const context: EventContext = {};\n\n // Add user data if non-empty\n if (Object.keys(hashedUserData).length > 0) {\n context.user = hashedUserData;\n }\n\n // Page context from event source\n context.page = {\n url: event.source?.url,\n };\n\n // Build event data\n const tiktokEvent: EventData = {\n event: event.name,\n event_id: event.id,\n timestamp: new Date(event.timestamp).toISOString(),\n context,\n properties,\n };\n\n // Build request body\n const body: RequestBody = {\n pixel_code: pixelCode,\n partner_name,\n data: [tiktokEvent],\n };\n\n // Test event code\n if (test_event_code) body.test_event_code = test_event_code;\n\n logger.debug('Calling TikTok Events API', {\n endpoint: url,\n method: 'POST',\n eventName: tiktokEvent.event,\n eventId: tiktokEvent.event_id,\n });\n\n const sendServerFn = (env as Env)?.sendServer || sendServer;\n const result = await sendServerFn(url, JSON.stringify(body), {\n headers: {\n 'Access-Token': accessToken,\n 'Content-Type': 'application/json',\n },\n });\n\n logger.debug('TikTok API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`TikTok API error: ${JSON.stringify(result)}`);\n }\n};\n","import type { UserData } from './types';\nimport { getHashServer } from '@walkeros/server-core';\n\nconst keysToHash = ['email', 'phone_number', 'external_id'];\n\nfunction shouldBeHashed(key: string, doNotHash: string[] = []): boolean {\n return keysToHash.includes(key) && !doNotHash.includes(key);\n}\n\nexport async function hashUserData(\n userData: UserData,\n doNotHash: string[] = [],\n): Promise<UserData> {\n const entries = await Promise.all(\n Object.entries(userData).map(async ([key, value]) => {\n if (value === undefined) return [key, value];\n if (shouldBeHashed(key, doNotHash)) {\n return [key, await getHashServer(String(value))];\n }\n return [key, value];\n }),\n );\n\n return Object.fromEntries(entries) as UserData;\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 pixelCode: string;\n accessToken: string;\n url?: string;\n test_event_code?: string;\n doNotHash?: string[];\n user_data?: WalkerOSMapping.Map;\n partner_name?: string;\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// TikTok Events API Request Body\nexport interface RequestBody {\n pixel_code: string;\n partner_name?: string;\n test_event_code?: string;\n data: EventData[];\n}\n\n// Individual event in the data array\nexport interface EventData {\n event: string;\n event_id: string;\n timestamp: string;\n context?: EventContext;\n properties?: Record<string, unknown>;\n}\n\n// Context object within each event\nexport interface EventContext {\n ip?: string;\n user_agent?: string;\n user?: UserData;\n page?: PageContext;\n ad?: AdContext;\n}\n\n// User identity fields\nexport interface UserData {\n email?: string;\n phone_number?: string;\n external_id?: string;\n ttp?: string;\n ttclid?: string;\n locale?: string;\n}\n\n// Page context\nexport interface PageContext {\n url?: string;\n referrer?: string;\n}\n\n// Ad attribution context\nexport interface AdContext {\n callback?: string;\n}\n\n// TikTok API response\nexport interface ResponseBody {\n code: number;\n message: string;\n data?: Record<string, unknown>;\n}\n\n// Standard TikTok event names\nexport type StandardEventName =\n | 'ViewContent'\n | 'ClickButton'\n | 'Search'\n | 'AddToWishlist'\n | 'AddToCart'\n | 'InitiateCheckout'\n | 'AddPaymentInfo'\n | 'CompletePayment'\n | 'PlaceAnOrder'\n | 'Contact'\n | 'Download'\n | 'SubmitForm'\n | 'CompleteRegistration'\n | 'Subscribe'\n | (string & {});\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,UAAU,IAAI;AAEnC,MAAI,CAAC,YAAa,QAAO,MAAM,qCAAqC;AACpE,MAAI,CAAC,UAAW,QAAO,MAAM,mCAAmC;AAEhE,QAAM,iBAA2B;AAAA,IAC/B,cAAc;AAAA,IACd,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,eAAe,UAAU,eAAe;AACtD;;;ACbA,kBAA0C;AAC1C,IAAAA,sBAA2B;;;ACR3B,yBAA8B;AAE9B,IAAM,aAAa,CAAC,SAAS,gBAAgB,aAAa;AAE1D,SAAS,eAAe,KAAa,YAAsB,CAAC,GAAY;AACtE,SAAO,WAAW,SAAS,GAAG,KAAK,CAAC,UAAU,SAAS,GAAG;AAC5D;AAEA,eAAsB,aACpB,UACA,YAAsB,CAAC,GACJ;AACnB,QAAM,UAAU,MAAM,QAAQ;A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SAAS;AACzB,WAAO,MAAM,KAAK,OAAO,OAAO;AAAA,EAClC;AACF;AAEA,IAAO,gBAAQ;","names":["import_server_core"]}
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{getMappingValue,isObject}from"@walkeros/core";import{sendServer}from"@walkeros/server-core";import{getHashServer}from"@walkeros/server-core";var keysToHash=["email","phone_number","external_id"];async function hashUserData(userData,doNotHash=[]){const entries=await Promise.all(Object.entries(userData).map(async([key,value])=>void 0===value?[key,value]:function(key,doNotHash=[]){return keysToHash.includes(key)&&!doNotHash.includes(key)}(key,doNotHash)?[key,await getHashServer(String(value))]:[key,value]));return Object.fromEntries(entries)}var types_exports={},destinationTikTok={type:"tiktok",config:{},async init({config:partialConfig,logger:logger}){const config=function(partialConfig={},logger){const settings=partialConfig.settings||{},{accessToken:accessToken,pixelCode:pixelCode}=settings;accessToken||logger.throw("Config settings accessToken missing"),pixelCode||logger.throw("Config settings pixelCode missing");const settingsConfig={partner_name:"walkerOS",...settings,accessToken:accessToken,pixelCode:pixelCode};return{...partialConfig,settings:settingsConfig}}(partialConfig,logger);return config},push:async(event,context)=>await async function(event,{config:config,rule:rule,data:data,collector:collector,env:env,logger:logger}){const{accessToken:accessToken,pixelCode:pixelCode,doNotHash:doNotHash,test_event_code:test_event_code,url:url="https://business-api.tiktok.com/open_api/v1.3/event/track/",user_data:user_data,partner_name:partner_name}=config.settings,eventData=isObject(data)?data:{},configData=config.data?await getMappingValue(event,config.data):{},userDataCustom=user_data?await getMappingValue(event,{map:user_data}):{},userData={...isObject(configData)&&isObject(configData.user_data)?configData.user_data:{},...isObject(userDataCustom)?userDataCustom:{},...isObject(eventData.user_data)?eventData.user_data:{}},properties={};if(isObject(eventData))for(const[key,value]of Object.entries(eventData))"user_data"!==key&&(properties[key]=value);const hashedUserData=await hashUserData(userData,doNotHash),context={};Object.keys(hashedUserData).length>0&&(context.user=hashedUserData),context.page={url:event.source.id};const tiktokEvent={event:event.name,event_id:event.id,timestamp:new Date(event.timestamp).toISOString(),context:context,properties:properties},body={pixel_code:pixelCode,partner_name:partner_name,data:[tiktokEvent]};test_event_code&&(body.test_event_code=test_event_code),logger.debug("Calling TikTok Events API",{endpoint:url,method:"POST",eventName:tiktokEvent.event,eventId:tiktokEvent.event_id});const sendServerFn=(null==env?void 0:env.sendServer)||sendServer,result=await sendServerFn(url,JSON.stringify(body),{headers:{"Access-Token":accessToken,"Content-Type":"application/json"}});logger.debug("TikTok API response",{ok:!isObject(result)||result.ok}),isObject(result)&&!1===result.ok&&logger.throw(`TikTok API error: ${JSON.stringify(result)}`)}(event,context)},index_default=destinationTikTok;export{types_exports as DestinationTikTok,index_default as default,destinationTikTok};//# sourceMappingURL=index.mjs.map
1
+ import{getMappingValue,isObject}from"@walkeros/core";import{sendServer}from"@walkeros/server-core";import{getHashServer}from"@walkeros/server-core";var keysToHash=["email","phone_number","external_id"];async function hashUserData(userData,doNotHash=[]){const entries=await Promise.all(Object.entries(userData).map(async([key,value])=>void 0===value?[key,value]:function(key,doNotHash=[]){return keysToHash.includes(key)&&!doNotHash.includes(key)}(key,doNotHash)?[key,await getHashServer(String(value))]:[key,value]));return Object.fromEntries(entries)}var types_exports={},destinationTikTok={type:"tiktok",config:{},async init({config:partialConfig,logger:logger}){const config=function(partialConfig={},logger){const settings=partialConfig.settings||{},{accessToken:accessToken,pixelCode:pixelCode}=settings;accessToken||logger.throw("Config settings accessToken missing"),pixelCode||logger.throw("Config settings pixelCode missing");const settingsConfig={partner_name:"walkerOS",...settings,accessToken:accessToken,pixelCode:pixelCode};return{...partialConfig,settings:settingsConfig}}(partialConfig,logger);return config},push:async(event,context)=>await async function(event,{config:config,rule:rule,data:data,collector:collector,env:env,logger:logger}){const{accessToken:accessToken,pixelCode:pixelCode,doNotHash:doNotHash,test_event_code:test_event_code,url:url="https://business-api.tiktok.com/open_api/v1.3/event/track/",user_data:user_data,partner_name:partner_name}=config.settings,eventData=isObject(data)?data:{},configData=config.data?await getMappingValue(event,config.data,{collector:collector}):{},userDataCustom=user_data?await getMappingValue(event,{map:user_data},{collector:collector}):{},userData={...isObject(configData)&&isObject(configData.user_data)?configData.user_data:{},...isObject(userDataCustom)?userDataCustom:{},...isObject(eventData.user_data)?eventData.user_data:{}},properties={};if(isObject(eventData))for(const[key,value]of Object.entries(eventData))"user_data"!==key&&(properties[key]=value);const hashedUserData=await hashUserData(userData,doNotHash),context={};Object.keys(hashedUserData).length>0&&(context.user=hashedUserData),context.page={url:event.source?.url};const tiktokEvent={event:event.name,event_id:event.id,timestamp:new Date(event.timestamp).toISOString(),context:context,properties:properties},body={pixel_code:pixelCode,partner_name:partner_name,data:[tiktokEvent]};test_event_code&&(body.test_event_code=test_event_code),logger.debug("Calling TikTok Events API",{endpoint:url,method:"POST",eventName:tiktokEvent.event,eventId:tiktokEvent.event_id});const sendServerFn=env?.sendServer||sendServer,result=await sendServerFn(url,JSON.stringify(body),{headers:{"Access-Token":accessToken,"Content-Type":"application/json"}});logger.debug("TikTok API response",{ok:!isObject(result)||result.ok}),isObject(result)&&!1===result.ok&&logger.throw(`TikTok API error: ${JSON.stringify(result)}`)}(event,context)},index_default=destinationTikTok;export{types_exports as DestinationTikTok,index_default as default,destinationTikTok};//# 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, pixelCode } = settings;\n\n if (!accessToken) logger.throw('Config settings accessToken missing');\n if (!pixelCode) logger.throw('Config settings pixelCode missing');\n\n const settingsConfig: Settings = {\n partner_name: 'walkerOS',\n ...settings,\n accessToken,\n pixelCode,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type {\n EventData,\n EventContext,\n PushFn,\n RequestBody,\n UserData,\n Env,\n} from './types';\nimport { getMappingValue, isObject } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport { hashUserData } from './hash';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, collector, env, logger },\n) {\n const {\n accessToken,\n pixelCode,\n doNotHash,\n test_event_code,\n url = 'https://business-api.tiktok.com/open_api/v1.3/event/track/',\n user_data,\n partner_name,\n } = config.settings as import('./types').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 // Build user data from multiple sources\n const userData: UserData = {\n // Destination config data\n ...(isObject(configData) && isObject(configData.user_data)\n ? (configData.user_data as UserData)\n : {}),\n // Custom user_data from settings\n ...(isObject(userDataCustom) ? (userDataCustom as UserData) : {}),\n // Event mapping data\n ...(isObject(eventData.user_data) ? (eventData.user_data as UserData) : {}),\n };\n\n // Build properties from event data, excluding user_data\n const properties: Record<string, unknown> = {};\n if (isObject(eventData)) {\n for (const [key, value] of Object.entries(eventData)) {\n if (key !== 'user_data') {\n properties[key] = value;\n }\n }\n }\n\n // Hash identity fields\n const hashedUserData = await hashUserData(userData, doNotHash);\n\n // Build context\n const context: EventContext = {};\n\n // Add user data if non-empty\n if (Object.keys(hashedUserData).length > 0) {\n context.user = hashedUserData;\n }\n\n // Page context from event source\n context.page = {\n url: event.source.id,\n };\n\n // Build event data\n const tiktokEvent: EventData = {\n event: event.name,\n event_id: event.id,\n timestamp: new Date(event.timestamp).toISOString(),\n context,\n properties,\n };\n\n // Build request body\n const body: RequestBody = {\n pixel_code: pixelCode,\n partner_name,\n data: [tiktokEvent],\n };\n\n // Test event code\n if (test_event_code) body.test_event_code = test_event_code;\n\n logger.debug('Calling TikTok Events API', {\n endpoint: url,\n method: 'POST',\n eventName: tiktokEvent.event,\n eventId: tiktokEvent.event_id,\n });\n\n const sendServerFn = (env as Env)?.sendServer || sendServer;\n const result = await sendServerFn(url, JSON.stringify(body), {\n headers: {\n 'Access-Token': accessToken,\n 'Content-Type': 'application/json',\n },\n });\n\n logger.debug('TikTok API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`TikTok API error: ${JSON.stringify(result)}`);\n }\n};\n","import type { UserData } from './types';\nimport { getHashServer } from '@walkeros/server-core';\n\nconst keysToHash = ['email', 'phone_number', 'external_id'];\n\nfunction shouldBeHashed(key: string, doNotHash: string[] = []): boolean {\n return keysToHash.includes(key) && !doNotHash.includes(key);\n}\n\nexport async function hashUserData(\n userData: UserData,\n doNotHash: string[] = [],\n): Promise<UserData> {\n const entries = await Promise.all(\n Object.entries(userData).map(async ([key, value]) => {\n if (value === undefined) return [key, value];\n if (shouldBeHashed(key, doNotHash)) {\n return [key, await getHashServer(String(value))];\n }\n return [key, value];\n }),\n );\n\n return Object.fromEntries(entries) as UserData;\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 pixelCode: string;\n accessToken: string;\n url?: string;\n test_event_code?: string;\n doNotHash?: string[];\n user_data?: WalkerOSMapping.Map;\n partner_name?: string;\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// TikTok Events API Request Body\nexport interface RequestBody {\n pixel_code: string;\n partner_name?: string;\n test_event_code?: string;\n data: EventData[];\n}\n\n// Individual event in the data array\nexport interface EventData {\n event: string;\n event_id: string;\n timestamp: string;\n context?: EventContext;\n properties?: Record<string, unknown>;\n}\n\n// Context object within each event\nexport interface EventContext {\n ip?: string;\n user_agent?: string;\n user?: UserData;\n page?: PageContext;\n ad?: AdContext;\n}\n\n// User identity fields\nexport interface UserData {\n email?: string;\n phone_number?: string;\n external_id?: string;\n ttp?: string;\n ttclid?: string;\n locale?: string;\n}\n\n// Page context\nexport interface PageContext {\n url?: string;\n referrer?: string;\n}\n\n// Ad attribution context\nexport interface AdContext {\n callback?: string;\n}\n\n// TikTok API response\nexport interface ResponseBody {\n code: number;\n message: string;\n data?: Record<string, unknown>;\n}\n\n// Standard TikTok event names\nexport type StandardEventName =\n | 'ViewContent'\n | 'ClickButton'\n | 'Search'\n | 'AddToWishlist'\n | 'AddToCart'\n | 'InitiateCheckout'\n | 'AddPaymentInfo'\n | 'CompletePayment'\n | 'PlaceAnOrder'\n | 'Contact'\n | 'Download'\n | 'SubmitForm'\n | 'CompleteRegistration'\n | 'Subscribe'\n | (string & {});\n","import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationTikTok from './types';\n\nexport const destinationTikTok: Destination = {\n type: 'tiktok',\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 destinationTikTok;\n"],"mappings":";AAGO,SAAS,UACd,gBAA+B,CAAC,GAChC,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,aAAa,UAAU,IAAI;AAEnC,MAAI,CAAC,YAAa,QAAO,MAAM,qCAAqC;AACpE,MAAI,CAAC,UAAW,QAAO,MAAM,mCAAmC;AAEhE,QAAM,iBAA2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,IAAI,OAAO,KAAK;AAAA,EACrC,CAAC;AAED,MAAI,SAAS,MAAM,KAAK,OAAO,OAAO,OAAO;AAC3C,WAAO,MAAM,qBAAqB,KAAK,UAAU,MAAM,CAAC,EAAE;AAAA,EAC5D;AACF;;;AEjHA;;;ACOO,IAAM,oBAAiC;AAAA,EAC5C,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":[]}
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, pixelCode } = settings;\n\n if (!accessToken) logger.throw('Config settings accessToken missing');\n if (!pixelCode) logger.throw('Config settings pixelCode missing');\n\n const settingsConfig: Settings = {\n partner_name: 'walkerOS',\n ...settings,\n accessToken,\n pixelCode,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type {\n EventData,\n EventContext,\n PushFn,\n RequestBody,\n UserData,\n Env,\n} from './types';\nimport { getMappingValue, isObject } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport { hashUserData } from './hash';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, collector, env, logger },\n) {\n const {\n accessToken,\n pixelCode,\n doNotHash,\n test_event_code,\n url = 'https://business-api.tiktok.com/open_api/v1.3/event/track/',\n user_data,\n partner_name,\n } = config.settings as import('./types').Settings;\n\n const eventData = isObject(data) ? data : {};\n const configData = config.data\n ? await getMappingValue(event, config.data, { collector })\n : {};\n const userDataCustom = user_data\n ? await getMappingValue(event, { map: user_data }, { collector })\n : {};\n\n // Build user data from multiple sources\n const userData: UserData = {\n // Destination config data\n ...(isObject(configData) && isObject(configData.user_data)\n ? (configData.user_data as UserData)\n : {}),\n // Custom user_data from settings\n ...(isObject(userDataCustom) ? (userDataCustom as UserData) : {}),\n // Event mapping data\n ...(isObject(eventData.user_data) ? (eventData.user_data as UserData) : {}),\n };\n\n // Build properties from event data, excluding user_data\n const properties: Record<string, unknown> = {};\n if (isObject(eventData)) {\n for (const [key, value] of Object.entries(eventData)) {\n if (key !== 'user_data') {\n properties[key] = value;\n }\n }\n }\n\n // Hash identity fields\n const hashedUserData = await hashUserData(userData, doNotHash);\n\n // Build context\n const context: EventContext = {};\n\n // Add user data if non-empty\n if (Object.keys(hashedUserData).length > 0) {\n context.user = hashedUserData;\n }\n\n // Page context from event source\n context.page = {\n url: event.source?.url,\n };\n\n // Build event data\n const tiktokEvent: EventData = {\n event: event.name,\n event_id: event.id,\n timestamp: new Date(event.timestamp).toISOString(),\n context,\n properties,\n };\n\n // Build request body\n const body: RequestBody = {\n pixel_code: pixelCode,\n partner_name,\n data: [tiktokEvent],\n };\n\n // Test event code\n if (test_event_code) body.test_event_code = test_event_code;\n\n logger.debug('Calling TikTok Events API', {\n endpoint: url,\n method: 'POST',\n eventName: tiktokEvent.event,\n eventId: tiktokEvent.event_id,\n });\n\n const sendServerFn = (env as Env)?.sendServer || sendServer;\n const result = await sendServerFn(url, JSON.stringify(body), {\n headers: {\n 'Access-Token': accessToken,\n 'Content-Type': 'application/json',\n },\n });\n\n logger.debug('TikTok API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`TikTok API error: ${JSON.stringify(result)}`);\n }\n};\n","import type { UserData } from './types';\nimport { getHashServer } from '@walkeros/server-core';\n\nconst keysToHash = ['email', 'phone_number', 'external_id'];\n\nfunction shouldBeHashed(key: string, doNotHash: string[] = []): boolean {\n return keysToHash.includes(key) && !doNotHash.includes(key);\n}\n\nexport async function hashUserData(\n userData: UserData,\n doNotHash: string[] = [],\n): Promise<UserData> {\n const entries = await Promise.all(\n Object.entries(userData).map(async ([key, value]) => {\n if (value === undefined) return [key, value];\n if (shouldBeHashed(key, doNotHash)) {\n return [key, await getHashServer(String(value))];\n }\n return [key, value];\n }),\n );\n\n return Object.fromEntries(entries) as UserData;\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 pixelCode: string;\n accessToken: string;\n url?: string;\n test_event_code?: string;\n doNotHash?: string[];\n user_data?: WalkerOSMapping.Map;\n partner_name?: string;\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// TikTok Events API Request Body\nexport interface RequestBody {\n pixel_code: string;\n partner_name?: string;\n test_event_code?: string;\n data: EventData[];\n}\n\n// Individual event in the data array\nexport interface EventData {\n event: string;\n event_id: string;\n timestamp: string;\n context?: EventContext;\n properties?: Record<string, unknown>;\n}\n\n// Context object within each event\nexport interface EventContext {\n ip?: string;\n user_agent?: string;\n user?: UserData;\n page?: PageContext;\n ad?: AdContext;\n}\n\n// User identity fields\nexport interface UserData {\n email?: string;\n phone_number?: string;\n external_id?: string;\n ttp?: string;\n ttclid?: string;\n locale?: string;\n}\n\n// Page context\nexport interface PageContext {\n url?: string;\n referrer?: string;\n}\n\n// Ad attribution context\nexport interface AdContext {\n callback?: string;\n}\n\n// TikTok API response\nexport interface ResponseBody {\n code: number;\n message: string;\n data?: Record<string, unknown>;\n}\n\n// Standard TikTok event names\nexport type StandardEventName =\n | 'ViewContent'\n | 'ClickButton'\n | 'Search'\n | 'AddToWishlist'\n | 'AddToCart'\n | 'InitiateCheckout'\n | 'AddPaymentInfo'\n | 'CompletePayment'\n | 'PlaceAnOrder'\n | 'Contact'\n | 'Download'\n | 'SubmitForm'\n | 'CompleteRegistration'\n | 'Subscribe'\n | (string & {});\n","import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationTikTok from './types';\n\nexport const destinationTikTok: Destination = {\n type: 'tiktok',\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 destinationTikTok;\n"],"mappings":";AAGO,SAAS,UACd,gBAA+B,CAAC,GAChC,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,aAAa,UAAU,IAAI;AAEnC,MAAI,CAAC,YAAa,QAAO,MAAM,qCAAqC;AACpE,MAAI,CAAC,UAAW,QAAO,MAAM,mCAAmC;AAEhE,QAAM,iBAA2B;AAAA,IAC/B,cAAc;AAAA,IACd,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,eAAe,UAAU,eAAe;AACtD;;;ACbA,SAAS,iBAAiB,gBAAgB;AAC1C,SAAS,kBAAkB;;;ACR3B,SAAS,qBAAqB;AAE9B,IAAM,aAAa,CAAC,SAAS,gBAAgB,aAAa;AAE1D,SAAS,eAAe,KAAa,YAAsB,CAAC,GAAY;AACtE,SAAO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AE,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":[]}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$meta": {
3
3
  "package": "@walkeros/server-destination-tiktok",
4
- "version": "3.4.2",
4
+ "version": "4.0.0-next-1777882869103",
5
5
  "type": "destination",
6
6
  "platform": [
7
7
  "server"
@@ -122,22 +122,16 @@
122
122
  "consent": {
123
123
  "functional": true
124
124
  },
125
- "id": "1700000901000-gr0up-1",
125
+ "id": "d1e2f3a4b5c60002",
126
126
  "trigger": "click",
127
127
  "entity": "product",
128
128
  "action": "add",
129
129
  "timestamp": 1700000901000,
130
130
  "timing": 3.14,
131
- "group": "gr0up",
132
- "count": 1,
133
- "version": {
134
- "source": "3.4.2",
135
- "tagging": 1
136
- },
137
131
  "source": {
138
- "type": "server",
139
- "id": "https://shop.example.com/products/running-shoes",
140
- "previous_id": ""
132
+ "type": "browser",
133
+ "platform": "web",
134
+ "url": "https://shop.example.com/products/running-shoes"
141
135
  }
142
136
  },
143
137
  "mapping": {
@@ -156,7 +150,7 @@
156
150
  "nested",
157
151
  {
158
152
  "condition": {
159
- "$code": "e=>k(e)&&\"product\"===e.entity"
153
+ "$code": "e=>y(e)&&\"product\"===e.entity"
160
154
  },
161
155
  "map": {
162
156
  "content_id": "data.id",
@@ -177,7 +171,7 @@
177
171
  [
178
172
  "sendServer",
179
173
  "https://business-api.tiktok.com/open_api/v1.3/event/track/",
180
- "{\"pixel_code\":\"PIXEL_CODE\",\"partner_name\":\"walkerOS\",\"data\":[{\"event\":\"AddToCart\",\"event_id\":\"1700000901000-gr0up-1\",\"timestamp\":\"2023-11-14T22:28:21.000Z\",\"context\":{\"page\":{\"url\":\"https://shop.example.com/products/running-shoes\"}},\"properties\":{\"content_type\":\"product\",\"value\":89.99,\"currency\":\"EUR\",\"contents\":[{\"content_id\":\"SKU-B2\",\"content_name\":\"Running Shoes\",\"quantity\":1,\"price\":89.99}]}}]}",
174
+ "{\"pixel_code\":\"PIXEL_CODE\",\"partner_name\":\"walkerOS\",\"data\":[{\"event\":\"AddToCart\",\"event_id\":\"d1e2f3a4b5c60002\",\"timestamp\":\"2023-11-14T22:28:21.000Z\",\"context\":{\"page\":{\"url\":\"https://shop.example.com/products/running-shoes\"}},\"properties\":{\"content_type\":\"product\",\"value\":89.99,\"currency\":\"EUR\",\"contents\":[{\"content_id\":\"SKU-B2\",\"content_name\":\"Running Shoes\",\"quantity\":1,\"price\":89.99}]}}]}",
181
175
  {
182
176
  "headers": {
183
177
  "Access-Token": "s3cr3t",
@@ -215,35 +209,22 @@
215
209
  "entity": "child",
216
210
  "data": {
217
211
  "is": "subordinated"
218
- },
219
- "nested": [],
220
- "context": {
221
- "element": [
222
- "child",
223
- 0
224
- ]
225
212
  }
226
213
  }
227
214
  ],
228
215
  "consent": {
229
216
  "functional": true
230
217
  },
231
- "id": "1700000903000-gr0up-1",
218
+ "id": "d1e2f3a4b5c60004",
232
219
  "trigger": "test",
233
220
  "entity": "form",
234
221
  "action": "submit",
235
222
  "timestamp": 1700000903000,
236
223
  "timing": 3.14,
237
- "group": "gr0up",
238
- "count": 1,
239
- "version": {
240
- "source": "3.4.2",
241
- "tagging": 1
242
- },
243
224
  "source": {
244
- "type": "server",
245
- "id": "https://example.com/contact",
246
- "previous_id": ""
225
+ "type": "browser",
226
+ "platform": "web",
227
+ "url": "https://example.com/contact"
247
228
  }
248
229
  },
249
230
  "mapping": {
@@ -262,7 +243,7 @@
262
243
  [
263
244
  "sendServer",
264
245
  "https://business-api.tiktok.com/open_api/v1.3/event/track/",
265
- "{\"pixel_code\":\"PIXEL_CODE\",\"partner_name\":\"walkerOS\",\"data\":[{\"event\":\"SubmitForm\",\"event_id\":\"1700000903000-gr0up-1\",\"timestamp\":\"2023-11-14T22:28:23.000Z\",\"context\":{\"user\":{\"email\":\"b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514\"},\"page\":{\"url\":\"https://example.com/contact\"}},\"properties\":{}}]}",
246
+ "{\"pixel_code\":\"PIXEL_CODE\",\"partner_name\":\"walkerOS\",\"data\":[{\"event\":\"SubmitForm\",\"event_id\":\"d1e2f3a4b5c60004\",\"timestamp\":\"2023-11-14T22:28:23.000Z\",\"context\":{\"user\":{\"email\":\"b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514\"},\"page\":{\"url\":\"https://example.com/contact\"}},\"properties\":{}}]}",
266
247
  {
267
248
  "headers": {
268
249
  "Access-Token": "s3cr3t",
@@ -307,42 +288,29 @@
307
288
  "entity": "child",
308
289
  "data": {
309
290
  "is": "subordinated"
310
- },
311
- "nested": [],
312
- "context": {
313
- "element": [
314
- "child",
315
- 0
316
- ]
317
291
  }
318
292
  }
319
293
  ],
320
294
  "consent": {
321
295
  "functional": true
322
296
  },
323
- "id": "1700000902000-gr0up-1",
297
+ "id": "d1e2f3a4b5c60003",
324
298
  "trigger": "load",
325
299
  "entity": "page",
326
300
  "action": "view",
327
301
  "timestamp": 1700000902000,
328
302
  "timing": 3.14,
329
- "group": "gr0up",
330
- "count": 1,
331
- "version": {
332
- "source": "3.4.2",
333
- "tagging": 1
334
- },
335
303
  "source": {
336
- "type": "server",
337
- "id": "https://example.com/docs/",
338
- "previous_id": ""
304
+ "type": "browser",
305
+ "platform": "web",
306
+ "url": "https://example.com/docs/"
339
307
  }
340
308
  },
341
309
  "out": [
342
310
  [
343
311
  "sendServer",
344
312
  "https://business-api.tiktok.com/open_api/v1.3/event/track/",
345
- "{\"pixel_code\":\"PIXEL_CODE\",\"partner_name\":\"walkerOS\",\"data\":[{\"event\":\"page view\",\"event_id\":\"1700000902000-gr0up-1\",\"timestamp\":\"2023-11-14T22:28:22.000Z\",\"context\":{\"page\":{\"url\":\"https://example.com/docs/\"}},\"properties\":{}}]}",
313
+ "{\"pixel_code\":\"PIXEL_CODE\",\"partner_name\":\"walkerOS\",\"data\":[{\"event\":\"page view\",\"event_id\":\"d1e2f3a4b5c60003\",\"timestamp\":\"2023-11-14T22:28:22.000Z\",\"context\":{\"page\":{\"url\":\"https://example.com/docs/\"}},\"properties\":{}}]}",
346
314
  {
347
315
  "headers": {
348
316
  "Access-Token": "s3cr3t",
@@ -392,22 +360,16 @@
392
360
  "consent": {
393
361
  "functional": true
394
362
  },
395
- "id": "1700000900000-gr0up-1",
363
+ "id": "d1e2f3a4b5c60001",
396
364
  "trigger": "load",
397
365
  "entity": "order",
398
366
  "action": "complete",
399
367
  "timestamp": 1700000900000,
400
368
  "timing": 3.14,
401
- "group": "gr0up",
402
- "count": 1,
403
- "version": {
404
- "source": "3.4.2",
405
- "tagging": 1
406
- },
407
369
  "source": {
408
- "type": "server",
409
- "id": "https://shop.example.com/checkout/complete",
410
- "previous_id": ""
370
+ "type": "browser",
371
+ "platform": "web",
372
+ "url": "https://shop.example.com/checkout/complete"
411
373
  }
412
374
  },
413
375
  "mapping": {
@@ -428,7 +390,7 @@
428
390
  "nested",
429
391
  {
430
392
  "condition": {
431
- "$code": "e=>k(e)&&\"product\"===e.entity"
393
+ "$code": "e=>y(e)&&\"product\"===e.entity"
432
394
  },
433
395
  "map": {
434
396
  "content_id": "data.id",
@@ -454,7 +416,7 @@
454
416
  [
455
417
  "sendServer",
456
418
  "https://business-api.tiktok.com/open_api/v1.3/event/track/",
457
- "{\"pixel_code\":\"PIXEL_CODE\",\"partner_name\":\"walkerOS\",\"data\":[{\"event\":\"CompletePayment\",\"event_id\":\"1700000900000-gr0up-1\",\"timestamp\":\"2023-11-14T22:28:20.000Z\",\"context\":{\"user\":{\"external_id\":\"fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8\"},\"page\":{\"url\":\"https://shop.example.com/checkout/complete\"}},\"properties\":{\"value\":249.99,\"currency\":\"EUR\",\"order_id\":\"ORD-300\",\"content_type\":\"product\",\"contents\":[{\"content_id\":\"SKU-A1\",\"content_name\":\"Widget Pro\",\"quantity\":2,\"price\":124.99}]}}]}",
419
+ "{\"pixel_code\":\"PIXEL_CODE\",\"partner_name\":\"walkerOS\",\"data\":[{\"event\":\"CompletePayment\",\"event_id\":\"d1e2f3a4b5c60001\",\"timestamp\":\"2023-11-14T22:28:20.000Z\",\"context\":{\"user\":{\"external_id\":\"fcdec6df4d44dbc637c7c5b58efface52a7f8a88535423430255be0bb89bedd8\"},\"page\":{\"url\":\"https://shop.example.com/checkout/complete\"}},\"properties\":{\"value\":249.99,\"currency\":\"EUR\",\"order_id\":\"ORD-300\",\"content_type\":\"product\",\"contents\":[{\"content_id\":\"SKU-A1\",\"content_name\":\"Widget Pro\",\"quantity\":2,\"price\":124.99}]}}]}",
458
420
  {
459
421
  "headers": {
460
422
  "Access-Token": "s3cr3t",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@walkeros/server-destination-tiktok",
3
3
  "description": "TikTok Events API server destination for walkerOS",
4
- "version": "3.4.2",
4
+ "version": "4.0.0-next-1777882869103",
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-1777882869103",
38
+ "@walkeros/server-core": "4.0.0-next-1777882869103"
39
39
  },
40
40
  "devDependencies": {
41
- "@walkeros/collector": "3.4.2"
41
+ "@walkeros/collector": "4.0.0-next-1777882869103"
42
42
  },
43
43
  "repository": {
44
44
  "url": "git+https://github.com/elbwalker/walkerOS.git",