@walkeros/server-destination-amplitude 3.3.0-next-1776098542393

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.ts ADDED
@@ -0,0 +1,287 @@
1
+ import * as _walkeros_core_dev from '@walkeros/core/dev';
2
+ import { z } from '@walkeros/core/dev';
3
+ import { Mapping as Mapping$1, Flow } from '@walkeros/core';
4
+ import { DestinationServer } from '@walkeros/server-core';
5
+
6
+ declare const SettingsSchema: z.ZodObject<{
7
+ apiKey: z.ZodString;
8
+ serverZone: z.ZodOptional<z.ZodEnum<{
9
+ US: "US";
10
+ EU: "EU";
11
+ }>>;
12
+ flushIntervalMillis: z.ZodOptional<z.ZodNumber>;
13
+ flushQueueSize: z.ZodOptional<z.ZodNumber>;
14
+ flushMaxRetries: z.ZodOptional<z.ZodNumber>;
15
+ useBatch: z.ZodOptional<z.ZodBoolean>;
16
+ minIdLength: z.ZodOptional<z.ZodNumber>;
17
+ serverUrl: z.ZodOptional<z.ZodString>;
18
+ optOut: z.ZodOptional<z.ZodBoolean>;
19
+ enableRequestBodyCompression: z.ZodOptional<z.ZodBoolean>;
20
+ identify: z.ZodOptional<z.ZodUnknown>;
21
+ eventOptions: z.ZodOptional<z.ZodUnknown>;
22
+ include: z.ZodOptional<z.ZodArray<z.ZodString>>;
23
+ }, z.core.$strip>;
24
+ type Settings$1 = z.infer<typeof SettingsSchema>;
25
+
26
+ declare const MappingSchema: z.ZodObject<{
27
+ identify: z.ZodOptional<z.ZodUnknown>;
28
+ revenue: z.ZodOptional<z.ZodUnknown>;
29
+ group: z.ZodOptional<z.ZodUnknown>;
30
+ groupIdentify: z.ZodOptional<z.ZodUnknown>;
31
+ eventOptions: z.ZodOptional<z.ZodUnknown>;
32
+ include: z.ZodOptional<z.ZodArray<z.ZodString>>;
33
+ }, z.core.$strip>;
34
+ type Mapping = z.infer<typeof MappingSchema>;
35
+
36
+ declare const settings: _walkeros_core_dev.JSONSchema;
37
+ declare const mapping: _walkeros_core_dev.JSONSchema;
38
+
39
+ type index$1_Mapping = Mapping;
40
+ declare const index$1_MappingSchema: typeof MappingSchema;
41
+ declare const index$1_SettingsSchema: typeof SettingsSchema;
42
+ declare const index$1_mapping: typeof mapping;
43
+ declare const index$1_settings: typeof settings;
44
+ declare namespace index$1 {
45
+ export { type index$1_Mapping as Mapping, index$1_MappingSchema as MappingSchema, type Settings$1 as Settings, index$1_SettingsSchema as SettingsSchema, index$1_mapping as mapping, index$1_settings as settings };
46
+ }
47
+
48
+ /**
49
+ * Amplitude SDK surface -- the subset of @amplitude/analytics-node the
50
+ * destination actually uses. Tests provide a mock via env.amplitude;
51
+ * production uses the real SDK import.
52
+ *
53
+ * Key difference from web: no setUserId/setDeviceId/setSessionId.
54
+ * Identity is per-event via EventOptions on every SDK call.
55
+ */
56
+ interface AmplitudeSDK {
57
+ init: (apiKey: string, options?: Record<string, unknown>) => {
58
+ promise: Promise<void>;
59
+ };
60
+ track: (eventType: string, eventProperties?: Record<string, unknown>, eventOptions?: EventOptions) => void;
61
+ identify: (identify: IdentifyInstance, eventOptions?: EventOptions) => void;
62
+ revenue: (revenue: RevenueInstance, eventOptions?: EventOptions) => void;
63
+ setGroup: (groupType: string, groupName: string | string[], eventOptions?: EventOptions) => void;
64
+ groupIdentify: (groupType: string, groupName: string, identify: IdentifyInstance, eventOptions?: EventOptions) => void;
65
+ setOptOut: (optOut: boolean) => void;
66
+ flush: () => {
67
+ promise: Promise<void>;
68
+ };
69
+ Identify: new () => IdentifyInstance;
70
+ Revenue: new () => RevenueInstance;
71
+ }
72
+ /**
73
+ * Per-event identity and metadata fields. Passed to every SDK call.
74
+ * Maps directly to Amplitude's EventOptions type from the Node SDK.
75
+ */
76
+ interface EventOptions {
77
+ user_id?: string;
78
+ device_id?: string;
79
+ session_id?: number;
80
+ time?: number;
81
+ insert_id?: string;
82
+ ip?: string;
83
+ city?: string;
84
+ country?: string;
85
+ region?: string;
86
+ language?: string;
87
+ platform?: string;
88
+ os_name?: string;
89
+ os_version?: string;
90
+ device_brand?: string;
91
+ device_manufacturer?: string;
92
+ device_model?: string;
93
+ app_version?: string;
94
+ carrier?: string;
95
+ user_agent?: string;
96
+ groups?: Record<string, unknown>;
97
+ plan?: Record<string, unknown>;
98
+ ingestion_metadata?: Record<string, unknown>;
99
+ partner_id?: string;
100
+ extra?: Record<string, unknown>;
101
+ }
102
+ /** Chainable Identify -- mirrors @amplitude/analytics-node Identify class. */
103
+ interface IdentifyInstance {
104
+ set: (property: string, value: unknown) => IdentifyInstance;
105
+ setOnce: (property: string, value: unknown) => IdentifyInstance;
106
+ add: (property: string, value: number) => IdentifyInstance;
107
+ append: (property: string, value: unknown) => IdentifyInstance;
108
+ prepend: (property: string, value: unknown) => IdentifyInstance;
109
+ preInsert: (property: string, value: unknown) => IdentifyInstance;
110
+ postInsert: (property: string, value: unknown) => IdentifyInstance;
111
+ remove: (property: string, value: unknown) => IdentifyInstance;
112
+ unset: (property: string) => IdentifyInstance;
113
+ clearAll: () => IdentifyInstance;
114
+ }
115
+ /** Chainable Revenue -- mirrors @amplitude/analytics-node Revenue class. */
116
+ interface RevenueInstance {
117
+ setProductId: (id: string) => RevenueInstance;
118
+ setPrice: (price: number) => RevenueInstance;
119
+ setQuantity: (quantity: number) => RevenueInstance;
120
+ setRevenueType: (type: string) => RevenueInstance;
121
+ setCurrency: (currency: string) => RevenueInstance;
122
+ setRevenue: (revenue: number) => RevenueInstance;
123
+ setReceipt: (receipt: string) => RevenueInstance;
124
+ setReceiptSig: (signature: string) => RevenueInstance;
125
+ setEventProperties: (properties: Record<string, unknown>) => RevenueInstance;
126
+ }
127
+ /**
128
+ * Destination-level settings. apiKey is required; all other fields
129
+ * are optional and passed through to the Amplitude Node SDK init().
130
+ */
131
+ interface Settings {
132
+ apiKey: string;
133
+ serverZone?: 'US' | 'EU';
134
+ flushIntervalMillis?: number;
135
+ flushQueueSize?: number;
136
+ flushMaxRetries?: number;
137
+ useBatch?: boolean;
138
+ minIdLength?: number;
139
+ serverUrl?: string;
140
+ logLevel?: number;
141
+ optOut?: boolean;
142
+ offline?: boolean;
143
+ enableRequestBodyCompression?: boolean;
144
+ plan?: Record<string, unknown>;
145
+ ingestionMetadata?: Record<string, unknown>;
146
+ /** walkerOS mapping value for per-event identity resolution. */
147
+ identify?: Mapping$1.Value;
148
+ /** walkerOS mapping value for per-event EventOptions (time, insert_id, ip, etc). */
149
+ eventOptions?: Mapping$1.Value;
150
+ /** Sections to include as event_properties (e.g., ['data', 'globals']). */
151
+ include?: string[];
152
+ }
153
+ /**
154
+ * Env -- optional SDK override. Production leaves this undefined and the
155
+ * destination falls back to the real @amplitude/analytics-node import.
156
+ * Tests provide a mock via env.amplitude.
157
+ */
158
+ interface Env extends DestinationServer.Env {
159
+ amplitude?: AmplitudeSDK;
160
+ }
161
+
162
+ declare const init: Env | undefined;
163
+ declare const push: Env;
164
+ declare const simulation: string[];
165
+
166
+ declare const env_init: typeof init;
167
+ declare const env_push: typeof push;
168
+ declare const env_simulation: typeof simulation;
169
+ declare namespace env {
170
+ export { env_init as init, env_push as push, env_simulation as simulation };
171
+ }
172
+
173
+ /**
174
+ * Extended step example type for Amplitude server destination.
175
+ * Settings and configInclude are read by the test runner and merged
176
+ * into the base destination configuration.
177
+ */
178
+ type AmplitudeStepExample = Flow.StepExample & {
179
+ settings?: Partial<Settings>;
180
+ configInclude?: string[];
181
+ };
182
+ /**
183
+ * Default event forwarding -- every walkerOS event becomes
184
+ * amplitude.track(event.name, event_properties). With no mapping and
185
+ * no destination-level include, event_properties is `{}`.
186
+ */
187
+ declare const defaultEventForwarding: AmplitudeStepExample;
188
+ /**
189
+ * Wildcard ignore -- walkerOS's standard way to drop events. The rule
190
+ * matches but does nothing. The destination fires zero SDK calls.
191
+ */
192
+ declare const wildcardIgnored: AmplitudeStepExample;
193
+ /**
194
+ * Destination-level settings.include flattens the walkerOS `data` section
195
+ * into prefixed event_properties on every push.
196
+ */
197
+ declare const destinationLevelInclude: AmplitudeStepExample;
198
+ /**
199
+ * Destination-level settings.identify resolves per-event identity.
200
+ * Unlike the web destination (which uses setUserId/setDeviceId/setSessionId),
201
+ * server-side identity goes into EventOptions passed to every SDK call.
202
+ *
203
+ * user.session is 's3ss10n' (string). The destination deterministically
204
+ * hashes non-numeric session strings via djb2.
205
+ * djb2('s3ss10n') = 394324160.
206
+ */
207
+ declare const destinationLevelIdentify: AmplitudeStepExample;
208
+ /**
209
+ * Per-event identify with the full operation vocabulary -- this is the
210
+ * "user login" pattern: set user_id, enrich user properties. `skip: true`
211
+ * suppresses the default amplitude.track() call because we're running
212
+ * identity side effects only.
213
+ *
214
+ * Server-side, user_id is passed via EventOptions on identify().
215
+ */
216
+ declare const userLoginIdentify: AmplitudeStepExample;
217
+ /**
218
+ * Single-product revenue -- resolves `settings.revenue` to one object and
219
+ * fires one amplitude.revenue() call. Note the `{ key: "data.currency",
220
+ * value: "EUR" }` fallback syntax: try data.currency, default to "EUR".
221
+ *
222
+ * The custom event has no data.currency, so the fallback fires.
223
+ * `skip: true` suppresses the default track().
224
+ */
225
+ declare const subscriptionRenewRevenue: AmplitudeStepExample;
226
+ /**
227
+ * Multi-product order -- the canonical Amplitude ecommerce pattern.
228
+ * `revenue.loop: ["nested", { map: ... }]` iterates event.nested and
229
+ * resolves one revenue item per entry. Each becomes a separate
230
+ * amplitude.revenue() call. The order-level track() fires once with
231
+ * include-based event_properties.
232
+ *
233
+ * The default "order complete" fixture has 3 nested entries: two
234
+ * products (ers, cc) and one gift. Products have `data.price`; the
235
+ * gift has only `data.name`. The `condition` on the loop inner value
236
+ * filters to products only (price must be present).
237
+ */
238
+ declare const orderCompleteMultiProduct: AmplitudeStepExample;
239
+ /**
240
+ * Group assignment + group properties. Typically used for B2B products
241
+ * where a user belongs to a company. Both SDK calls fire on the same rule.
242
+ */
243
+ declare const groupAssignmentWithProperties: AmplitudeStepExample;
244
+ /**
245
+ * EventOptions mapping -- `settings.eventOptions` maps walkerOS fields
246
+ * to Amplitude per-event metadata. Here `time` maps from the event
247
+ * timestamp and `insert_id` maps from the event id for deduplication.
248
+ */
249
+ declare const eventOptionsTimeInsertId: AmplitudeStepExample;
250
+ /**
251
+ * Consent revoked -> amplitude.setOptOut(true). The destination checks
252
+ * the consent keys declared in config.consent and toggles optOut
253
+ * accordingly (strict: all required keys must be granted).
254
+ *
255
+ * Uses the canonical StepExample.command='consent' pattern: the test
256
+ * runner dispatches via elb('walker consent', in) instead of pushing
257
+ * an event.
258
+ */
259
+ declare const consentRevokeOptOut: AmplitudeStepExample;
260
+ /**
261
+ * Consent granted -> amplitude.setOptOut(false).
262
+ */
263
+ declare const consentGrantOptIn: AmplitudeStepExample;
264
+
265
+ type step_AmplitudeStepExample = AmplitudeStepExample;
266
+ declare const step_consentGrantOptIn: typeof consentGrantOptIn;
267
+ declare const step_consentRevokeOptOut: typeof consentRevokeOptOut;
268
+ declare const step_defaultEventForwarding: typeof defaultEventForwarding;
269
+ declare const step_destinationLevelIdentify: typeof destinationLevelIdentify;
270
+ declare const step_destinationLevelInclude: typeof destinationLevelInclude;
271
+ declare const step_eventOptionsTimeInsertId: typeof eventOptionsTimeInsertId;
272
+ declare const step_groupAssignmentWithProperties: typeof groupAssignmentWithProperties;
273
+ declare const step_orderCompleteMultiProduct: typeof orderCompleteMultiProduct;
274
+ declare const step_subscriptionRenewRevenue: typeof subscriptionRenewRevenue;
275
+ declare const step_userLoginIdentify: typeof userLoginIdentify;
276
+ declare const step_wildcardIgnored: typeof wildcardIgnored;
277
+ declare namespace step {
278
+ export { type step_AmplitudeStepExample as AmplitudeStepExample, step_consentGrantOptIn as consentGrantOptIn, step_consentRevokeOptOut as consentRevokeOptOut, step_defaultEventForwarding as defaultEventForwarding, step_destinationLevelIdentify as destinationLevelIdentify, step_destinationLevelInclude as destinationLevelInclude, step_eventOptionsTimeInsertId as eventOptionsTimeInsertId, step_groupAssignmentWithProperties as groupAssignmentWithProperties, step_orderCompleteMultiProduct as orderCompleteMultiProduct, step_subscriptionRenewRevenue as subscriptionRenewRevenue, step_userLoginIdentify as userLoginIdentify, step_wildcardIgnored as wildcardIgnored };
279
+ }
280
+
281
+ declare const index_env: typeof env;
282
+ declare const index_step: typeof step;
283
+ declare namespace index {
284
+ export { index_env as env, index_step as step };
285
+ }
286
+
287
+ export { index as examples, index$1 as schemas };
package/dist/dev.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,a=(e,n)=>{for(var i in n)t(e,i,{get:n[i],enumerable:!0})},s={};a(s,{examples:()=>y,schemas:()=>o}),module.exports=(e=s,((e,a,s,o)=>{if(a&&"object"==typeof a||"function"==typeof a)for(let p of i(a))r.call(e,p)||p===s||t(e,p,{get:()=>a[p],enumerable:!(o=n(a,p))||o.enumerable});return e})(t({},"__esModule",{value:!0}),e));var o={};a(o,{MappingSchema:()=>c,SettingsSchema:()=>d,mapping:()=>v,settings:()=>m});var p=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),d=u.z.object({apiKey:u.z.string().min(1).describe('Your Amplitude project API key. Find it in your Amplitude project settings under "General" -> "API Keys".'),serverZone:u.z.enum(["US","EU"]).describe("Amplitude data residency zone. Use EU for European data residency. Default: US.").optional(),flushIntervalMillis:u.z.number().int().positive().describe("How often (in ms) to flush the event queue. Default: 10000.").optional(),flushQueueSize:u.z.number().int().positive().describe("Max queued events before a flush. Default: 200.").optional(),flushMaxRetries:u.z.number().int().nonnegative().describe("Max retries on failed flush. Default: 12.").optional(),useBatch:u.z.boolean().describe("Use the Amplitude batch endpoint for higher rate limits. Recommended for high-volume server flows. Default: false.").optional(),minIdLength:u.z.number().int().positive().describe("Minimum length for user_id and device_id fields.").optional(),serverUrl:u.z.string().url().describe("Custom server URL for proxies or self-hosted endpoints.").optional(),optOut:u.z.boolean().describe("Initial opt-out state. When true, no events are sent. Default: false.").optional(),enableRequestBodyCompression:u.z.boolean().describe("Enable gzip compression for request payloads. Default: false.").optional(),identify:u.z.unknown().describe("walkerOS mapping value resolving to per-event identity. Keys: user_id, device_id, session_id, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.").optional(),eventOptions:u.z.unknown().describe("walkerOS mapping value resolving to per-event EventOptions. Keys: time, insert_id, ip, city, country, region, language, platform, os_name, os_version, device_brand, device_model, app_version, user_agent.").optional(),include:u.z.array(u.z.string()).describe("walkerOS event sections to include as event_properties (like ['data', 'globals']).").optional()}),l=require("@walkeros/core/dev"),c=l.z.object({identify:l.z.unknown().describe("Per-event identity mapping. Resolves to an object with any of: user_id, device_id, session_id, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.").optional(),revenue:l.z.unknown().describe("Revenue mapping. Resolves to a single object or (via loop) an array, each with: productId, price, quantity, revenueType, currency, revenue, receipt, receiptSig, eventProperties. One amplitude.revenue() call fires per item.").optional(),group:l.z.unknown().describe("Group assignment. Resolves to { type, name } -> amplitude.setGroup(type, name, eventOptions).").optional(),groupIdentify:l.z.unknown().describe("Group properties. Resolves to { type, name, set?, setOnce?, ... } -> amplitude.groupIdentify(type, name, identify, eventOptions).").optional(),eventOptions:l.z.unknown().describe("Per-rule EventOptions override. Resolves to { time?, insert_id?, ip?, ... }. Overrides destination-level eventOptions for this rule.").optional(),include:l.z.array(l.z.string()).describe("Per-rule include override. Replaces destination-level include for this rule.").optional()}),m=(0,p.zodToSchema)(d),v=(0,p.zodToSchema)(c),y={};a(y,{env:()=>g,step:()=>I});var g={};a(g,{init:()=>O,push:()=>w,simulation:()=>k});var f=()=>{},h=()=>({promise:Promise.resolve()}),_=class{set(){return this}setOnce(){return this}add(){return this}append(){return this}prepend(){return this}preInsert(){return this}postInsert(){return this}remove(){return this}unset(){return this}clearAll(){return this}},b=class{setProductId(){return this}setPrice(){return this}setQuantity(){return this}setRevenueType(){return this}setCurrency(){return this}setRevenue(){return this}setReceipt(){return this}setReceiptSig(){return this}setEventProperties(){return this}},O={amplitude:{init:h,track:f,identify:f,revenue:f,setOptOut:f,setGroup:f,groupIdentify:f,flush:h,Identify:_,Revenue:b}},w={amplitude:{init:h,track:f,identify:f,revenue:f,setOptOut:f,setGroup:f,groupIdentify:f,flush:h,Identify:_,Revenue:b}},k=["call:amplitude.init","call:amplitude.track","call:amplitude.identify","call:amplitude.revenue","call:amplitude.setOptOut","call:amplitude.setGroup","call:amplitude.groupIdentify"],I={};a(I,{consentGrantOptIn:()=>D,consentRevokeOptOut:()=>G,defaultEventForwarding:()=>R,destinationLevelIdentify:()=>A,destinationLevelInclude:()=>P,eventOptionsTimeInsertId:()=>T,groupAssignmentWithProperties:()=>j,orderCompleteMultiProduct:()=>q,subscriptionRenewRevenue:()=>U,userLoginIdentify:()=>S,wildcardIgnored:()=>E});var z=require("@walkeros/core"),R={in:(0,z.getEvent)("product view",{timestamp:1700000100}),out:["amplitude.track","product view",{}]},E={in:(0,z.getEvent)("debug noise",{timestamp:1700000101}),mapping:{ignore:!0},out:[]},P={in:(0,z.getEvent)("product view",{timestamp:1700000102}),configInclude:["data"],out:["amplitude.track","product view",{data_id:"ers",data_name:"Everyday Ruck Snack",data_color:"black",data_size:"l",data_price:420}]},A={in:(0,z.getEvent)("page view",{timestamp:1700000104}),settings:{identify:{map:{user_id:"user.id",device_id:"user.device",session_id:"user.session"}}},out:["amplitude.track","page view",{},{user_id:"us3r",device_id:"c00k13",session_id:394324160}]},S={in:(0,z.getEvent)("user login",{timestamp:1700000105,data:{user_id:"new-user-123",plan:"premium",company:"Acme",email:"user@acme.com"}}),mapping:{skip:!0,settings:{identify:{map:{user_id:"data.user_id",set:{map:{plan:"data.plan",company:"data.company",email:"data.email"}},setOnce:{map:{first_login:"timestamp"}},add:{map:{login_count:{value:1}}}}}}},out:["amplitude.identify",{set:{plan:"premium",company:"Acme",email:"user@acme.com"},setOnce:{first_login:1700000105},add:{login_count:1}},{user_id:"new-user-123"}]},U={in:(0,z.getEvent)("subscription renew",{timestamp:1700000107,data:{plan_id:"plan-pro",amount:9.99}}),mapping:{skip:!0,settings:{revenue:{map:{productId:"data.plan_id",price:"data.amount",revenueType:{value:"renewal"},currency:{key:"data.currency",value:"EUR"}}}}},out:["amplitude.revenue",{productId:"plan-pro",price:9.99,revenueType:"renewal",currency:"EUR"}]},q={in:(0,z.getEvent)("order complete",{timestamp:1700000108}),mapping:{include:["data","globals"],settings:{revenue:{loop:["nested",{condition:e=>{var t;return"number"==typeof(null==(t=null==e?void 0:e.data)?void 0:t.price)},map:{productId:"data.id",price:"data.price",quantity:{key:"data.quantity",value:1},revenueType:{value:"purchase"},currency:{key:"data.currency",value:"EUR"}}}]}}},out:[["amplitude.revenue",{productId:"ers",price:420,quantity:1,revenueType:"purchase",currency:"EUR"}],["amplitude.revenue",{productId:"cc",price:42,quantity:1,revenueType:"purchase",currency:"EUR"}],["amplitude.track","order complete",{data_id:"0rd3r1d",data_currency:"EUR",data_shipping:5.22,data_taxes:73.76,data_total:555,globals_pagegroup:"shop"}]]},j={in:(0,z.getEvent)("company update",{timestamp:1700000109,data:{company:"Acme",industry:"tech",employee_count:50,founded_year:2020}}),mapping:{skip:!0,settings:{group:{map:{type:{value:"company"},name:"data.company"}},groupIdentify:{map:{type:{value:"company"},name:"data.company",set:{map:{industry:"data.industry",size:"data.employee_count"}},setOnce:{map:{founded:"data.founded_year"}}}}}},out:[["amplitude.setGroup","company","Acme"],["amplitude.groupIdentify","company","Acme",{set:{industry:"tech",size:50},setOnce:{founded:2020}}]]},T={in:(0,z.getEvent)("page view",{timestamp:1700000110}),settings:{eventOptions:{map:{time:"timestamp",insert_id:"id"}}},out:["amplitude.track","page view",{},{time:1700000110,insert_id:"1700000110-gr0up-1"}]},G={command:"consent",in:{analytics:!1},settings:{},out:["amplitude.setOptOut",!0]},D={command:"consent",in:{analytics:!0},settings:{},out:["amplitude.setOptOut",!1]};//# sourceMappingURL=dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.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 { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'Your Amplitude project API key. Find it in your Amplitude project settings under \"General\" -> \"API Keys\".',\n ),\n serverZone: z\n .enum(['US', 'EU'])\n .describe(\n 'Amplitude data residency zone. Use EU for European data residency. Default: US.',\n )\n .optional(),\n flushIntervalMillis: z\n .number()\n .int()\n .positive()\n .describe('How often (in ms) to flush the event queue. Default: 10000.')\n .optional(),\n flushQueueSize: z\n .number()\n .int()\n .positive()\n .describe('Max queued events before a flush. Default: 200.')\n .optional(),\n flushMaxRetries: z\n .number()\n .int()\n .nonnegative()\n .describe('Max retries on failed flush. Default: 12.')\n .optional(),\n useBatch: z\n .boolean()\n .describe(\n 'Use the Amplitude batch endpoint for higher rate limits. Recommended for high-volume server flows. Default: false.',\n )\n .optional(),\n minIdLength: z\n .number()\n .int()\n .positive()\n .describe('Minimum length for user_id and device_id fields.')\n .optional(),\n serverUrl: z\n .string()\n .url()\n .describe('Custom server URL for proxies or self-hosted endpoints.')\n .optional(),\n optOut: z\n .boolean()\n .describe(\n 'Initial opt-out state. When true, no events are sent. Default: false.',\n )\n .optional(),\n enableRequestBodyCompression: z\n .boolean()\n .describe('Enable gzip compression for request payloads. Default: false.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to per-event identity. Keys: user_id, device_id, session_id, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.',\n )\n .optional(),\n eventOptions: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to per-event EventOptions. Keys: time, insert_id, ip, city, country, region, language, platform, os_name, os_version, device_brand, device_model, app_version, user_agent.',\n )\n .optional(),\n include: z\n .array(z.string())\n .describe(\n \"walkerOS event sections to include as event_properties (like ['data', 'globals']).\",\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identity mapping. Resolves to an object with any of: user_id, device_id, session_id, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.',\n )\n .optional(),\n revenue: z\n .unknown()\n .describe(\n 'Revenue mapping. Resolves to a single object or (via loop) an array, each with: productId, price, quantity, revenueType, currency, revenue, receipt, receiptSig, eventProperties. One amplitude.revenue() call fires per item.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Group assignment. Resolves to { type, name } -> amplitude.setGroup(type, name, eventOptions).',\n )\n .optional(),\n groupIdentify: z\n .unknown()\n .describe(\n 'Group properties. Resolves to { type, name, set?, setOnce?, ... } -> amplitude.groupIdentify(type, name, identify, eventOptions).',\n )\n .optional(),\n eventOptions: z\n .unknown()\n .describe(\n 'Per-rule EventOptions override. Resolves to { time?, insert_id?, ip?, ... }. Overrides destination-level eventOptions for this rule.',\n )\n .optional(),\n include: z\n .array(z.string())\n .describe(\n 'Per-rule include override. Replaces destination-level include for this rule.',\n )\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 { Env, IdentifyInstance, RevenueInstance } from '../types';\n\nconst noop = () => {};\nconst noopPromise = () => ({ promise: Promise.resolve() });\n\nclass MockIdentify implements IdentifyInstance {\n set() {\n return this;\n }\n setOnce() {\n return this;\n }\n add() {\n return this;\n }\n append() {\n return this;\n }\n prepend() {\n return this;\n }\n preInsert() {\n return this;\n }\n postInsert() {\n return this;\n }\n remove() {\n return this;\n }\n unset() {\n return this;\n }\n clearAll() {\n return this;\n }\n}\n\nclass MockRevenue implements RevenueInstance {\n setProductId() {\n return this;\n }\n setPrice() {\n return this;\n }\n setQuantity() {\n return this;\n }\n setRevenueType() {\n return this;\n }\n setCurrency() {\n return this;\n }\n setRevenue() {\n return this;\n }\n setReceipt() {\n return this;\n }\n setReceiptSig() {\n return this;\n }\n setEventProperties() {\n return this;\n }\n}\n\nexport const init: Env | undefined = {\n amplitude: {\n init: noopPromise,\n track: noop,\n identify: noop,\n revenue: noop,\n setOptOut: noop,\n setGroup: noop,\n groupIdentify: noop,\n flush: noopPromise,\n Identify: MockIdentify,\n Revenue: MockRevenue,\n },\n};\n\nexport const push: Env = {\n amplitude: {\n init: noopPromise,\n track: noop,\n identify: noop,\n revenue: noop,\n setOptOut: noop,\n setGroup: noop,\n groupIdentify: noop,\n flush: noopPromise,\n Identify: MockIdentify,\n Revenue: MockRevenue,\n },\n};\n\nexport const simulation = [\n 'call:amplitude.init',\n 'call:amplitude.track',\n 'call:amplitude.identify',\n 'call:amplitude.revenue',\n 'call:amplitude.setOptOut',\n 'call:amplitude.setGroup',\n 'call:amplitude.groupIdentify',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * Extended step example type for Amplitude server destination.\n * Settings and configInclude are read by the test runner and merged\n * into the base destination configuration.\n */\nexport type AmplitudeStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n};\n\n/**\n * Default event forwarding -- every walkerOS event becomes\n * amplitude.track(event.name, event_properties). With no mapping and\n * no destination-level include, event_properties is `{}`.\n */\nexport const defaultEventForwarding: AmplitudeStepExample = {\n in: getEvent('product view', { timestamp: 1700000100 }),\n out: ['amplitude.track', 'product view', {}],\n};\n\n/**\n * Wildcard ignore -- walkerOS's standard way to drop events. The rule\n * matches but does nothing. The destination fires zero SDK calls.\n */\nexport const wildcardIgnored: AmplitudeStepExample = {\n in: getEvent('debug noise', { timestamp: 1700000101 }),\n mapping: { ignore: true },\n out: [],\n};\n\n/**\n * Destination-level settings.include flattens the walkerOS `data` section\n * into prefixed event_properties on every push.\n */\nexport const destinationLevelInclude: AmplitudeStepExample = {\n in: getEvent('product view', { timestamp: 1700000102 }),\n configInclude: ['data'],\n out: [\n 'amplitude.track',\n 'product view',\n {\n data_id: 'ers',\n data_name: 'Everyday Ruck Snack',\n data_color: 'black',\n data_size: 'l',\n data_price: 420,\n },\n ],\n};\n\n/**\n * Destination-level settings.identify resolves per-event identity.\n * Unlike the web destination (which uses setUserId/setDeviceId/setSessionId),\n * server-side identity goes into EventOptions passed to every SDK call.\n *\n * user.session is 's3ss10n' (string). The destination deterministically\n * hashes non-numeric session strings via djb2.\n * djb2('s3ss10n') = 394324160.\n */\nexport const destinationLevelIdentify: AmplitudeStepExample = {\n in: getEvent('page view', { timestamp: 1700000104 }),\n settings: {\n identify: {\n map: {\n user_id: 'user.id',\n device_id: 'user.device',\n session_id: 'user.session',\n },\n },\n },\n out: [\n 'amplitude.track',\n 'page view',\n {},\n {\n user_id: 'us3r',\n device_id: 'c00k13',\n session_id: 394324160,\n },\n ],\n};\n\n/**\n * Per-event identify with the full operation vocabulary -- this is the\n * \"user login\" pattern: set user_id, enrich user properties. `skip: true`\n * suppresses the default amplitude.track() call because we're running\n * identity side effects only.\n *\n * Server-side, user_id is passed via EventOptions on identify().\n */\nexport const userLoginIdentify: AmplitudeStepExample = {\n in: getEvent('user login', {\n timestamp: 1700000105,\n data: {\n user_id: 'new-user-123',\n plan: 'premium',\n company: 'Acme',\n email: 'user@acme.com',\n },\n }),\n mapping: {\n skip: true,\n settings: {\n identify: {\n map: {\n user_id: 'data.user_id',\n set: {\n map: {\n plan: 'data.plan',\n company: 'data.company',\n email: 'data.email',\n },\n },\n setOnce: {\n map: {\n first_login: 'timestamp',\n },\n },\n add: {\n map: {\n login_count: { value: 1 },\n },\n },\n },\n },\n },\n },\n out: [\n 'amplitude.identify',\n {\n set: {\n plan: 'premium',\n company: 'Acme',\n email: 'user@acme.com',\n },\n setOnce: {\n first_login: 1700000105,\n },\n add: {\n login_count: 1,\n },\n },\n {\n user_id: 'new-user-123',\n },\n ],\n};\n\n/**\n * Single-product revenue -- resolves `settings.revenue` to one object and\n * fires one amplitude.revenue() call. Note the `{ key: \"data.currency\",\n * value: \"EUR\" }` fallback syntax: try data.currency, default to \"EUR\".\n *\n * The custom event has no data.currency, so the fallback fires.\n * `skip: true` suppresses the default track().\n */\nexport const subscriptionRenewRevenue: AmplitudeStepExample = {\n in: getEvent('subscription renew', {\n timestamp: 1700000107,\n data: {\n plan_id: 'plan-pro',\n amount: 9.99,\n },\n }),\n mapping: {\n skip: true,\n settings: {\n revenue: {\n map: {\n productId: 'data.plan_id',\n price: 'data.amount',\n revenueType: { value: 'renewal' },\n currency: { key: 'data.currency', value: 'EUR' },\n },\n },\n },\n },\n out: [\n 'amplitude.revenue',\n {\n productId: 'plan-pro',\n price: 9.99,\n revenueType: 'renewal',\n currency: 'EUR',\n },\n ],\n};\n\n/**\n * Multi-product order -- the canonical Amplitude ecommerce pattern.\n * `revenue.loop: [\"nested\", { map: ... }]` iterates event.nested and\n * resolves one revenue item per entry. Each becomes a separate\n * amplitude.revenue() call. The order-level track() fires once with\n * include-based event_properties.\n *\n * The default \"order complete\" fixture has 3 nested entries: two\n * products (ers, cc) and one gift. Products have `data.price`; the\n * gift has only `data.name`. The `condition` on the loop inner value\n * filters to products only (price must be present).\n */\nexport const orderCompleteMultiProduct: AmplitudeStepExample = {\n in: getEvent('order complete', { timestamp: 1700000108 }),\n mapping: {\n include: ['data', 'globals'],\n settings: {\n revenue: {\n loop: [\n 'nested',\n {\n condition: (value: unknown) => {\n const v = value as { data?: { price?: unknown } };\n return typeof v?.data?.price === 'number';\n },\n map: {\n productId: 'data.id',\n price: 'data.price',\n quantity: { key: 'data.quantity', value: 1 },\n revenueType: { value: 'purchase' },\n currency: { key: 'data.currency', value: 'EUR' },\n },\n },\n ],\n },\n },\n },\n out: [\n [\n 'amplitude.revenue',\n {\n productId: 'ers',\n price: 420,\n quantity: 1,\n revenueType: 'purchase',\n currency: 'EUR',\n },\n ],\n [\n 'amplitude.revenue',\n {\n productId: 'cc',\n price: 42,\n quantity: 1,\n revenueType: 'purchase',\n currency: 'EUR',\n },\n ],\n [\n 'amplitude.track',\n 'order complete',\n {\n data_id: '0rd3r1d',\n data_currency: 'EUR',\n data_shipping: 5.22,\n data_taxes: 73.76,\n data_total: 555,\n globals_pagegroup: 'shop',\n },\n ],\n ],\n};\n\n/**\n * Group assignment + group properties. Typically used for B2B products\n * where a user belongs to a company. Both SDK calls fire on the same rule.\n */\nexport const groupAssignmentWithProperties: AmplitudeStepExample = {\n in: getEvent('company update', {\n timestamp: 1700000109,\n data: {\n company: 'Acme',\n industry: 'tech',\n employee_count: 50,\n founded_year: 2020,\n },\n }),\n mapping: {\n skip: true,\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n name: 'data.company',\n },\n },\n groupIdentify: {\n map: {\n type: { value: 'company' },\n name: 'data.company',\n set: {\n map: {\n industry: 'data.industry',\n size: 'data.employee_count',\n },\n },\n setOnce: {\n map: {\n founded: 'data.founded_year',\n },\n },\n },\n },\n },\n },\n out: [\n ['amplitude.setGroup', 'company', 'Acme'],\n [\n 'amplitude.groupIdentify',\n 'company',\n 'Acme',\n {\n set: {\n industry: 'tech',\n size: 50,\n },\n setOnce: {\n founded: 2020,\n },\n },\n ],\n ],\n};\n\n/**\n * EventOptions mapping -- `settings.eventOptions` maps walkerOS fields\n * to Amplitude per-event metadata. Here `time` maps from the event\n * timestamp and `insert_id` maps from the event id for deduplication.\n */\nexport const eventOptionsTimeInsertId: AmplitudeStepExample = {\n in: getEvent('page view', { timestamp: 1700000110 }),\n settings: {\n eventOptions: {\n map: {\n time: 'timestamp',\n insert_id: 'id',\n },\n },\n },\n out: [\n 'amplitude.track',\n 'page view',\n {},\n {\n time: 1700000110,\n insert_id: '1700000110-gr0up-1',\n },\n ],\n};\n\n/**\n * Consent revoked -> amplitude.setOptOut(true). The destination checks\n * the consent keys declared in config.consent and toggles optOut\n * accordingly (strict: all required keys must be granted).\n *\n * Uses the canonical StepExample.command='consent' pattern: the test\n * runner dispatches via elb('walker consent', in) instead of pushing\n * an event.\n */\nexport const consentRevokeOptOut: AmplitudeStepExample = {\n command: 'consent',\n in: { analytics: false } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: ['amplitude.setOptOut', true],\n};\n\n/**\n * Consent granted -> amplitude.setOptOut(false).\n */\nexport const consentGrantOptIn: AmplitudeStepExample = {\n command: 'consent',\n in: { analytics: true } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: ['amplitude.setOptOut', false],\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAA4B;;;ACA5B,iBAAkB;AAEX,IAAM,iBAAiB,aAAE,OAAO;AAAA,EACrC,QAAQ,aACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,YAAY,aACT,KAAK,CAAC,MAAM,IAAI,CAAC,EACjB;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,qBAAqB,aAClB,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,6DAA6D,EACtE,SAAS;AAAA,EACZ,gBAAgB,aACb,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,iDAAiD,EAC1D,SAAS;AAAA,EACZ,iBAAiB,aACd,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,SAAS,2CAA2C,EACpD,SAAS;AAAA,EACZ,UAAU,aACP,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,aAAa,aACV,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,kDAAkD,EAC3D,SAAS;AAAA,EACZ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,WAAW,KAAK;AAAA,EACtB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,uBAAuB,KAAK;AACpC;","names":["import_dev","import_dev"]}
package/dist/dev.mjs ADDED
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty,t=(t,i)=>{for(var n in i)e(t,n,{get:i[n],enumerable:!0})},i={};t(i,{MappingSchema:()=>o,SettingsSchema:()=>a,mapping:()=>u,settings:()=>p});import{zodToSchema as n}from"@walkeros/core/dev";import{z as r}from"@walkeros/core/dev";var a=r.object({apiKey:r.string().min(1).describe('Your Amplitude project API key. Find it in your Amplitude project settings under "General" -> "API Keys".'),serverZone:r.enum(["US","EU"]).describe("Amplitude data residency zone. Use EU for European data residency. Default: US.").optional(),flushIntervalMillis:r.number().int().positive().describe("How often (in ms) to flush the event queue. Default: 10000.").optional(),flushQueueSize:r.number().int().positive().describe("Max queued events before a flush. Default: 200.").optional(),flushMaxRetries:r.number().int().nonnegative().describe("Max retries on failed flush. Default: 12.").optional(),useBatch:r.boolean().describe("Use the Amplitude batch endpoint for higher rate limits. Recommended for high-volume server flows. Default: false.").optional(),minIdLength:r.number().int().positive().describe("Minimum length for user_id and device_id fields.").optional(),serverUrl:r.string().url().describe("Custom server URL for proxies or self-hosted endpoints.").optional(),optOut:r.boolean().describe("Initial opt-out state. When true, no events are sent. Default: false.").optional(),enableRequestBodyCompression:r.boolean().describe("Enable gzip compression for request payloads. Default: false.").optional(),identify:r.unknown().describe("walkerOS mapping value resolving to per-event identity. Keys: user_id, device_id, session_id, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.").optional(),eventOptions:r.unknown().describe("walkerOS mapping value resolving to per-event EventOptions. Keys: time, insert_id, ip, city, country, region, language, platform, os_name, os_version, device_brand, device_model, app_version, user_agent.").optional(),include:r.array(r.string()).describe("walkerOS event sections to include as event_properties (like ['data', 'globals']).").optional()});import{z as s}from"@walkeros/core/dev";var o=s.object({identify:s.unknown().describe("Per-event identity mapping. Resolves to an object with any of: user_id, device_id, session_id, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.").optional(),revenue:s.unknown().describe("Revenue mapping. Resolves to a single object or (via loop) an array, each with: productId, price, quantity, revenueType, currency, revenue, receipt, receiptSig, eventProperties. One amplitude.revenue() call fires per item.").optional(),group:s.unknown().describe("Group assignment. Resolves to { type, name } -> amplitude.setGroup(type, name, eventOptions).").optional(),groupIdentify:s.unknown().describe("Group properties. Resolves to { type, name, set?, setOnce?, ... } -> amplitude.groupIdentify(type, name, identify, eventOptions).").optional(),eventOptions:s.unknown().describe("Per-rule EventOptions override. Resolves to { time?, insert_id?, ip?, ... }. Overrides destination-level eventOptions for this rule.").optional(),include:s.array(s.string()).describe("Per-rule include override. Replaces destination-level include for this rule.").optional()}),p=n(a),u=n(o),d={};t(d,{env:()=>l,step:()=>_});var l={};t(l,{init:()=>g,push:()=>f,simulation:()=>h});var c=()=>{},m=()=>({promise:Promise.resolve()}),v=class{set(){return this}setOnce(){return this}add(){return this}append(){return this}prepend(){return this}preInsert(){return this}postInsert(){return this}remove(){return this}unset(){return this}clearAll(){return this}},y=class{setProductId(){return this}setPrice(){return this}setQuantity(){return this}setRevenueType(){return this}setCurrency(){return this}setRevenue(){return this}setReceipt(){return this}setReceiptSig(){return this}setEventProperties(){return this}},g={amplitude:{init:m,track:c,identify:c,revenue:c,setOptOut:c,setGroup:c,groupIdentify:c,flush:m,Identify:v,Revenue:y}},f={amplitude:{init:m,track:c,identify:c,revenue:c,setOptOut:c,setGroup:c,groupIdentify:c,flush:m,Identify:v,Revenue:y}},h=["call:amplitude.init","call:amplitude.track","call:amplitude.identify","call:amplitude.revenue","call:amplitude.setOptOut","call:amplitude.setGroup","call:amplitude.groupIdentify"],_={};t(_,{consentGrantOptIn:()=>q,consentRevokeOptOut:()=>S,defaultEventForwarding:()=>O,destinationLevelIdentify:()=>w,destinationLevelInclude:()=>I,eventOptionsTimeInsertId:()=>P,groupAssignmentWithProperties:()=>U,orderCompleteMultiProduct:()=>E,subscriptionRenewRevenue:()=>A,userLoginIdentify:()=>R,wildcardIgnored:()=>k});import{getEvent as b}from"@walkeros/core";var O={in:b("product view",{timestamp:1700000100}),out:["amplitude.track","product view",{}]},k={in:b("debug noise",{timestamp:1700000101}),mapping:{ignore:!0},out:[]},I={in:b("product view",{timestamp:1700000102}),configInclude:["data"],out:["amplitude.track","product view",{data_id:"ers",data_name:"Everyday Ruck Snack",data_color:"black",data_size:"l",data_price:420}]},w={in:b("page view",{timestamp:1700000104}),settings:{identify:{map:{user_id:"user.id",device_id:"user.device",session_id:"user.session"}}},out:["amplitude.track","page view",{},{user_id:"us3r",device_id:"c00k13",session_id:394324160}]},R={in:b("user login",{timestamp:1700000105,data:{user_id:"new-user-123",plan:"premium",company:"Acme",email:"user@acme.com"}}),mapping:{skip:!0,settings:{identify:{map:{user_id:"data.user_id",set:{map:{plan:"data.plan",company:"data.company",email:"data.email"}},setOnce:{map:{first_login:"timestamp"}},add:{map:{login_count:{value:1}}}}}}},out:["amplitude.identify",{set:{plan:"premium",company:"Acme",email:"user@acme.com"},setOnce:{first_login:1700000105},add:{login_count:1}},{user_id:"new-user-123"}]},A={in:b("subscription renew",{timestamp:1700000107,data:{plan_id:"plan-pro",amount:9.99}}),mapping:{skip:!0,settings:{revenue:{map:{productId:"data.plan_id",price:"data.amount",revenueType:{value:"renewal"},currency:{key:"data.currency",value:"EUR"}}}}},out:["amplitude.revenue",{productId:"plan-pro",price:9.99,revenueType:"renewal",currency:"EUR"}]},E={in:b("order complete",{timestamp:1700000108}),mapping:{include:["data","globals"],settings:{revenue:{loop:["nested",{condition:e=>{var t;return"number"==typeof(null==(t=null==e?void 0:e.data)?void 0:t.price)},map:{productId:"data.id",price:"data.price",quantity:{key:"data.quantity",value:1},revenueType:{value:"purchase"},currency:{key:"data.currency",value:"EUR"}}}]}}},out:[["amplitude.revenue",{productId:"ers",price:420,quantity:1,revenueType:"purchase",currency:"EUR"}],["amplitude.revenue",{productId:"cc",price:42,quantity:1,revenueType:"purchase",currency:"EUR"}],["amplitude.track","order complete",{data_id:"0rd3r1d",data_currency:"EUR",data_shipping:5.22,data_taxes:73.76,data_total:555,globals_pagegroup:"shop"}]]},U={in:b("company update",{timestamp:1700000109,data:{company:"Acme",industry:"tech",employee_count:50,founded_year:2020}}),mapping:{skip:!0,settings:{group:{map:{type:{value:"company"},name:"data.company"}},groupIdentify:{map:{type:{value:"company"},name:"data.company",set:{map:{industry:"data.industry",size:"data.employee_count"}},setOnce:{map:{founded:"data.founded_year"}}}}}},out:[["amplitude.setGroup","company","Acme"],["amplitude.groupIdentify","company","Acme",{set:{industry:"tech",size:50},setOnce:{founded:2020}}]]},P={in:b("page view",{timestamp:1700000110}),settings:{eventOptions:{map:{time:"timestamp",insert_id:"id"}}},out:["amplitude.track","page view",{},{time:1700000110,insert_id:"1700000110-gr0up-1"}]},S={command:"consent",in:{analytics:!1},settings:{},out:["amplitude.setOptOut",!0]},q={command:"consent",in:{analytics:!0},settings:{},out:["amplitude.setOptOut",!1]};export{d as examples,i as schemas};//# sourceMappingURL=dev.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.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 { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n apiKey: z\n .string()\n .min(1)\n .describe(\n 'Your Amplitude project API key. Find it in your Amplitude project settings under \"General\" -> \"API Keys\".',\n ),\n serverZone: z\n .enum(['US', 'EU'])\n .describe(\n 'Amplitude data residency zone. Use EU for European data residency. Default: US.',\n )\n .optional(),\n flushIntervalMillis: z\n .number()\n .int()\n .positive()\n .describe('How often (in ms) to flush the event queue. Default: 10000.')\n .optional(),\n flushQueueSize: z\n .number()\n .int()\n .positive()\n .describe('Max queued events before a flush. Default: 200.')\n .optional(),\n flushMaxRetries: z\n .number()\n .int()\n .nonnegative()\n .describe('Max retries on failed flush. Default: 12.')\n .optional(),\n useBatch: z\n .boolean()\n .describe(\n 'Use the Amplitude batch endpoint for higher rate limits. Recommended for high-volume server flows. Default: false.',\n )\n .optional(),\n minIdLength: z\n .number()\n .int()\n .positive()\n .describe('Minimum length for user_id and device_id fields.')\n .optional(),\n serverUrl: z\n .string()\n .url()\n .describe('Custom server URL for proxies or self-hosted endpoints.')\n .optional(),\n optOut: z\n .boolean()\n .describe(\n 'Initial opt-out state. When true, no events are sent. Default: false.',\n )\n .optional(),\n enableRequestBodyCompression: z\n .boolean()\n .describe('Enable gzip compression for request payloads. Default: false.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to per-event identity. Keys: user_id, device_id, session_id, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.',\n )\n .optional(),\n eventOptions: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to per-event EventOptions. Keys: time, insert_id, ip, city, country, region, language, platform, os_name, os_version, device_brand, device_model, app_version, user_agent.',\n )\n .optional(),\n include: z\n .array(z.string())\n .describe(\n \"walkerOS event sections to include as event_properties (like ['data', 'globals']).\",\n )\n .optional(),\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\nexport const MappingSchema = z.object({\n identify: z\n .unknown()\n .describe(\n 'Per-event identity mapping. Resolves to an object with any of: user_id, device_id, session_id, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.',\n )\n .optional(),\n revenue: z\n .unknown()\n .describe(\n 'Revenue mapping. Resolves to a single object or (via loop) an array, each with: productId, price, quantity, revenueType, currency, revenue, receipt, receiptSig, eventProperties. One amplitude.revenue() call fires per item.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Group assignment. Resolves to { type, name } -> amplitude.setGroup(type, name, eventOptions).',\n )\n .optional(),\n groupIdentify: z\n .unknown()\n .describe(\n 'Group properties. Resolves to { type, name, set?, setOnce?, ... } -> amplitude.groupIdentify(type, name, identify, eventOptions).',\n )\n .optional(),\n eventOptions: z\n .unknown()\n .describe(\n 'Per-rule EventOptions override. Resolves to { time?, insert_id?, ip?, ... }. Overrides destination-level eventOptions for this rule.',\n )\n .optional(),\n include: z\n .array(z.string())\n .describe(\n 'Per-rule include override. Replaces destination-level include for this rule.',\n )\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 { Env, IdentifyInstance, RevenueInstance } from '../types';\n\nconst noop = () => {};\nconst noopPromise = () => ({ promise: Promise.resolve() });\n\nclass MockIdentify implements IdentifyInstance {\n set() {\n return this;\n }\n setOnce() {\n return this;\n }\n add() {\n return this;\n }\n append() {\n return this;\n }\n prepend() {\n return this;\n }\n preInsert() {\n return this;\n }\n postInsert() {\n return this;\n }\n remove() {\n return this;\n }\n unset() {\n return this;\n }\n clearAll() {\n return this;\n }\n}\n\nclass MockRevenue implements RevenueInstance {\n setProductId() {\n return this;\n }\n setPrice() {\n return this;\n }\n setQuantity() {\n return this;\n }\n setRevenueType() {\n return this;\n }\n setCurrency() {\n return this;\n }\n setRevenue() {\n return this;\n }\n setReceipt() {\n return this;\n }\n setReceiptSig() {\n return this;\n }\n setEventProperties() {\n return this;\n }\n}\n\nexport const init: Env | undefined = {\n amplitude: {\n init: noopPromise,\n track: noop,\n identify: noop,\n revenue: noop,\n setOptOut: noop,\n setGroup: noop,\n groupIdentify: noop,\n flush: noopPromise,\n Identify: MockIdentify,\n Revenue: MockRevenue,\n },\n};\n\nexport const push: Env = {\n amplitude: {\n init: noopPromise,\n track: noop,\n identify: noop,\n revenue: noop,\n setOptOut: noop,\n setGroup: noop,\n groupIdentify: noop,\n flush: noopPromise,\n Identify: MockIdentify,\n Revenue: MockRevenue,\n },\n};\n\nexport const simulation = [\n 'call:amplitude.init',\n 'call:amplitude.track',\n 'call:amplitude.identify',\n 'call:amplitude.revenue',\n 'call:amplitude.setOptOut',\n 'call:amplitude.setGroup',\n 'call:amplitude.groupIdentify',\n];\n","import type { Flow, WalkerOS } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * Extended step example type for Amplitude server destination.\n * Settings and configInclude are read by the test runner and merged\n * into the base destination configuration.\n */\nexport type AmplitudeStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n};\n\n/**\n * Default event forwarding -- every walkerOS event becomes\n * amplitude.track(event.name, event_properties). With no mapping and\n * no destination-level include, event_properties is `{}`.\n */\nexport const defaultEventForwarding: AmplitudeStepExample = {\n in: getEvent('product view', { timestamp: 1700000100 }),\n out: ['amplitude.track', 'product view', {}],\n};\n\n/**\n * Wildcard ignore -- walkerOS's standard way to drop events. The rule\n * matches but does nothing. The destination fires zero SDK calls.\n */\nexport const wildcardIgnored: AmplitudeStepExample = {\n in: getEvent('debug noise', { timestamp: 1700000101 }),\n mapping: { ignore: true },\n out: [],\n};\n\n/**\n * Destination-level settings.include flattens the walkerOS `data` section\n * into prefixed event_properties on every push.\n */\nexport const destinationLevelInclude: AmplitudeStepExample = {\n in: getEvent('product view', { timestamp: 1700000102 }),\n configInclude: ['data'],\n out: [\n 'amplitude.track',\n 'product view',\n {\n data_id: 'ers',\n data_name: 'Everyday Ruck Snack',\n data_color: 'black',\n data_size: 'l',\n data_price: 420,\n },\n ],\n};\n\n/**\n * Destination-level settings.identify resolves per-event identity.\n * Unlike the web destination (which uses setUserId/setDeviceId/setSessionId),\n * server-side identity goes into EventOptions passed to every SDK call.\n *\n * user.session is 's3ss10n' (string). The destination deterministically\n * hashes non-numeric session strings via djb2.\n * djb2('s3ss10n') = 394324160.\n */\nexport const destinationLevelIdentify: AmplitudeStepExample = {\n in: getEvent('page view', { timestamp: 1700000104 }),\n settings: {\n identify: {\n map: {\n user_id: 'user.id',\n device_id: 'user.device',\n session_id: 'user.session',\n },\n },\n },\n out: [\n 'amplitude.track',\n 'page view',\n {},\n {\n user_id: 'us3r',\n device_id: 'c00k13',\n session_id: 394324160,\n },\n ],\n};\n\n/**\n * Per-event identify with the full operation vocabulary -- this is the\n * \"user login\" pattern: set user_id, enrich user properties. `skip: true`\n * suppresses the default amplitude.track() call because we're running\n * identity side effects only.\n *\n * Server-side, user_id is passed via EventOptions on identify().\n */\nexport const userLoginIdentify: AmplitudeStepExample = {\n in: getEvent('user login', {\n timestamp: 1700000105,\n data: {\n user_id: 'new-user-123',\n plan: 'premium',\n company: 'Acme',\n email: 'user@acme.com',\n },\n }),\n mapping: {\n skip: true,\n settings: {\n identify: {\n map: {\n user_id: 'data.user_id',\n set: {\n map: {\n plan: 'data.plan',\n company: 'data.company',\n email: 'data.email',\n },\n },\n setOnce: {\n map: {\n first_login: 'timestamp',\n },\n },\n add: {\n map: {\n login_count: { value: 1 },\n },\n },\n },\n },\n },\n },\n out: [\n 'amplitude.identify',\n {\n set: {\n plan: 'premium',\n company: 'Acme',\n email: 'user@acme.com',\n },\n setOnce: {\n first_login: 1700000105,\n },\n add: {\n login_count: 1,\n },\n },\n {\n user_id: 'new-user-123',\n },\n ],\n};\n\n/**\n * Single-product revenue -- resolves `settings.revenue` to one object and\n * fires one amplitude.revenue() call. Note the `{ key: \"data.currency\",\n * value: \"EUR\" }` fallback syntax: try data.currency, default to \"EUR\".\n *\n * The custom event has no data.currency, so the fallback fires.\n * `skip: true` suppresses the default track().\n */\nexport const subscriptionRenewRevenue: AmplitudeStepExample = {\n in: getEvent('subscription renew', {\n timestamp: 1700000107,\n data: {\n plan_id: 'plan-pro',\n amount: 9.99,\n },\n }),\n mapping: {\n skip: true,\n settings: {\n revenue: {\n map: {\n productId: 'data.plan_id',\n price: 'data.amount',\n revenueType: { value: 'renewal' },\n currency: { key: 'data.currency', value: 'EUR' },\n },\n },\n },\n },\n out: [\n 'amplitude.revenue',\n {\n productId: 'plan-pro',\n price: 9.99,\n revenueType: 'renewal',\n currency: 'EUR',\n },\n ],\n};\n\n/**\n * Multi-product order -- the canonical Amplitude ecommerce pattern.\n * `revenue.loop: [\"nested\", { map: ... }]` iterates event.nested and\n * resolves one revenue item per entry. Each becomes a separate\n * amplitude.revenue() call. The order-level track() fires once with\n * include-based event_properties.\n *\n * The default \"order complete\" fixture has 3 nested entries: two\n * products (ers, cc) and one gift. Products have `data.price`; the\n * gift has only `data.name`. The `condition` on the loop inner value\n * filters to products only (price must be present).\n */\nexport const orderCompleteMultiProduct: AmplitudeStepExample = {\n in: getEvent('order complete', { timestamp: 1700000108 }),\n mapping: {\n include: ['data', 'globals'],\n settings: {\n revenue: {\n loop: [\n 'nested',\n {\n condition: (value: unknown) => {\n const v = value as { data?: { price?: unknown } };\n return typeof v?.data?.price === 'number';\n },\n map: {\n productId: 'data.id',\n price: 'data.price',\n quantity: { key: 'data.quantity', value: 1 },\n revenueType: { value: 'purchase' },\n currency: { key: 'data.currency', value: 'EUR' },\n },\n },\n ],\n },\n },\n },\n out: [\n [\n 'amplitude.revenue',\n {\n productId: 'ers',\n price: 420,\n quantity: 1,\n revenueType: 'purchase',\n currency: 'EUR',\n },\n ],\n [\n 'amplitude.revenue',\n {\n productId: 'cc',\n price: 42,\n quantity: 1,\n revenueType: 'purchase',\n currency: 'EUR',\n },\n ],\n [\n 'amplitude.track',\n 'order complete',\n {\n data_id: '0rd3r1d',\n data_currency: 'EUR',\n data_shipping: 5.22,\n data_taxes: 73.76,\n data_total: 555,\n globals_pagegroup: 'shop',\n },\n ],\n ],\n};\n\n/**\n * Group assignment + group properties. Typically used for B2B products\n * where a user belongs to a company. Both SDK calls fire on the same rule.\n */\nexport const groupAssignmentWithProperties: AmplitudeStepExample = {\n in: getEvent('company update', {\n timestamp: 1700000109,\n data: {\n company: 'Acme',\n industry: 'tech',\n employee_count: 50,\n founded_year: 2020,\n },\n }),\n mapping: {\n skip: true,\n settings: {\n group: {\n map: {\n type: { value: 'company' },\n name: 'data.company',\n },\n },\n groupIdentify: {\n map: {\n type: { value: 'company' },\n name: 'data.company',\n set: {\n map: {\n industry: 'data.industry',\n size: 'data.employee_count',\n },\n },\n setOnce: {\n map: {\n founded: 'data.founded_year',\n },\n },\n },\n },\n },\n },\n out: [\n ['amplitude.setGroup', 'company', 'Acme'],\n [\n 'amplitude.groupIdentify',\n 'company',\n 'Acme',\n {\n set: {\n industry: 'tech',\n size: 50,\n },\n setOnce: {\n founded: 2020,\n },\n },\n ],\n ],\n};\n\n/**\n * EventOptions mapping -- `settings.eventOptions` maps walkerOS fields\n * to Amplitude per-event metadata. Here `time` maps from the event\n * timestamp and `insert_id` maps from the event id for deduplication.\n */\nexport const eventOptionsTimeInsertId: AmplitudeStepExample = {\n in: getEvent('page view', { timestamp: 1700000110 }),\n settings: {\n eventOptions: {\n map: {\n time: 'timestamp',\n insert_id: 'id',\n },\n },\n },\n out: [\n 'amplitude.track',\n 'page view',\n {},\n {\n time: 1700000110,\n insert_id: '1700000110-gr0up-1',\n },\n ],\n};\n\n/**\n * Consent revoked -> amplitude.setOptOut(true). The destination checks\n * the consent keys declared in config.consent and toggles optOut\n * accordingly (strict: all required keys must be granted).\n *\n * Uses the canonical StepExample.command='consent' pattern: the test\n * runner dispatches via elb('walker consent', in) instead of pushing\n * an event.\n */\nexport const consentRevokeOptOut: AmplitudeStepExample = {\n command: 'consent',\n in: { analytics: false } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: ['amplitude.setOptOut', true],\n};\n\n/**\n * Consent granted -> amplitude.setOptOut(false).\n */\nexport const consentGrantOptIn: AmplitudeStepExample = {\n command: 'consent',\n in: { analytics: true } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: ['amplitude.setOptOut', false],\n};\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,mBAAmB;;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