@walkeros/server-destination-mparticle 4.8.2 → 4.8.3-next-1793115089237

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/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @walkeros/server-destination-mparticle
2
2
 
3
+ ## 4.8.3-next-1793115089237
4
+
5
+ ### Patch Changes
6
+
7
+ - 5313635: Step example descriptions name the `settings.userIdentities` mapping
8
+ their output depends on (`customer_id` from `user.id`, plus `email` from
9
+ `user.email` where shown), so each example says where the batch's
10
+ `user_identities` come from.
11
+ - 5313635: The package publishes a minimal example: the API key and secret, read
12
+ as the `MPARTICLE_API_KEY` and `MPARTICLE_API_SECRET` secrets. The docs page
13
+ renders the install line, the integrated code and the flow from it, and the
14
+ package test runs the same settings.
15
+ - Updated dependencies [34fd225]
16
+ - Updated dependencies [5313635]
17
+ - Updated dependencies [5313635]
18
+ - Updated dependencies [5313635]
19
+ - Updated dependencies [5313635]
20
+ - Updated dependencies [5313635]
21
+ - Updated dependencies [34fd225]
22
+ - Updated dependencies [5313635]
23
+ - @walkeros/core@4.8.3-next-1793115089237
24
+ - @walkeros/server-core@4.8.3-next-1793115089237
25
+
3
26
  ## 4.8.2
4
27
 
5
28
  ### Patch Changes
@@ -262,9 +285,6 @@
262
285
  and `event.context` remain required.
263
286
  - Each source self-registers via TypeScript module augmentation of `SourceMap`
264
287
  in `@walkeros/core`.
265
- - App-side coordination (`/workspaces/developer/app`) is a follow-up plan, not
266
- part of this release. Telemetry from v4 CLI/MCP will not validate against
267
- the existing app schema until that follow-up ships.
268
288
  - `Mapping.Rule.skip` is renamed to `Mapping.Rule.silent`. Customer flow.json
269
289
  configs using `skip: true` in mapping rules must rename to `silent: true`.
270
290
  Hard cut: no legacy alias, the field is gone.
package/dist/dev.d.mts CHANGED
@@ -148,10 +148,17 @@ declare namespace step {
148
148
  export { step_commercePurchase as commercePurchase, step_customEvent as customEvent, step_identityAndAttributes as identityAndAttributes, step_screenView as screenView, step_silentRule as silentRule };
149
149
  }
150
150
 
151
+ /**
152
+ * The settings mParticle needs to deliver: the API key and secret, read
153
+ * from the environment.
154
+ */
155
+ declare const minimal: Flow.MinimalExample;
156
+
151
157
  declare const index_env: typeof env;
158
+ declare const index_minimal: typeof minimal;
152
159
  declare const index_step: typeof step;
153
160
  declare namespace index {
154
- export { index_env as env, index_step as step };
161
+ export { index_env as env, index_minimal as minimal, index_step as step };
155
162
  }
156
163
 
157
164
  export { index as examples, index$1 as schemas };
package/dist/dev.d.ts CHANGED
@@ -148,10 +148,17 @@ declare namespace step {
148
148
  export { step_commercePurchase as commercePurchase, step_customEvent as customEvent, step_identityAndAttributes as identityAndAttributes, step_screenView as screenView, step_silentRule as silentRule };
149
149
  }
150
150
 
151
+ /**
152
+ * The settings mParticle needs to deliver: the API key and secret, read
153
+ * from the environment.
154
+ */
155
+ declare const minimal: Flow.MinimalExample;
156
+
151
157
  declare const index_env: typeof env;
158
+ declare const index_minimal: typeof minimal;
152
159
  declare const index_step: typeof step;
153
160
  declare namespace index {
154
- export { index_env as env, index_step as step };
161
+ export { index_env as env, index_minimal as minimal, index_step as step };
155
162
  }
156
163
 
157
164
  export { index as examples, index$1 as schemas };
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:()=>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()}).strict(),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()=>({data:{}})},z=["sendServer"],P={};s(P,{commercePurchase:()=>x,customEvent:()=>E,identityAndAttributes:()=>T,screenView:()=>q,silentRule:()=>j});var k=require("@walkeros/core"),O="https://s2s.mparticle.com/v2/events",A={headers:{Authorization:"Basic a2V5OnNlY3JldA==","Content-Type":"application/json"}},E={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]]},q={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]]},x={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",value: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.value"}}}}}},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.createEvent)({name:"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]]},j={public:!1,description:"A rule with silent: true sends no request to mParticle.",in:(0,k.getEvent)("page view",{timestamp:170000099e4}),mapping:{silent:!0},out:[]};//# sourceMappingURL=dev.js.map
1
+ "use strict";var e,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,n=(e,r)=>{for(var i in r)t(e,i,{get:r[i],enumerable:!0})},o={};n(o,{examples:()=>f,schemas:()=>a}),module.exports=(e=o,((e,n,o,a)=>{if(n&&"object"==typeof n||"function"==typeof n)for(let c of i(n))s.call(e,c)||c===o||t(e,c,{get:()=>n[c],enumerable:!(a=r(n,c))||a.enumerable});return e})(t({},"__esModule",{value:!0}),e));var a={};n(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()}).strict(),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={};n(f,{env:()=>w,minimal:()=>M,step:()=>z});var w={};n(w,{push:()=>S,simulation:()=>P});var S={sendServer:async()=>({data:{}})},P=["sendServer"],z={};n(z,{commercePurchase:()=>O,customEvent:()=>I,identityAndAttributes:()=>q,screenView:()=>T,silentRule:()=>x});var k=require("@walkeros/core"),A="https://s2s.mparticle.com/v2/events",E={headers:{Authorization:"Basic a2V5OnNlY3JldA==","Content-Type":"application/json"}},I={title:"Custom event",description:"A walker event is sent to mParticle as a custom_event; with settings.userIdentities mapping customer_id to user.id, the batch carries the user id.",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",A,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"}),E]]},T={title:"Screen view",description:"A page view is mapped to an mParticle screen_view event with the event name as the screen name. The user identities come from settings.userIdentities (customer_id: user.id).",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",A,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"}),E]]},O={title:"Commerce purchase",description:"A completed order becomes an mParticle commerce_event with a purchase product_action block. The user identities come from settings.userIdentities (customer_id: user.id).",in:(0,k.getEvent)("order complete",{id:"ev-1700000300000",timestamp:17000003e5,data:{id:"ORD-300",value: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.value"}}}}}},out:[["sendServer",A,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"}),E]]},q={title:"User identities",description:"A form submission sends a custom_event whose batch carries user_identities resolved from settings.userIdentities (customer_id: user.id, email: user.email).",in:(0,k.createEvent)({name:"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",A,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"}),E]]},x={public:!1,description:"A rule with silent: true sends no request to mParticle.",in:(0,k.getEvent)("page view",{timestamp:170000099e4}),mapping:{silent:!0},out:[]},M={settings:{apiKey:"key",apiSecret:"secret"},secrets:{apiKey:"MPARTICLE_API_KEY",apiSecret:"MPARTICLE_API_SECRET"}};//# 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\n .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 .strict();\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 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 { createEvent, 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', value: 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.value',\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: createEvent({\n name: '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\n/** A silent rule sends nothing to mParticle. */\nexport const silentRule: Flow.StepExample = {\n public: false,\n description: 'A rule with silent: true sends no request to mParticle.',\n in: getEvent('page view', { timestamp: 1700000990000 }),\n mapping: { silent: true },\n out: [],\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,cAC3B,OAAO;AAAA,EACN,QAAQ,cACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,WAAW,cACR,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,gBAAgB,cACb,OAAO,cAAE,OAAO,GAAG,cAAE,QAAQ,CAAC,EAC9B;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,gBAAgB,cACb,QAAQ,EACR;AAA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AAA,IACN,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;AAGO,IAAM,aAA+B;AAAA,EAC1C,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,QAAI,sBAAS,aAAa,EAAE,WAAW,YAAc,CAAC;AAAA,EACtD,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,KAAK,CAAC;AACR;","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","../src/examples/minimal.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\n .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 .strict();\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';\nexport { minimal } from './minimal';\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 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 { createEvent, 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 settings.userIdentities mapping customer_id to user.id, the batch carries the user id.',\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. The user identities come from settings.userIdentities (customer_id: user.id).',\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. The user identities come from settings.userIdentities (customer_id: user.id).',\n in: getEvent('order complete', {\n id: 'ev-1700000300000',\n timestamp: 1700000300000,\n data: { id: 'ORD-300', value: 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.value',\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 settings.userIdentities (customer_id: user.id, email: user.email).',\n in: createEvent({\n name: '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\n/** A silent rule sends nothing to mParticle. */\nexport const silentRule: Flow.StepExample = {\n public: false,\n description: 'A rule with silent: true sends no request to mParticle.',\n in: getEvent('page view', { timestamp: 1700000990000 }),\n mapping: { silent: true },\n out: [],\n};\n","import type { Flow } from '@walkeros/core';\n\n/**\n * The settings mParticle needs to deliver: the API key and secret, read\n * from the environment.\n */\nexport const minimal: Flow.MinimalExample = {\n settings: { apiKey: 'key', apiSecret: 'secret' },\n secrets: { apiKey: 'MPARTICLE_API_KEY', apiSecret: 'MPARTICLE_API_SECRET' },\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,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AA,MACD;AAAA,IACF;AAAA,EACF;AACF;AAGO,IAAM,aAA+B;AAAA,EAC1C,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,QAAI,sBAAS,aAAa,EAAE,WAAW,YAAc,CAAC;AAAA,EACtD,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,KAAK,CAAC;AACR;;;AC5OO,IAAM,UAA+B;AAAA,EAC1C,UAAU,EAAE,QAAQ,OAAO,WAAW,SAAS;AAAA,EAC/C,SAAS,EAAE,QAAQ,qBAAqB,WAAW,uBAAuB;AAC5E;","names":["import_dev","import_dev","import_dev"]}
package/dist/dev.mjs CHANGED
@@ -1 +1 @@
1
- import{createRequire as e}from"module";e(import.meta.url);var t=Object.defineProperty,r=(e,r)=>{for(var i in r)t(e,i,{get:r[i],enumerable:!0})},i={};r(i,{CustomEventTypeSchema:()=>u,EnvironmentSchema:()=>c,EventTypeSchema:()=>m,MappingSchema:()=>v,PodSchema:()=>a,SettingsSchema:()=>p,mapping:()=>_,settings:()=>l});import{zodToSchema as s}from"@walkeros/core/dev";import{z as n}from"@walkeros/core/dev";import{z as o}from"@walkeros/core/dev";var a=o.enum(["us1","us2","eu1","au1"]),c=o.enum(["production","development"]),m=o.enum(["custom_event","screen_view","commerce_event"]),u=o.enum(["navigation","location","search","transaction","user_content","user_preference","social","media","attribution","other"]),p=n.object({apiKey:n.string().min(1).describe("mParticle input feed API key from the mParticle dashboard (Setup > Inputs > Feeds)."),apiSecret:n.string().min(1).describe("mParticle input feed API secret paired with apiKey. Used for HTTP Basic auth."),pod:a.describe("mParticle data pod selecting the regional endpoint. Default: 'us1'.").optional(),environment:c.describe("Environment the batch targets. Default: 'production'.").optional(),userIdentities:n.record(n.string(),n.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:n.unknown().describe("Mapping value that resolves to the user_attributes object placed on the batch.").optional(),consent:n.record(n.string(),n.unknown()).describe("Static consent_state envelope forwarded verbatim on the batch. See mParticle consent_state docs.").optional(),ip:n.unknown().describe("Mapping value resolving to the client IP for the batch.").optional(),sourceRequestId:n.unknown().describe("Mapping value resolving to the source_request_id for the batch. Falls back to event.id when unset.").optional()}).strict();import{z as d}from"@walkeros/core/dev";var v=d.object({eventType:m.describe("Per-event mParticle event type. Default: 'custom_event'.").optional(),customEventType:u.describe("Custom event type category for 'custom_event'. Default: 'other'.").optional(),commerce:d.unknown().describe("Mapping value resolving to the commerce fields (product_action, currency_code, products, ...) for a commerce_event.").optional(),userIdentities:d.record(d.string(),d.unknown()).describe("Per-event override mapping for user_identities. Merged over settings.userIdentities.").optional(),userAttributes:d.unknown().describe("Per-event override mapping for user_attributes.").optional()}),l=s(p),_=s(v),h={};r(h,{env:()=>g,step:()=>f});var g={};r(g,{push:()=>b,simulation:()=>y});var b={sendServer:async()=>({data:{}})},y=["sendServer"],f={};r(f,{commercePurchase:()=>O,customEvent:()=>A,identityAndAttributes:()=>T,screenView:()=>x,silentRule:()=>E});import{createEvent as w,getEvent as S}from"@walkeros/core";var k="https://s2s.mparticle.com/v2/events",P={headers:{Authorization:"Basic a2V5OnNlY3JldA==","Content-Type":"application/json"}},A={title:"Custom event",description:"A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.",in:S("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",k,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"}),P]]},x={title:"Screen view",description:"A page view is mapped to an mParticle screen_view event with the event name as the screen name.",in:S("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",k,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"}),P]]},O={title:"Commerce purchase",description:"A completed order becomes an mParticle commerce_event with a purchase product_action block.",in:S("order complete",{id:"ev-1700000300000",timestamp:17000003e5,data:{id:"ORD-300",value: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.value"}}}}}},out:[["sendServer",k,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"}),P]]},T={title:"User identities",description:"A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.",in:w({name:"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",k,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"}),P]]},E={public:!1,description:"A rule with silent: true sends no request to mParticle.",in:S("page view",{timestamp:170000099e4}),mapping:{silent:!0},out:[]};export{h as examples,i as schemas};//# sourceMappingURL=dev.mjs.map
1
+ import{createRequire as e}from"module";e(import.meta.url);var t=Object.defineProperty,i=(e,i)=>{for(var r in i)t(e,r,{get:i[r],enumerable:!0})},r={};i(r,{CustomEventTypeSchema:()=>u,EnvironmentSchema:()=>c,EventTypeSchema:()=>m,MappingSchema:()=>v,PodSchema:()=>a,SettingsSchema:()=>p,mapping:()=>_,settings:()=>l});import{zodToSchema as s}from"@walkeros/core/dev";import{z as n}from"@walkeros/core/dev";import{z as o}from"@walkeros/core/dev";var a=o.enum(["us1","us2","eu1","au1"]),c=o.enum(["production","development"]),m=o.enum(["custom_event","screen_view","commerce_event"]),u=o.enum(["navigation","location","search","transaction","user_content","user_preference","social","media","attribution","other"]),p=n.object({apiKey:n.string().min(1).describe("mParticle input feed API key from the mParticle dashboard (Setup > Inputs > Feeds)."),apiSecret:n.string().min(1).describe("mParticle input feed API secret paired with apiKey. Used for HTTP Basic auth."),pod:a.describe("mParticle data pod selecting the regional endpoint. Default: 'us1'.").optional(),environment:c.describe("Environment the batch targets. Default: 'production'.").optional(),userIdentities:n.record(n.string(),n.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:n.unknown().describe("Mapping value that resolves to the user_attributes object placed on the batch.").optional(),consent:n.record(n.string(),n.unknown()).describe("Static consent_state envelope forwarded verbatim on the batch. See mParticle consent_state docs.").optional(),ip:n.unknown().describe("Mapping value resolving to the client IP for the batch.").optional(),sourceRequestId:n.unknown().describe("Mapping value resolving to the source_request_id for the batch. Falls back to event.id when unset.").optional()}).strict();import{z as d}from"@walkeros/core/dev";var v=d.object({eventType:m.describe("Per-event mParticle event type. Default: 'custom_event'.").optional(),customEventType:u.describe("Custom event type category for 'custom_event'. Default: 'other'.").optional(),commerce:d.unknown().describe("Mapping value resolving to the commerce fields (product_action, currency_code, products, ...) for a commerce_event.").optional(),userIdentities:d.record(d.string(),d.unknown()).describe("Per-event override mapping for user_identities. Merged over settings.userIdentities.").optional(),userAttributes:d.unknown().describe("Per-event override mapping for user_attributes.").optional()}),l=s(p),_=s(v),h={};i(h,{env:()=>g,minimal:()=>C,step:()=>f});var g={};i(g,{push:()=>b,simulation:()=>y});var b={sendServer:async()=>({data:{}})},y=["sendServer"],f={};i(f,{commercePurchase:()=>T,customEvent:()=>A,identityAndAttributes:()=>E,screenView:()=>I,silentRule:()=>x});import{createEvent as w,getEvent as S}from"@walkeros/core";var P="https://s2s.mparticle.com/v2/events",k={headers:{Authorization:"Basic a2V5OnNlY3JldA==","Content-Type":"application/json"}},A={title:"Custom event",description:"A walker event is sent to mParticle as a custom_event; with settings.userIdentities mapping customer_id to user.id, the batch carries the user id.",in:S("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",P,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"}),k]]},I={title:"Screen view",description:"A page view is mapped to an mParticle screen_view event with the event name as the screen name. The user identities come from settings.userIdentities (customer_id: user.id).",in:S("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",P,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"}),k]]},T={title:"Commerce purchase",description:"A completed order becomes an mParticle commerce_event with a purchase product_action block. The user identities come from settings.userIdentities (customer_id: user.id).",in:S("order complete",{id:"ev-1700000300000",timestamp:17000003e5,data:{id:"ORD-300",value: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.value"}}}}}},out:[["sendServer",P,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"}),k]]},E={title:"User identities",description:"A form submission sends a custom_event whose batch carries user_identities resolved from settings.userIdentities (customer_id: user.id, email: user.email).",in:w({name:"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",P,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"}),k]]},x={public:!1,description:"A rule with silent: true sends no request to mParticle.",in:S("page view",{timestamp:170000099e4}),mapping:{silent:!0},out:[]},C={settings:{apiKey:"key",apiSecret:"secret"},secrets:{apiKey:"MPARTICLE_API_KEY",apiSecret:"MPARTICLE_API_SECRET"}};export{h 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\n .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 .strict();\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 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 { createEvent, 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', value: 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.value',\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: createEvent({\n name: '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\n/** A silent rule sends nothing to mParticle. */\nexport const silentRule: Flow.StepExample = {\n public: false,\n description: 'A rule with silent: true sends no request to mParticle.',\n in: getEvent('page view', { timestamp: 1700000990000 }),\n mapping: { silent: true },\n out: [],\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,GAC3B,OAAO;AAAA,EACN,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,gBAA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mBAAmB;AAAA,MACrB,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;AAMO,IAAM,wBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,aACE;AAAA,EACF,IAAI,YAAY;AAAA,IACd,MAAM;AAAA,IACN,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;AAGO,IAAM,aAA+B;AAAA,EAC1C,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,IAAI,SAAS,aAAa,EAAE,WAAW,YAAc,CAAC;AAAA,EACtD,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,KAAK,CAAC;AACR;","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","../src/examples/minimal.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\n .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 .strict();\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';\nexport { minimal } from './minimal';\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 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 { createEvent, 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 settings.userIdentities mapping customer_id to user.id, the batch carries the user id.',\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. The user identities come from settings.userIdentities (customer_id: user.id).',\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. The user identities come from settings.userIdentities (customer_id: user.id).',\n in: getEvent('order complete', {\n id: 'ev-1700000300000',\n timestamp: 1700000300000,\n data: { id: 'ORD-300', value: 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.value',\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 settings.userIdentities (customer_id: user.id, email: user.email).',\n in: createEvent({\n name: '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\n/** A silent rule sends nothing to mParticle. */\nexport const silentRule: Flow.StepExample = {\n public: false,\n description: 'A rule with silent: true sends no request to mParticle.',\n in: getEvent('page view', { timestamp: 1700000990000 }),\n mapping: { silent: true },\n out: [],\n};\n","import type { Flow } from '@walkeros/core';\n\n/**\n * The settings mParticle needs to deliver: the API key and secret, read\n * from the environment.\n */\nexport const minimal: Flow.MinimalExample = {\n settings: { apiKey: 'key', apiSecret: 'secret' },\n secrets: { apiKey: 'MPARTICLE_API_KEY', apiSecret: 'MPARTICLE_API_SECRET' },\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,CAA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AiB;AAAA,UACf,aAAa;AAAA,UACb,OAAO;AAAA,QACT;AAAA,QACA,mBAAmB;AAAA,MACrB,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;AAGO,IAAM,aAA+B;AAAA,EAC1C,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,IAAI,SAAS,aAAa,EAAE,WAAW,YAAc,CAAC;AAAA,EACtD,SAAS,EAAE,QAAQ,KAAK;AAAA,EACxB,KAAK,CAAC;AACR;;;AC5OO,IAAM,UAA+B;AAAA,EAC1C,UAAU,EAAE,QAAQ,OAAO,WAAW,SAAS;AAAA,EAC/C,SAAS,EAAE,QAAQ,qBAAqB,WAAW,uBAAuB;AAC5E;","names":["z","z","z","z"]}
@@ -52,4 +52,10 @@ declare namespace step {
52
52
  export { step_commercePurchase as commercePurchase, step_customEvent as customEvent, step_identityAndAttributes as identityAndAttributes, step_screenView as screenView, step_silentRule as silentRule };
53
53
  }
54
54
 
55
- export { env, step };
55
+ /**
56
+ * The settings mParticle needs to deliver: the API key and secret, read
57
+ * from the environment.
58
+ */
59
+ declare const minimal: Flow.MinimalExample;
60
+
61
+ export { env, minimal, step };
@@ -52,4 +52,10 @@ declare namespace step {
52
52
  export { step_commercePurchase as commercePurchase, step_customEvent as customEvent, step_identityAndAttributes as identityAndAttributes, step_screenView as screenView, step_silentRule as silentRule };
53
53
  }
54
54
 
55
- export { env, step };
55
+ /**
56
+ * The settings mParticle needs to deliver: the API key and secret, read
57
+ * from the environment.
58
+ */
59
+ declare const minimal: Flow.MinimalExample;
60
+
61
+ export { env, minimal, step };
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var examples_exports = {};
22
22
  __export(examples_exports, {
23
23
  env: () => env_exports,
24
+ minimal: () => minimal,
24
25
  step: () => step_exports
25
26
  });
26
27
  module.exports = __toCommonJS(examples_exports);
@@ -61,7 +62,7 @@ var OPTIONS = {
61
62
  };
62
63
  var customEvent = {
63
64
  title: "Custom event",
64
- description: "A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.",
65
+ description: "A walker event is sent to mParticle as a custom_event; with settings.userIdentities mapping customer_id to user.id, the batch carries the user id.",
65
66
  in: (0, import_core.getEvent)("product view", {
66
67
  id: "ev-1700000100000",
67
68
  timestamp: 17000001e5,
@@ -98,7 +99,7 @@ var customEvent = {
98
99
  };
99
100
  var screenView = {
100
101
  title: "Screen view",
101
- description: "A page view is mapped to an mParticle screen_view event with the event name as the screen name.",
102
+ description: "A page view is mapped to an mParticle screen_view event with the event name as the screen name. The user identities come from settings.userIdentities (customer_id: user.id).",
102
103
  in: (0, import_core.getEvent)("page view", {
103
104
  id: "ev-1700000200000",
104
105
  timestamp: 17000002e5,
@@ -136,7 +137,7 @@ var screenView = {
136
137
  };
137
138
  var commercePurchase = {
138
139
  title: "Commerce purchase",
139
- description: "A completed order becomes an mParticle commerce_event with a purchase product_action block.",
140
+ description: "A completed order becomes an mParticle commerce_event with a purchase product_action block. The user identities come from settings.userIdentities (customer_id: user.id).",
140
141
  in: (0, import_core.getEvent)("order complete", {
141
142
  id: "ev-1700000300000",
142
143
  timestamp: 17000003e5,
@@ -193,7 +194,7 @@ var commercePurchase = {
193
194
  };
194
195
  var identityAndAttributes = {
195
196
  title: "User identities",
196
- description: "A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.",
197
+ description: "A form submission sends a custom_event whose batch carries user_identities resolved from settings.userIdentities (customer_id: user.id, email: user.email).",
197
198
  in: (0, import_core.createEvent)({
198
199
  name: "form submit",
199
200
  id: "ev-1700000400000",
@@ -240,8 +241,15 @@ var silentRule = {
240
241
  mapping: { silent: true },
241
242
  out: []
242
243
  };
244
+
245
+ // src/examples/minimal.ts
246
+ var minimal = {
247
+ settings: { apiKey: "key", apiSecret: "secret" },
248
+ secrets: { apiKey: "MPARTICLE_API_KEY", apiSecret: "MPARTICLE_API_SECRET" }
249
+ };
243
250
  // Annotate the CommonJS export names for ESM import in node:
244
251
  0 && (module.exports = {
245
252
  env,
253
+ minimal,
246
254
  step
247
255
  });
@@ -40,7 +40,7 @@ var OPTIONS = {
40
40
  };
41
41
  var customEvent = {
42
42
  title: "Custom event",
43
- description: "A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.",
43
+ description: "A walker event is sent to mParticle as a custom_event; with settings.userIdentities mapping customer_id to user.id, the batch carries the user id.",
44
44
  in: getEvent("product view", {
45
45
  id: "ev-1700000100000",
46
46
  timestamp: 17000001e5,
@@ -77,7 +77,7 @@ var customEvent = {
77
77
  };
78
78
  var screenView = {
79
79
  title: "Screen view",
80
- description: "A page view is mapped to an mParticle screen_view event with the event name as the screen name.",
80
+ description: "A page view is mapped to an mParticle screen_view event with the event name as the screen name. The user identities come from settings.userIdentities (customer_id: user.id).",
81
81
  in: getEvent("page view", {
82
82
  id: "ev-1700000200000",
83
83
  timestamp: 17000002e5,
@@ -115,7 +115,7 @@ var screenView = {
115
115
  };
116
116
  var commercePurchase = {
117
117
  title: "Commerce purchase",
118
- description: "A completed order becomes an mParticle commerce_event with a purchase product_action block.",
118
+ description: "A completed order becomes an mParticle commerce_event with a purchase product_action block. The user identities come from settings.userIdentities (customer_id: user.id).",
119
119
  in: getEvent("order complete", {
120
120
  id: "ev-1700000300000",
121
121
  timestamp: 17000003e5,
@@ -172,7 +172,7 @@ var commercePurchase = {
172
172
  };
173
173
  var identityAndAttributes = {
174
174
  title: "User identities",
175
- description: "A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.",
175
+ description: "A form submission sends a custom_event whose batch carries user_identities resolved from settings.userIdentities (customer_id: user.id, email: user.email).",
176
176
  in: createEvent({
177
177
  name: "form submit",
178
178
  id: "ev-1700000400000",
@@ -219,7 +219,14 @@ var silentRule = {
219
219
  mapping: { silent: true },
220
220
  out: []
221
221
  };
222
+
223
+ // src/examples/minimal.ts
224
+ var minimal = {
225
+ settings: { apiKey: "key", apiSecret: "secret" },
226
+ secrets: { apiKey: "MPARTICLE_API_KEY", apiSecret: "MPARTICLE_API_SECRET" }
227
+ };
222
228
  export {
223
229
  env_exports as env,
230
+ minimal,
224
231
  step_exports as step
225
232
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$meta": {
3
3
  "package": "@walkeros/server-destination-mparticle",
4
- "version": "4.8.2",
4
+ "version": "4.8.3-next-1793115089237",
5
5
  "type": "destination",
6
6
  "platform": [
7
7
  "server"
@@ -133,10 +133,20 @@
133
133
  "sendServer"
134
134
  ]
135
135
  },
136
+ "minimal": {
137
+ "settings": {
138
+ "apiKey": "key",
139
+ "apiSecret": "secret"
140
+ },
141
+ "secrets": {
142
+ "apiKey": "MPARTICLE_API_KEY",
143
+ "apiSecret": "MPARTICLE_API_SECRET"
144
+ }
145
+ },
136
146
  "step": {
137
147
  "commercePurchase": {
138
148
  "title": "Commerce purchase",
139
- "description": "A completed order becomes an mParticle commerce_event with a purchase product_action block.",
149
+ "description": "A completed order becomes an mParticle commerce_event with a purchase product_action block. The user identities come from settings.userIdentities (customer_id: user.id).",
140
150
  "in": {
141
151
  "name": "order complete",
142
152
  "data": {
@@ -258,7 +268,7 @@
258
268
  },
259
269
  "customEvent": {
260
270
  "title": "Custom event",
261
- "description": "A walker event is sent to mParticle as a custom_event with user identities resolved from destination settings.",
271
+ "description": "A walker event is sent to mParticle as a custom_event; with settings.userIdentities mapping customer_id to user.id, the batch carries the user id.",
262
272
  "in": {
263
273
  "name": "product view",
264
274
  "data": {
@@ -314,7 +324,7 @@
314
324
  },
315
325
  "identityAndAttributes": {
316
326
  "title": "User identities",
317
- "description": "A form submission sends a custom_event whose batch carries user_identities resolved from destination settings.",
327
+ "description": "A form submission sends a custom_event whose batch carries user_identities resolved from settings.userIdentities (customer_id: user.id, email: user.email).",
318
328
  "in": {
319
329
  "name": "form submit",
320
330
  "data": {
@@ -376,7 +386,7 @@
376
386
  },
377
387
  "screenView": {
378
388
  "title": "Screen view",
379
- "description": "A page view is mapped to an mParticle screen_view event with the event name as the screen name.",
389
+ "description": "A page view is mapped to an mParticle screen_view event with the event name as the screen name. The user identities come from settings.userIdentities (customer_id: user.id).",
380
390
  "in": {
381
391
  "name": "page view",
382
392
  "data": {
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": "4.8.2",
4
+ "version": "4.8.3-next-1793115089237",
5
5
  "license": "MIT",
6
6
  "exports": {
7
7
  ".": {
@@ -35,11 +35,11 @@
35
35
  "update": "npx npm-check-updates -u && npm update"
36
36
  },
37
37
  "dependencies": {
38
- "@walkeros/core": "4.8.2",
39
- "@walkeros/server-core": "4.8.2"
38
+ "@walkeros/core": "4.8.3-next-1793115089237",
39
+ "@walkeros/server-core": "4.8.3-next-1793115089237"
40
40
  },
41
41
  "devDependencies": {
42
- "@walkeros/collector": "4.8.2"
42
+ "@walkeros/collector": "4.8.3-next-1793115089237"
43
43
  },
44
44
  "repository": {
45
45
  "url": "git+https://github.com/elbwalker/walkerOS.git",