@walkeros/server-destination-twitter 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.js +6 -0
- package/dist/examples/index.mjs +6 -0
- package/dist/walkerOS.json +10 -4
- package/package.json +4 -4
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e,
|
|
1
|
+
"use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,o=(e,r)=>{for(var i in r)t(e,i,{get:r[i],enumerable:!0})},n={};o(n,{examples:()=>x,schemas:()=>a}),module.exports=(e=n,((e,o,n,a)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let c of i(o))s.call(e,c)||c===n||t(e,c,{get:()=>o[c],enumerable:!(a=r(o,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={};o(a,{ApiVersionSchema:()=>p,EventIdSchema:()=>m,IdentifierTypeSchema:()=>l,MappingSchema:()=>b,SettingsSchema:()=>v,mapping:()=>f,settings:()=>g});var c=require("@walkeros/core/dev"),d=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),l=u.z.enum(["twclid","hashed_email","hashed_phone_number","ip_address","user_agent"]),m=u.z.string().regex(/^tw-[a-z0-9]+-[a-z0-9]+$/,"Event ID must match X format (e.g. tw-xxxxx-xxxxx)"),p=u.z.string().regex(/^\d+$/,'API version must be numeric (e.g. "12")'),v=d.z.object({pixelId:d.z.string().min(1).describe("X Pixel ID used in the Conversions API endpoint URL"),eventId:m.describe("Default pre-registered conversion event ID (like tw-xxxxx-xxxxx)"),consumerKey:d.z.string().min(1).describe("OAuth 1.0a API Key (Consumer Key) for X Ads API"),consumerSecret:d.z.string().min(1).describe("OAuth 1.0a API Key Secret (Consumer Secret)"),accessToken:d.z.string().min(1).describe("OAuth 1.0a User Access Token"),accessTokenSecret:d.z.string().min(1).describe("OAuth 1.0a User Access Token Secret"),apiVersion:p.describe('X Ads API version number (like "12")').optional(),doNotHash:d.z.array(d.z.string()).describe("Array of user data fields that should not be hashed (like ['email'])").optional(),url:d.z.string().url().describe("Custom base URL for the X Conversions API endpoint (like https://ads-api.x.com/)").optional(),user_data:d.z.record(d.z.string(),d.z.string()).describe("Mapping configuration for user identifiers (like { email: 'user.email', twclid: 'context.twclid' })").optional()}),h=require("@walkeros/core/dev"),b=h.z.object({eventId:h.z.string().describe("Override the default conversion event ID for this event").optional(),value:h.z.union([h.z.string(),h.z.number()]).describe("Conversion monetary value (sent to X as a string)").optional(),currency:h.z.string().describe("ISO 4217 currency code (like USD, EUR)").optional(),number_items:h.z.number().int().describe("Number of items in the conversion").optional(),description:h.z.string().describe("Free-text description of the conversion").optional()}),g=(0,c.zodToSchema)(v),f=(0,c.zodToSchema)(b),x={};o(x,{env:()=>z,step:()=>S});var z={};o(z,{push:()=>y,simulation:()=>w});var y={sendServer:async()=>({ok:!0,data:{request_id:"mock-request-id"}})},w=["sendServer"],S={};o(S,{lead:()=>O,purchase:()=>I,purchaseWithTwclid:()=>j});var _=require("@walkeros/core"),A="https://ads-api.x.com/12/measurement/conversions/o8z6j",k={headers:{Authorization:"<OAUTH_SIGNATURE>","Content-Type":"application/json"}},I={title:"Purchase",description:"A completed order is sent to the X (Twitter) Conversions API with conversion value and the hashed email.",in:(0,_.getEvent)("order complete",{timestamp:17000009e5,data:{total:249.99,currency:"EUR"},user:{email:"jane@example.com"},source:{type:"server",id:"https://shop.example.com",previous_id:""}}),mapping:{settings:{value:"data.total",currency:{key:"data.currency",value:"EUR"}}},out:[["sendServer",A,JSON.stringify({conversions:[{conversion_time:"2023-11-14T22:28:20.000Z",event_id:"tw-o8z6j-o8z21",identifiers:[{hashed_email:"8c87b489ce35cf2e2f39f80e282cb2e804932a56a213983eeeb428407d43b52d"}],conversion_id:"1700000900000-gr0up-1",value:"249.99"}]}),k]]},O={title:"Lead",description:"A form submission is sent to X as a conversion with the SHA-256 hashed email as the identifier.",in:(0,_.getEvent)("form submit",{timestamp:1700000901e3,user:{email:"user@example.com"},source:{type:"server",id:"https://example.com",previous_id:""}}),mapping:void 0,out:[["sendServer",A,JSON.stringify({conversions:[{conversion_time:"2023-11-14T22:28:21.000Z",event_id:"tw-o8z6j-o8z21",identifiers:[{hashed_email:"b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"}],conversion_id:"1700000901000-gr0up-1"}]}),k]]},j={title:"Purchase with twclid",description:"A purchase is sent to X with both the hashed email and the twclid click id for ads attribution.",in:(0,_.getEvent)("order complete",{timestamp:1700000902e3,data:{total:89.99,currency:"USD"},user:{email:"buyer@co.com"},context:{twclid:["23opevjt88psuo13lu8d020qkn",0]},source:{type:"server",id:"https://shop.example.com",previous_id:""}}),mapping:{settings:{value:"data.total",currency:{key:"data.currency",value:"USD"}},data:{map:{user_data:{map:{twclid:"context.twclid"}}}}},out:[["sendServer",A,JSON.stringify({conversions:[{conversion_time:"2023-11-14T22:28:22.000Z",event_id:"tw-o8z6j-o8z21",identifiers:[{hashed_email:"484c39bfb51212665d9673805c112b5ba04cbf0460b6d3f00bcdc18b92afed66"},{twclid:"23opevjt88psuo13lu8d020qkn"}],conversion_id:"1700000902000-gr0up-1",value:"89.99"}]}),k]]};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/primitives.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport * from './primitives';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\nimport { ApiVersionSchema, EventIdSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n pixelId: z\n .string()\n .min(1)\n .describe('X Pixel ID used in the Conversions API endpoint URL'),\n eventId: EventIdSchema.describe(\n 'Default pre-registered conversion event ID (like tw-xxxxx-xxxxx)',\n ),\n consumerKey: z\n .string()\n .min(1)\n .describe('OAuth 1.0a API Key (Consumer Key) for X Ads API'),\n consumerSecret: z\n .string()\n .min(1)\n .describe('OAuth 1.0a API Key Secret (Consumer Secret)'),\n accessToken: z.string().min(1).describe('OAuth 1.0a User Access Token'),\n accessTokenSecret: z\n .string()\n .min(1)\n .describe('OAuth 1.0a User Access Token Secret'),\n apiVersion: ApiVersionSchema.describe(\n 'X Ads API version number (like \"12\")',\n ).optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"Array of user data fields that should not be hashed (like ['email'])\",\n )\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Custom base URL for the X Conversions API endpoint (like https://ads-api.x.com/)',\n )\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\n \"Mapping configuration for user identifiers (like { email: 'user.email', twclid: 'context.twclid' })\",\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * X (Twitter) Identifier Type Enum\n * Types of user identifiers supported by X Conversions API.\n * Primary: twclid, hashed_email, hashed_phone_number.\n * Secondary: ip_address, user_agent.\n */\nexport const IdentifierTypeSchema = z.enum([\n 'twclid',\n 'hashed_email',\n 'hashed_phone_number',\n 'ip_address',\n 'user_agent',\n]);\n\n/**\n * X Event ID Schema\n * Pre-registered conversion event IDs follow the pattern `tw-xxxxx-xxxxx`.\n */\nexport const EventIdSchema = z\n .string()\n .regex(\n /^tw-[a-z0-9]+-[a-z0-9]+$/,\n 'Event ID must match X format (e.g. tw-xxxxx-xxxxx)',\n );\n\n/**\n * API Version Schema\n * X Ads API version number (numeric string).\n */\nexport const ApiVersionSchema = z\n .string()\n .regex(/^\\d+$/, 'API version must be numeric (e.g. \"12\")');\n","import { z } from '@walkeros/core/dev';\n\n/**\n * X (Twitter) Conversions API Mapping Schema\n *\n * Per-event override for the conversion event ID and monetary details.\n */\nexport const MappingSchema = z.object({\n eventId: z\n .string()\n .describe('Override the default conversion event ID for this event')\n .optional(),\n value: z\n .union([z.string(), z.number()])\n .describe('Conversion monetary value (sent to X as a string)')\n .optional(),\n currency: z\n .string()\n .describe('ISO 4217 currency code (like USD, EUR)')\n .optional(),\n number_items: z\n .number()\n .int()\n .describe('Number of items in the conversion')\n .optional(),\n description: z\n .string()\n .describe('Free-text description of the conversion')\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { SendDataValue, SendResponse } from '@walkeros/core';\nimport type { SendServerOptions } from '@walkeros/server-core';\nimport type { Env } from '../types';\n\n/**\n * Example environment configurations for X (Twitter) Conversions API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\ntype SendServerFn = (\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n) => Promise<SendResponse>;\n\n/**\n * Mock sendServer function that simulates successful HTTP responses\n */\nconst mockSendServer: SendServerFn = async () => {\n return {\n ok: true,\n data: { request_id: 'mock-request-id' },\n };\n};\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing X Conversions API events without making\n * actual HTTP requests to X'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 } from '@walkeros/core';\n\n/**\n * X (Twitter) Conversions API step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(url, body, { headers })` where:\n * - `url` is `${settings.url}${apiVersion}/measurement/conversions/${pixelId}`\n * - `body` is the JSON-stringified `{ conversions: [conversion] }` payload\n * - `headers` is `{ Authorization: '<OAuth-1.0a>', 'Content-Type': 'application/json' }`\n *\n * The test fixture pins `pixelId = 'o8z6j'`, `eventId = 'tw-o8z6j-o8z21'`.\n * OAuth 1.0a signing is non-deterministic (nonce + timestamp), so the test\n * normalizes the `Authorization` header to a stable marker before comparing.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * conversion_time, event_id, identifiers, conversion_id, value? (string).\n *\n * Emails are normalized (trim + lowercase) and hashed with SHA-256.\n */\nconst ENDPOINT = 'https://ads-api.x.com/12/measurement/conversions/o8z6j';\nconst HEADERS = {\n headers: {\n Authorization: '<OAUTH_SIGNATURE>',\n 'Content-Type': 'application/json',\n },\n};\n\nexport const purchase: Flow.StepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000900000,\n data: { total: 249.99, currency: 'EUR' },\n user: { email: 'jane@example.com' },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: {\n settings: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'EUR' },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n conversions: [\n {\n conversion_time: '2023-11-14T22:28:20.000Z',\n event_id: 'tw-o8z6j-o8z21',\n identifiers: [\n {\n hashed_email:\n '8c87b489ce35cf2e2f39f80e282cb2e804932a56a213983eeeb428407d43b52d',\n },\n ],\n conversion_id: '1700000900000-gr0up-1',\n value: '249.99',\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n in: getEvent('form submit', {\n timestamp: 1700000901000,\n user: { email: 'user@example.com' },\n source: { type: 'server', id: 'https://example.com', previous_id: '' },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n conversions: [\n {\n conversion_time: '2023-11-14T22:28:21.000Z',\n event_id: 'tw-o8z6j-o8z21',\n identifiers: [\n {\n hashed_email:\n 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514',\n },\n ],\n conversion_id: '1700000901000-gr0up-1',\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const purchaseWithTwclid: Flow.StepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000902000,\n data: { total: 89.99, currency: 'USD' },\n user: { email: 'buyer@co.com' },\n context: { twclid: ['23opevjt88psuo13lu8d020qkn', 0] },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: {\n settings: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'USD' },\n },\n data: {\n map: {\n user_data: {\n map: {\n twclid: 'context.twclid',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n conversions: [\n {\n conversion_time: '2023-11-14T22:28:22.000Z',\n event_id: 'tw-o8z6j-o8z21',\n identifiers: [\n {\n hashed_email:\n '484c39bfb51212665d9673805c112b5ba04cbf0460b6d3f00bcdc18b92afed66',\n },\n { twclid: '23opevjt88psuo13lu8d020qkn' },\n ],\n conversion_id: '1700000902000-gr0up-1',\n value: '89.99',\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;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,IAAAC,cAAkB;;;ACAlB,iBAAkB;AAQX,IAAM,uBAAuB,aAAE,KAAK;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,gBAAgB,aAC1B,OAAO,EACP;AAAA,EACC;AAAA,EACA;AACF;AAMK,IAAM,mBAAmB,aAC7B,OAAO,EACP,MAAM,SAAS,yCAAyC;;;AD9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AAA,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/primitives.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport * from './primitives';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\nimport { ApiVersionSchema, EventIdSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n pixelId: z\n .string()\n .min(1)\n .describe('X Pixel ID used in the Conversions API endpoint URL'),\n eventId: EventIdSchema.describe(\n 'Default pre-registered conversion event ID (like tw-xxxxx-xxxxx)',\n ),\n consumerKey: z\n .string()\n .min(1)\n .describe('OAuth 1.0a API Key (Consumer Key) for X Ads API'),\n consumerSecret: z\n .string()\n .min(1)\n .describe('OAuth 1.0a API Key Secret (Consumer Secret)'),\n accessToken: z.string().min(1).describe('OAuth 1.0a User Access Token'),\n accessTokenSecret: z\n .string()\n .min(1)\n .describe('OAuth 1.0a User Access Token Secret'),\n apiVersion: ApiVersionSchema.describe(\n 'X Ads API version number (like \"12\")',\n ).optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"Array of user data fields that should not be hashed (like ['email'])\",\n )\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Custom base URL for the X Conversions API endpoint (like https://ads-api.x.com/)',\n )\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\n \"Mapping configuration for user identifiers (like { email: 'user.email', twclid: 'context.twclid' })\",\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * X (Twitter) Identifier Type Enum\n * Types of user identifiers supported by X Conversions API.\n * Primary: twclid, hashed_email, hashed_phone_number.\n * Secondary: ip_address, user_agent.\n */\nexport const IdentifierTypeSchema = z.enum([\n 'twclid',\n 'hashed_email',\n 'hashed_phone_number',\n 'ip_address',\n 'user_agent',\n]);\n\n/**\n * X Event ID Schema\n * Pre-registered conversion event IDs follow the pattern `tw-xxxxx-xxxxx`.\n */\nexport const EventIdSchema = z\n .string()\n .regex(\n /^tw-[a-z0-9]+-[a-z0-9]+$/,\n 'Event ID must match X format (e.g. tw-xxxxx-xxxxx)',\n );\n\n/**\n * API Version Schema\n * X Ads API version number (numeric string).\n */\nexport const ApiVersionSchema = z\n .string()\n .regex(/^\\d+$/, 'API version must be numeric (e.g. \"12\")');\n","import { z } from '@walkeros/core/dev';\n\n/**\n * X (Twitter) Conversions API Mapping Schema\n *\n * Per-event override for the conversion event ID and monetary details.\n */\nexport const MappingSchema = z.object({\n eventId: z\n .string()\n .describe('Override the default conversion event ID for this event')\n .optional(),\n value: z\n .union([z.string(), z.number()])\n .describe('Conversion monetary value (sent to X as a string)')\n .optional(),\n currency: z\n .string()\n .describe('ISO 4217 currency code (like USD, EUR)')\n .optional(),\n number_items: z\n .number()\n .int()\n .describe('Number of items in the conversion')\n .optional(),\n description: z\n .string()\n .describe('Free-text description of the conversion')\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { SendDataValue, SendResponse } from '@walkeros/core';\nimport type { SendServerOptions } from '@walkeros/server-core';\nimport type { Env } from '../types';\n\n/**\n * Example environment configurations for X (Twitter) Conversions API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\ntype SendServerFn = (\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n) => Promise<SendResponse>;\n\n/**\n * Mock sendServer function that simulates successful HTTP responses\n */\nconst mockSendServer: SendServerFn = async () => {\n return {\n ok: true,\n data: { request_id: 'mock-request-id' },\n };\n};\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing X Conversions API events without making\n * actual HTTP requests to X'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 } from '@walkeros/core';\n\n/**\n * X (Twitter) Conversions API step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(url, body, { headers })` where:\n * - `url` is `${settings.url}${apiVersion}/measurement/conversions/${pixelId}`\n * - `body` is the JSON-stringified `{ conversions: [conversion] }` payload\n * - `headers` is `{ Authorization: '<OAuth-1.0a>', 'Content-Type': 'application/json' }`\n *\n * The test fixture pins `pixelId = 'o8z6j'`, `eventId = 'tw-o8z6j-o8z21'`.\n * OAuth 1.0a signing is non-deterministic (nonce + timestamp), so the test\n * normalizes the `Authorization` header to a stable marker before comparing.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * conversion_time, event_id, identifiers, conversion_id, value? (string).\n *\n * Emails are normalized (trim + lowercase) and hashed with SHA-256.\n */\nconst ENDPOINT = 'https://ads-api.x.com/12/measurement/conversions/o8z6j';\nconst HEADERS = {\n headers: {\n Authorization: '<OAUTH_SIGNATURE>',\n 'Content-Type': 'application/json',\n },\n};\n\nexport const purchase: Flow.StepExample = {\n title: 'Purchase',\n description:\n 'A completed order is sent to the X (Twitter) Conversions API with conversion value and the hashed email.',\n in: getEvent('order complete', {\n timestamp: 1700000900000,\n data: { total: 249.99, currency: 'EUR' },\n user: { email: 'jane@example.com' },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: {\n settings: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'EUR' },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n conversions: [\n {\n conversion_time: '2023-11-14T22:28:20.000Z',\n event_id: 'tw-o8z6j-o8z21',\n identifiers: [\n {\n hashed_email:\n '8c87b489ce35cf2e2f39f80e282cb2e804932a56a213983eeeb428407d43b52d',\n },\n ],\n conversion_id: '1700000900000-gr0up-1',\n value: '249.99',\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Lead',\n description:\n 'A form submission is sent to X as a conversion with the SHA-256 hashed email as the identifier.',\n in: getEvent('form submit', {\n timestamp: 1700000901000,\n user: { email: 'user@example.com' },\n source: { type: 'server', id: 'https://example.com', previous_id: '' },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n conversions: [\n {\n conversion_time: '2023-11-14T22:28:21.000Z',\n event_id: 'tw-o8z6j-o8z21',\n identifiers: [\n {\n hashed_email:\n 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514',\n },\n ],\n conversion_id: '1700000901000-gr0up-1',\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const purchaseWithTwclid: Flow.StepExample = {\n title: 'Purchase with twclid',\n description:\n 'A purchase is sent to X with both the hashed email and the twclid click id for ads attribution.',\n in: getEvent('order complete', {\n timestamp: 1700000902000,\n data: { total: 89.99, currency: 'USD' },\n user: { email: 'buyer@co.com' },\n context: { twclid: ['23opevjt88psuo13lu8d020qkn', 0] },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: {\n settings: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'USD' },\n },\n data: {\n map: {\n user_data: {\n map: {\n twclid: 'context.twclid',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n conversions: [\n {\n conversion_time: '2023-11-14T22:28:22.000Z',\n event_id: 'tw-o8z6j-o8z21',\n identifiers: [\n {\n hashed_email:\n '484c39bfb51212665d9673805c112b5ba04cbf0460b6d3f00bcdc18b92afed66',\n },\n { twclid: '23opevjt88psuo13lu8d020qkn' },\n ],\n conversion_id: '1700000902000-gr0up-1',\n value: '89.99',\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;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,IAAAC,cAAkB;;;ACAlB,iBAAkB;AAQX,IAAM,uBAAuB,aAAE,KAAK;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,gBAAgB,aAC1B,OAAO,EACP;AAAA,EACC;AAAA,EACA;AACF;AAMK,IAAM,mBAAmB,aAC7B,OAAO,EACP,MAAM,SAAS,yCAAyC;;;AD9BpD,IAAM,iBAAiB,cAAE,OAAO;AAAA,EACrC,SAAS,cACN,OAAO,EACP,IAAI,CAAC,EACL,SAAS,qDAAqD;AAAA,EACjE,SAAS,cAAc;AAAA,IACrB;AAAA,EACF;AAAA,EACA,aAAa,cACV,OAAO,EACP,IAAI,CAAC,EACL,SAAS,iDAAiD;AAAA,EAC7D,gBAAgB,cACb,OAAO,EACP,IAAI,CAAC,EACL,SAAS,6CAA6C;AAAA,EACzD,aAAa,cAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,8BAA8B;AAAA,EACtE,mBAAmB,cAChB,OAAO,EACP,IAAI,CAAC,EACL,SAAS,qCAAqC;AAAA,EACjD,YAAY,iBAAiB;AAAA,IAC3B;AAAA,EACF,EAAE,SAAS;AAAA,EACX,WAAW,cACR,MAAM,cAAE,OAAO,CAAC,EAChB;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,KAAK,cACF,OAAO,EACP,IAAI,EACJ;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,WAAW,cACR,OAAO,cAAE,OAAO,GAAG,cAAE,OAAO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AE;AAAA,IACrD,QAAQ,EAAE,MAAM,UAAU,IAAI,4BAA4B,aAAa,GAAG;AAAA,EAC5E,CAAC;AAAA,EACD,SAAS;AAAA,IACP,UAAU;AAAA,MACR,OAAO;AAAA,MACP,UAAU,EAAE,KAAK,iBAAiB,OAAO,MAAM;AAAA,IACjD;AAAA,IACA,MAAM;AAAA,MACJ,KAAK;AAAA,QACH,WAAW;AAAA,UACT,KAAK;AAAA,YACH,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,aAAa;AAAA,UACX;AAAA,YACE,iBAAiB;AAAA,YACjB,UAAU;AAAA,YACV,aAAa;AAAA,cACX;AAAA,gBACE,cACE;AAAA,cACJ;AAAA,cACA,EAAE,QAAQ,6BAA6B;AAAA,YACzC;AAAA,YACA,eAAe;AAAA,YACf,OAAO;AAAA,UACT;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,
|
|
1
|
+
var e=Object.defineProperty,i=(i,t)=>{for(var r in t)e(i,r,{get:t[r],enumerable:!0})},t={};i(t,{ApiVersionSchema:()=>c,EventIdSchema:()=>a,IdentifierTypeSchema:()=>n,MappingSchema:()=>p,SettingsSchema:()=>d,mapping:()=>l,settings:()=>u});import{zodToSchema as r}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";import{z as o}from"@walkeros/core/dev";var n=o.enum(["twclid","hashed_email","hashed_phone_number","ip_address","user_agent"]),a=o.string().regex(/^tw-[a-z0-9]+-[a-z0-9]+$/,"Event ID must match X format (e.g. tw-xxxxx-xxxxx)"),c=o.string().regex(/^\d+$/,'API version must be numeric (e.g. "12")'),d=s.object({pixelId:s.string().min(1).describe("X Pixel ID used in the Conversions API endpoint URL"),eventId:a.describe("Default pre-registered conversion event ID (like tw-xxxxx-xxxxx)"),consumerKey:s.string().min(1).describe("OAuth 1.0a API Key (Consumer Key) for X Ads API"),consumerSecret:s.string().min(1).describe("OAuth 1.0a API Key Secret (Consumer Secret)"),accessToken:s.string().min(1).describe("OAuth 1.0a User Access Token"),accessTokenSecret:s.string().min(1).describe("OAuth 1.0a User Access Token Secret"),apiVersion:c.describe('X Ads API version number (like "12")').optional(),doNotHash:s.array(s.string()).describe("Array of user data fields that should not be hashed (like ['email'])").optional(),url:s.string().url().describe("Custom base URL for the X Conversions API endpoint (like https://ads-api.x.com/)").optional(),user_data:s.record(s.string(),s.string()).describe("Mapping configuration for user identifiers (like { email: 'user.email', twclid: 'context.twclid' })").optional()});import{z as m}from"@walkeros/core/dev";var p=m.object({eventId:m.string().describe("Override the default conversion event ID for this event").optional(),value:m.union([m.string(),m.number()]).describe("Conversion monetary value (sent to X as a string)").optional(),currency:m.string().describe("ISO 4217 currency code (like USD, EUR)").optional(),number_items:m.number().int().describe("Number of items in the conversion").optional(),description:m.string().describe("Free-text description of the conversion").optional()}),u=r(d),l=r(p),v={};i(v,{env:()=>h,step:()=>g});var h={};i(h,{push:()=>b,simulation:()=>f});var b={sendServer:async()=>({ok:!0,data:{request_id:"mock-request-id"}})},f=["sendServer"],g={};i(g,{lead:()=>S,purchase:()=>A,purchaseWithTwclid:()=>_});import{getEvent as x}from"@walkeros/core";var y="https://ads-api.x.com/12/measurement/conversions/o8z6j",w={headers:{Authorization:"<OAUTH_SIGNATURE>","Content-Type":"application/json"}},A={title:"Purchase",description:"A completed order is sent to the X (Twitter) Conversions API with conversion value and the hashed email.",in:x("order complete",{timestamp:17000009e5,data:{total:249.99,currency:"EUR"},user:{email:"jane@example.com"},source:{type:"server",id:"https://shop.example.com",previous_id:""}}),mapping:{settings:{value:"data.total",currency:{key:"data.currency",value:"EUR"}}},out:[["sendServer",y,JSON.stringify({conversions:[{conversion_time:"2023-11-14T22:28:20.000Z",event_id:"tw-o8z6j-o8z21",identifiers:[{hashed_email:"8c87b489ce35cf2e2f39f80e282cb2e804932a56a213983eeeb428407d43b52d"}],conversion_id:"1700000900000-gr0up-1",value:"249.99"}]}),w]]},S={title:"Lead",description:"A form submission is sent to X as a conversion with the SHA-256 hashed email as the identifier.",in:x("form submit",{timestamp:1700000901e3,user:{email:"user@example.com"},source:{type:"server",id:"https://example.com",previous_id:""}}),mapping:void 0,out:[["sendServer",y,JSON.stringify({conversions:[{conversion_time:"2023-11-14T22:28:21.000Z",event_id:"tw-o8z6j-o8z21",identifiers:[{hashed_email:"b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"}],conversion_id:"1700000901000-gr0up-1"}]}),w]]},_={title:"Purchase with twclid",description:"A purchase is sent to X with both the hashed email and the twclid click id for ads attribution.",in:x("order complete",{timestamp:1700000902e3,data:{total:89.99,currency:"USD"},user:{email:"buyer@co.com"},context:{twclid:["23opevjt88psuo13lu8d020qkn",0]},source:{type:"server",id:"https://shop.example.com",previous_id:""}}),mapping:{settings:{value:"data.total",currency:{key:"data.currency",value:"USD"}},data:{map:{user_data:{map:{twclid:"context.twclid"}}}}},out:[["sendServer",y,JSON.stringify({conversions:[{conversion_time:"2023-11-14T22:28:22.000Z",event_id:"tw-o8z6j-o8z21",identifiers:[{hashed_email:"484c39bfb51212665d9673805c112b5ba04cbf0460b6d3f00bcdc18b92afed66"},{twclid:"23opevjt88psuo13lu8d020qkn"}],conversion_id:"1700000902000-gr0up-1",value:"89.99"}]}),w]]};export{v as examples,t as schemas};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/primitives.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport * from './primitives';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\nimport { ApiVersionSchema, EventIdSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n pixelId: z\n .string()\n .min(1)\n .describe('X Pixel ID used in the Conversions API endpoint URL'),\n eventId: EventIdSchema.describe(\n 'Default pre-registered conversion event ID (like tw-xxxxx-xxxxx)',\n ),\n consumerKey: z\n .string()\n .min(1)\n .describe('OAuth 1.0a API Key (Consumer Key) for X Ads API'),\n consumerSecret: z\n .string()\n .min(1)\n .describe('OAuth 1.0a API Key Secret (Consumer Secret)'),\n accessToken: z.string().min(1).describe('OAuth 1.0a User Access Token'),\n accessTokenSecret: z\n .string()\n .min(1)\n .describe('OAuth 1.0a User Access Token Secret'),\n apiVersion: ApiVersionSchema.describe(\n 'X Ads API version number (like \"12\")',\n ).optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"Array of user data fields that should not be hashed (like ['email'])\",\n )\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Custom base URL for the X Conversions API endpoint (like https://ads-api.x.com/)',\n )\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\n \"Mapping configuration for user identifiers (like { email: 'user.email', twclid: 'context.twclid' })\",\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * X (Twitter) Identifier Type Enum\n * Types of user identifiers supported by X Conversions API.\n * Primary: twclid, hashed_email, hashed_phone_number.\n * Secondary: ip_address, user_agent.\n */\nexport const IdentifierTypeSchema = z.enum([\n 'twclid',\n 'hashed_email',\n 'hashed_phone_number',\n 'ip_address',\n 'user_agent',\n]);\n\n/**\n * X Event ID Schema\n * Pre-registered conversion event IDs follow the pattern `tw-xxxxx-xxxxx`.\n */\nexport const EventIdSchema = z\n .string()\n .regex(\n /^tw-[a-z0-9]+-[a-z0-9]+$/,\n 'Event ID must match X format (e.g. tw-xxxxx-xxxxx)',\n );\n\n/**\n * API Version Schema\n * X Ads API version number (numeric string).\n */\nexport const ApiVersionSchema = z\n .string()\n .regex(/^\\d+$/, 'API version must be numeric (e.g. \"12\")');\n","import { z } from '@walkeros/core/dev';\n\n/**\n * X (Twitter) Conversions API Mapping Schema\n *\n * Per-event override for the conversion event ID and monetary details.\n */\nexport const MappingSchema = z.object({\n eventId: z\n .string()\n .describe('Override the default conversion event ID for this event')\n .optional(),\n value: z\n .union([z.string(), z.number()])\n .describe('Conversion monetary value (sent to X as a string)')\n .optional(),\n currency: z\n .string()\n .describe('ISO 4217 currency code (like USD, EUR)')\n .optional(),\n number_items: z\n .number()\n .int()\n .describe('Number of items in the conversion')\n .optional(),\n description: z\n .string()\n .describe('Free-text description of the conversion')\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { SendDataValue, SendResponse } from '@walkeros/core';\nimport type { SendServerOptions } from '@walkeros/server-core';\nimport type { Env } from '../types';\n\n/**\n * Example environment configurations for X (Twitter) Conversions API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\ntype SendServerFn = (\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n) => Promise<SendResponse>;\n\n/**\n * Mock sendServer function that simulates successful HTTP responses\n */\nconst mockSendServer: SendServerFn = async () => {\n return {\n ok: true,\n data: { request_id: 'mock-request-id' },\n };\n};\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing X Conversions API events without making\n * actual HTTP requests to X'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 } from '@walkeros/core';\n\n/**\n * X (Twitter) Conversions API step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(url, body, { headers })` where:\n * - `url` is `${settings.url}${apiVersion}/measurement/conversions/${pixelId}`\n * - `body` is the JSON-stringified `{ conversions: [conversion] }` payload\n * - `headers` is `{ Authorization: '<OAuth-1.0a>', 'Content-Type': 'application/json' }`\n *\n * The test fixture pins `pixelId = 'o8z6j'`, `eventId = 'tw-o8z6j-o8z21'`.\n * OAuth 1.0a signing is non-deterministic (nonce + timestamp), so the test\n * normalizes the `Authorization` header to a stable marker before comparing.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * conversion_time, event_id, identifiers, conversion_id, value? (string).\n *\n * Emails are normalized (trim + lowercase) and hashed with SHA-256.\n */\nconst ENDPOINT = 'https://ads-api.x.com/12/measurement/conversions/o8z6j';\nconst HEADERS = {\n headers: {\n Authorization: '<OAUTH_SIGNATURE>',\n 'Content-Type': 'application/json',\n },\n};\n\nexport const purchase: Flow.StepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000900000,\n data: { total: 249.99, currency: 'EUR' },\n user: { email: 'jane@example.com' },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: {\n settings: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'EUR' },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n conversions: [\n {\n conversion_time: '2023-11-14T22:28:20.000Z',\n event_id: 'tw-o8z6j-o8z21',\n identifiers: [\n {\n hashed_email:\n '8c87b489ce35cf2e2f39f80e282cb2e804932a56a213983eeeb428407d43b52d',\n },\n ],\n conversion_id: '1700000900000-gr0up-1',\n value: '249.99',\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n in: getEvent('form submit', {\n timestamp: 1700000901000,\n user: { email: 'user@example.com' },\n source: { type: 'server', id: 'https://example.com', previous_id: '' },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n conversions: [\n {\n conversion_time: '2023-11-14T22:28:21.000Z',\n event_id: 'tw-o8z6j-o8z21',\n identifiers: [\n {\n hashed_email:\n 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514',\n },\n ],\n conversion_id: '1700000901000-gr0up-1',\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const purchaseWithTwclid: Flow.StepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000902000,\n data: { total: 89.99, currency: 'USD' },\n user: { email: 'buyer@co.com' },\n context: { twclid: ['23opevjt88psuo13lu8d020qkn', 0] },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: {\n settings: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'USD' },\n },\n data: {\n map: {\n user_data: {\n map: {\n twclid: 'context.twclid',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n conversions: [\n {\n conversion_time: '2023-11-14T22:28:22.000Z',\n event_id: 'tw-o8z6j-o8z21',\n identifiers: [\n {\n hashed_email:\n '484c39bfb51212665d9673805c112b5ba04cbf0460b6d3f00bcdc18b92afed66',\n },\n { twclid: '23opevjt88psuo13lu8d020qkn' },\n ],\n conversion_id: '1700000902000-gr0up-1',\n value: '89.99',\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAQX,IAAM,uBAAuB,EAAE,KAAK;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,gBAAgB,EAC1B,OAAO,EACP;AAAA,EACC;AAAA,EACA;AACF;AAMK,IAAM,mBAAmB,EAC7B,OAAO,EACP,MAAM,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eAAe;AAAA,YACf,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;","names":["z","z","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/primitives.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport * from './primitives';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\nimport { ApiVersionSchema, EventIdSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n pixelId: z\n .string()\n .min(1)\n .describe('X Pixel ID used in the Conversions API endpoint URL'),\n eventId: EventIdSchema.describe(\n 'Default pre-registered conversion event ID (like tw-xxxxx-xxxxx)',\n ),\n consumerKey: z\n .string()\n .min(1)\n .describe('OAuth 1.0a API Key (Consumer Key) for X Ads API'),\n consumerSecret: z\n .string()\n .min(1)\n .describe('OAuth 1.0a API Key Secret (Consumer Secret)'),\n accessToken: z.string().min(1).describe('OAuth 1.0a User Access Token'),\n accessTokenSecret: z\n .string()\n .min(1)\n .describe('OAuth 1.0a User Access Token Secret'),\n apiVersion: ApiVersionSchema.describe(\n 'X Ads API version number (like \"12\")',\n ).optional(),\n doNotHash: z\n .array(z.string())\n .describe(\n \"Array of user data fields that should not be hashed (like ['email'])\",\n )\n .optional(),\n url: z\n .string()\n .url()\n .describe(\n 'Custom base URL for the X Conversions API endpoint (like https://ads-api.x.com/)',\n )\n .optional(),\n user_data: z\n .record(z.string(), z.string())\n .describe(\n \"Mapping configuration for user identifiers (like { email: 'user.email', twclid: 'context.twclid' })\",\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/**\n * X (Twitter) Identifier Type Enum\n * Types of user identifiers supported by X Conversions API.\n * Primary: twclid, hashed_email, hashed_phone_number.\n * Secondary: ip_address, user_agent.\n */\nexport const IdentifierTypeSchema = z.enum([\n 'twclid',\n 'hashed_email',\n 'hashed_phone_number',\n 'ip_address',\n 'user_agent',\n]);\n\n/**\n * X Event ID Schema\n * Pre-registered conversion event IDs follow the pattern `tw-xxxxx-xxxxx`.\n */\nexport const EventIdSchema = z\n .string()\n .regex(\n /^tw-[a-z0-9]+-[a-z0-9]+$/,\n 'Event ID must match X format (e.g. tw-xxxxx-xxxxx)',\n );\n\n/**\n * API Version Schema\n * X Ads API version number (numeric string).\n */\nexport const ApiVersionSchema = z\n .string()\n .regex(/^\\d+$/, 'API version must be numeric (e.g. \"12\")');\n","import { z } from '@walkeros/core/dev';\n\n/**\n * X (Twitter) Conversions API Mapping Schema\n *\n * Per-event override for the conversion event ID and monetary details.\n */\nexport const MappingSchema = z.object({\n eventId: z\n .string()\n .describe('Override the default conversion event ID for this event')\n .optional(),\n value: z\n .union([z.string(), z.number()])\n .describe('Conversion monetary value (sent to X as a string)')\n .optional(),\n currency: z\n .string()\n .describe('ISO 4217 currency code (like USD, EUR)')\n .optional(),\n number_items: z\n .number()\n .int()\n .describe('Number of items in the conversion')\n .optional(),\n description: z\n .string()\n .describe('Free-text description of the conversion')\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type { SendDataValue, SendResponse } from '@walkeros/core';\nimport type { SendServerOptions } from '@walkeros/server-core';\nimport type { Env } from '../types';\n\n/**\n * Example environment configurations for X (Twitter) Conversions API destination\n *\n * These environments provide standardized mock structures for testing\n * and development without requiring actual HTTP requests.\n */\n\ntype SendServerFn = (\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n) => Promise<SendResponse>;\n\n/**\n * Mock sendServer function that simulates successful HTTP responses\n */\nconst mockSendServer: SendServerFn = async () => {\n return {\n ok: true,\n data: { request_id: 'mock-request-id' },\n };\n};\n\n/**\n * Standard mock environment for push operations\n *\n * Use this for testing X Conversions API events without making\n * actual HTTP requests to X'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 } from '@walkeros/core';\n\n/**\n * X (Twitter) Conversions API step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(url, body, { headers })` where:\n * - `url` is `${settings.url}${apiVersion}/measurement/conversions/${pixelId}`\n * - `body` is the JSON-stringified `{ conversions: [conversion] }` payload\n * - `headers` is `{ Authorization: '<OAuth-1.0a>', 'Content-Type': 'application/json' }`\n *\n * The test fixture pins `pixelId = 'o8z6j'`, `eventId = 'tw-o8z6j-o8z21'`.\n * OAuth 1.0a signing is non-deterministic (nonce + timestamp), so the test\n * normalizes the `Authorization` header to a stable marker before comparing.\n *\n * Body fields are emitted in the order the destination constructs them\n * (insertion order matters for `JSON.stringify` string equality):\n * conversion_time, event_id, identifiers, conversion_id, value? (string).\n *\n * Emails are normalized (trim + lowercase) and hashed with SHA-256.\n */\nconst ENDPOINT = 'https://ads-api.x.com/12/measurement/conversions/o8z6j';\nconst HEADERS = {\n headers: {\n Authorization: '<OAUTH_SIGNATURE>',\n 'Content-Type': 'application/json',\n },\n};\n\nexport const purchase: Flow.StepExample = {\n title: 'Purchase',\n description:\n 'A completed order is sent to the X (Twitter) Conversions API with conversion value and the hashed email.',\n in: getEvent('order complete', {\n timestamp: 1700000900000,\n data: { total: 249.99, currency: 'EUR' },\n user: { email: 'jane@example.com' },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: {\n settings: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'EUR' },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n conversions: [\n {\n conversion_time: '2023-11-14T22:28:20.000Z',\n event_id: 'tw-o8z6j-o8z21',\n identifiers: [\n {\n hashed_email:\n '8c87b489ce35cf2e2f39f80e282cb2e804932a56a213983eeeb428407d43b52d',\n },\n ],\n conversion_id: '1700000900000-gr0up-1',\n value: '249.99',\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const lead: Flow.StepExample = {\n title: 'Lead',\n description:\n 'A form submission is sent to X as a conversion with the SHA-256 hashed email as the identifier.',\n in: getEvent('form submit', {\n timestamp: 1700000901000,\n user: { email: 'user@example.com' },\n source: { type: 'server', id: 'https://example.com', previous_id: '' },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n conversions: [\n {\n conversion_time: '2023-11-14T22:28:21.000Z',\n event_id: 'tw-o8z6j-o8z21',\n identifiers: [\n {\n hashed_email:\n 'b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514',\n },\n ],\n conversion_id: '1700000901000-gr0up-1',\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n\nexport const purchaseWithTwclid: Flow.StepExample = {\n title: 'Purchase with twclid',\n description:\n 'A purchase is sent to X with both the hashed email and the twclid click id for ads attribution.',\n in: getEvent('order complete', {\n timestamp: 1700000902000,\n data: { total: 89.99, currency: 'USD' },\n user: { email: 'buyer@co.com' },\n context: { twclid: ['23opevjt88psuo13lu8d020qkn', 0] },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: {\n settings: {\n value: 'data.total',\n currency: { key: 'data.currency', value: 'USD' },\n },\n data: {\n map: {\n user_data: {\n map: {\n twclid: 'context.twclid',\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n conversions: [\n {\n conversion_time: '2023-11-14T22:28:22.000Z',\n event_id: 'tw-o8z6j-o8z21',\n identifiers: [\n {\n hashed_email:\n '484c39bfb51212665d9673805c112b5ba04cbf0460b6d3f00bcdc18b92afed66',\n },\n { twclid: '23opevjt88psuo13lu8d020qkn' },\n ],\n conversion_id: '1700000902000-gr0up-1',\n value: '89.99',\n },\n ],\n }),\n HEADERS,\n ],\n ],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAQX,IAAM,uBAAuB,EAAE,KAAK;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAMM,IAAM,gBAAgB,EAC1B,OAAO,EACP;AAAA,EACC;AAAA,EACA;AACF;AAMK,IAAM,mBAAmB,EAC7B,OAAO,EACP,MAAM,SAAS,yCAAyC;;;AD9BpD,IAAM,iBAAiBC,GAAE,OAAO;AAAA,EACrC,SAASA,GACN,OAAO,EACP,IAAI,CAAC,EACL,SAAS,qDAAqD;AAAA,EACjE,SAAS,cAAc;AAAA,IACrB;AAAA,EACF;AAAA,EACA,aAAaA,GACV,OAAO,EACP,IAAI,CAAC,EACL,SAAS,iDAAiD;AAAA,EAC7D,gBAAgBA,GACb,OAAO,EACP,IAAI,CAAC,EACL,SAAS,6CAA6C;AAAA,EACzD,aAAaA,GAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,8BAA8B;AAAA,EACtE,mBAAmBA,GAChB,OAAO,EACP,IAAI,CAAC,EACL,SAAS,qCAAqC;AAAA,EACjD,YAAY,iBAAiB;AAAA,IAC3B;AAAA,EACF,EAAE,SAAS;AAAA,EACX,WAAWA,GACR,MAAMA,GAAE,OAAO,CAAC,EAChB;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,KAAKA,GACF,OAAO,EACP,IAAI,EACJ;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,WAAWA,GACR,OAAOA,GAAE,OAAO,GAAGA,GAAE,OAAO,CAAC,EAC7B;AAAA,IACC;AAAA,EACF,EACC,S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AAM,UAAU,IAAI,4BAA4B,aAAa,GAAG;AAAA,EAC5E,CAAC;AAAA,EACD,SAAS;AAAA,IACP,UAAU;AAAA,MACR,OAAO;AAAA,MACP,UAAU,EAAE,KAAK,iBAAiB,OAAO,MAAM;AAAA,IACjD;AAAA,IACA,MAAM;AAAA,MACJ,KAAK;AAAA,QACH,WAAW;AAAA,UACT,KAAK;AAAA,YACH,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,aAAa;AAAA,UACX;AAAA,YACE,iBAAiB;AAAA,YACjB,UAAU;AAAA,YACV,aAAa;AAAA,cACX;AAAA,gBACE,cACE;AAAA,cACJ;AAAA,cACA,EAAE,QAAQ,6BAA6B;AAAA,YACzC;AAAA,YACA,eAAe;AAAA,YACf,OAAO;AAAA,UACT;AAAA,QACF;AAAA,MACF,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;","names":["z","z","z"]}
|
package/dist/examples/index.js
CHANGED
|
@@ -58,6 +58,8 @@ var HEADERS = {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
var purchase = {
|
|
61
|
+
title: "Purchase",
|
|
62
|
+
description: "A completed order is sent to the X (Twitter) Conversions API with conversion value and the hashed email.",
|
|
61
63
|
in: (0, import_core.getEvent)("order complete", {
|
|
62
64
|
timestamp: 17000009e5,
|
|
63
65
|
data: { total: 249.99, currency: "EUR" },
|
|
@@ -94,6 +96,8 @@ var purchase = {
|
|
|
94
96
|
]
|
|
95
97
|
};
|
|
96
98
|
var lead = {
|
|
99
|
+
title: "Lead",
|
|
100
|
+
description: "A form submission is sent to X as a conversion with the SHA-256 hashed email as the identifier.",
|
|
97
101
|
in: (0, import_core.getEvent)("form submit", {
|
|
98
102
|
timestamp: 1700000901e3,
|
|
99
103
|
user: { email: "user@example.com" },
|
|
@@ -123,6 +127,8 @@ var lead = {
|
|
|
123
127
|
]
|
|
124
128
|
};
|
|
125
129
|
var purchaseWithTwclid = {
|
|
130
|
+
title: "Purchase with twclid",
|
|
131
|
+
description: "A purchase is sent to X with both the hashed email and the twclid click id for ads attribution.",
|
|
126
132
|
in: (0, import_core.getEvent)("order complete", {
|
|
127
133
|
timestamp: 1700000902e3,
|
|
128
134
|
data: { total: 89.99, currency: "USD" },
|
package/dist/examples/index.mjs
CHANGED
|
@@ -37,6 +37,8 @@ var HEADERS = {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
var purchase = {
|
|
40
|
+
title: "Purchase",
|
|
41
|
+
description: "A completed order is sent to the X (Twitter) Conversions API with conversion value and the hashed email.",
|
|
40
42
|
in: getEvent("order complete", {
|
|
41
43
|
timestamp: 17000009e5,
|
|
42
44
|
data: { total: 249.99, currency: "EUR" },
|
|
@@ -73,6 +75,8 @@ var purchase = {
|
|
|
73
75
|
]
|
|
74
76
|
};
|
|
75
77
|
var lead = {
|
|
78
|
+
title: "Lead",
|
|
79
|
+
description: "A form submission is sent to X as a conversion with the SHA-256 hashed email as the identifier.",
|
|
76
80
|
in: getEvent("form submit", {
|
|
77
81
|
timestamp: 1700000901e3,
|
|
78
82
|
user: { email: "user@example.com" },
|
|
@@ -102,6 +106,8 @@ var lead = {
|
|
|
102
106
|
]
|
|
103
107
|
};
|
|
104
108
|
var purchaseWithTwclid = {
|
|
109
|
+
title: "Purchase with twclid",
|
|
110
|
+
description: "A purchase is sent to X with both the hashed email and the twclid click id for ads attribution.",
|
|
105
111
|
in: getEvent("order complete", {
|
|
106
112
|
timestamp: 1700000902e3,
|
|
107
113
|
data: { total: 89.99, currency: "USD" },
|
package/dist/walkerOS.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$meta": {
|
|
3
3
|
"package": "@walkeros/server-destination-twitter",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.1",
|
|
5
5
|
"type": "destination",
|
|
6
6
|
"platform": [
|
|
7
7
|
"server"
|
|
@@ -132,6 +132,8 @@
|
|
|
132
132
|
},
|
|
133
133
|
"step": {
|
|
134
134
|
"lead": {
|
|
135
|
+
"title": "Lead",
|
|
136
|
+
"description": "A form submission is sent to X as a conversion with the SHA-256 hashed email as the identifier.",
|
|
135
137
|
"in": {
|
|
136
138
|
"name": "form submit",
|
|
137
139
|
"data": {
|
|
@@ -186,7 +188,7 @@
|
|
|
186
188
|
"group": "gr0up",
|
|
187
189
|
"count": 1,
|
|
188
190
|
"version": {
|
|
189
|
-
"source": "3.4.
|
|
191
|
+
"source": "3.4.1",
|
|
190
192
|
"tagging": 1
|
|
191
193
|
},
|
|
192
194
|
"source": {
|
|
@@ -210,6 +212,8 @@
|
|
|
210
212
|
]
|
|
211
213
|
},
|
|
212
214
|
"purchase": {
|
|
215
|
+
"title": "Purchase",
|
|
216
|
+
"description": "A completed order is sent to the X (Twitter) Conversions API with conversion value and the hashed email.",
|
|
213
217
|
"in": {
|
|
214
218
|
"name": "order complete",
|
|
215
219
|
"data": {
|
|
@@ -291,7 +295,7 @@
|
|
|
291
295
|
"group": "gr0up",
|
|
292
296
|
"count": 1,
|
|
293
297
|
"version": {
|
|
294
|
-
"source": "3.4.
|
|
298
|
+
"source": "3.4.1",
|
|
295
299
|
"tagging": 1
|
|
296
300
|
},
|
|
297
301
|
"source": {
|
|
@@ -324,6 +328,8 @@
|
|
|
324
328
|
]
|
|
325
329
|
},
|
|
326
330
|
"purchaseWithTwclid": {
|
|
331
|
+
"title": "Purchase with twclid",
|
|
332
|
+
"description": "A purchase is sent to X with both the hashed email and the twclid click id for ads attribution.",
|
|
327
333
|
"in": {
|
|
328
334
|
"name": "order complete",
|
|
329
335
|
"data": {
|
|
@@ -405,7 +411,7 @@
|
|
|
405
411
|
"group": "gr0up",
|
|
406
412
|
"count": 1,
|
|
407
413
|
"version": {
|
|
408
|
-
"source": "3.4.
|
|
414
|
+
"source": "3.4.1",
|
|
409
415
|
"tagging": 1
|
|
410
416
|
},
|
|
411
417
|
"source": {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/server-destination-twitter",
|
|
3
3
|
"description": "X (Twitter) Conversions API server destination for walkerOS",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -34,12 +34,12 @@
|
|
|
34
34
|
"update": "npx npm-check-updates -u && npm update"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@walkeros/core": "3.4.
|
|
38
|
-
"@walkeros/server-core": "3.4.
|
|
37
|
+
"@walkeros/core": "3.4.1",
|
|
38
|
+
"@walkeros/server-core": "3.4.1",
|
|
39
39
|
"oauth-1.0a": "^2.2.6"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@walkeros/collector": "3.4.
|
|
42
|
+
"@walkeros/collector": "3.4.1"
|
|
43
43
|
},
|
|
44
44
|
"repository": {
|
|
45
45
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|