@walkeros/server-destination-mparticle 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.d.mts CHANGED
@@ -114,25 +114,25 @@ declare namespace env {
114
114
  }
115
115
 
116
116
  /**
117
- * Default custom_event a walkerOS event with no `eventType` mapping.
117
+ * Default custom_event - a walkerOS event with no `eventType` mapping.
118
118
  * mParticle wraps it as a `custom_event` with the default `other` category.
119
119
  * user_identities are resolved at the batch level from
120
120
  * `settings.userIdentities`.
121
121
  */
122
122
  declare const customEvent: Flow.StepExample;
123
123
  /**
124
- * screen_view event mapping.settings.eventType switches the mParticle
124
+ * screen_view event - mapping.settings.eventType switches the mParticle
125
125
  * event shape. Uses event name as the `screen_name`.
126
126
  */
127
127
  declare const screenView: Flow.StepExample;
128
128
  /**
129
- * commerce_event mapping.settings.eventType: 'commerce_event' plus a
129
+ * commerce_event - mapping.settings.eventType: 'commerce_event' plus a
130
130
  * `commerce` mapping resolves a ProductAction block. Products, currency,
131
131
  * and transaction metadata are all driven by the commerce mapping value.
132
132
  */
133
133
  declare const commercePurchase: Flow.StepExample;
134
134
  /**
135
- * Identity + attributes verifies `user_identities` and `user_attributes`
135
+ * Identity + attributes - verifies `user_identities` and `user_attributes`
136
136
  * come from the batch-level settings mappings, not the event payload.
137
137
  */
138
138
  declare const identityAndAttributes: Flow.StepExample;
package/dist/dev.d.ts CHANGED
@@ -114,25 +114,25 @@ declare namespace env {
114
114
  }
115
115
 
116
116
  /**
117
- * Default custom_event a walkerOS event with no `eventType` mapping.
117
+ * Default custom_event - a walkerOS event with no `eventType` mapping.
118
118
  * mParticle wraps it as a `custom_event` with the default `other` category.
119
119
  * user_identities are resolved at the batch level from
120
120
  * `settings.userIdentities`.
121
121
  */
122
122
  declare const customEvent: Flow.StepExample;
123
123
  /**
124
- * screen_view event mapping.settings.eventType switches the mParticle
124
+ * screen_view event - mapping.settings.eventType switches the mParticle
125
125
  * event shape. Uses event name as the `screen_name`.
126
126
  */
127
127
  declare const screenView: Flow.StepExample;
128
128
  /**
129
- * commerce_event mapping.settings.eventType: 'commerce_event' plus a
129
+ * commerce_event - mapping.settings.eventType: 'commerce_event' plus a
130
130
  * `commerce` mapping resolves a ProductAction block. Products, currency,
131
131
  * and transaction metadata are all driven by the commerce mapping value.
132
132
  */
133
133
  declare const commercePurchase: Flow.StepExample;
134
134
  /**
135
- * Identity + attributes verifies `user_identities` and `user_attributes`
135
+ * Identity + attributes - verifies `user_identities` and `user_attributes`
136
136
  * come from the batch-level settings mappings, not the event payload.
137
137
  */
138
138
  declare const identityAndAttributes: Flow.StepExample;
package/dist/dev.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,s=(e,r)=>{for(var i in r)t(e,i,{get:r[i],enumerable:!0})},o={};s(o,{examples:()=>w,schemas:()=>a}),module.exports=(e=o,((e,s,o,a)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let c of i(s))n.call(e,c)||c===o||t(e,c,{get:()=>s[c],enumerable:!(a=r(s,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={};s(a,{CustomEventTypeSchema:()=>l,EnvironmentSchema:()=>d,EventTypeSchema:()=>v,MappingSchema:()=>g,PodSchema:()=>m,SettingsSchema:()=>_,mapping:()=>y,settings:()=>b});var c=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),p=require("@walkeros/core/dev"),m=p.z.enum(["us1","us2","eu1","au1"]),d=p.z.enum(["production","development"]),v=p.z.enum(["custom_event","screen_view","commerce_event"]),l=p.z.enum(["navigation","location","search","transaction","user_content","user_preference","social","media","attribution","other"]),_=u.z.object({apiKey:u.z.string().min(1).describe("mParticle input feed API key from the mParticle dashboard (Setup > Inputs > Feeds)."),apiSecret:u.z.string().min(1).describe("mParticle input feed API secret paired with apiKey. Used for HTTP Basic auth."),pod:m.describe("mParticle data pod selecting the regional endpoint. Default: 'us1'.").optional(),environment:d.describe("Environment the batch targets. Default: 'production'.").optional(),userIdentities:u.z.record(u.z.string(),u.z.unknown()).describe("Mapping that resolves to user_identities per batch. Keys are mParticle identity types (like customer_id, email); values are walkerOS mapping values.").optional(),userAttributes:u.z.unknown().describe("Mapping value that resolves to the user_attributes object placed on the batch.").optional(),consent:u.z.record(u.z.string(),u.z.unknown()).describe("Static consent_state envelope forwarded verbatim on the batch. See mParticle consent_state docs.").optional(),ip:u.z.unknown().describe("Mapping value resolving to the client IP for the batch.").optional(),sourceRequestId:u.z.unknown().describe("Mapping value resolving to the source_request_id for the batch. Falls back to event.id when unset.").optional()}),h=require("@walkeros/core/dev"),g=h.z.object({eventType:v.describe("Per-event mParticle event type. Default: 'custom_event'.").optional(),customEventType:l.describe("Custom event type category for 'custom_event'. Default: 'other'.").optional(),commerce:h.z.unknown().describe("Mapping value resolving to the commerce fields (product_action, currency_code, products, ...) for a commerce_event.").optional(),userIdentities:h.z.record(h.z.string(),h.z.unknown()).describe("Per-event override mapping for user_identities. Merged over settings.userIdentities.").optional(),userAttributes:h.z.unknown().describe("Per-event override mapping for user_attributes.").optional()}),b=(0,c.zodToSchema)(_),y=(0,c.zodToSchema)(g),w={};s(w,{env:()=>f,step:()=>P});var f={};s(f,{push:()=>S,simulation:()=>z});var S={sendServer:async()=>({ok:!0,data:{}})},z=["sendServer"],P={};s(P,{commercePurchase:()=>q,customEvent:()=>x,identityAndAttributes:()=>T,screenView:()=>E});var k=require("@walkeros/core"),O="https://s2s.mparticle.com/v2/events",A={headers:{Authorization:"Basic a2V5OnNlY3JldA==","Content-Type":"application/json"}},x={title:"Custom event",description:"A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.",in:(0,k.getEvent)("product view",{timestamp:17000001e5,data:{id:"SKU-A1",name:"Shoe",price:129.99},user:{id:"user-123"},source:{type:"server",id:"https://shop.example.com",previous_id:""}}),mapping:void 0,out:[["sendServer",O,JSON.stringify({events:[{event_type:"custom_event",data:{event_name:"product view",custom_event_type:"other",timestamp_unixtime_ms:17000001e5,source_message_id:"1700000100000-gr0up-1"}}],environment:"production",user_identities:{customer_id:"user-123"},source_request_id:"1700000100000-gr0up-1"}),A]]},E={title:"Screen view",description:"A page view is mapped to an mParticle screen_view event with the event name as the screen name.",in:(0,k.getEvent)("page view",{timestamp:17000002e5,data:{title:"Checkout",path:"/checkout"},user:{id:"user-123"},source:{type:"server",id:"https://shop.example.com",previous_id:""}}),mapping:{settings:{eventType:"screen_view"}},out:[["sendServer",O,JSON.stringify({events:[{event_type:"screen_view",data:{screen_name:"page view",timestamp_unixtime_ms:17000002e5,source_message_id:"1700000200000-gr0up-1"}}],environment:"production",user_identities:{customer_id:"user-123"},source_request_id:"1700000200000-gr0up-1"}),A]]},q={title:"Commerce purchase",description:"A completed order becomes an mParticle commerce_event with a purchase product_action block.",in:(0,k.getEvent)("order complete",{timestamp:17000003e5,data:{id:"ORD-300",total:249.99,currency:"EUR"},user:{id:"user-123"},source:{type:"server",id:"https://shop.example.com",previous_id:""}}),mapping:{settings:{eventType:"commerce_event",commerce:{map:{currency_code:"data.currency",product_action:{map:{action:{value:"purchase"},transaction_id:"data.id",total_amount:"data.total"}}}}}},out:[["sendServer",O,JSON.stringify({events:[{event_type:"commerce_event",data:{currency_code:"EUR",product_action:{action:"purchase",transaction_id:"ORD-300",total_amount:249.99},timestamp_unixtime_ms:17000003e5,source_message_id:"1700000300000-gr0up-1"}}],environment:"production",user_identities:{customer_id:"user-123"},source_request_id:"1700000300000-gr0up-1"}),A]]},T={title:"User identities",description:"A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.",in:(0,k.getEvent)("form submit",{timestamp:17000004e5,data:{type:"newsletter"},user:{id:"user-123",email:"user@example.com"},source:{type:"server",id:"https://example.com",previous_id:""}}),mapping:void 0,out:[["sendServer",O,JSON.stringify({events:[{event_type:"custom_event",data:{event_name:"form submit",custom_event_type:"other",timestamp_unixtime_ms:17000004e5,source_message_id:"1700000400000-gr0up-1"}}],environment:"production",user_identities:{customer_id:"user-123",email:"user@example.com"},source_request_id:"1700000400000-gr0up-1"}),A]]};//# sourceMappingURL=dev.js.map
1
+ "use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,s=(e,r)=>{for(var i in r)t(e,i,{get:r[i],enumerable:!0})},o={};s(o,{examples:()=>f,schemas:()=>a}),module.exports=(e=o,((e,s,o,a)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let c of i(s))n.call(e,c)||c===o||t(e,c,{get:()=>s[c],enumerable:!(a=r(s,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={};s(a,{CustomEventTypeSchema:()=>l,EnvironmentSchema:()=>d,EventTypeSchema:()=>v,MappingSchema:()=>g,PodSchema:()=>p,SettingsSchema:()=>_,mapping:()=>y,settings:()=>b});var c=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),m=require("@walkeros/core/dev"),p=m.z.enum(["us1","us2","eu1","au1"]),d=m.z.enum(["production","development"]),v=m.z.enum(["custom_event","screen_view","commerce_event"]),l=m.z.enum(["navigation","location","search","transaction","user_content","user_preference","social","media","attribution","other"]),_=u.z.object({apiKey:u.z.string().min(1).describe("mParticle input feed API key from the mParticle dashboard (Setup > Inputs > Feeds)."),apiSecret:u.z.string().min(1).describe("mParticle input feed API secret paired with apiKey. Used for HTTP Basic auth."),pod:p.describe("mParticle data pod selecting the regional endpoint. Default: 'us1'.").optional(),environment:d.describe("Environment the batch targets. Default: 'production'.").optional(),userIdentities:u.z.record(u.z.string(),u.z.unknown()).describe("Mapping that resolves to user_identities per batch. Keys are mParticle identity types (like customer_id, email); values are walkerOS mapping values.").optional(),userAttributes:u.z.unknown().describe("Mapping value that resolves to the user_attributes object placed on the batch.").optional(),consent:u.z.record(u.z.string(),u.z.unknown()).describe("Static consent_state envelope forwarded verbatim on the batch. See mParticle consent_state docs.").optional(),ip:u.z.unknown().describe("Mapping value resolving to the client IP for the batch.").optional(),sourceRequestId:u.z.unknown().describe("Mapping value resolving to the source_request_id for the batch. Falls back to event.id when unset.").optional()}),h=require("@walkeros/core/dev"),g=h.z.object({eventType:v.describe("Per-event mParticle event type. Default: 'custom_event'.").optional(),customEventType:l.describe("Custom event type category for 'custom_event'. Default: 'other'.").optional(),commerce:h.z.unknown().describe("Mapping value resolving to the commerce fields (product_action, currency_code, products, ...) for a commerce_event.").optional(),userIdentities:h.z.record(h.z.string(),h.z.unknown()).describe("Per-event override mapping for user_identities. Merged over settings.userIdentities.").optional(),userAttributes:h.z.unknown().describe("Per-event override mapping for user_attributes.").optional()}),b=(0,c.zodToSchema)(_),y=(0,c.zodToSchema)(g),f={};s(f,{env:()=>w,step:()=>P});var w={};s(w,{push:()=>S,simulation:()=>z});var S={sendServer:async()=>({ok:!0,data:{}})},z=["sendServer"],P={};s(P,{commercePurchase:()=>q,customEvent:()=>x,identityAndAttributes:()=>T,screenView:()=>E});var k=require("@walkeros/core"),O="https://s2s.mparticle.com/v2/events",A={headers:{Authorization:"Basic a2V5OnNlY3JldA==","Content-Type":"application/json"}},x={title:"Custom event",description:"A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.",in:(0,k.getEvent)("product view",{id:"ev-1700000100000",timestamp:17000001e5,data:{id:"SKU-A1",name:"Shoe",price:129.99},user:{id:"user-123"},source:{type:"express",platform:"server"}}),mapping:void 0,out:[["sendServer",O,JSON.stringify({events:[{event_type:"custom_event",data:{event_name:"product view",custom_event_type:"other",timestamp_unixtime_ms:17000001e5,source_message_id:"ev-1700000100000"}}],environment:"production",user_identities:{customer_id:"user-123"},source_request_id:"ev-1700000100000"}),A]]},E={title:"Screen view",description:"A page view is mapped to an mParticle screen_view event with the event name as the screen name.",in:(0,k.getEvent)("page view",{id:"ev-1700000200000",timestamp:17000002e5,data:{title:"Checkout",path:"/checkout"},user:{id:"user-123"},source:{type:"express",platform:"server"}}),mapping:{settings:{eventType:"screen_view"}},out:[["sendServer",O,JSON.stringify({events:[{event_type:"screen_view",data:{screen_name:"page view",timestamp_unixtime_ms:17000002e5,source_message_id:"ev-1700000200000"}}],environment:"production",user_identities:{customer_id:"user-123"},source_request_id:"ev-1700000200000"}),A]]},q={title:"Commerce purchase",description:"A completed order becomes an mParticle commerce_event with a purchase product_action block.",in:(0,k.getEvent)("order complete",{id:"ev-1700000300000",timestamp:17000003e5,data:{id:"ORD-300",total:249.99,currency:"EUR"},user:{id:"user-123"},source:{type:"express",platform:"server"}}),mapping:{settings:{eventType:"commerce_event",commerce:{map:{currency_code:"data.currency",product_action:{map:{action:{value:"purchase"},transaction_id:"data.id",total_amount:"data.total"}}}}}},out:[["sendServer",O,JSON.stringify({events:[{event_type:"commerce_event",data:{currency_code:"EUR",product_action:{action:"purchase",transaction_id:"ORD-300",total_amount:249.99},timestamp_unixtime_ms:17000003e5,source_message_id:"ev-1700000300000"}}],environment:"production",user_identities:{customer_id:"user-123"},source_request_id:"ev-1700000300000"}),A]]},T={title:"User identities",description:"A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.",in:(0,k.getEvent)("form submit",{id:"ev-1700000400000",timestamp:17000004e5,data:{type:"newsletter"},user:{id:"user-123",email:"user@example.com"},source:{type:"express",platform:"server"}}),mapping:void 0,out:[["sendServer",O,JSON.stringify({events:[{event_type:"custom_event",data:{event_name:"form submit",custom_event_type:"other",timestamp_unixtime_ms:17000004e5,source_message_id:"ev-1700000400000"}}],environment:"production",user_identities:{customer_id:"user-123",email:"user@example.com"},source_request_id:"ev-1700000400000"}),A]]};//# 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 { EnvironmentSchema, PodSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'mParticle input feed API key from the mParticle dashboard (Setup > Inputs > Feeds).',\n ),\n apiSecret: z\n .string()\n .min(1)\n .describe(\n 'mParticle input feed API secret paired with apiKey. Used for HTTP Basic auth.',\n ),\n pod: PodSchema.describe(\n \"mParticle data pod selecting the regional endpoint. Default: 'us1'.\",\n ).optional(),\n environment: EnvironmentSchema.describe(\n \"Environment the batch targets. Default: 'production'.\",\n ).optional(),\n userIdentities: z\n .record(z.string(), z.unknown())\n .describe(\n 'Mapping that resolves to user_identities per batch. Keys are mParticle identity types (like customer_id, email); values are walkerOS mapping values.',\n )\n .optional(),\n userAttributes: z\n .unknown()\n .describe(\n 'Mapping value that resolves to the user_attributes object placed on the batch.',\n )\n .optional(),\n consent: z\n .record(z.string(), z.unknown())\n .describe(\n 'Static consent_state envelope forwarded verbatim on the batch. See mParticle consent_state docs.',\n )\n .optional(),\n ip: z\n .unknown()\n .describe('Mapping value resolving to the client IP for the batch.')\n .optional(),\n sourceRequestId: z\n .unknown()\n .describe(\n 'Mapping value resolving to the source_request_id for the batch. Falls back to event.id when unset.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/** mParticle data pod (regional endpoint selector). */\nexport const PodSchema = z.enum(['us1', 'us2', 'eu1', 'au1']);\n\n/** Target environment for the batch. */\nexport const EnvironmentSchema = z.enum(['production', 'development']);\n\n/** Supported mParticle event types emitted by this destination. */\nexport const EventTypeSchema = z.enum([\n 'custom_event',\n 'screen_view',\n 'commerce_event',\n]);\n\n/** mParticle custom event category for `custom_event`. */\nexport const CustomEventTypeSchema = z.enum([\n 'navigation',\n 'location',\n 'search',\n 'transaction',\n 'user_content',\n 'user_preference',\n 'social',\n 'media',\n 'attribution',\n 'other',\n]);\n","import { z } from '@walkeros/core/dev';\nimport { CustomEventTypeSchema, EventTypeSchema } from './primitives';\n\nexport const MappingSchema = z.object({\n eventType: EventTypeSchema.describe(\n \"Per-event mParticle event type. Default: 'custom_event'.\",\n ).optional(),\n customEventType: CustomEventTypeSchema.describe(\n \"Custom event type category for 'custom_event'. Default: 'other'.\",\n ).optional(),\n commerce: z\n .unknown()\n .describe(\n 'Mapping value resolving to the commerce fields (product_action, currency_code, products, ...) for a commerce_event.',\n )\n .optional(),\n userIdentities: z\n .record(z.string(), z.unknown())\n .describe(\n 'Per-event override mapping for user_identities. Merged over settings.userIdentities.',\n )\n .optional(),\n userAttributes: z\n .unknown()\n .describe('Per-event override mapping for user_attributes.')\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 mParticle Events API destination.\n *\n * Provides a standardized mock `sendServer` so tests and simulations can\n * run without making real HTTP calls to mParticle.\n */\n\ntype MockSendServer = (\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n) => Promise<SendResponse>;\n\nconst mockSendServer: MockSendServer = async () => {\n // Simulates mParticle's typical 202 Accepted response for the Events API.\n return {\n ok: true,\n data: {},\n };\n};\n\n/**\n * Standard mock environment for push operations.\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 * mParticle Events API step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(endpoint, JSON.stringify(batch), options)` where\n * endpoint = `buildEndpoint(pod)` (default pod `us1` → `https://s2s.mparticle.com/v2/events`)\n * batch = the mParticle v2 batch envelope\n *\n * Test fixture pins `apiKey = 'key'`, `apiSecret = 'secret'`, pod `us1`, so\n * every call targets that endpoint with `Authorization: Basic a2V5OnNlY3JldA==`.\n *\n * The batch keys appear in the order the destination constructs them:\n * 1. events (always a single-element array)\n * 2. environment ('production' by default)\n * 3. user_identities (only when resolved)\n * 4. user_attributes (only when resolved)\n * 5. ip (only when mapped)\n * 6. source_request_id (falls back to `event.id`)\n * 7. consent_state, context (unused here)\n *\n * `options` carries Authorization + Content-Type headers.\n */\nconst ENDPOINT = 'https://s2s.mparticle.com/v2/events';\nconst OPTIONS = {\n headers: {\n // Basic base64('key:secret')\n Authorization: 'Basic a2V5OnNlY3JldA==',\n 'Content-Type': 'application/json',\n },\n};\n\n/**\n * Default custom_event — a walkerOS event with no `eventType` mapping.\n * mParticle wraps it as a `custom_event` with the default `other` category.\n * user_identities are resolved at the batch level from\n * `settings.userIdentities`.\n */\nexport const customEvent: Flow.StepExample = {\n title: 'Custom event',\n description:\n 'A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.',\n in: getEvent('product view', {\n timestamp: 1700000100000,\n data: { id: 'SKU-A1', name: 'Shoe', price: 129.99 },\n user: { id: 'user-123' },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'custom_event',\n data: {\n event_name: 'product view',\n custom_event_type: 'other',\n timestamp_unixtime_ms: 1700000100000,\n source_message_id: '1700000100000-gr0up-1',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n },\n source_request_id: '1700000100000-gr0up-1',\n }),\n OPTIONS,\n ],\n ],\n};\n\n/**\n * screen_view event — mapping.settings.eventType switches the mParticle\n * event shape. Uses event name as the `screen_name`.\n */\nexport const screenView: Flow.StepExample = {\n title: 'Screen view',\n description:\n 'A page view is mapped to an mParticle screen_view event with the event name as the screen name.',\n in: getEvent('page view', {\n timestamp: 1700000200000,\n data: { title: 'Checkout', path: '/checkout' },\n user: { id: 'user-123' },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: {\n settings: { eventType: 'screen_view' },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'screen_view',\n data: {\n screen_name: 'page view',\n timestamp_unixtime_ms: 1700000200000,\n source_message_id: '1700000200000-gr0up-1',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n },\n source_request_id: '1700000200000-gr0up-1',\n }),\n OPTIONS,\n ],\n ],\n};\n\n/**\n * commerce_event — mapping.settings.eventType: 'commerce_event' plus a\n * `commerce` mapping resolves a ProductAction block. Products, currency,\n * and transaction metadata are all driven by the commerce mapping value.\n */\nexport const commercePurchase: Flow.StepExample = {\n title: 'Commerce purchase',\n description:\n 'A completed order becomes an mParticle commerce_event with a purchase product_action block.',\n in: getEvent('order complete', {\n timestamp: 1700000300000,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n user: { id: 'user-123' },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: {\n settings: {\n eventType: 'commerce_event',\n commerce: {\n map: {\n currency_code: 'data.currency',\n product_action: {\n map: {\n action: { value: 'purchase' },\n transaction_id: 'data.id',\n total_amount: 'data.total',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'commerce_event',\n data: {\n currency_code: 'EUR',\n product_action: {\n action: 'purchase',\n transaction_id: 'ORD-300',\n total_amount: 249.99,\n },\n timestamp_unixtime_ms: 1700000300000,\n source_message_id: '1700000300000-gr0up-1',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n },\n source_request_id: '1700000300000-gr0up-1',\n }),\n OPTIONS,\n ],\n ],\n};\n\n/**\n * Identity + attributes — verifies `user_identities` and `user_attributes`\n * come from the batch-level settings mappings, not the event payload.\n */\nexport const identityAndAttributes: Flow.StepExample = {\n title: 'User identities',\n description:\n 'A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.',\n in: getEvent('form submit', {\n timestamp: 1700000400000,\n data: { type: 'newsletter' },\n user: {\n id: 'user-123',\n email: 'user@example.com',\n },\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 events: [\n {\n event_type: 'custom_event',\n data: {\n event_name: 'form submit',\n custom_event_type: 'other',\n timestamp_unixtime_ms: 1700000400000,\n source_message_id: '1700000400000-gr0up-1',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n email: 'user@example.com',\n },\n source_request_id: '1700000400000-gr0up-1',\n }),\n OPTIONS,\n ],\n ],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,IAAAC,cAAkB;;;ACAlB,iBAAkB;AAGX,IAAM,YAAY,aAAE,KAAK,CAAC,OAAO,OAAO,OAAO,KAAK,CAAC;AAGrD,IAAM,oBAAoB,aAAE,KAAK,CAAC,cAAc,aAAa,CAAC;AAG9D,IAAM,kBAAkB,aAAE,KAAK;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,wBAAwB,aAAE,KAAK;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;;;ADxBM,IAAM,iBAAiB,cAAE,OAAO;AAAA,EACrC,QAAQ,cACL,OAAO,EACP,I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AAQ;AAAA,gBACR,gBAAgB;AAAA,gBAChB,cAAc;AAAA,cAChB;AAAA,cACA,uBAAuB;AAAA,cACvB,mBAAmB;AAAA,YACrB;AAAA,UACF;AAAA,QACF;AAAA,QACA,aAAa;AAAA,QACb,iBAAiB;AAAA,UACf,aAAa;AAAA,QACf;AAAA,QACA,mBAAmB;AAAA,MACrB,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;AAMO,IAAM,wBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,aACE;AAAA,EACF,QAAI,sBAAS,eAAe;AAAA,IAC1B,WAAW;AAAA,IACX,MAAM,EAAE,MAAM,aAAa;AAAA,IAC3B,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,IACT;AAAA,IACA,QAAQ,EAAE,MAAM,UAAU,IAAI,uBAAuB,aAAa,GAAG;AAAA,EACvE,CAAC;AAAA,EACD,SAAS;AAAA,EACT,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,QAAQ;AAAA,UACN;AAAA,YACE,YAAY;AAAA,YACZ,MAAM;AAAA,cACJ,YAAY;AAAA,cACZ,mBAAmB;AAAA,cACnB,uBAAuB;AAAA,cACvB,mBAAmB;AAAA,YACrB;AAAA,UACF;AAAA,QACF;AAAA,QACA,aAAa;AAAA,QACb,iBAAiB;AAAA,UACf,aAAa;AAAA,UACb,OAAO;AAAA,QACT;AAAA,QACA,mBAAmB;AAAA,MACrB,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 { EnvironmentSchema, PodSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'mParticle input feed API key from the mParticle dashboard (Setup > Inputs > Feeds).',\n ),\n apiSecret: z\n .string()\n .min(1)\n .describe(\n 'mParticle input feed API secret paired with apiKey. Used for HTTP Basic auth.',\n ),\n pod: PodSchema.describe(\n \"mParticle data pod selecting the regional endpoint. Default: 'us1'.\",\n ).optional(),\n environment: EnvironmentSchema.describe(\n \"Environment the batch targets. Default: 'production'.\",\n ).optional(),\n userIdentities: z\n .record(z.string(), z.unknown())\n .describe(\n 'Mapping that resolves to user_identities per batch. Keys are mParticle identity types (like customer_id, email); values are walkerOS mapping values.',\n )\n .optional(),\n userAttributes: z\n .unknown()\n .describe(\n 'Mapping value that resolves to the user_attributes object placed on the batch.',\n )\n .optional(),\n consent: z\n .record(z.string(), z.unknown())\n .describe(\n 'Static consent_state envelope forwarded verbatim on the batch. See mParticle consent_state docs.',\n )\n .optional(),\n ip: z\n .unknown()\n .describe('Mapping value resolving to the client IP for the batch.')\n .optional(),\n sourceRequestId: z\n .unknown()\n .describe(\n 'Mapping value resolving to the source_request_id for the batch. Falls back to event.id when unset.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/** mParticle data pod (regional endpoint selector). */\nexport const PodSchema = z.enum(['us1', 'us2', 'eu1', 'au1']);\n\n/** Target environment for the batch. */\nexport const EnvironmentSchema = z.enum(['production', 'development']);\n\n/** Supported mParticle event types emitted by this destination. */\nexport const EventTypeSchema = z.enum([\n 'custom_event',\n 'screen_view',\n 'commerce_event',\n]);\n\n/** mParticle custom event category for `custom_event`. */\nexport const CustomEventTypeSchema = z.enum([\n 'navigation',\n 'location',\n 'search',\n 'transaction',\n 'user_content',\n 'user_preference',\n 'social',\n 'media',\n 'attribution',\n 'other',\n]);\n","import { z } from '@walkeros/core/dev';\nimport { CustomEventTypeSchema, EventTypeSchema } from './primitives';\n\nexport const MappingSchema = z.object({\n eventType: EventTypeSchema.describe(\n \"Per-event mParticle event type. Default: 'custom_event'.\",\n ).optional(),\n customEventType: CustomEventTypeSchema.describe(\n \"Custom event type category for 'custom_event'. Default: 'other'.\",\n ).optional(),\n commerce: z\n .unknown()\n .describe(\n 'Mapping value resolving to the commerce fields (product_action, currency_code, products, ...) for a commerce_event.',\n )\n .optional(),\n userIdentities: z\n .record(z.string(), z.unknown())\n .describe(\n 'Per-event override mapping for user_identities. Merged over settings.userIdentities.',\n )\n .optional(),\n userAttributes: z\n .unknown()\n .describe('Per-event override mapping for user_attributes.')\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 mParticle Events API destination.\n *\n * Provides a standardized mock `sendServer` so tests and simulations can\n * run without making real HTTP calls to mParticle.\n */\n\ntype MockSendServer = (\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n) => Promise<SendResponse>;\n\nconst mockSendServer: MockSendServer = async () => {\n // Simulates mParticle's typical 202 Accepted response for the Events API.\n return {\n ok: true,\n data: {},\n };\n};\n\n/**\n * Standard mock environment for push operations.\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 * mParticle Events API step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(endpoint, JSON.stringify(batch), options)` where\n * endpoint = `buildEndpoint(pod)` (default pod `us1` → `https://s2s.mparticle.com/v2/events`)\n * batch = the mParticle v2 batch envelope\n *\n * Test fixture pins `apiKey = 'key'`, `apiSecret = 'secret'`, pod `us1`, so\n * every call targets that endpoint with `Authorization: Basic a2V5OnNlY3JldA==`.\n *\n * The batch keys appear in the order the destination constructs them:\n * 1. events (always a single-element array)\n * 2. environment ('production' by default)\n * 3. user_identities (only when resolved)\n * 4. user_attributes (only when resolved)\n * 5. ip (only when mapped)\n * 6. source_request_id (falls back to `event.id`)\n * 7. consent_state, context (unused here)\n *\n * `options` carries Authorization + Content-Type headers.\n */\nconst ENDPOINT = 'https://s2s.mparticle.com/v2/events';\nconst OPTIONS = {\n headers: {\n // Basic base64('key:secret')\n Authorization: 'Basic a2V5OnNlY3JldA==',\n 'Content-Type': 'application/json',\n },\n};\n\n/**\n * Default custom_event - a walkerOS event with no `eventType` mapping.\n * mParticle wraps it as a `custom_event` with the default `other` category.\n * user_identities are resolved at the batch level from\n * `settings.userIdentities`.\n */\nexport const customEvent: Flow.StepExample = {\n title: 'Custom event',\n description:\n 'A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.',\n in: getEvent('product view', {\n id: 'ev-1700000100000',\n timestamp: 1700000100000,\n data: { id: 'SKU-A1', name: 'Shoe', price: 129.99 },\n user: { id: 'user-123' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'custom_event',\n data: {\n event_name: 'product view',\n custom_event_type: 'other',\n timestamp_unixtime_ms: 1700000100000,\n source_message_id: 'ev-1700000100000',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n },\n source_request_id: 'ev-1700000100000',\n }),\n OPTIONS,\n ],\n ],\n};\n\n/**\n * screen_view event - mapping.settings.eventType switches the mParticle\n * event shape. Uses event name as the `screen_name`.\n */\nexport const screenView: Flow.StepExample = {\n title: 'Screen view',\n description:\n 'A page view is mapped to an mParticle screen_view event with the event name as the screen name.',\n in: getEvent('page view', {\n id: 'ev-1700000200000',\n timestamp: 1700000200000,\n data: { title: 'Checkout', path: '/checkout' },\n user: { id: 'user-123' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n settings: { eventType: 'screen_view' },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'screen_view',\n data: {\n screen_name: 'page view',\n timestamp_unixtime_ms: 1700000200000,\n source_message_id: 'ev-1700000200000',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n },\n source_request_id: 'ev-1700000200000',\n }),\n OPTIONS,\n ],\n ],\n};\n\n/**\n * commerce_event - mapping.settings.eventType: 'commerce_event' plus a\n * `commerce` mapping resolves a ProductAction block. Products, currency,\n * and transaction metadata are all driven by the commerce mapping value.\n */\nexport const commercePurchase: Flow.StepExample = {\n title: 'Commerce purchase',\n description:\n 'A completed order becomes an mParticle commerce_event with a purchase product_action block.',\n in: getEvent('order complete', {\n id: 'ev-1700000300000',\n timestamp: 1700000300000,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n user: { id: 'user-123' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n settings: {\n eventType: 'commerce_event',\n commerce: {\n map: {\n currency_code: 'data.currency',\n product_action: {\n map: {\n action: { value: 'purchase' },\n transaction_id: 'data.id',\n total_amount: 'data.total',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'commerce_event',\n data: {\n currency_code: 'EUR',\n product_action: {\n action: 'purchase',\n transaction_id: 'ORD-300',\n total_amount: 249.99,\n },\n timestamp_unixtime_ms: 1700000300000,\n source_message_id: 'ev-1700000300000',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n },\n source_request_id: 'ev-1700000300000',\n }),\n OPTIONS,\n ],\n ],\n};\n\n/**\n * Identity + attributes - verifies `user_identities` and `user_attributes`\n * come from the batch-level settings mappings, not the event payload.\n */\nexport const identityAndAttributes: Flow.StepExample = {\n title: 'User identities',\n description:\n 'A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.',\n in: getEvent('form submit', {\n id: 'ev-1700000400000',\n timestamp: 1700000400000,\n data: { type: 'newsletter' },\n user: {\n id: 'user-123',\n email: 'user@example.com',\n },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'custom_event',\n data: {\n event_name: 'form submit',\n custom_event_type: 'other',\n timestamp_unixtime_ms: 1700000400000,\n source_message_id: 'ev-1700000400000',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n email: 'user@example.com',\n },\n source_request_id: 'ev-1700000400000',\n }),\n OPTIONS,\n ],\n ],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,IAAAC,cAAkB;;;ACAlB,iBAAkB;AAGX,IAAM,YAAY,aAAE,KAAK,CAAC,OAAO,OAAO,OAAO,KAAK,CAAC;AAGrD,IAAM,oBAAoB,aAAE,KAAK,CAAC,cAAc,aAAa,CAAC;AAG9D,IAAM,kBAAkB,aAAE,KAAK;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,wBAAwB,aAAE,KAAK;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;;;ADxBM,IAAM,iBAAiB,cAAE,OAAO;AAAA,EACrC,QAAQ,cACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,WAAW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AAAA,cAChB;AAAA,cACA,uBAAuB;AAAA,cACvB,mBAAmB;AAAA,YACrB;AAAA,UACF;AAAA,QACF;AAAA,QACA,aAAa;AAAA,QACb,iBAAiB;AAAA,UACf,aAAa;AAAA,QACf;AAAA,QACA,mBAAmB;AAAA,MACrB,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;AAMO,IAAM,wBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,aACE;AAAA,EACF,QAAI,sBAAS,eAAe;AAAA,IAC1B,IAAI;AAAA,IACJ,WAAW;AAAA,IACX,MAAM,EAAE,MAAM,aAAa;AAAA,IAC3B,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,IACT;AAAA,IACA,QAAQ,EAAE,MAAM,WAAW,UAAU,SAAS;AAAA,EAChD,CAAC;AAAA,EACD,SAAS;AAAA,EACT,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,QAAQ;AAAA,UACN;AAAA,YACE,YAAY;AAAA,YACZ,MAAM;AAAA,cACJ,YAAY;AAAA,cACZ,mBAAmB;AAAA,cACnB,uBAAuB;AAAA,cACvB,mBAAmB;AAAA,YACrB;AAAA,UACF;AAAA,QACF;AAAA,QACA,aAAa;AAAA,QACb,iBAAiB;AAAA,UACf,aAAa;AAAA,UACb,OAAO;AAAA,QACT;AAAA,QACA,mBAAmB;AAAA,MACrB,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,r)=>{for(var i in r)e(t,i,{get:r[i],enumerable:!0})},r={};t(r,{CustomEventTypeSchema:()=>u,EnvironmentSchema:()=>a,EventTypeSchema:()=>c,MappingSchema:()=>d,PodSchema:()=>o,SettingsSchema:()=>m,mapping:()=>l,settings:()=>v});import{zodToSchema as i}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";import{z as n}from"@walkeros/core/dev";var o=n.enum(["us1","us2","eu1","au1"]),a=n.enum(["production","development"]),c=n.enum(["custom_event","screen_view","commerce_event"]),u=n.enum(["navigation","location","search","transaction","user_content","user_preference","social","media","attribution","other"]),m=s.object({apiKey:s.string().min(1).describe("mParticle input feed API key from the mParticle dashboard (Setup > Inputs > Feeds)."),apiSecret:s.string().min(1).describe("mParticle input feed API secret paired with apiKey. Used for HTTP Basic auth."),pod:o.describe("mParticle data pod selecting the regional endpoint. Default: 'us1'.").optional(),environment:a.describe("Environment the batch targets. Default: 'production'.").optional(),userIdentities:s.record(s.string(),s.unknown()).describe("Mapping that resolves to user_identities per batch. Keys are mParticle identity types (like customer_id, email); values are walkerOS mapping values.").optional(),userAttributes:s.unknown().describe("Mapping value that resolves to the user_attributes object placed on the batch.").optional(),consent:s.record(s.string(),s.unknown()).describe("Static consent_state envelope forwarded verbatim on the batch. See mParticle consent_state docs.").optional(),ip:s.unknown().describe("Mapping value resolving to the client IP for the batch.").optional(),sourceRequestId:s.unknown().describe("Mapping value resolving to the source_request_id for the batch. Falls back to event.id when unset.").optional()});import{z as p}from"@walkeros/core/dev";var d=p.object({eventType:c.describe("Per-event mParticle event type. Default: 'custom_event'.").optional(),customEventType:u.describe("Custom event type category for 'custom_event'. Default: 'other'.").optional(),commerce:p.unknown().describe("Mapping value resolving to the commerce fields (product_action, currency_code, products, ...) for a commerce_event.").optional(),userIdentities:p.record(p.string(),p.unknown()).describe("Per-event override mapping for user_identities. Merged over settings.userIdentities.").optional(),userAttributes:p.unknown().describe("Per-event override mapping for user_attributes.").optional()}),v=i(m),l=i(d),_={};t(_,{env:()=>h,step:()=>y});var h={};t(h,{push:()=>g,simulation:()=>b});var g={sendServer:async()=>({ok:!0,data:{}})},b=["sendServer"],y={};t(y,{commercePurchase:()=>A,customEvent:()=>k,identityAndAttributes:()=>x,screenView:()=>P});import{getEvent as w}from"@walkeros/core";var f="https://s2s.mparticle.com/v2/events",S={headers:{Authorization:"Basic a2V5OnNlY3JldA==","Content-Type":"application/json"}},k={title:"Custom event",description:"A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.",in:w("product view",{timestamp:17000001e5,data:{id:"SKU-A1",name:"Shoe",price:129.99},user:{id:"user-123"},source:{type:"server",id:"https://shop.example.com",previous_id:""}}),mapping:void 0,out:[["sendServer",f,JSON.stringify({events:[{event_type:"custom_event",data:{event_name:"product view",custom_event_type:"other",timestamp_unixtime_ms:17000001e5,source_message_id:"1700000100000-gr0up-1"}}],environment:"production",user_identities:{customer_id:"user-123"},source_request_id:"1700000100000-gr0up-1"}),S]]},P={title:"Screen view",description:"A page view is mapped to an mParticle screen_view event with the event name as the screen name.",in:w("page view",{timestamp:17000002e5,data:{title:"Checkout",path:"/checkout"},user:{id:"user-123"},source:{type:"server",id:"https://shop.example.com",previous_id:""}}),mapping:{settings:{eventType:"screen_view"}},out:[["sendServer",f,JSON.stringify({events:[{event_type:"screen_view",data:{screen_name:"page view",timestamp_unixtime_ms:17000002e5,source_message_id:"1700000200000-gr0up-1"}}],environment:"production",user_identities:{customer_id:"user-123"},source_request_id:"1700000200000-gr0up-1"}),S]]},A={title:"Commerce purchase",description:"A completed order becomes an mParticle commerce_event with a purchase product_action block.",in:w("order complete",{timestamp:17000003e5,data:{id:"ORD-300",total:249.99,currency:"EUR"},user:{id:"user-123"},source:{type:"server",id:"https://shop.example.com",previous_id:""}}),mapping:{settings:{eventType:"commerce_event",commerce:{map:{currency_code:"data.currency",product_action:{map:{action:{value:"purchase"},transaction_id:"data.id",total_amount:"data.total"}}}}}},out:[["sendServer",f,JSON.stringify({events:[{event_type:"commerce_event",data:{currency_code:"EUR",product_action:{action:"purchase",transaction_id:"ORD-300",total_amount:249.99},timestamp_unixtime_ms:17000003e5,source_message_id:"1700000300000-gr0up-1"}}],environment:"production",user_identities:{customer_id:"user-123"},source_request_id:"1700000300000-gr0up-1"}),S]]},x={title:"User identities",description:"A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.",in:w("form submit",{timestamp:17000004e5,data:{type:"newsletter"},user:{id:"user-123",email:"user@example.com"},source:{type:"server",id:"https://example.com",previous_id:""}}),mapping:void 0,out:[["sendServer",f,JSON.stringify({events:[{event_type:"custom_event",data:{event_name:"form submit",custom_event_type:"other",timestamp_unixtime_ms:17000004e5,source_message_id:"1700000400000-gr0up-1"}}],environment:"production",user_identities:{customer_id:"user-123",email:"user@example.com"},source_request_id:"1700000400000-gr0up-1"}),S]]};export{_ as examples,r as schemas};//# sourceMappingURL=dev.mjs.map
1
+ var e=Object.defineProperty,t=(t,r)=>{for(var i in r)e(t,i,{get:r[i],enumerable:!0})},r={};t(r,{CustomEventTypeSchema:()=>m,EnvironmentSchema:()=>a,EventTypeSchema:()=>c,MappingSchema:()=>d,PodSchema:()=>o,SettingsSchema:()=>u,mapping:()=>l,settings:()=>v});import{zodToSchema as i}from"@walkeros/core/dev";import{z as s}from"@walkeros/core/dev";import{z as n}from"@walkeros/core/dev";var o=n.enum(["us1","us2","eu1","au1"]),a=n.enum(["production","development"]),c=n.enum(["custom_event","screen_view","commerce_event"]),m=n.enum(["navigation","location","search","transaction","user_content","user_preference","social","media","attribution","other"]),u=s.object({apiKey:s.string().min(1).describe("mParticle input feed API key from the mParticle dashboard (Setup > Inputs > Feeds)."),apiSecret:s.string().min(1).describe("mParticle input feed API secret paired with apiKey. Used for HTTP Basic auth."),pod:o.describe("mParticle data pod selecting the regional endpoint. Default: 'us1'.").optional(),environment:a.describe("Environment the batch targets. Default: 'production'.").optional(),userIdentities:s.record(s.string(),s.unknown()).describe("Mapping that resolves to user_identities per batch. Keys are mParticle identity types (like customer_id, email); values are walkerOS mapping values.").optional(),userAttributes:s.unknown().describe("Mapping value that resolves to the user_attributes object placed on the batch.").optional(),consent:s.record(s.string(),s.unknown()).describe("Static consent_state envelope forwarded verbatim on the batch. See mParticle consent_state docs.").optional(),ip:s.unknown().describe("Mapping value resolving to the client IP for the batch.").optional(),sourceRequestId:s.unknown().describe("Mapping value resolving to the source_request_id for the batch. Falls back to event.id when unset.").optional()});import{z as p}from"@walkeros/core/dev";var d=p.object({eventType:c.describe("Per-event mParticle event type. Default: 'custom_event'.").optional(),customEventType:m.describe("Custom event type category for 'custom_event'. Default: 'other'.").optional(),commerce:p.unknown().describe("Mapping value resolving to the commerce fields (product_action, currency_code, products, ...) for a commerce_event.").optional(),userIdentities:p.record(p.string(),p.unknown()).describe("Per-event override mapping for user_identities. Merged over settings.userIdentities.").optional(),userAttributes:p.unknown().describe("Per-event override mapping for user_attributes.").optional()}),v=i(u),l=i(d),_={};t(_,{env:()=>h,step:()=>y});var h={};t(h,{push:()=>g,simulation:()=>b});var g={sendServer:async()=>({ok:!0,data:{}})},b=["sendServer"],y={};t(y,{commercePurchase:()=>A,customEvent:()=>k,identityAndAttributes:()=>x,screenView:()=>P});import{getEvent as f}from"@walkeros/core";var w="https://s2s.mparticle.com/v2/events",S={headers:{Authorization:"Basic a2V5OnNlY3JldA==","Content-Type":"application/json"}},k={title:"Custom event",description:"A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.",in:f("product view",{id:"ev-1700000100000",timestamp:17000001e5,data:{id:"SKU-A1",name:"Shoe",price:129.99},user:{id:"user-123"},source:{type:"express",platform:"server"}}),mapping:void 0,out:[["sendServer",w,JSON.stringify({events:[{event_type:"custom_event",data:{event_name:"product view",custom_event_type:"other",timestamp_unixtime_ms:17000001e5,source_message_id:"ev-1700000100000"}}],environment:"production",user_identities:{customer_id:"user-123"},source_request_id:"ev-1700000100000"}),S]]},P={title:"Screen view",description:"A page view is mapped to an mParticle screen_view event with the event name as the screen name.",in:f("page view",{id:"ev-1700000200000",timestamp:17000002e5,data:{title:"Checkout",path:"/checkout"},user:{id:"user-123"},source:{type:"express",platform:"server"}}),mapping:{settings:{eventType:"screen_view"}},out:[["sendServer",w,JSON.stringify({events:[{event_type:"screen_view",data:{screen_name:"page view",timestamp_unixtime_ms:17000002e5,source_message_id:"ev-1700000200000"}}],environment:"production",user_identities:{customer_id:"user-123"},source_request_id:"ev-1700000200000"}),S]]},A={title:"Commerce purchase",description:"A completed order becomes an mParticle commerce_event with a purchase product_action block.",in:f("order complete",{id:"ev-1700000300000",timestamp:17000003e5,data:{id:"ORD-300",total:249.99,currency:"EUR"},user:{id:"user-123"},source:{type:"express",platform:"server"}}),mapping:{settings:{eventType:"commerce_event",commerce:{map:{currency_code:"data.currency",product_action:{map:{action:{value:"purchase"},transaction_id:"data.id",total_amount:"data.total"}}}}}},out:[["sendServer",w,JSON.stringify({events:[{event_type:"commerce_event",data:{currency_code:"EUR",product_action:{action:"purchase",transaction_id:"ORD-300",total_amount:249.99},timestamp_unixtime_ms:17000003e5,source_message_id:"ev-1700000300000"}}],environment:"production",user_identities:{customer_id:"user-123"},source_request_id:"ev-1700000300000"}),S]]},x={title:"User identities",description:"A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.",in:f("form submit",{id:"ev-1700000400000",timestamp:17000004e5,data:{type:"newsletter"},user:{id:"user-123",email:"user@example.com"},source:{type:"express",platform:"server"}}),mapping:void 0,out:[["sendServer",w,JSON.stringify({events:[{event_type:"custom_event",data:{event_name:"form submit",custom_event_type:"other",timestamp_unixtime_ms:17000004e5,source_message_id:"ev-1700000400000"}}],environment:"production",user_identities:{customer_id:"user-123",email:"user@example.com"},source_request_id:"ev-1700000400000"}),S]]};export{_ as examples,r 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 { EnvironmentSchema, PodSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'mParticle input feed API key from the mParticle dashboard (Setup > Inputs > Feeds).',\n ),\n apiSecret: z\n .string()\n .min(1)\n .describe(\n 'mParticle input feed API secret paired with apiKey. Used for HTTP Basic auth.',\n ),\n pod: PodSchema.describe(\n \"mParticle data pod selecting the regional endpoint. Default: 'us1'.\",\n ).optional(),\n environment: EnvironmentSchema.describe(\n \"Environment the batch targets. Default: 'production'.\",\n ).optional(),\n userIdentities: z\n .record(z.string(), z.unknown())\n .describe(\n 'Mapping that resolves to user_identities per batch. Keys are mParticle identity types (like customer_id, email); values are walkerOS mapping values.',\n )\n .optional(),\n userAttributes: z\n .unknown()\n .describe(\n 'Mapping value that resolves to the user_attributes object placed on the batch.',\n )\n .optional(),\n consent: z\n .record(z.string(), z.unknown())\n .describe(\n 'Static consent_state envelope forwarded verbatim on the batch. See mParticle consent_state docs.',\n )\n .optional(),\n ip: z\n .unknown()\n .describe('Mapping value resolving to the client IP for the batch.')\n .optional(),\n sourceRequestId: z\n .unknown()\n .describe(\n 'Mapping value resolving to the source_request_id for the batch. Falls back to event.id when unset.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/** mParticle data pod (regional endpoint selector). */\nexport const PodSchema = z.enum(['us1', 'us2', 'eu1', 'au1']);\n\n/** Target environment for the batch. */\nexport const EnvironmentSchema = z.enum(['production', 'development']);\n\n/** Supported mParticle event types emitted by this destination. */\nexport const EventTypeSchema = z.enum([\n 'custom_event',\n 'screen_view',\n 'commerce_event',\n]);\n\n/** mParticle custom event category for `custom_event`. */\nexport const CustomEventTypeSchema = z.enum([\n 'navigation',\n 'location',\n 'search',\n 'transaction',\n 'user_content',\n 'user_preference',\n 'social',\n 'media',\n 'attribution',\n 'other',\n]);\n","import { z } from '@walkeros/core/dev';\nimport { CustomEventTypeSchema, EventTypeSchema } from './primitives';\n\nexport const MappingSchema = z.object({\n eventType: EventTypeSchema.describe(\n \"Per-event mParticle event type. Default: 'custom_event'.\",\n ).optional(),\n customEventType: CustomEventTypeSchema.describe(\n \"Custom event type category for 'custom_event'. Default: 'other'.\",\n ).optional(),\n commerce: z\n .unknown()\n .describe(\n 'Mapping value resolving to the commerce fields (product_action, currency_code, products, ...) for a commerce_event.',\n )\n .optional(),\n userIdentities: z\n .record(z.string(), z.unknown())\n .describe(\n 'Per-event override mapping for user_identities. Merged over settings.userIdentities.',\n )\n .optional(),\n userAttributes: z\n .unknown()\n .describe('Per-event override mapping for user_attributes.')\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 mParticle Events API destination.\n *\n * Provides a standardized mock `sendServer` so tests and simulations can\n * run without making real HTTP calls to mParticle.\n */\n\ntype MockSendServer = (\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n) => Promise<SendResponse>;\n\nconst mockSendServer: MockSendServer = async () => {\n // Simulates mParticle's typical 202 Accepted response for the Events API.\n return {\n ok: true,\n data: {},\n };\n};\n\n/**\n * Standard mock environment for push operations.\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 * mParticle Events API step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(endpoint, JSON.stringify(batch), options)` where\n * endpoint = `buildEndpoint(pod)` (default pod `us1` → `https://s2s.mparticle.com/v2/events`)\n * batch = the mParticle v2 batch envelope\n *\n * Test fixture pins `apiKey = 'key'`, `apiSecret = 'secret'`, pod `us1`, so\n * every call targets that endpoint with `Authorization: Basic a2V5OnNlY3JldA==`.\n *\n * The batch keys appear in the order the destination constructs them:\n * 1. events (always a single-element array)\n * 2. environment ('production' by default)\n * 3. user_identities (only when resolved)\n * 4. user_attributes (only when resolved)\n * 5. ip (only when mapped)\n * 6. source_request_id (falls back to `event.id`)\n * 7. consent_state, context (unused here)\n *\n * `options` carries Authorization + Content-Type headers.\n */\nconst ENDPOINT = 'https://s2s.mparticle.com/v2/events';\nconst OPTIONS = {\n headers: {\n // Basic base64('key:secret')\n Authorization: 'Basic a2V5OnNlY3JldA==',\n 'Content-Type': 'application/json',\n },\n};\n\n/**\n * Default custom_event — a walkerOS event with no `eventType` mapping.\n * mParticle wraps it as a `custom_event` with the default `other` category.\n * user_identities are resolved at the batch level from\n * `settings.userIdentities`.\n */\nexport const customEvent: Flow.StepExample = {\n title: 'Custom event',\n description:\n 'A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.',\n in: getEvent('product view', {\n timestamp: 1700000100000,\n data: { id: 'SKU-A1', name: 'Shoe', price: 129.99 },\n user: { id: 'user-123' },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'custom_event',\n data: {\n event_name: 'product view',\n custom_event_type: 'other',\n timestamp_unixtime_ms: 1700000100000,\n source_message_id: '1700000100000-gr0up-1',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n },\n source_request_id: '1700000100000-gr0up-1',\n }),\n OPTIONS,\n ],\n ],\n};\n\n/**\n * screen_view event — mapping.settings.eventType switches the mParticle\n * event shape. Uses event name as the `screen_name`.\n */\nexport const screenView: Flow.StepExample = {\n title: 'Screen view',\n description:\n 'A page view is mapped to an mParticle screen_view event with the event name as the screen name.',\n in: getEvent('page view', {\n timestamp: 1700000200000,\n data: { title: 'Checkout', path: '/checkout' },\n user: { id: 'user-123' },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: {\n settings: { eventType: 'screen_view' },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'screen_view',\n data: {\n screen_name: 'page view',\n timestamp_unixtime_ms: 1700000200000,\n source_message_id: '1700000200000-gr0up-1',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n },\n source_request_id: '1700000200000-gr0up-1',\n }),\n OPTIONS,\n ],\n ],\n};\n\n/**\n * commerce_event — mapping.settings.eventType: 'commerce_event' plus a\n * `commerce` mapping resolves a ProductAction block. Products, currency,\n * and transaction metadata are all driven by the commerce mapping value.\n */\nexport const commercePurchase: Flow.StepExample = {\n title: 'Commerce purchase',\n description:\n 'A completed order becomes an mParticle commerce_event with a purchase product_action block.',\n in: getEvent('order complete', {\n timestamp: 1700000300000,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n user: { id: 'user-123' },\n source: { type: 'server', id: 'https://shop.example.com', previous_id: '' },\n }),\n mapping: {\n settings: {\n eventType: 'commerce_event',\n commerce: {\n map: {\n currency_code: 'data.currency',\n product_action: {\n map: {\n action: { value: 'purchase' },\n transaction_id: 'data.id',\n total_amount: 'data.total',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'commerce_event',\n data: {\n currency_code: 'EUR',\n product_action: {\n action: 'purchase',\n transaction_id: 'ORD-300',\n total_amount: 249.99,\n },\n timestamp_unixtime_ms: 1700000300000,\n source_message_id: '1700000300000-gr0up-1',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n },\n source_request_id: '1700000300000-gr0up-1',\n }),\n OPTIONS,\n ],\n ],\n};\n\n/**\n * Identity + attributes — verifies `user_identities` and `user_attributes`\n * come from the batch-level settings mappings, not the event payload.\n */\nexport const identityAndAttributes: Flow.StepExample = {\n title: 'User identities',\n description:\n 'A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.',\n in: getEvent('form submit', {\n timestamp: 1700000400000,\n data: { type: 'newsletter' },\n user: {\n id: 'user-123',\n email: 'user@example.com',\n },\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 events: [\n {\n event_type: 'custom_event',\n data: {\n event_name: 'form submit',\n custom_event_type: 'other',\n timestamp_unixtime_ms: 1700000400000,\n source_message_id: '1700000400000-gr0up-1',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n email: 'user@example.com',\n },\n source_request_id: '1700000400000-gr0up-1',\n }),\n OPTIONS,\n ],\n ],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAGX,IAAM,YAAY,EAAE,KAAK,CAAC,OAAO,OAAO,OAAO,KAAK,CAAC;AAGrD,IAAM,oBAAoB,EAAE,KAAK,CAAC,cAAc,aAAa,CAAC;AAG9D,IAAM,kBAAkB,EAAE,KAAK;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,wBAAwB,EAAE,KAAK;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;;;ADxBM,IAAM,iBAAiBC,GAAE,OAAO;AAAA,EACrC,QAAQA,GACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,WAAWA,GACR,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,KAAK,UAAU;AAAA,IACb;AAAA,EACF,EAAE,SAAS;AAAA,EACX,aAAa,kBAAkB;AAAA,IAC7B;AAAA,EACF,EA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AAAA,QACA,mBAAmB;AAAA,MACrB,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;AAMO,IAAM,wBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,aACE;AAAA,EACF,IAAI,SAAS,eAAe;AAAA,IAC1B,WAAW;AAAA,IACX,MAAM,EAAE,MAAM,aAAa;AAAA,IAC3B,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,IACT;AAAA,IACA,QAAQ,EAAE,MAAM,UAAU,IAAI,uBAAuB,aAAa,GAAG;AAAA,EACvE,CAAC;AAAA,EACD,SAAS;AAAA,EACT,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,QAAQ;AAAA,UACN;AAAA,YACE,YAAY;AAAA,YACZ,MAAM;AAAA,cACJ,YAAY;AAAA,cACZ,mBAAmB;AAAA,cACnB,uBAAuB;AAAA,cACvB,mBAAmB;AAAA,YACrB;AAAA,UACF;AAAA,QACF;AAAA,QACA,aAAa;AAAA,QACb,iBAAiB;AAAA,UACf,aAAa;AAAA,UACb,OAAO;AAAA,QACT;AAAA,QACA,mBAAmB;AAAA,MACrB,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;","names":["z","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 { EnvironmentSchema, PodSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'mParticle input feed API key from the mParticle dashboard (Setup > Inputs > Feeds).',\n ),\n apiSecret: z\n .string()\n .min(1)\n .describe(\n 'mParticle input feed API secret paired with apiKey. Used for HTTP Basic auth.',\n ),\n pod: PodSchema.describe(\n \"mParticle data pod selecting the regional endpoint. Default: 'us1'.\",\n ).optional(),\n environment: EnvironmentSchema.describe(\n \"Environment the batch targets. Default: 'production'.\",\n ).optional(),\n userIdentities: z\n .record(z.string(), z.unknown())\n .describe(\n 'Mapping that resolves to user_identities per batch. Keys are mParticle identity types (like customer_id, email); values are walkerOS mapping values.',\n )\n .optional(),\n userAttributes: z\n .unknown()\n .describe(\n 'Mapping value that resolves to the user_attributes object placed on the batch.',\n )\n .optional(),\n consent: z\n .record(z.string(), z.unknown())\n .describe(\n 'Static consent_state envelope forwarded verbatim on the batch. See mParticle consent_state docs.',\n )\n .optional(),\n ip: z\n .unknown()\n .describe('Mapping value resolving to the client IP for the batch.')\n .optional(),\n sourceRequestId: z\n .unknown()\n .describe(\n 'Mapping value resolving to the source_request_id for the batch. Falls back to event.id when unset.',\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n/** mParticle data pod (regional endpoint selector). */\nexport const PodSchema = z.enum(['us1', 'us2', 'eu1', 'au1']);\n\n/** Target environment for the batch. */\nexport const EnvironmentSchema = z.enum(['production', 'development']);\n\n/** Supported mParticle event types emitted by this destination. */\nexport const EventTypeSchema = z.enum([\n 'custom_event',\n 'screen_view',\n 'commerce_event',\n]);\n\n/** mParticle custom event category for `custom_event`. */\nexport const CustomEventTypeSchema = z.enum([\n 'navigation',\n 'location',\n 'search',\n 'transaction',\n 'user_content',\n 'user_preference',\n 'social',\n 'media',\n 'attribution',\n 'other',\n]);\n","import { z } from '@walkeros/core/dev';\nimport { CustomEventTypeSchema, EventTypeSchema } from './primitives';\n\nexport const MappingSchema = z.object({\n eventType: EventTypeSchema.describe(\n \"Per-event mParticle event type. Default: 'custom_event'.\",\n ).optional(),\n customEventType: CustomEventTypeSchema.describe(\n \"Custom event type category for 'custom_event'. Default: 'other'.\",\n ).optional(),\n commerce: z\n .unknown()\n .describe(\n 'Mapping value resolving to the commerce fields (product_action, currency_code, products, ...) for a commerce_event.',\n )\n .optional(),\n userIdentities: z\n .record(z.string(), z.unknown())\n .describe(\n 'Per-event override mapping for user_identities. Merged over settings.userIdentities.',\n )\n .optional(),\n userAttributes: z\n .unknown()\n .describe('Per-event override mapping for user_attributes.')\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 mParticle Events API destination.\n *\n * Provides a standardized mock `sendServer` so tests and simulations can\n * run without making real HTTP calls to mParticle.\n */\n\ntype MockSendServer = (\n url: string,\n data?: SendDataValue,\n options?: SendServerOptions,\n) => Promise<SendResponse>;\n\nconst mockSendServer: MockSendServer = async () => {\n // Simulates mParticle's typical 202 Accepted response for the Events API.\n return {\n ok: true,\n data: {},\n };\n};\n\n/**\n * Standard mock environment for push operations.\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 * mParticle Events API step examples.\n *\n * At push time, the destination calls\n * `env.sendServer(endpoint, JSON.stringify(batch), options)` where\n * endpoint = `buildEndpoint(pod)` (default pod `us1` → `https://s2s.mparticle.com/v2/events`)\n * batch = the mParticle v2 batch envelope\n *\n * Test fixture pins `apiKey = 'key'`, `apiSecret = 'secret'`, pod `us1`, so\n * every call targets that endpoint with `Authorization: Basic a2V5OnNlY3JldA==`.\n *\n * The batch keys appear in the order the destination constructs them:\n * 1. events (always a single-element array)\n * 2. environment ('production' by default)\n * 3. user_identities (only when resolved)\n * 4. user_attributes (only when resolved)\n * 5. ip (only when mapped)\n * 6. source_request_id (falls back to `event.id`)\n * 7. consent_state, context (unused here)\n *\n * `options` carries Authorization + Content-Type headers.\n */\nconst ENDPOINT = 'https://s2s.mparticle.com/v2/events';\nconst OPTIONS = {\n headers: {\n // Basic base64('key:secret')\n Authorization: 'Basic a2V5OnNlY3JldA==',\n 'Content-Type': 'application/json',\n },\n};\n\n/**\n * Default custom_event - a walkerOS event with no `eventType` mapping.\n * mParticle wraps it as a `custom_event` with the default `other` category.\n * user_identities are resolved at the batch level from\n * `settings.userIdentities`.\n */\nexport const customEvent: Flow.StepExample = {\n title: 'Custom event',\n description:\n 'A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.',\n in: getEvent('product view', {\n id: 'ev-1700000100000',\n timestamp: 1700000100000,\n data: { id: 'SKU-A1', name: 'Shoe', price: 129.99 },\n user: { id: 'user-123' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'custom_event',\n data: {\n event_name: 'product view',\n custom_event_type: 'other',\n timestamp_unixtime_ms: 1700000100000,\n source_message_id: 'ev-1700000100000',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n },\n source_request_id: 'ev-1700000100000',\n }),\n OPTIONS,\n ],\n ],\n};\n\n/**\n * screen_view event - mapping.settings.eventType switches the mParticle\n * event shape. Uses event name as the `screen_name`.\n */\nexport const screenView: Flow.StepExample = {\n title: 'Screen view',\n description:\n 'A page view is mapped to an mParticle screen_view event with the event name as the screen name.',\n in: getEvent('page view', {\n id: 'ev-1700000200000',\n timestamp: 1700000200000,\n data: { title: 'Checkout', path: '/checkout' },\n user: { id: 'user-123' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n settings: { eventType: 'screen_view' },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'screen_view',\n data: {\n screen_name: 'page view',\n timestamp_unixtime_ms: 1700000200000,\n source_message_id: 'ev-1700000200000',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n },\n source_request_id: 'ev-1700000200000',\n }),\n OPTIONS,\n ],\n ],\n};\n\n/**\n * commerce_event - mapping.settings.eventType: 'commerce_event' plus a\n * `commerce` mapping resolves a ProductAction block. Products, currency,\n * and transaction metadata are all driven by the commerce mapping value.\n */\nexport const commercePurchase: Flow.StepExample = {\n title: 'Commerce purchase',\n description:\n 'A completed order becomes an mParticle commerce_event with a purchase product_action block.',\n in: getEvent('order complete', {\n id: 'ev-1700000300000',\n timestamp: 1700000300000,\n data: { id: 'ORD-300', total: 249.99, currency: 'EUR' },\n user: { id: 'user-123' },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: {\n settings: {\n eventType: 'commerce_event',\n commerce: {\n map: {\n currency_code: 'data.currency',\n product_action: {\n map: {\n action: { value: 'purchase' },\n transaction_id: 'data.id',\n total_amount: 'data.total',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'commerce_event',\n data: {\n currency_code: 'EUR',\n product_action: {\n action: 'purchase',\n transaction_id: 'ORD-300',\n total_amount: 249.99,\n },\n timestamp_unixtime_ms: 1700000300000,\n source_message_id: 'ev-1700000300000',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n },\n source_request_id: 'ev-1700000300000',\n }),\n OPTIONS,\n ],\n ],\n};\n\n/**\n * Identity + attributes - verifies `user_identities` and `user_attributes`\n * come from the batch-level settings mappings, not the event payload.\n */\nexport const identityAndAttributes: Flow.StepExample = {\n title: 'User identities',\n description:\n 'A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.',\n in: getEvent('form submit', {\n id: 'ev-1700000400000',\n timestamp: 1700000400000,\n data: { type: 'newsletter' },\n user: {\n id: 'user-123',\n email: 'user@example.com',\n },\n source: { type: 'express', platform: 'server' },\n }),\n mapping: undefined,\n out: [\n [\n 'sendServer',\n ENDPOINT,\n JSON.stringify({\n events: [\n {\n event_type: 'custom_event',\n data: {\n event_name: 'form submit',\n custom_event_type: 'other',\n timestamp_unixtime_ms: 1700000400000,\n source_message_id: 'ev-1700000400000',\n },\n },\n ],\n environment: 'production',\n user_identities: {\n customer_id: 'user-123',\n email: 'user@example.com',\n },\n source_request_id: 'ev-1700000400000',\n }),\n OPTIONS,\n ],\n ],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;;ACA5B,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAAS;AAGX,IAAM,YAAY,EAAE,KAAK,CAAC,OAAO,OAAO,OAAO,KAAK,CAAC;AAGrD,IAAM,oBAAoB,EAAE,KAAK,CAAC,cAAc,aAAa,CAAC;AAG9D,IAAM,kBAAkB,EAAE,KAAK;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,IAAM,wBAAwB,EAAE,KAAK;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;;;ADxBM,IAAM,iBAAiBC,GAAE,OAAO;AAAA,EACrC,QAAQA,GACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,WAAWA,GACR,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,KAAK,UAAU;AAAA,IACb;AAAA,EACF,EAAE,SAAS;AAAA,EACX,aAAa,kBAAkB;AAAA,IAC7B;AAAA,EACF,EAAE,SAAS;AAAA,EACX,gBAAgBA,GACb,OAAOA,GAAE,OAAO,GAAGA,GAAE,QAAQ,CAAC,EAC9B;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EAC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P,aACE;AAAA,EACF,IAAI,SAAS,eAAe;AAAA,IAC1B,IAAI;AAAA,IACJ,WAAW;AAAA,IACX,MAAM,EAAE,MAAM,aAAa;AAAA,IAC3B,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,IACT;AAAA,IACA,QAAQ,EAAE,MAAM,WAAW,UAAU,SAAS;AAAA,EAChD,CAAC;AAAA,EACD,SAAS;AAAA,EACT,KAAK;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA,KAAK,UAAU;AAAA,QACb,QAAQ;AAAA,UACN;AAAA,YACE,YAAY;AAAA,YACZ,MAAM;AAAA,cACJ,YAAY;AAAA,cACZ,mBAAmB;AAAA,cACnB,uBAAuB;AAAA,cACvB,mBAAmB;AAAA,YACrB;AAAA,UACF;AAAA,QACF;AAAA,QACA,aAAa;AAAA,QACb,iBAAiB;AAAA,UACf,aAAa;AAAA,UACb,OAAO;AAAA,QACT;AAAA,QACA,mBAAmB;AAAA,MACrB,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;","names":["z","z","z","z"]}
@@ -18,25 +18,25 @@ declare namespace env {
18
18
  }
19
19
 
20
20
  /**
21
- * Default custom_event a walkerOS event with no `eventType` mapping.
21
+ * Default custom_event - a walkerOS event with no `eventType` mapping.
22
22
  * mParticle wraps it as a `custom_event` with the default `other` category.
23
23
  * user_identities are resolved at the batch level from
24
24
  * `settings.userIdentities`.
25
25
  */
26
26
  declare const customEvent: Flow.StepExample;
27
27
  /**
28
- * screen_view event mapping.settings.eventType switches the mParticle
28
+ * screen_view event - mapping.settings.eventType switches the mParticle
29
29
  * event shape. Uses event name as the `screen_name`.
30
30
  */
31
31
  declare const screenView: Flow.StepExample;
32
32
  /**
33
- * commerce_event mapping.settings.eventType: 'commerce_event' plus a
33
+ * commerce_event - mapping.settings.eventType: 'commerce_event' plus a
34
34
  * `commerce` mapping resolves a ProductAction block. Products, currency,
35
35
  * and transaction metadata are all driven by the commerce mapping value.
36
36
  */
37
37
  declare const commercePurchase: Flow.StepExample;
38
38
  /**
39
- * Identity + attributes verifies `user_identities` and `user_attributes`
39
+ * Identity + attributes - verifies `user_identities` and `user_attributes`
40
40
  * come from the batch-level settings mappings, not the event payload.
41
41
  */
42
42
  declare const identityAndAttributes: Flow.StepExample;
@@ -18,25 +18,25 @@ declare namespace env {
18
18
  }
19
19
 
20
20
  /**
21
- * Default custom_event a walkerOS event with no `eventType` mapping.
21
+ * Default custom_event - a walkerOS event with no `eventType` mapping.
22
22
  * mParticle wraps it as a `custom_event` with the default `other` category.
23
23
  * user_identities are resolved at the batch level from
24
24
  * `settings.userIdentities`.
25
25
  */
26
26
  declare const customEvent: Flow.StepExample;
27
27
  /**
28
- * screen_view event mapping.settings.eventType switches the mParticle
28
+ * screen_view event - mapping.settings.eventType switches the mParticle
29
29
  * event shape. Uses event name as the `screen_name`.
30
30
  */
31
31
  declare const screenView: Flow.StepExample;
32
32
  /**
33
- * commerce_event mapping.settings.eventType: 'commerce_event' plus a
33
+ * commerce_event - mapping.settings.eventType: 'commerce_event' plus a
34
34
  * `commerce` mapping resolves a ProductAction block. Products, currency,
35
35
  * and transaction metadata are all driven by the commerce mapping value.
36
36
  */
37
37
  declare const commercePurchase: Flow.StepExample;
38
38
  /**
39
- * Identity + attributes verifies `user_identities` and `user_attributes`
39
+ * Identity + attributes - verifies `user_identities` and `user_attributes`
40
40
  * come from the batch-level settings mappings, not the event payload.
41
41
  */
42
42
  declare const identityAndAttributes: Flow.StepExample;
@@ -63,10 +63,11 @@ var customEvent = {
63
63
  title: "Custom event",
64
64
  description: "A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.",
65
65
  in: (0, import_core.getEvent)("product view", {
66
+ id: "ev-1700000100000",
66
67
  timestamp: 17000001e5,
67
68
  data: { id: "SKU-A1", name: "Shoe", price: 129.99 },
68
69
  user: { id: "user-123" },
69
- source: { type: "server", id: "https://shop.example.com", previous_id: "" }
70
+ source: { type: "express", platform: "server" }
70
71
  }),
71
72
  mapping: void 0,
72
73
  out: [
@@ -81,7 +82,7 @@ var customEvent = {
81
82
  event_name: "product view",
82
83
  custom_event_type: "other",
83
84
  timestamp_unixtime_ms: 17000001e5,
84
- source_message_id: "1700000100000-gr0up-1"
85
+ source_message_id: "ev-1700000100000"
85
86
  }
86
87
  }
87
88
  ],
@@ -89,7 +90,7 @@ var customEvent = {
89
90
  user_identities: {
90
91
  customer_id: "user-123"
91
92
  },
92
- source_request_id: "1700000100000-gr0up-1"
93
+ source_request_id: "ev-1700000100000"
93
94
  }),
94
95
  OPTIONS
95
96
  ]
@@ -99,10 +100,11 @@ var screenView = {
99
100
  title: "Screen view",
100
101
  description: "A page view is mapped to an mParticle screen_view event with the event name as the screen name.",
101
102
  in: (0, import_core.getEvent)("page view", {
103
+ id: "ev-1700000200000",
102
104
  timestamp: 17000002e5,
103
105
  data: { title: "Checkout", path: "/checkout" },
104
106
  user: { id: "user-123" },
105
- source: { type: "server", id: "https://shop.example.com", previous_id: "" }
107
+ source: { type: "express", platform: "server" }
106
108
  }),
107
109
  mapping: {
108
110
  settings: { eventType: "screen_view" }
@@ -118,7 +120,7 @@ var screenView = {
118
120
  data: {
119
121
  screen_name: "page view",
120
122
  timestamp_unixtime_ms: 17000002e5,
121
- source_message_id: "1700000200000-gr0up-1"
123
+ source_message_id: "ev-1700000200000"
122
124
  }
123
125
  }
124
126
  ],
@@ -126,7 +128,7 @@ var screenView = {
126
128
  user_identities: {
127
129
  customer_id: "user-123"
128
130
  },
129
- source_request_id: "1700000200000-gr0up-1"
131
+ source_request_id: "ev-1700000200000"
130
132
  }),
131
133
  OPTIONS
132
134
  ]
@@ -136,10 +138,11 @@ var commercePurchase = {
136
138
  title: "Commerce purchase",
137
139
  description: "A completed order becomes an mParticle commerce_event with a purchase product_action block.",
138
140
  in: (0, import_core.getEvent)("order complete", {
141
+ id: "ev-1700000300000",
139
142
  timestamp: 17000003e5,
140
143
  data: { id: "ORD-300", total: 249.99, currency: "EUR" },
141
144
  user: { id: "user-123" },
142
- source: { type: "server", id: "https://shop.example.com", previous_id: "" }
145
+ source: { type: "express", platform: "server" }
143
146
  }),
144
147
  mapping: {
145
148
  settings: {
@@ -174,7 +177,7 @@ var commercePurchase = {
174
177
  total_amount: 249.99
175
178
  },
176
179
  timestamp_unixtime_ms: 17000003e5,
177
- source_message_id: "1700000300000-gr0up-1"
180
+ source_message_id: "ev-1700000300000"
178
181
  }
179
182
  }
180
183
  ],
@@ -182,7 +185,7 @@ var commercePurchase = {
182
185
  user_identities: {
183
186
  customer_id: "user-123"
184
187
  },
185
- source_request_id: "1700000300000-gr0up-1"
188
+ source_request_id: "ev-1700000300000"
186
189
  }),
187
190
  OPTIONS
188
191
  ]
@@ -192,13 +195,14 @@ var identityAndAttributes = {
192
195
  title: "User identities",
193
196
  description: "A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.",
194
197
  in: (0, import_core.getEvent)("form submit", {
198
+ id: "ev-1700000400000",
195
199
  timestamp: 17000004e5,
196
200
  data: { type: "newsletter" },
197
201
  user: {
198
202
  id: "user-123",
199
203
  email: "user@example.com"
200
204
  },
201
- source: { type: "server", id: "https://example.com", previous_id: "" }
205
+ source: { type: "express", platform: "server" }
202
206
  }),
203
207
  mapping: void 0,
204
208
  out: [
@@ -213,7 +217,7 @@ var identityAndAttributes = {
213
217
  event_name: "form submit",
214
218
  custom_event_type: "other",
215
219
  timestamp_unixtime_ms: 17000004e5,
216
- source_message_id: "1700000400000-gr0up-1"
220
+ source_message_id: "ev-1700000400000"
217
221
  }
218
222
  }
219
223
  ],
@@ -222,7 +226,7 @@ var identityAndAttributes = {
222
226
  customer_id: "user-123",
223
227
  email: "user@example.com"
224
228
  },
225
- source_request_id: "1700000400000-gr0up-1"
229
+ source_request_id: "ev-1700000400000"
226
230
  }),
227
231
  OPTIONS
228
232
  ]
@@ -42,10 +42,11 @@ var customEvent = {
42
42
  title: "Custom event",
43
43
  description: "A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.",
44
44
  in: getEvent("product view", {
45
+ id: "ev-1700000100000",
45
46
  timestamp: 17000001e5,
46
47
  data: { id: "SKU-A1", name: "Shoe", price: 129.99 },
47
48
  user: { id: "user-123" },
48
- source: { type: "server", id: "https://shop.example.com", previous_id: "" }
49
+ source: { type: "express", platform: "server" }
49
50
  }),
50
51
  mapping: void 0,
51
52
  out: [
@@ -60,7 +61,7 @@ var customEvent = {
60
61
  event_name: "product view",
61
62
  custom_event_type: "other",
62
63
  timestamp_unixtime_ms: 17000001e5,
63
- source_message_id: "1700000100000-gr0up-1"
64
+ source_message_id: "ev-1700000100000"
64
65
  }
65
66
  }
66
67
  ],
@@ -68,7 +69,7 @@ var customEvent = {
68
69
  user_identities: {
69
70
  customer_id: "user-123"
70
71
  },
71
- source_request_id: "1700000100000-gr0up-1"
72
+ source_request_id: "ev-1700000100000"
72
73
  }),
73
74
  OPTIONS
74
75
  ]
@@ -78,10 +79,11 @@ var screenView = {
78
79
  title: "Screen view",
79
80
  description: "A page view is mapped to an mParticle screen_view event with the event name as the screen name.",
80
81
  in: getEvent("page view", {
82
+ id: "ev-1700000200000",
81
83
  timestamp: 17000002e5,
82
84
  data: { title: "Checkout", path: "/checkout" },
83
85
  user: { id: "user-123" },
84
- source: { type: "server", id: "https://shop.example.com", previous_id: "" }
86
+ source: { type: "express", platform: "server" }
85
87
  }),
86
88
  mapping: {
87
89
  settings: { eventType: "screen_view" }
@@ -97,7 +99,7 @@ var screenView = {
97
99
  data: {
98
100
  screen_name: "page view",
99
101
  timestamp_unixtime_ms: 17000002e5,
100
- source_message_id: "1700000200000-gr0up-1"
102
+ source_message_id: "ev-1700000200000"
101
103
  }
102
104
  }
103
105
  ],
@@ -105,7 +107,7 @@ var screenView = {
105
107
  user_identities: {
106
108
  customer_id: "user-123"
107
109
  },
108
- source_request_id: "1700000200000-gr0up-1"
110
+ source_request_id: "ev-1700000200000"
109
111
  }),
110
112
  OPTIONS
111
113
  ]
@@ -115,10 +117,11 @@ var commercePurchase = {
115
117
  title: "Commerce purchase",
116
118
  description: "A completed order becomes an mParticle commerce_event with a purchase product_action block.",
117
119
  in: getEvent("order complete", {
120
+ id: "ev-1700000300000",
118
121
  timestamp: 17000003e5,
119
122
  data: { id: "ORD-300", total: 249.99, currency: "EUR" },
120
123
  user: { id: "user-123" },
121
- source: { type: "server", id: "https://shop.example.com", previous_id: "" }
124
+ source: { type: "express", platform: "server" }
122
125
  }),
123
126
  mapping: {
124
127
  settings: {
@@ -153,7 +156,7 @@ var commercePurchase = {
153
156
  total_amount: 249.99
154
157
  },
155
158
  timestamp_unixtime_ms: 17000003e5,
156
- source_message_id: "1700000300000-gr0up-1"
159
+ source_message_id: "ev-1700000300000"
157
160
  }
158
161
  }
159
162
  ],
@@ -161,7 +164,7 @@ var commercePurchase = {
161
164
  user_identities: {
162
165
  customer_id: "user-123"
163
166
  },
164
- source_request_id: "1700000300000-gr0up-1"
167
+ source_request_id: "ev-1700000300000"
165
168
  }),
166
169
  OPTIONS
167
170
  ]
@@ -171,13 +174,14 @@ var identityAndAttributes = {
171
174
  title: "User identities",
172
175
  description: "A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.",
173
176
  in: getEvent("form submit", {
177
+ id: "ev-1700000400000",
174
178
  timestamp: 17000004e5,
175
179
  data: { type: "newsletter" },
176
180
  user: {
177
181
  id: "user-123",
178
182
  email: "user@example.com"
179
183
  },
180
- source: { type: "server", id: "https://example.com", previous_id: "" }
184
+ source: { type: "express", platform: "server" }
181
185
  }),
182
186
  mapping: void 0,
183
187
  out: [
@@ -192,7 +196,7 @@ var identityAndAttributes = {
192
196
  event_name: "form submit",
193
197
  custom_event_type: "other",
194
198
  timestamp_unixtime_ms: 17000004e5,
195
- source_message_id: "1700000400000-gr0up-1"
199
+ source_message_id: "ev-1700000400000"
196
200
  }
197
201
  }
198
202
  ],
@@ -201,7 +205,7 @@ var identityAndAttributes = {
201
205
  customer_id: "user-123",
202
206
  email: "user@example.com"
203
207
  },
204
- source_request_id: "1700000400000-gr0up-1"
208
+ source_request_id: "ev-1700000400000"
205
209
  }),
206
210
  OPTIONS
207
211
  ]
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,o={};((e,n)=>{for(var i in n)t(e,i,{get:n[i],enumerable:!0})})(o,{DestinationMParticle:()=>m,default:()=>l,destinationMParticle:()=>v}),module.exports=(e=o,((e,o,r,c)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let a of i(o))s.call(e,a)||a===r||t(e,a,{get:()=>o[a],enumerable:!(c=n(o,a))||c.enumerable});return e})(t({},"__esModule",{value:!0}),e));var r=require("@walkeros/core"),c=require("@walkeros/server-core");var a=async function(e,{config:t,rule:n,data:i,env:s,logger:o}){var a;const m=t.settings,{apiKey:v,apiSecret:l,pod:d="us1",environment:g="production",userIdentities:f,userAttributes:y,consent:b,ip:_,sourceRequestId:O}=m,j=(null==n?void 0:n.settings)||{},w=(0,r.isObject)(i)?i:{},h=await async function(e,t,n){const i={...(0,r.isObject)(t)?t:{},...(0,r.isObject)(n)?n:{}},s=Object.keys(i);if(0===s.length)return;const o={};for(const t of s){const n=p(await(0,r.getMappingValue)(e,i[t]));void 0!==n&&(o[t]=n)}return Object.keys(o).length>0?o:void 0}(e,f,j.userIdentities),k=await async function(e,t,n){const i=t?await(0,r.getMappingValue)(e,t):void 0,s=n?await(0,r.getMappingValue)(e,n):void 0,o={...(0,r.isObject)(i)?i:{},...(0,r.isObject)(s)?s:{}};return Object.keys(o).length>0?o:void 0}(e,y,j.userAttributes),P=_?u(await(0,r.getMappingValue)(e,_)):void 0,S=null!=(a=u(O?await(0,r.getMappingValue)(e,O):void 0))?a:e.id||void 0,I=(null==n?void 0:n.name)||e.name,M=e.timestamp||Date.now(),q=e.id||void 0,x=j.eventType||"custom_event";let A;if("screen_view"===x)A=function(e,t,n,i){return{event_type:"screen_view",data:{...e?{screen_name:e}:{},...t&&Object.keys(t).length>0?{custom_attributes:t}:{},...void 0!==n?{timestamp_unixtime_ms:n}:{},...i?{source_message_id:i}:{}}}}(I,w,M,q);else if("commerce_event"===x){const t=j.commerce?await(0,r.getMappingValue)(e,j.commerce):void 0;A=function(e,t,n,i){return{event_type:"commerce_event",data:{...e||{},...t&&Object.keys(t).length>0?{custom_attributes:t}:{},...void 0!==n?{timestamp_unixtime_ms:n}:{},...i?{source_message_id:i}:{}}}}((0,r.isObject)(t)?t:void 0,w,M,q)}else{A=function(e,t,n,i,s){return{event_type:"custom_event",data:{event_name:e,custom_event_type:t,...n&&Object.keys(n).length>0?{custom_attributes:n}:{},...void 0!==i?{timestamp_unixtime_ms:i}:{},...s?{source_message_id:s}:{}}}}(I,j.customEventType||"other",w,M,q)}const V=function(e,t,n,i,s={}){const o={events:e,environment:i};return t&&Object.keys(t).length>0&&(o.user_identities=t),n&&Object.keys(n).length>0&&(o.user_attributes=n),s.ip&&(o.ip=s.ip),s.sourceRequestId&&(o.source_request_id=s.sourceRequestId),s.consent&&(o.consent_state=s.consent),s.context&&(o.context=s.context),o}([A],h,k,g,{ip:P,sourceRequestId:S,consent:b}),T=function(e="us1"){return"us1"===e?"https://s2s.mparticle.com/v2/events":`https://s2s.${e}.mparticle.com/v2/events`}(d),$=function(e,t){return`Basic ${Buffer.from(`${e}:${t}`).toString("base64")}`}(v,l);o.debug("Calling mParticle Events API",{endpoint:T,method:"POST",eventType:A.event_type,eventName:I,eventId:e.id});const C=(null==s?void 0:s.sendServer)||c.sendServer,K=await C(T,JSON.stringify(V),{headers:{Authorization:$,"Content-Type":"application/json"}});o.debug("mParticle API response",{ok:!(0,r.isObject)(K)||K.ok}),(0,r.isObject)(K)&&!1===K.ok&&o.throw(`mParticle API error: ${JSON.stringify(K)}`)};function u(e){if(null!=e)return"string"==typeof e?e||void 0:"number"==typeof e||"boolean"==typeof e?String(e):void 0}function p(e){if(null!=e)return"string"==typeof e?e||void 0:"number"==typeof e?e:"boolean"==typeof e?String(e):void 0}var m={},v={type:"mparticle",config:{},async init({config:e,logger:t}){const n=function(e={},t){const n=e.settings||{},{apiKey:i,apiSecret:s}=n;i||t.throw("Config settings apiKey missing"),s||t.throw("Config settings apiSecret missing");const o={pod:"us1",environment:"production",...n,apiKey:i,apiSecret:s};return{...e,settings:o}}(e,t);return n},push:async(e,t)=>await a(e,t)},l=v;//# sourceMappingURL=index.js.map
1
+ "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,s={};((e,n)=>{for(var i in n)t(e,i,{get:n[i],enumerable:!0})})(s,{DestinationMParticle:()=>l,default:()=>g,destinationMParticle:()=>m}),module.exports=(e=s,((e,s,r,c)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let a of i(s))o.call(e,a)||a===r||t(e,a,{get:()=>s[a],enumerable:!(c=n(s,a))||c.enumerable});return e})(t({},"__esModule",{value:!0}),e));var r=require("@walkeros/core"),c=require("@walkeros/server-core");var a=async function(e,{config:t,rule:n,data:i,env:o,logger:s,collector:a}){const l=t.settings,{apiKey:m,apiSecret:g,pod:v="us1",environment:d="production",userIdentities:f,userAttributes:y,consent:b,ip:_,sourceRequestId:O}=l,j=n?.settings||{},w=(0,r.isObject)(i)?i:{},h=await async function(e,t,n,i){const o={...(0,r.isObject)(t)?t:{},...(0,r.isObject)(n)?n:{}},s=Object.keys(o);if(0===s.length)return;const c={};for(const t of s){const n=p(await(0,r.getMappingValue)(e,o[t],{collector:i}));void 0!==n&&(c[t]=n)}return Object.keys(c).length>0?c:void 0}(e,f,j.userIdentities,a),k=await async function(e,t,n,i){const o=t?await(0,r.getMappingValue)(e,t,{collector:i}):void 0,s=n?await(0,r.getMappingValue)(e,n,{collector:i}):void 0,c={...(0,r.isObject)(o)?o:{},...(0,r.isObject)(s)?s:{}};return Object.keys(c).length>0?c:void 0}(e,y,j.userAttributes,a),P=_?u(await(0,r.getMappingValue)(e,_,{collector:a})):void 0,S=u(O?await(0,r.getMappingValue)(e,O,{collector:a}):void 0)??(e.id||void 0),I=n?.name||e.name,M=e.timestamp||Date.now(),q=e.id||void 0,x=j.eventType||"custom_event";let A;if("screen_view"===x)A=function(e,t,n,i){return{event_type:"screen_view",data:{...e?{screen_name:e}:{},...t&&Object.keys(t).length>0?{custom_attributes:t}:{},...void 0!==n?{timestamp_unixtime_ms:n}:{},...i?{source_message_id:i}:{}}}}(I,w,M,q);else if("commerce_event"===x){const t=j.commerce?await(0,r.getMappingValue)(e,j.commerce,{collector:a}):void 0;A=function(e,t,n,i){return{event_type:"commerce_event",data:{...e||{},...t&&Object.keys(t).length>0?{custom_attributes:t}:{},...void 0!==n?{timestamp_unixtime_ms:n}:{},...i?{source_message_id:i}:{}}}}((0,r.isObject)(t)?t:void 0,w,M,q)}else{A=function(e,t,n,i,o){return{event_type:"custom_event",data:{event_name:e,custom_event_type:t,...n&&Object.keys(n).length>0?{custom_attributes:n}:{},...void 0!==i?{timestamp_unixtime_ms:i}:{},...o?{source_message_id:o}:{}}}}(I,j.customEventType||"other",w,M,q)}const V=function(e,t,n,i,o={}){const s={events:e,environment:i};return t&&Object.keys(t).length>0&&(s.user_identities=t),n&&Object.keys(n).length>0&&(s.user_attributes=n),o.ip&&(s.ip=o.ip),o.sourceRequestId&&(s.source_request_id=o.sourceRequestId),o.consent&&(s.consent_state=o.consent),o.context&&(s.context=o.context),s}([A],h,k,d,{ip:P,sourceRequestId:S,consent:b}),T=function(e="us1"){return"us1"===e?"https://s2s.mparticle.com/v2/events":`https://s2s.${e}.mparticle.com/v2/events`}(v),$=function(e,t){return`Basic ${Buffer.from(`${e}:${t}`).toString("base64")}`}(m,g);s.debug("Calling mParticle Events API",{endpoint:T,method:"POST",eventType:A.event_type,eventName:I,eventId:e.id});const C=o?.sendServer||c.sendServer,K=await C(T,JSON.stringify(V),{headers:{Authorization:$,"Content-Type":"application/json"}});s.debug("mParticle API response",{ok:!(0,r.isObject)(K)||K.ok}),(0,r.isObject)(K)&&!1===K.ok&&s.throw(`mParticle API error: ${JSON.stringify(K)}`)};function u(e){if(null!=e)return"string"==typeof e?e||void 0:"number"==typeof e||"boolean"==typeof e?String(e):void 0}function p(e){if(null!=e)return"string"==typeof e?e||void 0:"number"==typeof e?e:"boolean"==typeof e?String(e):void 0}var l={},m={type:"mparticle",config:{},async init({config:e,logger:t}){const n=function(e={},t){const n=e.settings||{},{apiKey:i,apiSecret:o}=n;i||t.throw("Config settings apiKey missing"),o||t.throw("Config settings apiSecret missing");const s={pod:"us1",environment:"production",...n,apiKey:i,apiSecret:o};return{...e,settings:s}}(e,t);return n},push:async(e,t)=>await a(e,t)},g=m;//# 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/batch.ts","../src/types/index.ts"],"sourcesContent":["import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationMParticle from './types';\n\nexport const destinationMParticle: Destination = {\n type: 'mparticle',\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 destinationMParticle;\n","import type { Config, PartialConfig, Settings } 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 { apiKey, apiSecret } = settings;\n\n if (!apiKey) logger.throw('Config settings apiKey missing');\n if (!apiSecret) logger.throw('Config settings apiSecret missing');\n\n const settingsConfig: Settings = {\n pod: 'us1',\n environment: 'production',\n ...settings,\n apiKey: apiKey as string,\n apiSecret: apiSecret as string,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { WalkerOS, Mapping as WalkerOSMapping } from '@walkeros/core';\nimport { getMappingValue, isObject } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport type {\n CommerceEventData,\n ConsentState,\n CustomEventType,\n Mapping,\n MParticleEvent,\n PushFn,\n Settings,\n} from './types';\nimport {\n buildAuthHeader,\n buildBatch,\n buildCommerceEvent,\n buildCustomEvent,\n buildEndpoint,\n buildScreenViewEvent,\n} from './batch';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, env, logger },\n) {\n const settings = config.settings as Settings;\n const {\n apiKey,\n apiSecret,\n pod = 'us1',\n environment = 'production',\n userIdentities: settingsIdentities,\n userAttributes: settingsUserAttributes,\n consent,\n ip: ipSetting,\n sourceRequestId: sourceRequestIdSetting,\n } = settings;\n\n const ruleSettings: Mapping = (rule?.settings || {}) as Mapping;\n\n const customAttributes = isObject(data)\n ? (data as Record<string, unknown>)\n : {};\n\n const userIdentities = await resolveIdentities(\n event,\n settingsIdentities,\n ruleSettings.userIdentities,\n );\n\n const userAttributes = await resolveUserAttributes(\n event,\n settingsUserAttributes,\n ruleSettings.userAttributes,\n );\n\n const ip = ipSetting\n ? toStringValue(await getMappingValue(event, ipSetting))\n : undefined;\n\n const sourceRequestIdRaw = sourceRequestIdSetting\n ? await getMappingValue(event, sourceRequestIdSetting)\n : undefined;\n const sourceRequestId =\n toStringValue(sourceRequestIdRaw) ?? (event.id || undefined);\n\n const eventName = rule?.name || event.name;\n const timestamp = event.timestamp || Date.now();\n const sourceMessageId = event.id || undefined;\n const eventType = ruleSettings.eventType || 'custom_event';\n\n let mpEvent: MParticleEvent;\n if (eventType === 'screen_view') {\n mpEvent = buildScreenViewEvent(\n eventName,\n customAttributes,\n timestamp,\n sourceMessageId,\n );\n } else if (eventType === 'commerce_event') {\n const commerceResolved = ruleSettings.commerce\n ? await getMappingValue(event, ruleSettings.commerce)\n : undefined;\n const commerceData = isObject(commerceResolved)\n ? (commerceResolved as Partial<CommerceEventData>)\n : undefined;\n mpEvent = buildCommerceEvent(\n commerceData,\n customAttributes,\n timestamp,\n sourceMessageId,\n );\n } else {\n const customEventType: CustomEventType =\n ruleSettings.customEventType || 'other';\n mpEvent = buildCustomEvent(\n eventName,\n customEventType,\n customAttributes,\n timestamp,\n sourceMessageId,\n );\n }\n\n const batch = buildBatch(\n [mpEvent],\n userIdentities,\n userAttributes,\n environment,\n {\n ip,\n sourceRequestId,\n consent: consent as ConsentState | undefined,\n },\n );\n\n const endpoint = buildEndpoint(pod);\n const authHeader = buildAuthHeader(apiKey, apiSecret);\n\n logger.debug('Calling mParticle Events API', {\n endpoint,\n method: 'POST',\n eventType: mpEvent.event_type,\n eventName,\n eventId: event.id,\n });\n\n const sendServerFn = env?.sendServer || sendServer;\n const result = await sendServerFn(endpoint, JSON.stringify(batch), {\n headers: {\n Authorization: authHeader,\n 'Content-Type': 'application/json',\n },\n });\n\n logger.debug('mParticle API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`mParticle API error: ${JSON.stringify(result)}`);\n }\n};\n\nasync function resolveIdentities(\n event: WalkerOS.Event,\n settingsIdentities: WalkerOSMapping.Map | undefined,\n ruleIdentities: WalkerOSMapping.Map | undefined,\n): Promise<Record<string, string | number> | undefined> {\n const merged: WalkerOSMapping.Map = {\n ...(isObject(settingsIdentities) ? settingsIdentities : {}),\n ...(isObject(ruleIdentities) ? ruleIdentities : {}),\n };\n const keys = Object.keys(merged);\n if (keys.length === 0) return undefined;\n\n const out: Record<string, string | number> = {};\n for (const key of keys) {\n const raw = await getMappingValue(event, merged[key]);\n const coerced = toIdentityValue(raw);\n if (coerced !== undefined) out[key] = coerced;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\nasync function resolveUserAttributes(\n event: WalkerOS.Event,\n settingsAttributes: WalkerOSMapping.Value | undefined,\n ruleAttributes: WalkerOSMapping.Value | undefined,\n): Promise<Record<string, unknown> | undefined> {\n const settingsResolved = settingsAttributes\n ? await getMappingValue(event, settingsAttributes)\n : undefined;\n const ruleResolved = ruleAttributes\n ? await getMappingValue(event, ruleAttributes)\n : undefined;\n\n const merged: Record<string, unknown> = {\n ...(isObject(settingsResolved)\n ? (settingsResolved as Record<string, unknown>)\n : {}),\n ...(isObject(ruleResolved)\n ? (ruleResolved as Record<string, unknown>)\n : {}),\n };\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction toStringValue(value: unknown): string | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value === 'string') return value || undefined;\n if (typeof value === 'number' || typeof value === 'boolean')\n return String(value);\n return undefined;\n}\n\nfunction toIdentityValue(value: unknown): string | number | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value === 'string') return value || undefined;\n if (typeof value === 'number') return value;\n if (typeof value === 'boolean') return String(value);\n return undefined;\n}\n","import type {\n CommerceEventData,\n ConsentState,\n CustomEventType,\n Environment,\n MParticleBatch,\n MParticleEvent,\n Pod,\n ScreenViewEventData,\n} from './types';\n\n/**\n * Returns the mParticle Events API endpoint for the given pod.\n * us1 resolves to the legacy host (`s2s.mparticle.com`); other pods use the\n * pod-qualified host.\n * https://docs.mparticle.com/developers/server/http/#endpoint\n */\nexport function buildEndpoint(pod: Pod = 'us1'): string {\n if (pod === 'us1') return 'https://s2s.mparticle.com/v2/events';\n return `https://s2s.${pod}.mparticle.com/v2/events`;\n}\n\n/**\n * Builds the HTTP Basic auth header value from an API key/secret pair.\n * Uses Buffer (Node) for base64 encoding to keep server semantics.\n */\nexport function buildAuthHeader(apiKey: string, apiSecret: string): string {\n const token = Buffer.from(`${apiKey}:${apiSecret}`).toString('base64');\n return `Basic ${token}`;\n}\n\n/**\n * Builds a custom_event payload.\n */\nexport function buildCustomEvent(\n eventName: string,\n customEventType: CustomEventType,\n customAttributes: Record<string, unknown> | undefined,\n timestamp: number | undefined,\n sourceMessageId: string | undefined,\n): MParticleEvent {\n return {\n event_type: 'custom_event',\n data: {\n event_name: eventName,\n custom_event_type: customEventType,\n ...(customAttributes && Object.keys(customAttributes).length > 0\n ? { custom_attributes: customAttributes }\n : {}),\n ...(timestamp !== undefined ? { timestamp_unixtime_ms: timestamp } : {}),\n ...(sourceMessageId ? { source_message_id: sourceMessageId } : {}),\n },\n };\n}\n\n/**\n * Builds a screen_view event payload.\n */\nexport function buildScreenViewEvent(\n screenName: string | undefined,\n customAttributes: Record<string, unknown> | undefined,\n timestamp: number | undefined,\n sourceMessageId: string | undefined,\n): MParticleEvent {\n const data: ScreenViewEventData = {\n ...(screenName ? { screen_name: screenName } : {}),\n ...(customAttributes && Object.keys(customAttributes).length > 0\n ? { custom_attributes: customAttributes }\n : {}),\n ...(timestamp !== undefined ? { timestamp_unixtime_ms: timestamp } : {}),\n ...(sourceMessageId ? { source_message_id: sourceMessageId } : {}),\n };\n return { event_type: 'screen_view', data };\n}\n\n/**\n * Builds a commerce_event payload. Commerce data is a loosely-shaped subset\n * of {@link CommerceEventData} (product_action, currency_code, ...) resolved\n * from the per-rule commerce mapping.\n */\nexport function buildCommerceEvent(\n commerceData: Partial<CommerceEventData> | undefined,\n customAttributes: Record<string, unknown> | undefined,\n timestamp: number | undefined,\n sourceMessageId: string | undefined,\n): MParticleEvent {\n const data: CommerceEventData = {\n ...(commerceData || {}),\n ...(customAttributes && Object.keys(customAttributes).length > 0\n ? { custom_attributes: customAttributes }\n : {}),\n ...(timestamp !== undefined ? { timestamp_unixtime_ms: timestamp } : {}),\n ...(sourceMessageId ? { source_message_id: sourceMessageId } : {}),\n };\n return { event_type: 'commerce_event', data };\n}\n\nexport interface BuildBatchOptions {\n ip?: string;\n sourceRequestId?: string;\n consent?: ConsentState;\n context?: Record<string, unknown>;\n}\n\n/**\n * Assembles the batch envelope wrapping events + identity + environment.\n */\nexport function buildBatch(\n events: MParticleEvent[],\n userIdentities: Record<string, string | number> | undefined,\n userAttributes: Record<string, unknown> | undefined,\n environment: Environment,\n options: BuildBatchOptions = {},\n): MParticleBatch {\n const batch: MParticleBatch = {\n events,\n environment,\n };\n if (userIdentities && Object.keys(userIdentities).length > 0)\n batch.user_identities = userIdentities;\n if (userAttributes && Object.keys(userAttributes).length > 0)\n batch.user_attributes = userAttributes;\n if (options.ip) batch.ip = options.ip;\n if (options.sourceRequestId)\n batch.source_request_id = options.sourceRequestId;\n if (options.consent) batch.consent_state = options.consent;\n if (options.context) batch.context = options.context;\n return batch;\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\n/**\n * mParticle data pod. Determines the regional endpoint used for the Events\n * API. Defaults to `us1`. See {@link buildEndpoint} in `batch.ts`.\n */\nexport type Pod = 'us1' | 'us2' | 'eu1' | 'au1';\n\n/**\n * mParticle environment for the batch. `production` routes to production\n * data streams; `development` sends to debug/verify streams.\n */\nexport type Environment = 'production' | 'development';\n\n/**\n * Event type used for the outgoing mParticle event. Defaults to\n * `custom_event` when not explicitly mapped via rule settings.\n */\nexport type EventType = 'custom_event' | 'screen_view' | 'commerce_event';\n\n/**\n * mParticle custom event type (category) for `custom_event`s. Defaults to\n * `other` when not specified.\n */\nexport type CustomEventType =\n | 'navigation'\n | 'location'\n | 'search'\n | 'transaction'\n | 'user_content'\n | 'user_preference'\n | 'social'\n | 'media'\n | 'attribution'\n | 'other';\n\n/**\n * mParticle product action verbs for commerce events.\n */\nexport type ProductActionType =\n | 'add_to_cart'\n | 'remove_from_cart'\n | 'checkout'\n | 'checkout_option'\n | 'click'\n | 'view_detail'\n | 'purchase'\n | 'refund'\n | 'add_to_wishlist'\n | 'remove_from_wishlist';\n\nexport interface Settings {\n /** mParticle input feed API key. */\n apiKey: string;\n /** mParticle input feed API secret. */\n apiSecret: string;\n /** Data pod selecting the regional endpoint. Default: `us1`. */\n pod?: Pod;\n /** Environment the batch targets. Default: `production`. */\n environment?: Environment;\n /**\n * Mapping that resolves to `user_identities` per batch. Each entry value\n * is a walkerOS mapping value; the resolved object is placed into the\n * mParticle batch `user_identities` envelope.\n */\n userIdentities?: WalkerOSMapping.Map;\n /**\n * Mapping that resolves to `user_attributes` per batch.\n */\n userAttributes?: WalkerOSMapping.Value;\n /**\n * Optional static consent state passthrough — shape is forwarded verbatim\n * to `consent_state` on the batch.\n */\n consent?: ConsentState;\n /** walkerOS mapping value resolving to the client IP for the batch. */\n ip?: WalkerOSMapping.Value;\n /**\n * Optional request correlation id. When omitted, falls back to `event.id`.\n */\n sourceRequestId?: WalkerOSMapping.Value;\n}\n\nexport type InitSettings = Partial<Settings>;\n\n/**\n * Per-rule mapping settings. Determines which mParticle event shape is\n * produced for this walkerOS event and allows per-event identity overrides.\n */\nexport interface Mapping {\n /** Event type. Default: `custom_event`. */\n eventType?: EventType;\n /** Custom event type category for `custom_event`. Default: `other`. */\n customEventType?: CustomEventType;\n /** Commerce mapping resolving to ProductAction and related fields. */\n commerce?: WalkerOSMapping.Value;\n /** Per-event override for `user_identities`. Merged over settings. */\n userIdentities?: WalkerOSMapping.Map;\n /** Per-event override for `user_attributes`. */\n userAttributes?: WalkerOSMapping.Value;\n}\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>;\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\n/**\n * Top-level mParticle batch payload posted to\n * `https://s2s.{pod}.mparticle.com/v2/events`.\n * https://docs.mparticle.com/developers/server/http/\n */\nexport interface MParticleBatch {\n events: MParticleEvent[];\n user_identities?: Record<string, string | number>;\n user_attributes?: Record<string, unknown>;\n environment: Environment;\n schema_version?: number;\n ip?: string;\n source_request_id?: string;\n consent_state?: ConsentState;\n context?: Record<string, unknown>;\n}\n\nexport type MParticleEvent =\n | { event_type: 'custom_event'; data: CustomEventData }\n | { event_type: 'screen_view'; data: ScreenViewEventData }\n | { event_type: 'commerce_event'; data: CommerceEventData };\n\nexport interface CommonEventData {\n timestamp_unixtime_ms?: number;\n source_message_id?: string;\n session_uuid?: string;\n custom_attributes?: Record<string, unknown>;\n custom_flags?: Record<string, unknown>;\n location?: Record<string, unknown>;\n}\n\nexport interface CustomEventData extends CommonEventData {\n event_name: string;\n custom_event_type: CustomEventType;\n}\n\nexport interface ScreenViewEventData extends CommonEventData {\n screen_name?: string;\n}\n\nexport interface CommerceEventData extends CommonEventData {\n product_action?: ProductAction;\n promotion_action?: PromotionAction;\n product_impressions?: ProductImpression[];\n currency_code?: string;\n is_non_interactive?: boolean;\n}\n\nexport interface ProductAction {\n action: ProductActionType;\n transaction_id?: string;\n total_amount?: number;\n tax_amount?: number;\n shipping_amount?: number;\n coupon_code?: string;\n affiliation?: string;\n checkout_step?: number;\n checkout_options?: string;\n products?: Product[];\n}\n\nexport interface Product {\n id?: string;\n name?: string;\n brand?: string;\n category?: string;\n variant?: string;\n position?: number;\n price?: number;\n quantity?: number;\n coupon_code?: string;\n total_product_amount?: number;\n custom_attributes?: Record<string, unknown>;\n}\n\nexport interface PromotionAction {\n action: 'view' | 'click';\n promotions?: Array<{\n id?: string;\n name?: string;\n creative?: string;\n position?: string;\n }>;\n}\n\nexport interface ProductImpression {\n product_impression_list?: string;\n products?: Product[];\n}\n\n/**\n * mParticle consent state envelope forwarded verbatim on the batch.\n * https://docs.mparticle.com/developers/server/http/#consent-state\n */\nexport interface ConsentState {\n gdpr?: Record<string, GDPRConsentState>;\n ccpa?: { data_sale_opt_out?: CCPAConsentState };\n}\n\nexport interface GDPRConsentState {\n consented: boolean;\n document?: string;\n timestamp_unixtime_ms?: number;\n location?: string;\n hardware_id?: string;\n}\n\nexport interface CCPAConsentState {\n consented: boolean;\n document?: string;\n timestamp_unixtime_ms?: number;\n location?: string;\n hardware_id?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BAC8C;AAC9C,QAAM,mBAAmB,qBACrB,UAAM,6BAAgB,OAAO,kBAAkB,IAC/C;AACJ,QAAM,eAAe,iBACjB,UAAM,6BAAgB,OAAO,cAAc,IAC3C;AAEJ,QAAM,SAAkC;AAAA,IACtC,OAAI,sBAAS,gBAAgB,IACxB,mBACD,CAAC;AAAA,IACL,OAAI,sBAAS,YAAY,IACpB,eACD,CAAC;AAAA,EACP;AACA,SAAO,OAAO,KAAK,MAAM,EAAE,SAAS,IAAI,SAAS;AACnD;AAEA,SAAS,cAAc,OAAoC;AACzD,MAAI,UAAU,UAAa,UAAU,KAAM,QAAO;AAClD,MAAI,OAAO,UAAU,SAAU,QAAO,SAAS;AAC/C,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU;AAChD,WAAO,OAAO,KAAK;AACrB,SAAO;AACT;AAEA,SAAS,gBAAgB,OAA6C;AACpE,MAAI,UAAU,UAAa,UAAU,KAAM,QAAO;AAClD,MAAI,OAAO,UAAU,SAAU,QAAO,SAAS;AAC/C,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI,OAAO,UAAU,UAAW,QAAO,OAAO,KAAK;AACnD,SAAO;AACT;;;AE1MA;;;AJOO,IAAM,uBAAoC;AAAA,EAC/C,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/index.ts","../src/config.ts","../src/push.ts","../src/batch.ts","../src/types/index.ts"],"sourcesContent":["import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationMParticle from './types';\n\nexport const destinationMParticle: Destination = {\n type: 'mparticle',\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 destinationMParticle;\n","import type { Config, PartialConfig, Settings } 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 { apiKey, apiSecret } = settings;\n\n if (!apiKey) logger.throw('Config settings apiKey missing');\n if (!apiSecret) logger.throw('Config settings apiSecret missing');\n\n const settingsConfig: Settings = {\n pod: 'us1',\n environment: 'production',\n ...settings,\n apiKey: apiKey as string,\n apiSecret: apiSecret as string,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type {\n Collector,\n WalkerOS,\n Mapping as WalkerOSMapping,\n} from '@walkeros/core';\nimport { getMappingValue, isObject } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport type {\n CommerceEventData,\n ConsentState,\n CustomEventType,\n Mapping,\n MParticleEvent,\n PushFn,\n Settings,\n} from './types';\nimport {\n buildAuthHeader,\n buildBatch,\n buildCommerceEvent,\n buildCustomEvent,\n buildEndpoint,\n buildScreenViewEvent,\n} from './batch';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, env, logger, collector },\n) {\n const settings = config.settings as Settings;\n const {\n apiKey,\n apiSecret,\n pod = 'us1',\n environment = 'production',\n userIdentities: settingsIdentities,\n userAttributes: settingsUserAttributes,\n consent,\n ip: ipSetting,\n sourceRequestId: sourceRequestIdSetting,\n } = settings;\n\n const ruleSettings: Mapping = (rule?.settings || {}) as Mapping;\n\n const customAttributes = isObject(data)\n ? (data as Record<string, unknown>)\n : {};\n\n const userIdentities = await resolveIdentities(\n event,\n settingsIdentities,\n ruleSettings.userIdentities,\n collector,\n );\n\n const userAttributes = await resolveUserAttributes(\n event,\n settingsUserAttributes,\n ruleSettings.userAttributes,\n collector,\n );\n\n const ip = ipSetting\n ? toStringValue(await getMappingValue(event, ipSetting, { collector }))\n : undefined;\n\n const sourceRequestIdRaw = sourceRequestIdSetting\n ? await getMappingValue(event, sourceRequestIdSetting, { collector })\n : undefined;\n const sourceRequestId =\n toStringValue(sourceRequestIdRaw) ?? (event.id || undefined);\n\n const eventName = rule?.name || event.name;\n const timestamp = event.timestamp || Date.now();\n const sourceMessageId = event.id || undefined;\n const eventType = ruleSettings.eventType || 'custom_event';\n\n let mpEvent: MParticleEvent;\n if (eventType === 'screen_view') {\n mpEvent = buildScreenViewEvent(\n eventName,\n customAttributes,\n timestamp,\n sourceMessageId,\n );\n } else if (eventType === 'commerce_event') {\n const commerceResolved = ruleSettings.commerce\n ? await getMappingValue(event, ruleSettings.commerce, { collector })\n : undefined;\n const commerceData = isObject(commerceResolved)\n ? (commerceResolved as Partial<CommerceEventData>)\n : undefined;\n mpEvent = buildCommerceEvent(\n commerceData,\n customAttributes,\n timestamp,\n sourceMessageId,\n );\n } else {\n const customEventType: CustomEventType =\n ruleSettings.customEventType || 'other';\n mpEvent = buildCustomEvent(\n eventName,\n customEventType,\n customAttributes,\n timestamp,\n sourceMessageId,\n );\n }\n\n const batch = buildBatch(\n [mpEvent],\n userIdentities,\n userAttributes,\n environment,\n {\n ip,\n sourceRequestId,\n consent: consent as ConsentState | undefined,\n },\n );\n\n const endpoint = buildEndpoint(pod);\n const authHeader = buildAuthHeader(apiKey, apiSecret);\n\n logger.debug('Calling mParticle Events API', {\n endpoint,\n method: 'POST',\n eventType: mpEvent.event_type,\n eventName,\n eventId: event.id,\n });\n\n const sendServerFn = env?.sendServer || sendServer;\n const result = await sendServerFn(endpoint, JSON.stringify(batch), {\n headers: {\n Authorization: authHeader,\n 'Content-Type': 'application/json',\n },\n });\n\n logger.debug('mParticle API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`mParticle API error: ${JSON.stringify(result)}`);\n }\n};\n\nasync function resolveIdentities(\n event: WalkerOS.Event,\n settingsIdentities: WalkerOSMapping.Map | undefined,\n ruleIdentities: WalkerOSMapping.Map | undefined,\n collector: Collector.Instance,\n): Promise<Record<string, string | number> | undefined> {\n const merged: WalkerOSMapping.Map = {\n ...(isObject(settingsIdentities) ? settingsIdentities : {}),\n ...(isObject(ruleIdentities) ? ruleIdentities : {}),\n };\n const keys = Object.keys(merged);\n if (keys.length === 0) return undefined;\n\n const out: Record<string, string | number> = {};\n for (const key of keys) {\n const raw = await getMappingValue(event, merged[key], { collector });\n const coerced = toIdentityValue(raw);\n if (coerced !== undefined) out[key] = coerced;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\nasync function resolveUserAttributes(\n event: WalkerOS.Event,\n settingsAttributes: WalkerOSMapping.Value | undefined,\n ruleAttributes: WalkerOSMapping.Value | undefined,\n collector: Collector.Instance,\n): Promise<Record<string, unknown> | undefined> {\n const settingsResolved = settingsAttributes\n ? await getMappingValue(event, settingsAttributes, { collector })\n : undefined;\n const ruleResolved = ruleAttributes\n ? await getMappingValue(event, ruleAttributes, { collector })\n : undefined;\n\n const merged: Record<string, unknown> = {\n ...(isObject(settingsResolved)\n ? (settingsResolved as Record<string, unknown>)\n : {}),\n ...(isObject(ruleResolved)\n ? (ruleResolved as Record<string, unknown>)\n : {}),\n };\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction toStringValue(value: unknown): string | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value === 'string') return value || undefined;\n if (typeof value === 'number' || typeof value === 'boolean')\n return String(value);\n return undefined;\n}\n\nfunction toIdentityValue(value: unknown): string | number | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value === 'string') return value || undefined;\n if (typeof value === 'number') return value;\n if (typeof value === 'boolean') return String(value);\n return undefined;\n}\n","import type {\n CommerceEventData,\n ConsentState,\n CustomEventType,\n Environment,\n MParticleBatch,\n MParticleEvent,\n Pod,\n ScreenViewEventData,\n} from './types';\n\n/**\n * Returns the mParticle Events API endpoint for the given pod.\n * us1 resolves to the legacy host (`s2s.mparticle.com`); other pods use the\n * pod-qualified host.\n * https://docs.mparticle.com/developers/server/http/#endpoint\n */\nexport function buildEndpoint(pod: Pod = 'us1'): string {\n if (pod === 'us1') return 'https://s2s.mparticle.com/v2/events';\n return `https://s2s.${pod}.mparticle.com/v2/events`;\n}\n\n/**\n * Builds the HTTP Basic auth header value from an API key/secret pair.\n * Uses Buffer (Node) for base64 encoding to keep server semantics.\n */\nexport function buildAuthHeader(apiKey: string, apiSecret: string): string {\n const token = Buffer.from(`${apiKey}:${apiSecret}`).toString('base64');\n return `Basic ${token}`;\n}\n\n/**\n * Builds a custom_event payload.\n */\nexport function buildCustomEvent(\n eventName: string,\n customEventType: CustomEventType,\n customAttributes: Record<string, unknown> | undefined,\n timestamp: number | undefined,\n sourceMessageId: string | undefined,\n): MParticleEvent {\n return {\n event_type: 'custom_event',\n data: {\n event_name: eventName,\n custom_event_type: customEventType,\n ...(customAttributes && Object.keys(customAttributes).length > 0\n ? { custom_attributes: customAttributes }\n : {}),\n ...(timestamp !== undefined ? { timestamp_unixtime_ms: timestamp } : {}),\n ...(sourceMessageId ? { source_message_id: sourceMessageId } : {}),\n },\n };\n}\n\n/**\n * Builds a screen_view event payload.\n */\nexport function buildScreenViewEvent(\n screenName: string | undefined,\n customAttributes: Record<string, unknown> | undefined,\n timestamp: number | undefined,\n sourceMessageId: string | undefined,\n): MParticleEvent {\n const data: ScreenViewEventData = {\n ...(screenName ? { screen_name: screenName } : {}),\n ...(customAttributes && Object.keys(customAttributes).length > 0\n ? { custom_attributes: customAttributes }\n : {}),\n ...(timestamp !== undefined ? { timestamp_unixtime_ms: timestamp } : {}),\n ...(sourceMessageId ? { source_message_id: sourceMessageId } : {}),\n };\n return { event_type: 'screen_view', data };\n}\n\n/**\n * Builds a commerce_event payload. Commerce data is a loosely-shaped subset\n * of {@link CommerceEventData} (product_action, currency_code, ...) resolved\n * from the per-rule commerce mapping.\n */\nexport function buildCommerceEvent(\n commerceData: Partial<CommerceEventData> | undefined,\n customAttributes: Record<string, unknown> | undefined,\n timestamp: number | undefined,\n sourceMessageId: string | undefined,\n): MParticleEvent {\n const data: CommerceEventData = {\n ...(commerceData || {}),\n ...(customAttributes && Object.keys(customAttributes).length > 0\n ? { custom_attributes: customAttributes }\n : {}),\n ...(timestamp !== undefined ? { timestamp_unixtime_ms: timestamp } : {}),\n ...(sourceMessageId ? { source_message_id: sourceMessageId } : {}),\n };\n return { event_type: 'commerce_event', data };\n}\n\nexport interface BuildBatchOptions {\n ip?: string;\n sourceRequestId?: string;\n consent?: ConsentState;\n context?: Record<string, unknown>;\n}\n\n/**\n * Assembles the batch envelope wrapping events + identity + environment.\n */\nexport function buildBatch(\n events: MParticleEvent[],\n userIdentities: Record<string, string | number> | undefined,\n userAttributes: Record<string, unknown> | undefined,\n environment: Environment,\n options: BuildBatchOptions = {},\n): MParticleBatch {\n const batch: MParticleBatch = {\n events,\n environment,\n };\n if (userIdentities && Object.keys(userIdentities).length > 0)\n batch.user_identities = userIdentities;\n if (userAttributes && Object.keys(userAttributes).length > 0)\n batch.user_attributes = userAttributes;\n if (options.ip) batch.ip = options.ip;\n if (options.sourceRequestId)\n batch.source_request_id = options.sourceRequestId;\n if (options.consent) batch.consent_state = options.consent;\n if (options.context) batch.context = options.context;\n return batch;\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\n/**\n * mParticle data pod. Determines the regional endpoint used for the Events\n * API. Defaults to `us1`. See {@link buildEndpoint} in `batch.ts`.\n */\nexport type Pod = 'us1' | 'us2' | 'eu1' | 'au1';\n\n/**\n * mParticle environment for the batch. `production` routes to production\n * data streams; `development` sends to debug/verify streams.\n */\nexport type Environment = 'production' | 'development';\n\n/**\n * Event type used for the outgoing mParticle event. Defaults to\n * `custom_event` when not explicitly mapped via rule settings.\n */\nexport type EventType = 'custom_event' | 'screen_view' | 'commerce_event';\n\n/**\n * mParticle custom event type (category) for `custom_event`s. Defaults to\n * `other` when not specified.\n */\nexport type CustomEventType =\n | 'navigation'\n | 'location'\n | 'search'\n | 'transaction'\n | 'user_content'\n | 'user_preference'\n | 'social'\n | 'media'\n | 'attribution'\n | 'other';\n\n/**\n * mParticle product action verbs for commerce events.\n */\nexport type ProductActionType =\n | 'add_to_cart'\n | 'remove_from_cart'\n | 'checkout'\n | 'checkout_option'\n | 'click'\n | 'view_detail'\n | 'purchase'\n | 'refund'\n | 'add_to_wishlist'\n | 'remove_from_wishlist';\n\nexport interface Settings {\n /** mParticle input feed API key. */\n apiKey: string;\n /** mParticle input feed API secret. */\n apiSecret: string;\n /** Data pod selecting the regional endpoint. Default: `us1`. */\n pod?: Pod;\n /** Environment the batch targets. Default: `production`. */\n environment?: Environment;\n /**\n * Mapping that resolves to `user_identities` per batch. Each entry value\n * is a walkerOS mapping value; the resolved object is placed into the\n * mParticle batch `user_identities` envelope.\n */\n userIdentities?: WalkerOSMapping.Map;\n /**\n * Mapping that resolves to `user_attributes` per batch.\n */\n userAttributes?: WalkerOSMapping.Value;\n /**\n * Optional static consent state passthrough — shape is forwarded verbatim\n * to `consent_state` on the batch.\n */\n consent?: ConsentState;\n /** walkerOS mapping value resolving to the client IP for the batch. */\n ip?: WalkerOSMapping.Value;\n /**\n * Optional request correlation id. When omitted, falls back to `event.id`.\n */\n sourceRequestId?: WalkerOSMapping.Value;\n}\n\nexport type InitSettings = Partial<Settings>;\n\n/**\n * Per-rule mapping settings. Determines which mParticle event shape is\n * produced for this walkerOS event and allows per-event identity overrides.\n */\nexport interface Mapping {\n /** Event type. Default: `custom_event`. */\n eventType?: EventType;\n /** Custom event type category for `custom_event`. Default: `other`. */\n customEventType?: CustomEventType;\n /** Commerce mapping resolving to ProductAction and related fields. */\n commerce?: WalkerOSMapping.Value;\n /** Per-event override for `user_identities`. Merged over settings. */\n userIdentities?: WalkerOSMapping.Map;\n /** Per-event override for `user_attributes`. */\n userAttributes?: WalkerOSMapping.Value;\n}\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>;\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\n/**\n * Top-level mParticle batch payload posted to\n * `https://s2s.{pod}.mparticle.com/v2/events`.\n * https://docs.mparticle.com/developers/server/http/\n */\nexport interface MParticleBatch {\n events: MParticleEvent[];\n user_identities?: Record<string, string | number>;\n user_attributes?: Record<string, unknown>;\n environment: Environment;\n schema_version?: number;\n ip?: string;\n source_request_id?: string;\n consent_state?: ConsentState;\n context?: Record<string, unknown>;\n}\n\nexport type MParticleEvent =\n | { event_type: 'custom_event'; data: CustomEventData }\n | { event_type: 'screen_view'; data: ScreenViewEventData }\n | { event_type: 'commerce_event'; data: CommerceEventData };\n\nexport interface CommonEventData {\n timestamp_unixtime_ms?: number;\n source_message_id?: string;\n session_uuid?: string;\n custom_attributes?: Record<string, unknown>;\n custom_flags?: Record<string, unknown>;\n location?: Record<string, unknown>;\n}\n\nexport interface CustomEventData extends CommonEventData {\n event_name: string;\n custom_event_type: CustomEventType;\n}\n\nexport interface ScreenViewEventData extends CommonEventData {\n screen_name?: string;\n}\n\nexport interface CommerceEventData extends CommonEventData {\n product_action?: ProductAction;\n promotion_action?: PromotionAction;\n product_impressions?: ProductImpression[];\n currency_code?: string;\n is_non_interactive?: boolean;\n}\n\nexport interface ProductAction {\n action: ProductActionType;\n transaction_id?: string;\n total_amount?: number;\n tax_amount?: number;\n shipping_amount?: number;\n coupon_code?: string;\n affiliation?: string;\n checkout_step?: number;\n checkout_options?: string;\n products?: Product[];\n}\n\nexport interface Product {\n id?: string;\n name?: string;\n brand?: string;\n category?: string;\n variant?: string;\n position?: number;\n price?: number;\n quantity?: number;\n coupon_code?: string;\n total_product_amount?: number;\n custom_attributes?: Record<string, unknown>;\n}\n\nexport interface PromotionAction {\n action: 'view' | 'click';\n promotions?: Array<{\n id?: string;\n name?: string;\n creative?: string;\n position?: string;\n }>;\n}\n\nexport interface ProductImpression {\n product_impression_list?: string;\n products?: Product[];\n}\n\n/**\n * mParticle consent state envelope forwarded verbatim on the batch.\n * https://docs.mparticle.com/developers/server/http/#consent-state\n */\nexport interface ConsentState {\n gdpr?: Record<string, GDPRConsentState>;\n ccpa?: { data_sale_opt_out?: CCPAConsentState };\n}\n\nexport interface GDPRConsentState {\n consented: boolean;\n document?: string;\n timestamp_unixtime_ms?: number;\n location?: string;\n hardware_id?: string;\n}\n\nexport interface CCPAConsentState {\n consented: boolean;\n document?: string;\n timestamp_unixtime_ms?: number;\n location?: string;\n hardware_id?: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,SAAS,UACd,gBAA+B,CAAC,GAChC,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,QAAQ,UAAU,IAAI;AAE9B,MAAI,CAAC,OAAQ,QAAO,MAAM,gCAAgC;AAC1D,MAAI,CAAC,UAAW,QAAO,MAAM,mCAAmC;AAEhE,QAAM,iBAA2B;AAAA,IAC/B,KAAK;AAAA,IACL,aAAa;AAAA,IACb,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,eAAe,UAAU,eAAe;AACtD;;;ACjBA,kBAA0C;AAC1C,yBAA2B;;;ACWpB,SAAS,cAAc,MAAW,OAAe;AACtD,MAAI,QAAQ,MAAO,QAAO;AAC1B,SAAO,eA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I,OAAO,UAAU,YAAY,OAAO,UAAU;AAChD,WAAO,OAAO,KAAK;AACrB,SAAO;AACT;AAEA,SAAS,gBAAgB,OAA6C;AACpE,MAAI,UAAU,UAAa,UAAU,KAAM,QAAO;AAClD,MAAI,OAAO,UAAU,SAAU,QAAO,SAAS;AAC/C,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI,OAAO,UAAU,UAAW,QAAO,OAAO,KAAK;AACnD,SAAO;AACT;;;AElNA;;;AJOO,IAAM,uBAAoC;AAAA,EAC/C,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":[]}
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{getMappingValue as e,isObject as t}from"@walkeros/core";import{sendServer as n}from"@walkeros/server-core";var i=async function(i,{config:r,rule:c,data:a,env:u,logger:m}){var v;const d=r.settings,{apiKey:p,apiSecret:l,pod:f="us1",environment:g="production",userIdentities:y,userAttributes:_,consent:b,ip:h,sourceRequestId:w}=d,k=(null==c?void 0:c.settings)||{},O=t(a)?a:{},S=await async function(n,i,s){const r={...t(i)?i:{},...t(s)?s:{}},c=Object.keys(r);if(0===c.length)return;const a={};for(const t of c){const i=o(await e(n,r[t]));void 0!==i&&(a[t]=i)}return Object.keys(a).length>0?a:void 0}(i,y,k.userIdentities),I=await async function(n,i,s){const o=i?await e(n,i):void 0,r=s?await e(n,s):void 0,c={...t(o)?o:{},...t(r)?r:{}};return Object.keys(c).length>0?c:void 0}(i,_,k.userAttributes),j=h?s(await e(i,h)):void 0,P=null!=(v=s(w?await e(i,w):void 0))?v:i.id||void 0,x=(null==c?void 0:c.name)||i.name,A=i.timestamp||Date.now(),q=i.id||void 0,T=k.eventType||"custom_event";let $;if("screen_view"===T)$=function(e,t,n,i){return{event_type:"screen_view",data:{...e?{screen_name:e}:{},...t&&Object.keys(t).length>0?{custom_attributes:t}:{},...void 0!==n?{timestamp_unixtime_ms:n}:{},...i?{source_message_id:i}:{}}}}(x,O,A,q);else if("commerce_event"===T){const n=k.commerce?await e(i,k.commerce):void 0;$=function(e,t,n,i){return{event_type:"commerce_event",data:{...e||{},...t&&Object.keys(t).length>0?{custom_attributes:t}:{},...void 0!==n?{timestamp_unixtime_ms:n}:{},...i?{source_message_id:i}:{}}}}(t(n)?n:void 0,O,A,q)}else{$=function(e,t,n,i,s){return{event_type:"custom_event",data:{event_name:e,custom_event_type:t,...n&&Object.keys(n).length>0?{custom_attributes:n}:{},...void 0!==i?{timestamp_unixtime_ms:i}:{},...s?{source_message_id:s}:{}}}}(x,k.customEventType||"other",O,A,q)}const C=function(e,t,n,i,s={}){const o={events:e,environment:i};return t&&Object.keys(t).length>0&&(o.user_identities=t),n&&Object.keys(n).length>0&&(o.user_attributes=n),s.ip&&(o.ip=s.ip),s.sourceRequestId&&(o.source_request_id=s.sourceRequestId),s.consent&&(o.consent_state=s.consent),s.context&&(o.context=s.context),o}([$],S,I,g,{ip:j,sourceRequestId:P,consent:b}),K=function(e="us1"){return"us1"===e?"https://s2s.mparticle.com/v2/events":`https://s2s.${e}.mparticle.com/v2/events`}(f),R=function(e,t){return`Basic ${Buffer.from(`${e}:${t}`).toString("base64")}`}(p,l);m.debug("Calling mParticle Events API",{endpoint:K,method:"POST",eventType:$.event_type,eventName:x,eventId:i.id});const N=(null==u?void 0:u.sendServer)||n,B=await N(K,JSON.stringify(C),{headers:{Authorization:R,"Content-Type":"application/json"}});m.debug("mParticle API response",{ok:!t(B)||B.ok}),t(B)&&!1===B.ok&&m.throw(`mParticle API error: ${JSON.stringify(B)}`)};function s(e){if(null!=e)return"string"==typeof e?e||void 0:"number"==typeof e||"boolean"==typeof e?String(e):void 0}function o(e){if(null!=e)return"string"==typeof e?e||void 0:"number"==typeof e?e:"boolean"==typeof e?String(e):void 0}var r={},c={type:"mparticle",config:{},async init({config:e,logger:t}){const n=function(e={},t){const n=e.settings||{},{apiKey:i,apiSecret:s}=n;i||t.throw("Config settings apiKey missing"),s||t.throw("Config settings apiSecret missing");const o={pod:"us1",environment:"production",...n,apiKey:i,apiSecret:s};return{...e,settings:o}}(e,t);return n},push:async(e,t)=>await i(e,t)},a=c;export{r as DestinationMParticle,a as default,c as destinationMParticle};//# sourceMappingURL=index.mjs.map
1
+ import{getMappingValue as e,isObject as t}from"@walkeros/core";import{sendServer as n}from"@walkeros/server-core";var o=async function(o,{config:r,rule:c,data:a,env:u,logger:m,collector:p}){const v=r.settings,{apiKey:d,apiSecret:l,pod:f="us1",environment:g="production",userIdentities:y,userAttributes:_,consent:b,ip:h,sourceRequestId:w}=v,k=c?.settings||{},O=t(a)?a:{},S=await async function(n,o,i,r){const c={...t(o)?o:{},...t(i)?i:{}},a=Object.keys(c);if(0===a.length)return;const u={};for(const t of a){const o=s(await e(n,c[t],{collector:r}));void 0!==o&&(u[t]=o)}return Object.keys(u).length>0?u:void 0}(o,y,k.userIdentities,p),I=await async function(n,o,i,s){const r=o?await e(n,o,{collector:s}):void 0,c=i?await e(n,i,{collector:s}):void 0,a={...t(r)?r:{},...t(c)?c:{}};return Object.keys(a).length>0?a:void 0}(o,_,k.userAttributes,p),j=h?i(await e(o,h,{collector:p})):void 0,P=i(w?await e(o,w,{collector:p}):void 0)??(o.id||void 0),x=c?.name||o.name,A=o.timestamp||Date.now(),q=o.id||void 0,T=k.eventType||"custom_event";let $;if("screen_view"===T)$=function(e,t,n,o){return{event_type:"screen_view",data:{...e?{screen_name:e}:{},...t&&Object.keys(t).length>0?{custom_attributes:t}:{},...void 0!==n?{timestamp_unixtime_ms:n}:{},...o?{source_message_id:o}:{}}}}(x,O,A,q);else if("commerce_event"===T){const n=k.commerce?await e(o,k.commerce,{collector:p}):void 0;$=function(e,t,n,o){return{event_type:"commerce_event",data:{...e||{},...t&&Object.keys(t).length>0?{custom_attributes:t}:{},...void 0!==n?{timestamp_unixtime_ms:n}:{},...o?{source_message_id:o}:{}}}}(t(n)?n:void 0,O,A,q)}else{$=function(e,t,n,o,i){return{event_type:"custom_event",data:{event_name:e,custom_event_type:t,...n&&Object.keys(n).length>0?{custom_attributes:n}:{},...void 0!==o?{timestamp_unixtime_ms:o}:{},...i?{source_message_id:i}:{}}}}(x,k.customEventType||"other",O,A,q)}const C=function(e,t,n,o,i={}){const s={events:e,environment:o};return t&&Object.keys(t).length>0&&(s.user_identities=t),n&&Object.keys(n).length>0&&(s.user_attributes=n),i.ip&&(s.ip=i.ip),i.sourceRequestId&&(s.source_request_id=i.sourceRequestId),i.consent&&(s.consent_state=i.consent),i.context&&(s.context=i.context),s}([$],S,I,g,{ip:j,sourceRequestId:P,consent:b}),K=function(e="us1"){return"us1"===e?"https://s2s.mparticle.com/v2/events":`https://s2s.${e}.mparticle.com/v2/events`}(f),R=function(e,t){return`Basic ${Buffer.from(`${e}:${t}`).toString("base64")}`}(d,l);m.debug("Calling mParticle Events API",{endpoint:K,method:"POST",eventType:$.event_type,eventName:x,eventId:o.id});const N=u?.sendServer||n,B=await N(K,JSON.stringify(C),{headers:{Authorization:R,"Content-Type":"application/json"}});m.debug("mParticle API response",{ok:!t(B)||B.ok}),t(B)&&!1===B.ok&&m.throw(`mParticle API error: ${JSON.stringify(B)}`)};function i(e){if(null!=e)return"string"==typeof e?e||void 0:"number"==typeof e||"boolean"==typeof e?String(e):void 0}function s(e){if(null!=e)return"string"==typeof e?e||void 0:"number"==typeof e?e:"boolean"==typeof e?String(e):void 0}var r={},c={type:"mparticle",config:{},async init({config:e,logger:t}){const n=function(e={},t){const n=e.settings||{},{apiKey:o,apiSecret:i}=n;o||t.throw("Config settings apiKey missing"),i||t.throw("Config settings apiSecret missing");const s={pod:"us1",environment:"production",...n,apiKey:o,apiSecret:i};return{...e,settings:s}}(e,t);return n},push:async(e,t)=>await o(e,t)},a=c;export{r as DestinationMParticle,a as default,c as destinationMParticle};//# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts","../src/push.ts","../src/batch.ts","../src/types/index.ts","../src/index.ts"],"sourcesContent":["import type { Config, PartialConfig, Settings } 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 { apiKey, apiSecret } = settings;\n\n if (!apiKey) logger.throw('Config settings apiKey missing');\n if (!apiSecret) logger.throw('Config settings apiSecret missing');\n\n const settingsConfig: Settings = {\n pod: 'us1',\n environment: 'production',\n ...settings,\n apiKey: apiKey as string,\n apiSecret: apiSecret as string,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type { WalkerOS, Mapping as WalkerOSMapping } from '@walkeros/core';\nimport { getMappingValue, isObject } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport type {\n CommerceEventData,\n ConsentState,\n CustomEventType,\n Mapping,\n MParticleEvent,\n PushFn,\n Settings,\n} from './types';\nimport {\n buildAuthHeader,\n buildBatch,\n buildCommerceEvent,\n buildCustomEvent,\n buildEndpoint,\n buildScreenViewEvent,\n} from './batch';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, env, logger },\n) {\n const settings = config.settings as Settings;\n const {\n apiKey,\n apiSecret,\n pod = 'us1',\n environment = 'production',\n userIdentities: settingsIdentities,\n userAttributes: settingsUserAttributes,\n consent,\n ip: ipSetting,\n sourceRequestId: sourceRequestIdSetting,\n } = settings;\n\n const ruleSettings: Mapping = (rule?.settings || {}) as Mapping;\n\n const customAttributes = isObject(data)\n ? (data as Record<string, unknown>)\n : {};\n\n const userIdentities = await resolveIdentities(\n event,\n settingsIdentities,\n ruleSettings.userIdentities,\n );\n\n const userAttributes = await resolveUserAttributes(\n event,\n settingsUserAttributes,\n ruleSettings.userAttributes,\n );\n\n const ip = ipSetting\n ? toStringValue(await getMappingValue(event, ipSetting))\n : undefined;\n\n const sourceRequestIdRaw = sourceRequestIdSetting\n ? await getMappingValue(event, sourceRequestIdSetting)\n : undefined;\n const sourceRequestId =\n toStringValue(sourceRequestIdRaw) ?? (event.id || undefined);\n\n const eventName = rule?.name || event.name;\n const timestamp = event.timestamp || Date.now();\n const sourceMessageId = event.id || undefined;\n const eventType = ruleSettings.eventType || 'custom_event';\n\n let mpEvent: MParticleEvent;\n if (eventType === 'screen_view') {\n mpEvent = buildScreenViewEvent(\n eventName,\n customAttributes,\n timestamp,\n sourceMessageId,\n );\n } else if (eventType === 'commerce_event') {\n const commerceResolved = ruleSettings.commerce\n ? await getMappingValue(event, ruleSettings.commerce)\n : undefined;\n const commerceData = isObject(commerceResolved)\n ? (commerceResolved as Partial<CommerceEventData>)\n : undefined;\n mpEvent = buildCommerceEvent(\n commerceData,\n customAttributes,\n timestamp,\n sourceMessageId,\n );\n } else {\n const customEventType: CustomEventType =\n ruleSettings.customEventType || 'other';\n mpEvent = buildCustomEvent(\n eventName,\n customEventType,\n customAttributes,\n timestamp,\n sourceMessageId,\n );\n }\n\n const batch = buildBatch(\n [mpEvent],\n userIdentities,\n userAttributes,\n environment,\n {\n ip,\n sourceRequestId,\n consent: consent as ConsentState | undefined,\n },\n );\n\n const endpoint = buildEndpoint(pod);\n const authHeader = buildAuthHeader(apiKey, apiSecret);\n\n logger.debug('Calling mParticle Events API', {\n endpoint,\n method: 'POST',\n eventType: mpEvent.event_type,\n eventName,\n eventId: event.id,\n });\n\n const sendServerFn = env?.sendServer || sendServer;\n const result = await sendServerFn(endpoint, JSON.stringify(batch), {\n headers: {\n Authorization: authHeader,\n 'Content-Type': 'application/json',\n },\n });\n\n logger.debug('mParticle API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`mParticle API error: ${JSON.stringify(result)}`);\n }\n};\n\nasync function resolveIdentities(\n event: WalkerOS.Event,\n settingsIdentities: WalkerOSMapping.Map | undefined,\n ruleIdentities: WalkerOSMapping.Map | undefined,\n): Promise<Record<string, string | number> | undefined> {\n const merged: WalkerOSMapping.Map = {\n ...(isObject(settingsIdentities) ? settingsIdentities : {}),\n ...(isObject(ruleIdentities) ? ruleIdentities : {}),\n };\n const keys = Object.keys(merged);\n if (keys.length === 0) return undefined;\n\n const out: Record<string, string | number> = {};\n for (const key of keys) {\n const raw = await getMappingValue(event, merged[key]);\n const coerced = toIdentityValue(raw);\n if (coerced !== undefined) out[key] = coerced;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\nasync function resolveUserAttributes(\n event: WalkerOS.Event,\n settingsAttributes: WalkerOSMapping.Value | undefined,\n ruleAttributes: WalkerOSMapping.Value | undefined,\n): Promise<Record<string, unknown> | undefined> {\n const settingsResolved = settingsAttributes\n ? await getMappingValue(event, settingsAttributes)\n : undefined;\n const ruleResolved = ruleAttributes\n ? await getMappingValue(event, ruleAttributes)\n : undefined;\n\n const merged: Record<string, unknown> = {\n ...(isObject(settingsResolved)\n ? (settingsResolved as Record<string, unknown>)\n : {}),\n ...(isObject(ruleResolved)\n ? (ruleResolved as Record<string, unknown>)\n : {}),\n };\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction toStringValue(value: unknown): string | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value === 'string') return value || undefined;\n if (typeof value === 'number' || typeof value === 'boolean')\n return String(value);\n return undefined;\n}\n\nfunction toIdentityValue(value: unknown): string | number | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value === 'string') return value || undefined;\n if (typeof value === 'number') return value;\n if (typeof value === 'boolean') return String(value);\n return undefined;\n}\n","import type {\n CommerceEventData,\n ConsentState,\n CustomEventType,\n Environment,\n MParticleBatch,\n MParticleEvent,\n Pod,\n ScreenViewEventData,\n} from './types';\n\n/**\n * Returns the mParticle Events API endpoint for the given pod.\n * us1 resolves to the legacy host (`s2s.mparticle.com`); other pods use the\n * pod-qualified host.\n * https://docs.mparticle.com/developers/server/http/#endpoint\n */\nexport function buildEndpoint(pod: Pod = 'us1'): string {\n if (pod === 'us1') return 'https://s2s.mparticle.com/v2/events';\n return `https://s2s.${pod}.mparticle.com/v2/events`;\n}\n\n/**\n * Builds the HTTP Basic auth header value from an API key/secret pair.\n * Uses Buffer (Node) for base64 encoding to keep server semantics.\n */\nexport function buildAuthHeader(apiKey: string, apiSecret: string): string {\n const token = Buffer.from(`${apiKey}:${apiSecret}`).toString('base64');\n return `Basic ${token}`;\n}\n\n/**\n * Builds a custom_event payload.\n */\nexport function buildCustomEvent(\n eventName: string,\n customEventType: CustomEventType,\n customAttributes: Record<string, unknown> | undefined,\n timestamp: number | undefined,\n sourceMessageId: string | undefined,\n): MParticleEvent {\n return {\n event_type: 'custom_event',\n data: {\n event_name: eventName,\n custom_event_type: customEventType,\n ...(customAttributes && Object.keys(customAttributes).length > 0\n ? { custom_attributes: customAttributes }\n : {}),\n ...(timestamp !== undefined ? { timestamp_unixtime_ms: timestamp } : {}),\n ...(sourceMessageId ? { source_message_id: sourceMessageId } : {}),\n },\n };\n}\n\n/**\n * Builds a screen_view event payload.\n */\nexport function buildScreenViewEvent(\n screenName: string | undefined,\n customAttributes: Record<string, unknown> | undefined,\n timestamp: number | undefined,\n sourceMessageId: string | undefined,\n): MParticleEvent {\n const data: ScreenViewEventData = {\n ...(screenName ? { screen_name: screenName } : {}),\n ...(customAttributes && Object.keys(customAttributes).length > 0\n ? { custom_attributes: customAttributes }\n : {}),\n ...(timestamp !== undefined ? { timestamp_unixtime_ms: timestamp } : {}),\n ...(sourceMessageId ? { source_message_id: sourceMessageId } : {}),\n };\n return { event_type: 'screen_view', data };\n}\n\n/**\n * Builds a commerce_event payload. Commerce data is a loosely-shaped subset\n * of {@link CommerceEventData} (product_action, currency_code, ...) resolved\n * from the per-rule commerce mapping.\n */\nexport function buildCommerceEvent(\n commerceData: Partial<CommerceEventData> | undefined,\n customAttributes: Record<string, unknown> | undefined,\n timestamp: number | undefined,\n sourceMessageId: string | undefined,\n): MParticleEvent {\n const data: CommerceEventData = {\n ...(commerceData || {}),\n ...(customAttributes && Object.keys(customAttributes).length > 0\n ? { custom_attributes: customAttributes }\n : {}),\n ...(timestamp !== undefined ? { timestamp_unixtime_ms: timestamp } : {}),\n ...(sourceMessageId ? { source_message_id: sourceMessageId } : {}),\n };\n return { event_type: 'commerce_event', data };\n}\n\nexport interface BuildBatchOptions {\n ip?: string;\n sourceRequestId?: string;\n consent?: ConsentState;\n context?: Record<string, unknown>;\n}\n\n/**\n * Assembles the batch envelope wrapping events + identity + environment.\n */\nexport function buildBatch(\n events: MParticleEvent[],\n userIdentities: Record<string, string | number> | undefined,\n userAttributes: Record<string, unknown> | undefined,\n environment: Environment,\n options: BuildBatchOptions = {},\n): MParticleBatch {\n const batch: MParticleBatch = {\n events,\n environment,\n };\n if (userIdentities && Object.keys(userIdentities).length > 0)\n batch.user_identities = userIdentities;\n if (userAttributes && Object.keys(userAttributes).length > 0)\n batch.user_attributes = userAttributes;\n if (options.ip) batch.ip = options.ip;\n if (options.sourceRequestId)\n batch.source_request_id = options.sourceRequestId;\n if (options.consent) batch.consent_state = options.consent;\n if (options.context) batch.context = options.context;\n return batch;\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\n/**\n * mParticle data pod. Determines the regional endpoint used for the Events\n * API. Defaults to `us1`. See {@link buildEndpoint} in `batch.ts`.\n */\nexport type Pod = 'us1' | 'us2' | 'eu1' | 'au1';\n\n/**\n * mParticle environment for the batch. `production` routes to production\n * data streams; `development` sends to debug/verify streams.\n */\nexport type Environment = 'production' | 'development';\n\n/**\n * Event type used for the outgoing mParticle event. Defaults to\n * `custom_event` when not explicitly mapped via rule settings.\n */\nexport type EventType = 'custom_event' | 'screen_view' | 'commerce_event';\n\n/**\n * mParticle custom event type (category) for `custom_event`s. Defaults to\n * `other` when not specified.\n */\nexport type CustomEventType =\n | 'navigation'\n | 'location'\n | 'search'\n | 'transaction'\n | 'user_content'\n | 'user_preference'\n | 'social'\n | 'media'\n | 'attribution'\n | 'other';\n\n/**\n * mParticle product action verbs for commerce events.\n */\nexport type ProductActionType =\n | 'add_to_cart'\n | 'remove_from_cart'\n | 'checkout'\n | 'checkout_option'\n | 'click'\n | 'view_detail'\n | 'purchase'\n | 'refund'\n | 'add_to_wishlist'\n | 'remove_from_wishlist';\n\nexport interface Settings {\n /** mParticle input feed API key. */\n apiKey: string;\n /** mParticle input feed API secret. */\n apiSecret: string;\n /** Data pod selecting the regional endpoint. Default: `us1`. */\n pod?: Pod;\n /** Environment the batch targets. Default: `production`. */\n environment?: Environment;\n /**\n * Mapping that resolves to `user_identities` per batch. Each entry value\n * is a walkerOS mapping value; the resolved object is placed into the\n * mParticle batch `user_identities` envelope.\n */\n userIdentities?: WalkerOSMapping.Map;\n /**\n * Mapping that resolves to `user_attributes` per batch.\n */\n userAttributes?: WalkerOSMapping.Value;\n /**\n * Optional static consent state passthrough — shape is forwarded verbatim\n * to `consent_state` on the batch.\n */\n consent?: ConsentState;\n /** walkerOS mapping value resolving to the client IP for the batch. */\n ip?: WalkerOSMapping.Value;\n /**\n * Optional request correlation id. When omitted, falls back to `event.id`.\n */\n sourceRequestId?: WalkerOSMapping.Value;\n}\n\nexport type InitSettings = Partial<Settings>;\n\n/**\n * Per-rule mapping settings. Determines which mParticle event shape is\n * produced for this walkerOS event and allows per-event identity overrides.\n */\nexport interface Mapping {\n /** Event type. Default: `custom_event`. */\n eventType?: EventType;\n /** Custom event type category for `custom_event`. Default: `other`. */\n customEventType?: CustomEventType;\n /** Commerce mapping resolving to ProductAction and related fields. */\n commerce?: WalkerOSMapping.Value;\n /** Per-event override for `user_identities`. Merged over settings. */\n userIdentities?: WalkerOSMapping.Map;\n /** Per-event override for `user_attributes`. */\n userAttributes?: WalkerOSMapping.Value;\n}\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>;\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\n/**\n * Top-level mParticle batch payload posted to\n * `https://s2s.{pod}.mparticle.com/v2/events`.\n * https://docs.mparticle.com/developers/server/http/\n */\nexport interface MParticleBatch {\n events: MParticleEvent[];\n user_identities?: Record<string, string | number>;\n user_attributes?: Record<string, unknown>;\n environment: Environment;\n schema_version?: number;\n ip?: string;\n source_request_id?: string;\n consent_state?: ConsentState;\n context?: Record<string, unknown>;\n}\n\nexport type MParticleEvent =\n | { event_type: 'custom_event'; data: CustomEventData }\n | { event_type: 'screen_view'; data: ScreenViewEventData }\n | { event_type: 'commerce_event'; data: CommerceEventData };\n\nexport interface CommonEventData {\n timestamp_unixtime_ms?: number;\n source_message_id?: string;\n session_uuid?: string;\n custom_attributes?: Record<string, unknown>;\n custom_flags?: Record<string, unknown>;\n location?: Record<string, unknown>;\n}\n\nexport interface CustomEventData extends CommonEventData {\n event_name: string;\n custom_event_type: CustomEventType;\n}\n\nexport interface ScreenViewEventData extends CommonEventData {\n screen_name?: string;\n}\n\nexport interface CommerceEventData extends CommonEventData {\n product_action?: ProductAction;\n promotion_action?: PromotionAction;\n product_impressions?: ProductImpression[];\n currency_code?: string;\n is_non_interactive?: boolean;\n}\n\nexport interface ProductAction {\n action: ProductActionType;\n transaction_id?: string;\n total_amount?: number;\n tax_amount?: number;\n shipping_amount?: number;\n coupon_code?: string;\n affiliation?: string;\n checkout_step?: number;\n checkout_options?: string;\n products?: Product[];\n}\n\nexport interface Product {\n id?: string;\n name?: string;\n brand?: string;\n category?: string;\n variant?: string;\n position?: number;\n price?: number;\n quantity?: number;\n coupon_code?: string;\n total_product_amount?: number;\n custom_attributes?: Record<string, unknown>;\n}\n\nexport interface PromotionAction {\n action: 'view' | 'click';\n promotions?: Array<{\n id?: string;\n name?: string;\n creative?: string;\n position?: string;\n }>;\n}\n\nexport interface ProductImpression {\n product_impression_list?: string;\n products?: Product[];\n}\n\n/**\n * mParticle consent state envelope forwarded verbatim on the batch.\n * https://docs.mparticle.com/developers/server/http/#consent-state\n */\nexport interface ConsentState {\n gdpr?: Record<string, GDPRConsentState>;\n ccpa?: { data_sale_opt_out?: CCPAConsentState };\n}\n\nexport interface GDPRConsentState {\n consented: boolean;\n document?: string;\n timestamp_unixtime_ms?: number;\n location?: string;\n hardware_id?: string;\n}\n\nexport interface CCPAConsentState {\n consented: boolean;\n document?: string;\n timestamp_unixtime_ms?: number;\n location?: string;\n hardware_id?: string;\n}\n","import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationMParticle from './types';\n\nexport const destinationMParticle: Destination = {\n type: 'mparticle',\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 destinationMParticle;\n"],"mappings":";AAGO,SAAS,UACd,gBAA+B,CAAC,GAChC,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,QAAQ,UAAU,IAAI;AAE9B,MAAI,CAAC,OAAQ,QAAO,MAAM,gCAAgC;AAC1D,MAAI,CAAC,UAAW,QAAO,MAAM,mCAAmC;AAEhE,QAAM,iBAA2B;AAAA,IAC/B,KAAK;AAAA,IACL,aAAa;AAAA,IACb,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,eAAe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,SAAS;AAC/C,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU;AAChD,WAAO,OAAO,KAAK;AACrB,SAAO;AACT;AAEA,SAAS,gBAAgB,OAA6C;AACpE,MAAI,UAAU,UAAa,UAAU,KAAM,QAAO;AAClD,MAAI,OAAO,UAAU,SAAU,QAAO,SAAS;AAC/C,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,MAAI,OAAO,UAAU,UAAW,QAAO,OAAO,KAAK;AACnD,SAAO;AACT;;;AE1MA;;;ACOO,IAAM,uBAAoC;AAAA,EAC/C,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/batch.ts","../src/types/index.ts","../src/index.ts"],"sourcesContent":["import type { Config, PartialConfig, Settings } 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 { apiKey, apiSecret } = settings;\n\n if (!apiKey) logger.throw('Config settings apiKey missing');\n if (!apiSecret) logger.throw('Config settings apiSecret missing');\n\n const settingsConfig: Settings = {\n pod: 'us1',\n environment: 'production',\n ...settings,\n apiKey: apiKey as string,\n apiSecret: apiSecret as string,\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type {\n Collector,\n WalkerOS,\n Mapping as WalkerOSMapping,\n} from '@walkeros/core';\nimport { getMappingValue, isObject } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport type {\n CommerceEventData,\n ConsentState,\n CustomEventType,\n Mapping,\n MParticleEvent,\n PushFn,\n Settings,\n} from './types';\nimport {\n buildAuthHeader,\n buildBatch,\n buildCommerceEvent,\n buildCustomEvent,\n buildEndpoint,\n buildScreenViewEvent,\n} from './batch';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, env, logger, collector },\n) {\n const settings = config.settings as Settings;\n const {\n apiKey,\n apiSecret,\n pod = 'us1',\n environment = 'production',\n userIdentities: settingsIdentities,\n userAttributes: settingsUserAttributes,\n consent,\n ip: ipSetting,\n sourceRequestId: sourceRequestIdSetting,\n } = settings;\n\n const ruleSettings: Mapping = (rule?.settings || {}) as Mapping;\n\n const customAttributes = isObject(data)\n ? (data as Record<string, unknown>)\n : {};\n\n const userIdentities = await resolveIdentities(\n event,\n settingsIdentities,\n ruleSettings.userIdentities,\n collector,\n );\n\n const userAttributes = await resolveUserAttributes(\n event,\n settingsUserAttributes,\n ruleSettings.userAttributes,\n collector,\n );\n\n const ip = ipSetting\n ? toStringValue(await getMappingValue(event, ipSetting, { collector }))\n : undefined;\n\n const sourceRequestIdRaw = sourceRequestIdSetting\n ? await getMappingValue(event, sourceRequestIdSetting, { collector })\n : undefined;\n const sourceRequestId =\n toStringValue(sourceRequestIdRaw) ?? (event.id || undefined);\n\n const eventName = rule?.name || event.name;\n const timestamp = event.timestamp || Date.now();\n const sourceMessageId = event.id || undefined;\n const eventType = ruleSettings.eventType || 'custom_event';\n\n let mpEvent: MParticleEvent;\n if (eventType === 'screen_view') {\n mpEvent = buildScreenViewEvent(\n eventName,\n customAttributes,\n timestamp,\n sourceMessageId,\n );\n } else if (eventType === 'commerce_event') {\n const commerceResolved = ruleSettings.commerce\n ? await getMappingValue(event, ruleSettings.commerce, { collector })\n : undefined;\n const commerceData = isObject(commerceResolved)\n ? (commerceResolved as Partial<CommerceEventData>)\n : undefined;\n mpEvent = buildCommerceEvent(\n commerceData,\n customAttributes,\n timestamp,\n sourceMessageId,\n );\n } else {\n const customEventType: CustomEventType =\n ruleSettings.customEventType || 'other';\n mpEvent = buildCustomEvent(\n eventName,\n customEventType,\n customAttributes,\n timestamp,\n sourceMessageId,\n );\n }\n\n const batch = buildBatch(\n [mpEvent],\n userIdentities,\n userAttributes,\n environment,\n {\n ip,\n sourceRequestId,\n consent: consent as ConsentState | undefined,\n },\n );\n\n const endpoint = buildEndpoint(pod);\n const authHeader = buildAuthHeader(apiKey, apiSecret);\n\n logger.debug('Calling mParticle Events API', {\n endpoint,\n method: 'POST',\n eventType: mpEvent.event_type,\n eventName,\n eventId: event.id,\n });\n\n const sendServerFn = env?.sendServer || sendServer;\n const result = await sendServerFn(endpoint, JSON.stringify(batch), {\n headers: {\n Authorization: authHeader,\n 'Content-Type': 'application/json',\n },\n });\n\n logger.debug('mParticle API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`mParticle API error: ${JSON.stringify(result)}`);\n }\n};\n\nasync function resolveIdentities(\n event: WalkerOS.Event,\n settingsIdentities: WalkerOSMapping.Map | undefined,\n ruleIdentities: WalkerOSMapping.Map | undefined,\n collector: Collector.Instance,\n): Promise<Record<string, string | number> | undefined> {\n const merged: WalkerOSMapping.Map = {\n ...(isObject(settingsIdentities) ? settingsIdentities : {}),\n ...(isObject(ruleIdentities) ? ruleIdentities : {}),\n };\n const keys = Object.keys(merged);\n if (keys.length === 0) return undefined;\n\n const out: Record<string, string | number> = {};\n for (const key of keys) {\n const raw = await getMappingValue(event, merged[key], { collector });\n const coerced = toIdentityValue(raw);\n if (coerced !== undefined) out[key] = coerced;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\nasync function resolveUserAttributes(\n event: WalkerOS.Event,\n settingsAttributes: WalkerOSMapping.Value | undefined,\n ruleAttributes: WalkerOSMapping.Value | undefined,\n collector: Collector.Instance,\n): Promise<Record<string, unknown> | undefined> {\n const settingsResolved = settingsAttributes\n ? await getMappingValue(event, settingsAttributes, { collector })\n : undefined;\n const ruleResolved = ruleAttributes\n ? await getMappingValue(event, ruleAttributes, { collector })\n : undefined;\n\n const merged: Record<string, unknown> = {\n ...(isObject(settingsResolved)\n ? (settingsResolved as Record<string, unknown>)\n : {}),\n ...(isObject(ruleResolved)\n ? (ruleResolved as Record<string, unknown>)\n : {}),\n };\n return Object.keys(merged).length > 0 ? merged : undefined;\n}\n\nfunction toStringValue(value: unknown): string | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value === 'string') return value || undefined;\n if (typeof value === 'number' || typeof value === 'boolean')\n return String(value);\n return undefined;\n}\n\nfunction toIdentityValue(value: unknown): string | number | undefined {\n if (value === undefined || value === null) return undefined;\n if (typeof value === 'string') return value || undefined;\n if (typeof value === 'number') return value;\n if (typeof value === 'boolean') return String(value);\n return undefined;\n}\n","import type {\n CommerceEventData,\n ConsentState,\n CustomEventType,\n Environment,\n MParticleBatch,\n MParticleEvent,\n Pod,\n ScreenViewEventData,\n} from './types';\n\n/**\n * Returns the mParticle Events API endpoint for the given pod.\n * us1 resolves to the legacy host (`s2s.mparticle.com`); other pods use the\n * pod-qualified host.\n * https://docs.mparticle.com/developers/server/http/#endpoint\n */\nexport function buildEndpoint(pod: Pod = 'us1'): string {\n if (pod === 'us1') return 'https://s2s.mparticle.com/v2/events';\n return `https://s2s.${pod}.mparticle.com/v2/events`;\n}\n\n/**\n * Builds the HTTP Basic auth header value from an API key/secret pair.\n * Uses Buffer (Node) for base64 encoding to keep server semantics.\n */\nexport function buildAuthHeader(apiKey: string, apiSecret: string): string {\n const token = Buffer.from(`${apiKey}:${apiSecret}`).toString('base64');\n return `Basic ${token}`;\n}\n\n/**\n * Builds a custom_event payload.\n */\nexport function buildCustomEvent(\n eventName: string,\n customEventType: CustomEventType,\n customAttributes: Record<string, unknown> | undefined,\n timestamp: number | undefined,\n sourceMessageId: string | undefined,\n): MParticleEvent {\n return {\n event_type: 'custom_event',\n data: {\n event_name: eventName,\n custom_event_type: customEventType,\n ...(customAttributes && Object.keys(customAttributes).length > 0\n ? { custom_attributes: customAttributes }\n : {}),\n ...(timestamp !== undefined ? { timestamp_unixtime_ms: timestamp } : {}),\n ...(sourceMessageId ? { source_message_id: sourceMessageId } : {}),\n },\n };\n}\n\n/**\n * Builds a screen_view event payload.\n */\nexport function buildScreenViewEvent(\n screenName: string | undefined,\n customAttributes: Record<string, unknown> | undefined,\n timestamp: number | undefined,\n sourceMessageId: string | undefined,\n): MParticleEvent {\n const data: ScreenViewEventData = {\n ...(screenName ? { screen_name: screenName } : {}),\n ...(customAttributes && Object.keys(customAttributes).length > 0\n ? { custom_attributes: customAttributes }\n : {}),\n ...(timestamp !== undefined ? { timestamp_unixtime_ms: timestamp } : {}),\n ...(sourceMessageId ? { source_message_id: sourceMessageId } : {}),\n };\n return { event_type: 'screen_view', data };\n}\n\n/**\n * Builds a commerce_event payload. Commerce data is a loosely-shaped subset\n * of {@link CommerceEventData} (product_action, currency_code, ...) resolved\n * from the per-rule commerce mapping.\n */\nexport function buildCommerceEvent(\n commerceData: Partial<CommerceEventData> | undefined,\n customAttributes: Record<string, unknown> | undefined,\n timestamp: number | undefined,\n sourceMessageId: string | undefined,\n): MParticleEvent {\n const data: CommerceEventData = {\n ...(commerceData || {}),\n ...(customAttributes && Object.keys(customAttributes).length > 0\n ? { custom_attributes: customAttributes }\n : {}),\n ...(timestamp !== undefined ? { timestamp_unixtime_ms: timestamp } : {}),\n ...(sourceMessageId ? { source_message_id: sourceMessageId } : {}),\n };\n return { event_type: 'commerce_event', data };\n}\n\nexport interface BuildBatchOptions {\n ip?: string;\n sourceRequestId?: string;\n consent?: ConsentState;\n context?: Record<string, unknown>;\n}\n\n/**\n * Assembles the batch envelope wrapping events + identity + environment.\n */\nexport function buildBatch(\n events: MParticleEvent[],\n userIdentities: Record<string, string | number> | undefined,\n userAttributes: Record<string, unknown> | undefined,\n environment: Environment,\n options: BuildBatchOptions = {},\n): MParticleBatch {\n const batch: MParticleBatch = {\n events,\n environment,\n };\n if (userIdentities && Object.keys(userIdentities).length > 0)\n batch.user_identities = userIdentities;\n if (userAttributes && Object.keys(userAttributes).length > 0)\n batch.user_attributes = userAttributes;\n if (options.ip) batch.ip = options.ip;\n if (options.sourceRequestId)\n batch.source_request_id = options.sourceRequestId;\n if (options.consent) batch.consent_state = options.consent;\n if (options.context) batch.context = options.context;\n return batch;\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\n/**\n * mParticle data pod. Determines the regional endpoint used for the Events\n * API. Defaults to `us1`. See {@link buildEndpoint} in `batch.ts`.\n */\nexport type Pod = 'us1' | 'us2' | 'eu1' | 'au1';\n\n/**\n * mParticle environment for the batch. `production` routes to production\n * data streams; `development` sends to debug/verify streams.\n */\nexport type Environment = 'production' | 'development';\n\n/**\n * Event type used for the outgoing mParticle event. Defaults to\n * `custom_event` when not explicitly mapped via rule settings.\n */\nexport type EventType = 'custom_event' | 'screen_view' | 'commerce_event';\n\n/**\n * mParticle custom event type (category) for `custom_event`s. Defaults to\n * `other` when not specified.\n */\nexport type CustomEventType =\n | 'navigation'\n | 'location'\n | 'search'\n | 'transaction'\n | 'user_content'\n | 'user_preference'\n | 'social'\n | 'media'\n | 'attribution'\n | 'other';\n\n/**\n * mParticle product action verbs for commerce events.\n */\nexport type ProductActionType =\n | 'add_to_cart'\n | 'remove_from_cart'\n | 'checkout'\n | 'checkout_option'\n | 'click'\n | 'view_detail'\n | 'purchase'\n | 'refund'\n | 'add_to_wishlist'\n | 'remove_from_wishlist';\n\nexport interface Settings {\n /** mParticle input feed API key. */\n apiKey: string;\n /** mParticle input feed API secret. */\n apiSecret: string;\n /** Data pod selecting the regional endpoint. Default: `us1`. */\n pod?: Pod;\n /** Environment the batch targets. Default: `production`. */\n environment?: Environment;\n /**\n * Mapping that resolves to `user_identities` per batch. Each entry value\n * is a walkerOS mapping value; the resolved object is placed into the\n * mParticle batch `user_identities` envelope.\n */\n userIdentities?: WalkerOSMapping.Map;\n /**\n * Mapping that resolves to `user_attributes` per batch.\n */\n userAttributes?: WalkerOSMapping.Value;\n /**\n * Optional static consent state passthrough — shape is forwarded verbatim\n * to `consent_state` on the batch.\n */\n consent?: ConsentState;\n /** walkerOS mapping value resolving to the client IP for the batch. */\n ip?: WalkerOSMapping.Value;\n /**\n * Optional request correlation id. When omitted, falls back to `event.id`.\n */\n sourceRequestId?: WalkerOSMapping.Value;\n}\n\nexport type InitSettings = Partial<Settings>;\n\n/**\n * Per-rule mapping settings. Determines which mParticle event shape is\n * produced for this walkerOS event and allows per-event identity overrides.\n */\nexport interface Mapping {\n /** Event type. Default: `custom_event`. */\n eventType?: EventType;\n /** Custom event type category for `custom_event`. Default: `other`. */\n customEventType?: CustomEventType;\n /** Commerce mapping resolving to ProductAction and related fields. */\n commerce?: WalkerOSMapping.Value;\n /** Per-event override for `user_identities`. Merged over settings. */\n userIdentities?: WalkerOSMapping.Map;\n /** Per-event override for `user_attributes`. */\n userAttributes?: WalkerOSMapping.Value;\n}\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>;\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\n/**\n * Top-level mParticle batch payload posted to\n * `https://s2s.{pod}.mparticle.com/v2/events`.\n * https://docs.mparticle.com/developers/server/http/\n */\nexport interface MParticleBatch {\n events: MParticleEvent[];\n user_identities?: Record<string, string | number>;\n user_attributes?: Record<string, unknown>;\n environment: Environment;\n schema_version?: number;\n ip?: string;\n source_request_id?: string;\n consent_state?: ConsentState;\n context?: Record<string, unknown>;\n}\n\nexport type MParticleEvent =\n | { event_type: 'custom_event'; data: CustomEventData }\n | { event_type: 'screen_view'; data: ScreenViewEventData }\n | { event_type: 'commerce_event'; data: CommerceEventData };\n\nexport interface CommonEventData {\n timestamp_unixtime_ms?: number;\n source_message_id?: string;\n session_uuid?: string;\n custom_attributes?: Record<string, unknown>;\n custom_flags?: Record<string, unknown>;\n location?: Record<string, unknown>;\n}\n\nexport interface CustomEventData extends CommonEventData {\n event_name: string;\n custom_event_type: CustomEventType;\n}\n\nexport interface ScreenViewEventData extends CommonEventData {\n screen_name?: string;\n}\n\nexport interface CommerceEventData extends CommonEventData {\n product_action?: ProductAction;\n promotion_action?: PromotionAction;\n product_impressions?: ProductImpression[];\n currency_code?: string;\n is_non_interactive?: boolean;\n}\n\nexport interface ProductAction {\n action: ProductActionType;\n transaction_id?: string;\n total_amount?: number;\n tax_amount?: number;\n shipping_amount?: number;\n coupon_code?: string;\n affiliation?: string;\n checkout_step?: number;\n checkout_options?: string;\n products?: Product[];\n}\n\nexport interface Product {\n id?: string;\n name?: string;\n brand?: string;\n category?: string;\n variant?: string;\n position?: number;\n price?: number;\n quantity?: number;\n coupon_code?: string;\n total_product_amount?: number;\n custom_attributes?: Record<string, unknown>;\n}\n\nexport interface PromotionAction {\n action: 'view' | 'click';\n promotions?: Array<{\n id?: string;\n name?: string;\n creative?: string;\n position?: string;\n }>;\n}\n\nexport interface ProductImpression {\n product_impression_list?: string;\n products?: Product[];\n}\n\n/**\n * mParticle consent state envelope forwarded verbatim on the batch.\n * https://docs.mparticle.com/developers/server/http/#consent-state\n */\nexport interface ConsentState {\n gdpr?: Record<string, GDPRConsentState>;\n ccpa?: { data_sale_opt_out?: CCPAConsentState };\n}\n\nexport interface GDPRConsentState {\n consented: boolean;\n document?: string;\n timestamp_unixtime_ms?: number;\n location?: string;\n hardware_id?: string;\n}\n\nexport interface CCPAConsentState {\n consented: boolean;\n document?: string;\n timestamp_unixtime_ms?: number;\n location?: string;\n hardware_id?: string;\n}\n","import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationMParticle from './types';\n\nexport const destinationMParticle: Destination = {\n type: 'mparticle',\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 destinationMParticle;\n"],"mappings":";AAGO,SAAS,UACd,gBAA+B,CAAC,GAChC,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,QAAQ,UAAU,IAAI;AAE9B,MAAI,CAAC,OAAQ,QAAO,MAAM,gCAAgC;AAC1D,MAAI,CAAC,UAAW,QAAO,MAAM,mCAAmC;AAEhE,QAAM,iBAA2B;AAAA,IAC/B,KAAK;AAAA,IACL,aAAa;AAAA,IACb,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,eAAe,UAAU,eAAe;AACtD;;;ACjBA,SAAS,iBAAiB,gBAAgB;AAC1C,SAAS,kBAAkB;;;ACWpB,SAAS,cAAc,MAAW,OAAe;AACtD,MAAI,QAAQ,MAAO,QAAO;AAC1B,SAAO,eAAe,GAAG;AAC3B;AAMO,SAAS,gBAAgB,QAAgB,WAA2B;AACzE,QAAM,QAAQ,OAAO,KAAK,GAAG,MAAM,IAAI,SAAS,EAAE,EAAE,SAAS,QAAQ;AACrE,SAAO,SAAS,KAAK;AACvB;AAKO,SAAS,iBACd,WACA,iBACA,kBACA,WACA,iBACgB;AAChB,SAAO;AAAA,IACL,YAAY;AAAA,IACZ,MAAM;AAAA,MACJ,YAAY;AAAA,MACZ,mBAAmB;AAAA,MACnB,GAAI,oBAAoB,OAAO,KAAK,gBAAgB,EAAE,SAAS,IAC3D,EAAE,mBAAmB,iBAAiB,IACtC,CAAC;AAAA,MACL,GAAI,cAAc,SAAY,EAAE,uBAAuB,UAAU,IAAI,CAAC;AAAA,MACtE,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AAA,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-mparticle",
4
- "version": "3.4.2",
4
+ "version": "4.0.0-next-1777882869103",
5
5
  "type": "destination",
6
6
  "platform": [
7
7
  "server"
@@ -209,22 +209,15 @@
209
209
  "consent": {
210
210
  "functional": true
211
211
  },
212
- "id": "1700000300000-gr0up-1",
212
+ "id": "ev-1700000300000",
213
213
  "trigger": "load",
214
214
  "entity": "order",
215
215
  "action": "complete",
216
216
  "timestamp": 1700000300000,
217
217
  "timing": 3.14,
218
- "group": "gr0up",
219
- "count": 1,
220
- "version": {
221
- "source": "3.4.2",
222
- "tagging": 1
223
- },
224
218
  "source": {
225
- "type": "server",
226
- "id": "https://shop.example.com",
227
- "previous_id": ""
219
+ "type": "express",
220
+ "platform": "server"
228
221
  }
229
222
  },
230
223
  "mapping": {
@@ -250,7 +243,7 @@
250
243
  [
251
244
  "sendServer",
252
245
  "https://s2s.mparticle.com/v2/events",
253
- "{\"events\":[{\"event_type\":\"commerce_event\",\"data\":{\"currency_code\":\"EUR\",\"product_action\":{\"action\":\"purchase\",\"transaction_id\":\"ORD-300\",\"total_amount\":249.99},\"timestamp_unixtime_ms\":1700000300000,\"source_message_id\":\"1700000300000-gr0up-1\"}}],\"environment\":\"production\",\"user_identities\":{\"customer_id\":\"user-123\"},\"source_request_id\":\"1700000300000-gr0up-1\"}",
246
+ "{\"events\":[{\"event_type\":\"commerce_event\",\"data\":{\"currency_code\":\"EUR\",\"product_action\":{\"action\":\"purchase\",\"transaction_id\":\"ORD-300\",\"total_amount\":249.99},\"timestamp_unixtime_ms\":1700000300000,\"source_message_id\":\"ev-1700000300000\"}}],\"environment\":\"production\",\"user_identities\":{\"customer_id\":\"user-123\"},\"source_request_id\":\"ev-1700000300000\"}",
254
247
  {
255
248
  "headers": {
256
249
  "Authorization": "Basic a2V5OnNlY3JldA==",
@@ -289,29 +282,22 @@
289
282
  "consent": {
290
283
  "functional": true
291
284
  },
292
- "id": "1700000100000-gr0up-1",
285
+ "id": "ev-1700000100000",
293
286
  "trigger": "load",
294
287
  "entity": "product",
295
288
  "action": "view",
296
289
  "timestamp": 1700000100000,
297
290
  "timing": 3.14,
298
- "group": "gr0up",
299
- "count": 1,
300
- "version": {
301
- "source": "3.4.2",
302
- "tagging": 1
303
- },
304
291
  "source": {
305
- "type": "server",
306
- "id": "https://shop.example.com",
307
- "previous_id": ""
292
+ "type": "express",
293
+ "platform": "server"
308
294
  }
309
295
  },
310
296
  "out": [
311
297
  [
312
298
  "sendServer",
313
299
  "https://s2s.mparticle.com/v2/events",
314
- "{\"events\":[{\"event_type\":\"custom_event\",\"data\":{\"event_name\":\"product view\",\"custom_event_type\":\"other\",\"timestamp_unixtime_ms\":1700000100000,\"source_message_id\":\"1700000100000-gr0up-1\"}}],\"environment\":\"production\",\"user_identities\":{\"customer_id\":\"user-123\"},\"source_request_id\":\"1700000100000-gr0up-1\"}",
300
+ "{\"events\":[{\"event_type\":\"custom_event\",\"data\":{\"event_name\":\"product view\",\"custom_event_type\":\"other\",\"timestamp_unixtime_ms\":1700000100000,\"source_message_id\":\"ev-1700000100000\"}}],\"environment\":\"production\",\"user_identities\":{\"customer_id\":\"user-123\"},\"source_request_id\":\"ev-1700000100000\"}",
315
301
  {
316
302
  "headers": {
317
303
  "Authorization": "Basic a2V5OnNlY3JldA==",
@@ -350,42 +336,28 @@
350
336
  "entity": "child",
351
337
  "data": {
352
338
  "is": "subordinated"
353
- },
354
- "nested": [],
355
- "context": {
356
- "element": [
357
- "child",
358
- 0
359
- ]
360
339
  }
361
340
  }
362
341
  ],
363
342
  "consent": {
364
343
  "functional": true
365
344
  },
366
- "id": "1700000400000-gr0up-1",
345
+ "id": "ev-1700000400000",
367
346
  "trigger": "test",
368
347
  "entity": "form",
369
348
  "action": "submit",
370
349
  "timestamp": 1700000400000,
371
350
  "timing": 3.14,
372
- "group": "gr0up",
373
- "count": 1,
374
- "version": {
375
- "source": "3.4.2",
376
- "tagging": 1
377
- },
378
351
  "source": {
379
- "type": "server",
380
- "id": "https://example.com",
381
- "previous_id": ""
352
+ "type": "express",
353
+ "platform": "server"
382
354
  }
383
355
  },
384
356
  "out": [
385
357
  [
386
358
  "sendServer",
387
359
  "https://s2s.mparticle.com/v2/events",
388
- "{\"events\":[{\"event_type\":\"custom_event\",\"data\":{\"event_name\":\"form submit\",\"custom_event_type\":\"other\",\"timestamp_unixtime_ms\":1700000400000,\"source_message_id\":\"1700000400000-gr0up-1\"}}],\"environment\":\"production\",\"user_identities\":{\"customer_id\":\"user-123\",\"email\":\"user@example.com\"},\"source_request_id\":\"1700000400000-gr0up-1\"}",
360
+ "{\"events\":[{\"event_type\":\"custom_event\",\"data\":{\"event_name\":\"form submit\",\"custom_event_type\":\"other\",\"timestamp_unixtime_ms\":1700000400000,\"source_message_id\":\"ev-1700000400000\"}}],\"environment\":\"production\",\"user_identities\":{\"customer_id\":\"user-123\",\"email\":\"user@example.com\"},\"source_request_id\":\"ev-1700000400000\"}",
389
361
  {
390
362
  "headers": {
391
363
  "Authorization": "Basic a2V5OnNlY3JldA==",
@@ -424,35 +396,21 @@
424
396
  "entity": "child",
425
397
  "data": {
426
398
  "is": "subordinated"
427
- },
428
- "nested": [],
429
- "context": {
430
- "element": [
431
- "child",
432
- 0
433
- ]
434
399
  }
435
400
  }
436
401
  ],
437
402
  "consent": {
438
403
  "functional": true
439
404
  },
440
- "id": "1700000200000-gr0up-1",
405
+ "id": "ev-1700000200000",
441
406
  "trigger": "load",
442
407
  "entity": "page",
443
408
  "action": "view",
444
409
  "timestamp": 1700000200000,
445
410
  "timing": 3.14,
446
- "group": "gr0up",
447
- "count": 1,
448
- "version": {
449
- "source": "3.4.2",
450
- "tagging": 1
451
- },
452
411
  "source": {
453
- "type": "server",
454
- "id": "https://shop.example.com",
455
- "previous_id": ""
412
+ "type": "express",
413
+ "platform": "server"
456
414
  }
457
415
  },
458
416
  "mapping": {
@@ -464,7 +422,7 @@
464
422
  [
465
423
  "sendServer",
466
424
  "https://s2s.mparticle.com/v2/events",
467
- "{\"events\":[{\"event_type\":\"screen_view\",\"data\":{\"screen_name\":\"page view\",\"timestamp_unixtime_ms\":1700000200000,\"source_message_id\":\"1700000200000-gr0up-1\"}}],\"environment\":\"production\",\"user_identities\":{\"customer_id\":\"user-123\"},\"source_request_id\":\"1700000200000-gr0up-1\"}",
425
+ "{\"events\":[{\"event_type\":\"screen_view\",\"data\":{\"screen_name\":\"page view\",\"timestamp_unixtime_ms\":1700000200000,\"source_message_id\":\"ev-1700000200000\"}}],\"environment\":\"production\",\"user_identities\":{\"customer_id\":\"user-123\"},\"source_request_id\":\"ev-1700000200000\"}",
468
426
  {
469
427
  "headers": {
470
428
  "Authorization": "Basic a2V5OnNlY3JldA==",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@walkeros/server-destination-mparticle",
3
3
  "description": "mParticle 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",