@walkeros/web-destination-amplitude 4.2.0 → 4.2.1-next-1781538735002
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 +8 -0
- package/dist/dev.d.mts +3 -1
- package/dist/dev.d.ts +3 -1
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.d.mts +3 -1
- package/dist/examples/index.d.ts +3 -1
- package/dist/examples/index.js +5 -1
- package/dist/examples/index.mjs +5 -1
- package/dist/walkerOS.json +18 -11
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @walkeros/web-destination-amplitude
|
|
2
2
|
|
|
3
|
+
## 4.2.1-next-1781538735002
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [5cbcd23]
|
|
8
|
+
- @walkeros/core@4.2.1-next-1781538735002
|
|
9
|
+
- @walkeros/web-core@4.2.1-next-1781538735002
|
|
10
|
+
|
|
3
11
|
## 4.2.0
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/dev.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
2
2
|
import { z } from '@walkeros/core/dev';
|
|
3
|
-
import { Mapping as Mapping$1, Flow } from '@walkeros/core';
|
|
3
|
+
import { Mapping as Mapping$1, Flow, WalkerOS } from '@walkeros/core';
|
|
4
4
|
import { DestinationWeb } from '@walkeros/web-core';
|
|
5
5
|
import { Types } from '@amplitude/unified';
|
|
6
6
|
import { SessionReplayOptions } from '@amplitude/plugin-session-replay-browser';
|
|
@@ -171,6 +171,8 @@ declare namespace env {
|
|
|
171
171
|
type AmplitudeStepExample = Flow.StepExample & {
|
|
172
172
|
settings?: Partial<Settings>;
|
|
173
173
|
configInclude?: string[];
|
|
174
|
+
/** Consent granted before `in` so a gated destination is loaded first. */
|
|
175
|
+
before?: WalkerOS.Consent;
|
|
174
176
|
};
|
|
175
177
|
/**
|
|
176
178
|
* Default event forwarding - every walkerOS event becomes
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _walkeros_core_dev from '@walkeros/core/dev';
|
|
2
2
|
import { z } from '@walkeros/core/dev';
|
|
3
|
-
import { Mapping as Mapping$1, Flow } from '@walkeros/core';
|
|
3
|
+
import { Mapping as Mapping$1, Flow, WalkerOS } from '@walkeros/core';
|
|
4
4
|
import { DestinationWeb } from '@walkeros/web-core';
|
|
5
5
|
import { Types } from '@amplitude/unified';
|
|
6
6
|
import { SessionReplayOptions } from '@amplitude/plugin-session-replay-browser';
|
|
@@ -171,6 +171,8 @@ declare namespace env {
|
|
|
171
171
|
type AmplitudeStepExample = Flow.StepExample & {
|
|
172
172
|
settings?: Partial<Settings>;
|
|
173
173
|
configInclude?: string[];
|
|
174
|
+
/** Consent granted before `in` so a gated destination is loaded first. */
|
|
175
|
+
before?: WalkerOS.Consent;
|
|
174
176
|
};
|
|
175
177
|
/**
|
|
176
178
|
* Default event forwarding - every walkerOS event becomes
|
package/dist/dev.js
CHANGED
|
@@ -1 +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 d of i(a))r.call(e,d)||d===s||t(e,d,{get:()=>a[d],enumerable:!(o=n(a,d))||o.enumerable});return e})(t({},"__esModule",{value:!0}),e));var o={};a(o,{MappingSchema:()=>c,SettingsSchema:()=>p,mapping:()=>v,settings:()=>m});var d=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),p=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" (like a1b2c3d4e5f6789012345678abcdef12).'),serverZone:u.z.enum(["US","EU"]).describe("Amplitude server zone. Default: US.").optional(),flushIntervalMillis:u.z.number().int().positive().describe("How often (in ms) to flush the event queue. Default: 1000.").optional(),flushQueueSize:u.z.number().int().positive().describe("Max queued events before a flush. Default: 30.").optional(),flushMaxRetries:u.z.number().int().nonnegative().describe("Max retries on failed flush. Default: 5.").optional(),transport:u.z.enum(["fetch","xhr","beacon"]).describe("HTTP transport. Default: fetch.").optional(),useBatch:u.z.boolean().describe("Use the Amplitude batch endpoint instead of the standard endpoint. Default: false.").optional(),appVersion:u.z.string().describe("Application version; tagged onto every event.").optional(),identify:u.z.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: user, device, session, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.").optional(),sessionReplay:u.z.unknown().describe("Session Replay options. When present, session replay is enabled via @amplitude/unified with the provided options.").optional(),experiment:u.z.unknown().describe("Feature Experiment config. Must include `deploymentKey`. When present, the experiment plugin from @amplitude/unified is configured with the provided options.").optional(),engagement:u.z.unknown().describe("Guides & Surveys config. Pass `true` for defaults, or an options object for custom configuration. Enabled via @amplitude/unified.").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, device, session, 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 of objects, 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).").optional(),groupIdentify:l.z.unknown().describe("Group properties. Resolves to { type, name, set?, setOnce?, ... } → amplitude.groupIdentify(type, name, identify).").optional(),reset:l.z.unknown().describe("Logout trigger. Resolves to a truthy value → amplitude.reset() (clears userId, regenerates deviceId). Typically used with silent: true on a user logout rule.").optional()}),m=(0,d.zodToSchema)(p),v=(0,d.zodToSchema)(c),y={};a(y,{env:()=>g,step:()=>O});var g={};a(g,{init:()=>_,push:()=>w,simulation:()=>k});var h=()=>{},f=()=>({promise:Promise.resolve()}),b=class{constructor(){this._ops={}}_record(e,t,n){return this._ops[e]||(this._ops[e]={}),this._ops[e][t]=n,this}set(e,t){return this._record("set",e,t)}setOnce(e,t){return this._record("setOnce",e,t)}add(e,t){return this._record("add",e,t)}append(e,t){return this._record("append",e,t)}prepend(e,t){return this._record("prepend",e,t)}preInsert(e,t){return this._record("preInsert",e,t)}postInsert(e,t){return this._record("postInsert",e,t)}remove(e,t){return this._record("remove",e,t)}unset(e){return this._record("unset",e)}clearAll(){return this._ops.clearAll={},this}toJSON(){return this._ops}},I=class{constructor(){this._data={}}setProductId(e){return this._data.productId=e,this}setPrice(e){return this._data.price=e,this}setQuantity(e){return this._data.quantity=e,this}setRevenueType(e){return this._data.revenueType=e,this}setCurrency(e){return this._data.currency=e,this}setRevenue(e){return this._data.revenue=e,this}setReceipt(e){return this._data.receipt=e,this}setReceiptSig(e){return this._data.receiptSig=e,this}setEventProperties(e){return this._data.eventProperties=e,this}toJSON(){return this._data}},_={amplitude:{initAll:()=>Promise.resolve(),track:h,identify:h,revenue:h,reset:h,setOptOut:h,setUserId:h,setDeviceId:h,setSessionId:h,setGroup:h,groupIdentify:h,flush:f,add:f,Identify:b,Revenue:I}},w={amplitude:{initAll:()=>Promise.resolve(),track:h,identify:h,revenue:h,reset:h,setOptOut:h,setUserId:h,setDeviceId:h,setSessionId:h,setGroup:h,groupIdentify:h,flush:f,add:f,Identify:b,Revenue:I}},k=["call:amplitude.initAll","call:amplitude.track","call:amplitude.identify","call:amplitude.revenue","call:amplitude.reset","call:amplitude.setOptOut","call:amplitude.setUserId","call:amplitude.setDeviceId","call:amplitude.setSessionId","call:amplitude.setGroup","call:amplitude.groupIdentify"],O={};a(O,{consentGrantOptIn:()=>x,consentRevokeOptOut:()=>G,defaultEventForwarding:()=>R,destinationLevelIdentify:()=>P,destinationLevelInclude:()=>E,groupAssignmentWithProperties:()=>T,orderCompleteMultiProduct:()=>q,ruleIncludeReplaces:()=>S,subscriptionRenewRevenue:()=>j,userLoginIdentify:()=>U,userLogoutReset:()=>D,wildcardIgnored:()=>z});var A=require("@walkeros/core"),R={title:"Default track",description:"A walker event is forwarded to Amplitude as an amplitude.track call with the event name and empty properties.",in:(0,A.getEvent)("product view",{timestamp:1700000100}),out:[["amplitude.track","product view",{}]]},z={public:!1,in:(0,A.getEvent)("debug noise",{timestamp:1700000101}),mapping:{ignore:!0},out:[]},E={title:"Include data",description:"Destination-level include flattens the event data section into prefixed event_properties on every track call.",in:(0,A.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}]]},S={title:"Rule include overrides",description:"A per-rule include replaces the destination-level include for the matched event, here using only globals.",in:(0,A.getEvent)("order complete",{timestamp:1700000103}),configInclude:["data"],mapping:{include:["globals"]},out:[["amplitude.track","order complete",{globals_pagegroup:"shop"}]]},P={title:"Destination identify",description:"Destination-level identify sets userId, deviceId, and sessionId on the Amplitude client before sending events; setters only re-fire when the resolved values change (cached values are not re-applied on subsequent pushes).",in:(0,A.getEvent)("page view",{timestamp:1700000104}),settings:{identify:{map:{user:"user.id",device:"user.device",session:"user.session"}}},out:[["amplitude.setUserId","us3r"],["amplitude.setDeviceId","c00k13"],["amplitude.setSessionId",394324160],["amplitude.track","page view",{}]]},U={title:"User login identify",description:"A user login sets the Amplitude userId and runs identify with set, setOnce, and add operations.",in:(0,A.getEvent)("user login",{timestamp:1700000105,data:{user_id:"new-user-123",plan:"premium",company:"Acme",email:"user@acme.com"}}),mapping:{silent:!0,settings:{identify:{map:{user:"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.setUserId","new-user-123"],["amplitude.identify",{set:{plan:"premium",company:"Acme",email:"user@acme.com"},setOnce:{first_login:1700000105},add:{login_count:1}}]]},D={title:"User logout reset",description:"A user logout calls amplitude.reset to clear the userId and regenerate the deviceId.",in:(0,A.getEvent)("user logout",{timestamp:1700000106}),mapping:{silent:!0,settings:{reset:!0}},out:[["amplitude.reset"]]},j={title:"Subscription revenue",description:"A subscription renewal fires a single amplitude.revenue call with productId, price, and currency fallback.",in:(0,A.getEvent)("subscription renew",{timestamp:1700000107,data:{plan_id:"plan-pro",amount:9.99}}),mapping:{silent:!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={title:"Multi-product order",description:"An order fires one amplitude.revenue call per nested product plus a single track for the order totals.",in:(0,A.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"}]]},T={title:"Group assignment",description:"A company update assigns the user to a group and sets group properties via setGroup and groupIdentify.",in:(0,A.getEvent)("company update",{timestamp:1700000109,data:{company:"Acme",industry:"tech",employee_count:50,founded_year:2020}}),mapping:{silent:!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}}]]},G={title:"Consent revoked",description:"A walker consent command with analytics denied opts out of Amplitude tracking via setOptOut(true).",command:"consent",in:{analytics:!1},settings:{},out:[["amplitude.setOptOut",!0]]},x={title:"Consent granted",description:"A walker consent command with analytics granted opts back into Amplitude tracking via setOptOut(false).",command:"consent",in:{analytics:!0},settings:{},out:[["amplitude.setOptOut",!1]]};//# sourceMappingURL=dev.js.map
|
|
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 d of i(a))r.call(e,d)||d===s||t(e,d,{get:()=>a[d],enumerable:!(o=n(a,d))||o.enumerable});return e})(t({},"__esModule",{value:!0}),e));var o={};a(o,{MappingSchema:()=>c,SettingsSchema:()=>p,mapping:()=>v,settings:()=>m});var d=require("@walkeros/core/dev"),u=require("@walkeros/core/dev"),p=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" (like a1b2c3d4e5f6789012345678abcdef12).'),serverZone:u.z.enum(["US","EU"]).describe("Amplitude server zone. Default: US.").optional(),flushIntervalMillis:u.z.number().int().positive().describe("How often (in ms) to flush the event queue. Default: 1000.").optional(),flushQueueSize:u.z.number().int().positive().describe("Max queued events before a flush. Default: 30.").optional(),flushMaxRetries:u.z.number().int().nonnegative().describe("Max retries on failed flush. Default: 5.").optional(),transport:u.z.enum(["fetch","xhr","beacon"]).describe("HTTP transport. Default: fetch.").optional(),useBatch:u.z.boolean().describe("Use the Amplitude batch endpoint instead of the standard endpoint. Default: false.").optional(),appVersion:u.z.string().describe("Application version; tagged onto every event.").optional(),identify:u.z.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: user, device, session, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.").optional(),sessionReplay:u.z.unknown().describe("Session Replay options. When present, session replay is enabled via @amplitude/unified with the provided options.").optional(),experiment:u.z.unknown().describe("Feature Experiment config. Must include `deploymentKey`. When present, the experiment plugin from @amplitude/unified is configured with the provided options.").optional(),engagement:u.z.unknown().describe("Guides & Surveys config. Pass `true` for defaults, or an options object for custom configuration. Enabled via @amplitude/unified.").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, device, session, 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 of objects, 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).").optional(),groupIdentify:l.z.unknown().describe("Group properties. Resolves to { type, name, set?, setOnce?, ... } → amplitude.groupIdentify(type, name, identify).").optional(),reset:l.z.unknown().describe("Logout trigger. Resolves to a truthy value → amplitude.reset() (clears userId, regenerates deviceId). Typically used with silent: true on a user logout rule.").optional()}),m=(0,d.zodToSchema)(p),v=(0,d.zodToSchema)(c),y={};a(y,{env:()=>g,step:()=>O});var g={};a(g,{init:()=>_,push:()=>w,simulation:()=>k});var h=()=>{},f=()=>({promise:Promise.resolve()}),b=class{constructor(){this._ops={}}_record(e,t,n){return this._ops[e]||(this._ops[e]={}),this._ops[e][t]=n,this}set(e,t){return this._record("set",e,t)}setOnce(e,t){return this._record("setOnce",e,t)}add(e,t){return this._record("add",e,t)}append(e,t){return this._record("append",e,t)}prepend(e,t){return this._record("prepend",e,t)}preInsert(e,t){return this._record("preInsert",e,t)}postInsert(e,t){return this._record("postInsert",e,t)}remove(e,t){return this._record("remove",e,t)}unset(e){return this._record("unset",e)}clearAll(){return this._ops.clearAll={},this}toJSON(){return this._ops}},I=class{constructor(){this._data={}}setProductId(e){return this._data.productId=e,this}setPrice(e){return this._data.price=e,this}setQuantity(e){return this._data.quantity=e,this}setRevenueType(e){return this._data.revenueType=e,this}setCurrency(e){return this._data.currency=e,this}setRevenue(e){return this._data.revenue=e,this}setReceipt(e){return this._data.receipt=e,this}setReceiptSig(e){return this._data.receiptSig=e,this}setEventProperties(e){return this._data.eventProperties=e,this}toJSON(){return this._data}},_={amplitude:{initAll:()=>Promise.resolve(),track:h,identify:h,revenue:h,reset:h,setOptOut:h,setUserId:h,setDeviceId:h,setSessionId:h,setGroup:h,groupIdentify:h,flush:f,add:f,Identify:b,Revenue:I}},w={amplitude:{initAll:()=>Promise.resolve(),track:h,identify:h,revenue:h,reset:h,setOptOut:h,setUserId:h,setDeviceId:h,setSessionId:h,setGroup:h,groupIdentify:h,flush:f,add:f,Identify:b,Revenue:I}},k=["call:amplitude.initAll","call:amplitude.track","call:amplitude.identify","call:amplitude.revenue","call:amplitude.reset","call:amplitude.setOptOut","call:amplitude.setUserId","call:amplitude.setDeviceId","call:amplitude.setSessionId","call:amplitude.setGroup","call:amplitude.groupIdentify"],O={};a(O,{consentGrantOptIn:()=>x,consentRevokeOptOut:()=>G,defaultEventForwarding:()=>R,destinationLevelIdentify:()=>P,destinationLevelInclude:()=>E,groupAssignmentWithProperties:()=>T,orderCompleteMultiProduct:()=>q,ruleIncludeReplaces:()=>S,subscriptionRenewRevenue:()=>j,userLoginIdentify:()=>U,userLogoutReset:()=>D,wildcardIgnored:()=>z});var A=require("@walkeros/core"),R={title:"Default track",description:"A walker event is forwarded to Amplitude as an amplitude.track call with the event name and empty properties.",in:(0,A.getEvent)("product view",{timestamp:1700000100}),out:[["amplitude.track","product view",{}]]},z={public:!1,in:(0,A.getEvent)("debug noise",{timestamp:1700000101}),mapping:{ignore:!0},out:[]},E={title:"Include data",description:"Destination-level include flattens the event data section into prefixed event_properties on every track call.",in:(0,A.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}]]},S={title:"Rule include overrides",description:"A per-rule include replaces the destination-level include for the matched event, here using only globals.",in:(0,A.getEvent)("order complete",{timestamp:1700000103}),configInclude:["data"],mapping:{include:["globals"]},out:[["amplitude.track","order complete",{globals_pagegroup:"shop"}]]},P={title:"Destination identify",description:"Destination-level identify sets userId, deviceId, and sessionId on the Amplitude client before sending events; setters only re-fire when the resolved values change (cached values are not re-applied on subsequent pushes).",in:(0,A.getEvent)("page view",{timestamp:1700000104}),settings:{identify:{map:{user:"user.id",device:"user.device",session:"user.session"}}},out:[["amplitude.setUserId","us3r"],["amplitude.setDeviceId","c00k13"],["amplitude.setSessionId",394324160],["amplitude.track","page view",{}]]},U={title:"User login identify",description:"A user login sets the Amplitude userId and runs identify with set, setOnce, and add operations.",in:(0,A.getEvent)("user login",{timestamp:1700000105,data:{user_id:"new-user-123",plan:"premium",company:"Acme",email:"user@acme.com"}}),mapping:{silent:!0,settings:{identify:{map:{user:"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.setUserId","new-user-123"],["amplitude.identify",{set:{plan:"premium",company:"Acme",email:"user@acme.com"},setOnce:{first_login:1700000105},add:{login_count:1}}]]},D={title:"User logout reset",description:"A user logout calls amplitude.reset to clear the userId and regenerate the deviceId.",in:(0,A.getEvent)("user logout",{timestamp:1700000106}),mapping:{silent:!0,settings:{reset:!0}},out:[["amplitude.reset"]]},j={title:"Subscription revenue",description:"A subscription renewal fires a single amplitude.revenue call with productId, price, and currency fallback.",in:(0,A.getEvent)("subscription renew",{timestamp:1700000107,data:{plan_id:"plan-pro",amount:9.99}}),mapping:{silent:!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={title:"Multi-product order",description:"An order fires one amplitude.revenue call per nested product plus a single track for the order totals.",in:(0,A.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"}]]},T={title:"Group assignment",description:"A company update assigns the user to a group and sets group properties via setGroup and groupIdentify.",in:(0,A.getEvent)("company update",{timestamp:1700000109,data:{company:"Acme",industry:"tech",employee_count:50,founded_year:2020}}),mapping:{silent:!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}}]]},G={title:"Consent revoked",description:"A walker consent command with analytics denied opts out of Amplitude tracking via setOptOut(true).",command:"consent",before:{analytics:!0},in:{analytics:!1},settings:{},out:[["amplitude.setOptOut",!1],["amplitude.setOptOut",!0]]},x={title:"Consent granted",description:"A walker consent command with analytics granted opts back into Amplitude tracking via setOptOut(false).",command:"consent",in:{analytics:!0},settings:{},out:[["amplitude.setOptOut",!1]]};//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/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\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n 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\" (like a1b2c3d4e5f6789012345678abcdef12).',\n ),\n serverZone: z\n .enum(['US', 'EU'])\n .describe('Amplitude server zone. Default: US.')\n .optional(),\n flushIntervalMillis: z\n .number()\n .int()\n .positive()\n .describe('How often (in ms) to flush the event queue. Default: 1000.')\n .optional(),\n flushQueueSize: z\n .number()\n .int()\n .positive()\n .describe('Max queued events before a flush. Default: 30.')\n .optional(),\n flushMaxRetries: z\n .number()\n .int()\n .nonnegative()\n .describe('Max retries on failed flush. Default: 5.')\n .optional(),\n transport: z\n .enum(['fetch', 'xhr', 'beacon'])\n .describe('HTTP transport. Default: fetch.')\n .optional(),\n useBatch: z\n .boolean()\n .describe(\n 'Use the Amplitude batch endpoint instead of the standard endpoint. Default: false.',\n )\n .optional(),\n appVersion: z\n .string()\n .describe('Application version; tagged onto every event.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to an identity object. Keys: user, device, session, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.',\n )\n .optional(),\n sessionReplay: z\n .unknown()\n .describe(\n 'Session Replay options. When present, session replay is enabled via @amplitude/unified with the provided options.',\n )\n .optional(),\n experiment: z\n .unknown()\n .describe(\n 'Feature Experiment config. Must include `deploymentKey`. When present, the experiment plugin from @amplitude/unified is configured with the provided options.',\n )\n .optional(),\n engagement: z\n .unknown()\n .describe(\n 'Guides & Surveys config. Pass `true` for defaults, or an options object for custom configuration. Enabled via @amplitude/unified.',\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, device, session, 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 of objects, 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).',\n )\n .optional(),\n groupIdentify: z\n .unknown()\n .describe(\n 'Group properties. Resolves to { type, name, set?, setOnce?, ... } → amplitude.groupIdentify(type, name, identify).',\n )\n .optional(),\n reset: z\n .unknown()\n .describe(\n 'Logout trigger. Resolves to a truthy value → amplitude.reset() (clears userId, regenerates deviceId). Typically used with silent: true on a user logout 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\n/**\n * Example environment configurations for the Amplitude destination.\n *\n * Tests clone `push` and replace individual methods with jest spies.\n * Production leaves `env.amplitude` undefined — the destination falls back\n * to the real `@amplitude/unified` module namespace.\n */\n\nconst noop = () => {};\nconst noopPromise = () => ({ promise: Promise.resolve() });\n\n/**\n * Minimal chainable Identify mock. The real SDK class has the same shape.\n * Tests spy by replacing these methods with jest.fn() in the test runner.\n */\nclass MockIdentify implements IdentifyInstance {\n _ops: Record<string, Record<string, unknown>> = {};\n\n private _record(op: string, prop: string, value?: unknown) {\n if (!this._ops[op]) this._ops[op] = {};\n this._ops[op][prop] = value;\n return this;\n }\n\n set(prop: string, value: unknown) {\n return this._record('set', prop, value);\n }\n setOnce(prop: string, value: unknown) {\n return this._record('setOnce', prop, value);\n }\n add(prop: string, value: unknown) {\n return this._record('add', prop, value);\n }\n append(prop: string, value: unknown) {\n return this._record('append', prop, value);\n }\n prepend(prop: string, value: unknown) {\n return this._record('prepend', prop, value);\n }\n preInsert(prop: string, value: unknown) {\n return this._record('preInsert', prop, value);\n }\n postInsert(prop: string, value: unknown) {\n return this._record('postInsert', prop, value);\n }\n remove(prop: string, value: unknown) {\n return this._record('remove', prop, value);\n }\n unset(prop: string) {\n return this._record('unset', prop);\n }\n clearAll() {\n this._ops['clearAll'] = {};\n return this;\n }\n\n toJSON() {\n return this._ops;\n }\n}\n\n/** Minimal chainable Revenue mock. */\nclass MockRevenue implements RevenueInstance {\n _data: Record<string, unknown> = {};\n\n setProductId(v: string) {\n this._data.productId = v;\n return this;\n }\n setPrice(v: number) {\n this._data.price = v;\n return this;\n }\n setQuantity(v: number) {\n this._data.quantity = v;\n return this;\n }\n setRevenueType(v: string) {\n this._data.revenueType = v;\n return this;\n }\n setCurrency(v: string) {\n this._data.currency = v;\n return this;\n }\n setRevenue(v: number) {\n this._data.revenue = v;\n return this;\n }\n setReceipt(v: string) {\n this._data.receipt = v;\n return this;\n }\n setReceiptSig(v: string) {\n this._data.receiptSig = v;\n return this;\n }\n setEventProperties(v: unknown) {\n this._data.eventProperties = v;\n return this;\n }\n\n toJSON() {\n return this._data;\n }\n}\n\n/**\n * Pre-init env — all methods are no-ops until the test runner wires spies.\n */\nexport const init: Env | undefined = {\n amplitude: {\n initAll: () => Promise.resolve(),\n track: noop,\n identify: noop,\n revenue: noop,\n reset: noop,\n setOptOut: noop,\n setUserId: noop,\n setDeviceId: noop,\n setSessionId: noop,\n setGroup: noop,\n groupIdentify: noop,\n flush: noopPromise,\n add: noopPromise,\n Identify: MockIdentify,\n Revenue: MockRevenue,\n },\n};\n\n/**\n * Post-init env — same shape. The test runner clones this and replaces\n * individual methods with jest.fn() so it can assert on calls.\n */\nexport const push: Env = {\n amplitude: {\n initAll: () => Promise.resolve(),\n track: noop,\n identify: noop,\n revenue: noop,\n reset: noop,\n setOptOut: noop,\n setUserId: noop,\n setDeviceId: noop,\n setSessionId: noop,\n setGroup: noop,\n groupIdentify: noop,\n flush: noopPromise,\n add: noopPromise,\n Identify: MockIdentify,\n Revenue: MockRevenue,\n },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:amplitude.initAll',\n 'call:amplitude.track',\n 'call:amplitude.identify',\n 'call:amplitude.revenue',\n 'call:amplitude.reset',\n 'call:amplitude.setOptOut',\n 'call:amplitude.setUserId',\n 'call:amplitude.setDeviceId',\n 'call:amplitude.setSessionId',\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 * Examples may optionally carry destination-level settings and/or an\n * `await` hint for async scenarios. The test runner reads `settings`\n * from the example and merges it into the base destination settings\n * on top of the fixed apiKey. `configInclude` is passed as config-level\n * include when registering the destination.\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 title: 'Default track',\n description:\n 'A walker event is forwarded to Amplitude as an amplitude.track call with the event name and empty properties.',\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 public: false,\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 title: 'Include data',\n description:\n 'Destination-level include flattens the event data section into prefixed event_properties on every track call.',\n in: getEvent('product view', { timestamp: 1700000102 }),\n configInclude: ['data'],\n out: [\n [\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/**\n * Per-rule settings.include REPLACES destination-level include for the\n * matched rule. Here destination-level sends `data`, but the rule\n * overrides it with `globals` only.\n */\nexport const ruleIncludeReplaces: AmplitudeStepExample = {\n title: 'Rule include overrides',\n description:\n 'A per-rule include replaces the destination-level include for the matched event, here using only globals.',\n in: getEvent('order complete', { timestamp: 1700000103 }),\n configInclude: ['data'],\n mapping: {\n include: ['globals'],\n },\n out: [\n [\n 'amplitude.track',\n 'order complete',\n {\n globals_pagegroup: 'shop',\n },\n ],\n ],\n};\n\n/**\n * Destination-level settings.identify fires on the first push (once the\n * state cache is empty). The destination sets user/device/session IDs\n * and tracks them in runtime state; subsequent pushes with unchanged\n * values do NOT re-fire the setters.\n *\n * This example represents the first push in a fresh session. user.id,\n * user.device, user.session come from the walkerOS session fixture.\n *\n * The walkerOS fixture's user.session is 's3ss10n' (string). The\n * destination deterministically hashes non-numeric session strings via\n * djb2 so the same walkerOS session always maps to the same Amplitude\n * session number (cross-page-load consistency). djb2('s3ss10n') = 394324160.\n */\nexport const destinationLevelIdentify: AmplitudeStepExample = {\n title: 'Destination identify',\n description:\n 'Destination-level identify sets userId, deviceId, and sessionId on the Amplitude client before sending events; setters only re-fire when the resolved values change (cached values are not re-applied on subsequent pushes).',\n in: getEvent('page view', { timestamp: 1700000104 }),\n settings: {\n identify: {\n map: {\n user: 'user.id',\n device: 'user.device',\n session: 'user.session',\n },\n },\n },\n out: [\n ['amplitude.setUserId', 'us3r'],\n ['amplitude.setDeviceId', 'c00k13'],\n ['amplitude.setSessionId', 394324160],\n ['amplitude.track', 'page view', {}],\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. `silent: true`\n * suppresses the default amplitude.track() call because we're running\n * identity side effects only.\n */\nexport const userLoginIdentify: AmplitudeStepExample = {\n title: 'User login identify',\n description:\n 'A user login sets the Amplitude userId and runs identify with set, setOnce, and add operations.',\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 silent: true,\n settings: {\n identify: {\n map: {\n user: '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.setUserId', 'new-user-123'],\n [\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 ],\n};\n\n/**\n * User logout - reset: true fires amplitude.reset(), which clears userId\n * and regenerates deviceId. `silent: true` because we're only running the\n * reset side effect, no default track().\n */\nexport const userLogoutReset: AmplitudeStepExample = {\n title: 'User logout reset',\n description:\n 'A user logout calls amplitude.reset to clear the userId and regenerate the deviceId.',\n in: getEvent('user logout', { timestamp: 1700000106 }),\n mapping: {\n silent: true,\n settings: {\n reset: true,\n },\n },\n out: [['amplitude.reset']],\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 walkerOS default event has no data.currency, so the fallback fires.\n */\nexport const subscriptionRenewRevenue: AmplitudeStepExample = {\n title: 'Subscription revenue',\n description:\n 'A subscription renewal fires a single amplitude.revenue call with productId, price, and currency fallback.',\n in: getEvent('subscription renew', {\n timestamp: 1700000107,\n data: {\n plan_id: 'plan-pro',\n amount: 9.99,\n },\n }),\n mapping: {\n silent: 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 [\n 'amplitude.revenue',\n {\n productId: 'plan-pro',\n price: 9.99,\n revenueType: 'renewal',\n currency: 'EUR',\n },\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 title: 'Multi-product order',\n description:\n 'An order fires one amplitude.revenue call per nested product plus a single track for the order totals.',\n in: getEvent('order complete', { timestamp: 1700000108 }),\n mapping: {\n include: ['data', 'globals'],\n settings: {\n revenue: {\n loop: [\n 'nested',\n {\n // Only iterate nested entries that have a price field (products).\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 title: 'Group assignment',\n description:\n 'A company update assigns the user to a group and sets group properties via setGroup and groupIdentify.',\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 silent: 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 * 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 title: 'Consent revoked',\n description:\n 'A walker consent command with analytics denied opts out of Amplitude tracking via setOptOut(true).',\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 title: 'Consent granted',\n description:\n 'A walker consent command with analytics granted opts back into Amplitude tracking via setOptOut(false).',\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,SAAS,qCAAqC,EAC9C,SAAS;AAAA,EACZ,qBAAqB,aAClB,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,4DAA4D,EACrE,SAAS;AAAA,EACZ,gBAAgB,aACb,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,gDAAgD,EACzD,SAAS;AAAA,EACZ,iBAAiB,aACd,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,SAAS,0CAA0C,EACnD,SAAS;AAAA,EACZ,WAAW,aACR,KAAK,CAAC,SAAS,OAAO,QAAQ,CAAC,EAC/B,SAAS,iCAAiC,EAC1C,SAAS;AAAA,EACZ,UAAU,aACP,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,YAAY,aACT,OAAO,EACP,SAAS,+CAA+C,EACxD,SAAS;AAAA,EACZ,UAAU,aACP,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,eAAe,aACZ,QAAQ,EACR;AAAA,IACC;AAAA,E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A,MACA;AAAA,MACA;AAAA,QACE,KAAK;AAAA,UACH,UAAU;AAAA,UACV,MAAM;AAAA,QACR;AAAA,QACA,SAAS;AAAA,UACP,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAWO,IAAM,sBAA4C;AAAA,EACvD,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,MAAM;AAAA,EACvB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,uBAAuB,IAAI,CAAC;AACrC;AAKO,IAAM,oBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,KAAK;AAAA,EACtB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,uBAAuB,KAAK,CAAC;AACtC;","names":["import_dev","import_dev"]}
|
|
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\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n 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\" (like a1b2c3d4e5f6789012345678abcdef12).',\n ),\n serverZone: z\n .enum(['US', 'EU'])\n .describe('Amplitude server zone. Default: US.')\n .optional(),\n flushIntervalMillis: z\n .number()\n .int()\n .positive()\n .describe('How often (in ms) to flush the event queue. Default: 1000.')\n .optional(),\n flushQueueSize: z\n .number()\n .int()\n .positive()\n .describe('Max queued events before a flush. Default: 30.')\n .optional(),\n flushMaxRetries: z\n .number()\n .int()\n .nonnegative()\n .describe('Max retries on failed flush. Default: 5.')\n .optional(),\n transport: z\n .enum(['fetch', 'xhr', 'beacon'])\n .describe('HTTP transport. Default: fetch.')\n .optional(),\n useBatch: z\n .boolean()\n .describe(\n 'Use the Amplitude batch endpoint instead of the standard endpoint. Default: false.',\n )\n .optional(),\n appVersion: z\n .string()\n .describe('Application version; tagged onto every event.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to an identity object. Keys: user, device, session, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.',\n )\n .optional(),\n sessionReplay: z\n .unknown()\n .describe(\n 'Session Replay options. When present, session replay is enabled via @amplitude/unified with the provided options.',\n )\n .optional(),\n experiment: z\n .unknown()\n .describe(\n 'Feature Experiment config. Must include `deploymentKey`. When present, the experiment plugin from @amplitude/unified is configured with the provided options.',\n )\n .optional(),\n engagement: z\n .unknown()\n .describe(\n 'Guides & Surveys config. Pass `true` for defaults, or an options object for custom configuration. Enabled via @amplitude/unified.',\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, device, session, 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 of objects, 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).',\n )\n .optional(),\n groupIdentify: z\n .unknown()\n .describe(\n 'Group properties. Resolves to { type, name, set?, setOnce?, ... } → amplitude.groupIdentify(type, name, identify).',\n )\n .optional(),\n reset: z\n .unknown()\n .describe(\n 'Logout trigger. Resolves to a truthy value → amplitude.reset() (clears userId, regenerates deviceId). Typically used with silent: true on a user logout 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\n/**\n * Example environment configurations for the Amplitude destination.\n *\n * Tests clone `push` and replace individual methods with jest spies.\n * Production leaves `env.amplitude` undefined — the destination falls back\n * to the real `@amplitude/unified` module namespace.\n */\n\nconst noop = () => {};\nconst noopPromise = () => ({ promise: Promise.resolve() });\n\n/**\n * Minimal chainable Identify mock. The real SDK class has the same shape.\n * Tests spy by replacing these methods with jest.fn() in the test runner.\n */\nclass MockIdentify implements IdentifyInstance {\n _ops: Record<string, Record<string, unknown>> = {};\n\n private _record(op: string, prop: string, value?: unknown) {\n if (!this._ops[op]) this._ops[op] = {};\n this._ops[op][prop] = value;\n return this;\n }\n\n set(prop: string, value: unknown) {\n return this._record('set', prop, value);\n }\n setOnce(prop: string, value: unknown) {\n return this._record('setOnce', prop, value);\n }\n add(prop: string, value: unknown) {\n return this._record('add', prop, value);\n }\n append(prop: string, value: unknown) {\n return this._record('append', prop, value);\n }\n prepend(prop: string, value: unknown) {\n return this._record('prepend', prop, value);\n }\n preInsert(prop: string, value: unknown) {\n return this._record('preInsert', prop, value);\n }\n postInsert(prop: string, value: unknown) {\n return this._record('postInsert', prop, value);\n }\n remove(prop: string, value: unknown) {\n return this._record('remove', prop, value);\n }\n unset(prop: string) {\n return this._record('unset', prop);\n }\n clearAll() {\n this._ops['clearAll'] = {};\n return this;\n }\n\n toJSON() {\n return this._ops;\n }\n}\n\n/** Minimal chainable Revenue mock. */\nclass MockRevenue implements RevenueInstance {\n _data: Record<string, unknown> = {};\n\n setProductId(v: string) {\n this._data.productId = v;\n return this;\n }\n setPrice(v: number) {\n this._data.price = v;\n return this;\n }\n setQuantity(v: number) {\n this._data.quantity = v;\n return this;\n }\n setRevenueType(v: string) {\n this._data.revenueType = v;\n return this;\n }\n setCurrency(v: string) {\n this._data.currency = v;\n return this;\n }\n setRevenue(v: number) {\n this._data.revenue = v;\n return this;\n }\n setReceipt(v: string) {\n this._data.receipt = v;\n return this;\n }\n setReceiptSig(v: string) {\n this._data.receiptSig = v;\n return this;\n }\n setEventProperties(v: unknown) {\n this._data.eventProperties = v;\n return this;\n }\n\n toJSON() {\n return this._data;\n }\n}\n\n/**\n * Pre-init env — all methods are no-ops until the test runner wires spies.\n */\nexport const init: Env | undefined = {\n amplitude: {\n initAll: () => Promise.resolve(),\n track: noop,\n identify: noop,\n revenue: noop,\n reset: noop,\n setOptOut: noop,\n setUserId: noop,\n setDeviceId: noop,\n setSessionId: noop,\n setGroup: noop,\n groupIdentify: noop,\n flush: noopPromise,\n add: noopPromise,\n Identify: MockIdentify,\n Revenue: MockRevenue,\n },\n};\n\n/**\n * Post-init env — same shape. The test runner clones this and replaces\n * individual methods with jest.fn() so it can assert on calls.\n */\nexport const push: Env = {\n amplitude: {\n initAll: () => Promise.resolve(),\n track: noop,\n identify: noop,\n revenue: noop,\n reset: noop,\n setOptOut: noop,\n setUserId: noop,\n setDeviceId: noop,\n setSessionId: noop,\n setGroup: noop,\n groupIdentify: noop,\n flush: noopPromise,\n add: noopPromise,\n Identify: MockIdentify,\n Revenue: MockRevenue,\n },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:amplitude.initAll',\n 'call:amplitude.track',\n 'call:amplitude.identify',\n 'call:amplitude.revenue',\n 'call:amplitude.reset',\n 'call:amplitude.setOptOut',\n 'call:amplitude.setUserId',\n 'call:amplitude.setDeviceId',\n 'call:amplitude.setSessionId',\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 * Examples may optionally carry destination-level settings and/or an\n * `await` hint for async scenarios. The test runner reads `settings`\n * from the example and merges it into the base destination settings\n * on top of the fixed apiKey. `configInclude` is passed as config-level\n * include when registering the destination.\n */\nexport type AmplitudeStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n /** Consent granted before `in` so a gated destination is loaded first. */\n before?: WalkerOS.Consent;\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 title: 'Default track',\n description:\n 'A walker event is forwarded to Amplitude as an amplitude.track call with the event name and empty properties.',\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 public: false,\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 title: 'Include data',\n description:\n 'Destination-level include flattens the event data section into prefixed event_properties on every track call.',\n in: getEvent('product view', { timestamp: 1700000102 }),\n configInclude: ['data'],\n out: [\n [\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/**\n * Per-rule settings.include REPLACES destination-level include for the\n * matched rule. Here destination-level sends `data`, but the rule\n * overrides it with `globals` only.\n */\nexport const ruleIncludeReplaces: AmplitudeStepExample = {\n title: 'Rule include overrides',\n description:\n 'A per-rule include replaces the destination-level include for the matched event, here using only globals.',\n in: getEvent('order complete', { timestamp: 1700000103 }),\n configInclude: ['data'],\n mapping: {\n include: ['globals'],\n },\n out: [\n [\n 'amplitude.track',\n 'order complete',\n {\n globals_pagegroup: 'shop',\n },\n ],\n ],\n};\n\n/**\n * Destination-level settings.identify fires on the first push (once the\n * state cache is empty). The destination sets user/device/session IDs\n * and tracks them in runtime state; subsequent pushes with unchanged\n * values do NOT re-fire the setters.\n *\n * This example represents the first push in a fresh session. user.id,\n * user.device, user.session come from the walkerOS session fixture.\n *\n * The walkerOS fixture's user.session is 's3ss10n' (string). The\n * destination deterministically hashes non-numeric session strings via\n * djb2 so the same walkerOS session always maps to the same Amplitude\n * session number (cross-page-load consistency). djb2('s3ss10n') = 394324160.\n */\nexport const destinationLevelIdentify: AmplitudeStepExample = {\n title: 'Destination identify',\n description:\n 'Destination-level identify sets userId, deviceId, and sessionId on the Amplitude client before sending events; setters only re-fire when the resolved values change (cached values are not re-applied on subsequent pushes).',\n in: getEvent('page view', { timestamp: 1700000104 }),\n settings: {\n identify: {\n map: {\n user: 'user.id',\n device: 'user.device',\n session: 'user.session',\n },\n },\n },\n out: [\n ['amplitude.setUserId', 'us3r'],\n ['amplitude.setDeviceId', 'c00k13'],\n ['amplitude.setSessionId', 394324160],\n ['amplitude.track', 'page view', {}],\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. `silent: true`\n * suppresses the default amplitude.track() call because we're running\n * identity side effects only.\n */\nexport const userLoginIdentify: AmplitudeStepExample = {\n title: 'User login identify',\n description:\n 'A user login sets the Amplitude userId and runs identify with set, setOnce, and add operations.',\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 silent: true,\n settings: {\n identify: {\n map: {\n user: '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.setUserId', 'new-user-123'],\n [\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 ],\n};\n\n/**\n * User logout - reset: true fires amplitude.reset(), which clears userId\n * and regenerates deviceId. `silent: true` because we're only running the\n * reset side effect, no default track().\n */\nexport const userLogoutReset: AmplitudeStepExample = {\n title: 'User logout reset',\n description:\n 'A user logout calls amplitude.reset to clear the userId and regenerate the deviceId.',\n in: getEvent('user logout', { timestamp: 1700000106 }),\n mapping: {\n silent: true,\n settings: {\n reset: true,\n },\n },\n out: [['amplitude.reset']],\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 walkerOS default event has no data.currency, so the fallback fires.\n */\nexport const subscriptionRenewRevenue: AmplitudeStepExample = {\n title: 'Subscription revenue',\n description:\n 'A subscription renewal fires a single amplitude.revenue call with productId, price, and currency fallback.',\n in: getEvent('subscription renew', {\n timestamp: 1700000107,\n data: {\n plan_id: 'plan-pro',\n amount: 9.99,\n },\n }),\n mapping: {\n silent: 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 [\n 'amplitude.revenue',\n {\n productId: 'plan-pro',\n price: 9.99,\n revenueType: 'renewal',\n currency: 'EUR',\n },\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 title: 'Multi-product order',\n description:\n 'An order fires one amplitude.revenue call per nested product plus a single track for the order totals.',\n in: getEvent('order complete', { timestamp: 1700000108 }),\n mapping: {\n include: ['data', 'globals'],\n settings: {\n revenue: {\n loop: [\n 'nested',\n {\n // Only iterate nested entries that have a price field (products).\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 title: 'Group assignment',\n description:\n 'A company update assigns the user to a group and sets group properties via setGroup and groupIdentify.',\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 silent: 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 * 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 title: 'Consent revoked',\n description:\n 'A walker consent command with analytics denied opts out of Amplitude tracking via setOptOut(true).',\n command: 'consent',\n before: { analytics: true },\n in: { analytics: false } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [\n ['amplitude.setOptOut', false],\n ['amplitude.setOptOut', true],\n ],\n};\n\n/**\n * Consent granted → amplitude.setOptOut(false).\n */\nexport const consentGrantOptIn: AmplitudeStepExample = {\n title: 'Consent granted',\n description:\n 'A walker consent command with analytics granted opts back into Amplitude tracking via setOptOut(false).',\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,SAAS,qCAAqC,EAC9C,SAAS;AAAA,EACZ,qBAAqB,aAClB,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,4DAA4D,EACrE,SAAS;A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QAAQ;AAAA,IACR,UAAU;AAAA,MACR,OAAO;AAAA,QACL,KAAK;AAAA,UACH,MAAM,EAAE,OAAO,UAAU;AAAA,UACzB,MAAM;AAAA,QACR;AAAA,MACF;AAAA,MACA,eAAe;AAAA,QACb,KAAK;AAAA,UACH,MAAM,EAAE,OAAO,UAAU;AAAA,UACzB,MAAM;AAAA,UACN,KAAK;AAAA,YACH,KAAK;AAAA,cACH,UAAU;AAAA,cACV,MAAM;AAAA,YACR;AAAA,UACF;AAAA,UACA,SAAS;AAAA,YACP,KAAK;AAAA,cACH,SAAS;AAAA,YACX;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EACA,KAAK;AAAA,IACH,CAAC,sBAAsB,WAAW,MAAM;AAAA,IACxC;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACE,KAAK;AAAA,UACH,UAAU;AAAA,UACV,MAAM;AAAA,QACR;AAAA,QACA,SAAS;AAAA,UACP,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAWO,IAAM,sBAA4C;AAAA,EACvD,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,QAAQ,EAAE,WAAW,KAAK;AAAA,EAC1B,IAAI,EAAE,WAAW,MAAM;AAAA,EACvB,UAAU,CAAC;AAAA,EACX,KAAK;AAAA,IACH,CAAC,uBAAuB,KAAK;AAAA,IAC7B,CAAC,uBAAuB,IAAI;AAAA,EAC9B;AACF;AAKO,IAAM,oBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,KAAK;AAAA,EACtB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,uBAAuB,KAAK,CAAC;AACtC;","names":["import_dev","import_dev"]}
|
package/dist/dev.mjs
CHANGED
|
@@ -1 +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:()=>p,settings:()=>d});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" (like a1b2c3d4e5f6789012345678abcdef12).'),serverZone:r.enum(["US","EU"]).describe("Amplitude server zone. Default: US.").optional(),flushIntervalMillis:r.number().int().positive().describe("How often (in ms) to flush the event queue. Default: 1000.").optional(),flushQueueSize:r.number().int().positive().describe("Max queued events before a flush. Default: 30.").optional(),flushMaxRetries:r.number().int().nonnegative().describe("Max retries on failed flush. Default: 5.").optional(),transport:r.enum(["fetch","xhr","beacon"]).describe("HTTP transport. Default: fetch.").optional(),useBatch:r.boolean().describe("Use the Amplitude batch endpoint instead of the standard endpoint. Default: false.").optional(),appVersion:r.string().describe("Application version; tagged onto every event.").optional(),identify:r.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: user, device, session, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.").optional(),sessionReplay:r.unknown().describe("Session Replay options. When present, session replay is enabled via @amplitude/unified with the provided options.").optional(),experiment:r.unknown().describe("Feature Experiment config. Must include `deploymentKey`. When present, the experiment plugin from @amplitude/unified is configured with the provided options.").optional(),engagement:r.unknown().describe("Guides & Surveys config. Pass `true` for defaults, or an options object for custom configuration. Enabled via @amplitude/unified.").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, device, session, 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 of objects, 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).").optional(),groupIdentify:s.unknown().describe("Group properties. Resolves to { type, name, set?, setOnce?, ... } → amplitude.groupIdentify(type, name, identify).").optional(),reset:s.unknown().describe("Logout trigger. Resolves to a truthy value → amplitude.reset() (clears userId, regenerates deviceId). Typically used with silent: true on a user logout rule.").optional()}),d=n(a),p=n(o),u={};t(u,{env:()=>l,step:()=>I});var l={};t(l,{init:()=>g,push:()=>h,simulation:()=>f});var c=()=>{},m=()=>({promise:Promise.resolve()}),v=class{constructor(){this._ops={}}_record(e,t,i){return this._ops[e]||(this._ops[e]={}),this._ops[e][t]=i,this}set(e,t){return this._record("set",e,t)}setOnce(e,t){return this._record("setOnce",e,t)}add(e,t){return this._record("add",e,t)}append(e,t){return this._record("append",e,t)}prepend(e,t){return this._record("prepend",e,t)}preInsert(e,t){return this._record("preInsert",e,t)}postInsert(e,t){return this._record("postInsert",e,t)}remove(e,t){return this._record("remove",e,t)}unset(e){return this._record("unset",e)}clearAll(){return this._ops.clearAll={},this}toJSON(){return this._ops}},y=class{constructor(){this._data={}}setProductId(e){return this._data.productId=e,this}setPrice(e){return this._data.price=e,this}setQuantity(e){return this._data.quantity=e,this}setRevenueType(e){return this._data.revenueType=e,this}setCurrency(e){return this._data.currency=e,this}setRevenue(e){return this._data.revenue=e,this}setReceipt(e){return this._data.receipt=e,this}setReceiptSig(e){return this._data.receiptSig=e,this}setEventProperties(e){return this._data.eventProperties=e,this}toJSON(){return this._data}},g={amplitude:{initAll:()=>Promise.resolve(),track:c,identify:c,revenue:c,reset:c,setOptOut:c,setUserId:c,setDeviceId:c,setSessionId:c,setGroup:c,groupIdentify:c,flush:m,add:m,Identify:v,Revenue:y}},h={amplitude:{initAll:()=>Promise.resolve(),track:c,identify:c,revenue:c,reset:c,setOptOut:c,setUserId:c,setDeviceId:c,setSessionId:c,setGroup:c,groupIdentify:c,flush:m,add:m,Identify:v,Revenue:y}},f=["call:amplitude.initAll","call:amplitude.track","call:amplitude.identify","call:amplitude.revenue","call:amplitude.reset","call:amplitude.setOptOut","call:amplitude.setUserId","call:amplitude.setDeviceId","call:amplitude.setSessionId","call:amplitude.setGroup","call:amplitude.groupIdentify"],I={};t(I,{consentGrantOptIn:()=>G,consentRevokeOptOut:()=>E,defaultEventForwarding:()=>_,destinationLevelIdentify:()=>O,destinationLevelInclude:()=>k,groupAssignmentWithProperties:()=>D,orderCompleteMultiProduct:()=>P,ruleIncludeReplaces:()=>A,subscriptionRenewRevenue:()=>U,userLoginIdentify:()=>R,userLogoutReset:()=>S,wildcardIgnored:()=>w});import{getEvent as b}from"@walkeros/core";var _={title:"Default track",description:"A walker event is forwarded to Amplitude as an amplitude.track call with the event name and empty properties.",in:b("product view",{timestamp:1700000100}),out:[["amplitude.track","product view",{}]]},w={public:!1,in:b("debug noise",{timestamp:1700000101}),mapping:{ignore:!0},out:[]},k={title:"Include data",description:"Destination-level include flattens the event data section into prefixed event_properties on every track call.",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}]]},A={title:"Rule include overrides",description:"A per-rule include replaces the destination-level include for the matched event, here using only globals.",in:b("order complete",{timestamp:1700000103}),configInclude:["data"],mapping:{include:["globals"]},out:[["amplitude.track","order complete",{globals_pagegroup:"shop"}]]},O={title:"Destination identify",description:"Destination-level identify sets userId, deviceId, and sessionId on the Amplitude client before sending events; setters only re-fire when the resolved values change (cached values are not re-applied on subsequent pushes).",in:b("page view",{timestamp:1700000104}),settings:{identify:{map:{user:"user.id",device:"user.device",session:"user.session"}}},out:[["amplitude.setUserId","us3r"],["amplitude.setDeviceId","c00k13"],["amplitude.setSessionId",394324160],["amplitude.track","page view",{}]]},R={title:"User login identify",description:"A user login sets the Amplitude userId and runs identify with set, setOnce, and add operations.",in:b("user login",{timestamp:1700000105,data:{user_id:"new-user-123",plan:"premium",company:"Acme",email:"user@acme.com"}}),mapping:{silent:!0,settings:{identify:{map:{user:"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.setUserId","new-user-123"],["amplitude.identify",{set:{plan:"premium",company:"Acme",email:"user@acme.com"},setOnce:{first_login:1700000105},add:{login_count:1}}]]},S={title:"User logout reset",description:"A user logout calls amplitude.reset to clear the userId and regenerate the deviceId.",in:b("user logout",{timestamp:1700000106}),mapping:{silent:!0,settings:{reset:!0}},out:[["amplitude.reset"]]},U={title:"Subscription revenue",description:"A subscription renewal fires a single amplitude.revenue call with productId, price, and currency fallback.",in:b("subscription renew",{timestamp:1700000107,data:{plan_id:"plan-pro",amount:9.99}}),mapping:{silent:!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"}]]},P={title:"Multi-product order",description:"An order fires one amplitude.revenue call per nested product plus a single track for the order totals.",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"}]]},D={title:"Group assignment",description:"A company update assigns the user to a group and sets group properties via setGroup and groupIdentify.",in:b("company update",{timestamp:1700000109,data:{company:"Acme",industry:"tech",employee_count:50,founded_year:2020}}),mapping:{silent:!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}}]]},E={title:"Consent revoked",description:"A walker consent command with analytics denied opts out of Amplitude tracking via setOptOut(true).",command:"consent",in:{analytics:!1},settings:{},out:[["amplitude.setOptOut",!0]]},G={title:"Consent granted",description:"A walker consent command with analytics granted opts back into Amplitude tracking via setOptOut(false).",command:"consent",in:{analytics:!0},settings:{},out:[["amplitude.setOptOut",!1]]};export{u as examples,i as schemas};//# sourceMappingURL=dev.mjs.map
|
|
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:()=>p,settings:()=>d});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" (like a1b2c3d4e5f6789012345678abcdef12).'),serverZone:r.enum(["US","EU"]).describe("Amplitude server zone. Default: US.").optional(),flushIntervalMillis:r.number().int().positive().describe("How often (in ms) to flush the event queue. Default: 1000.").optional(),flushQueueSize:r.number().int().positive().describe("Max queued events before a flush. Default: 30.").optional(),flushMaxRetries:r.number().int().nonnegative().describe("Max retries on failed flush. Default: 5.").optional(),transport:r.enum(["fetch","xhr","beacon"]).describe("HTTP transport. Default: fetch.").optional(),useBatch:r.boolean().describe("Use the Amplitude batch endpoint instead of the standard endpoint. Default: false.").optional(),appVersion:r.string().describe("Application version; tagged onto every event.").optional(),identify:r.unknown().describe("walkerOS mapping value resolving to an identity object. Keys: user, device, session, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.").optional(),sessionReplay:r.unknown().describe("Session Replay options. When present, session replay is enabled via @amplitude/unified with the provided options.").optional(),experiment:r.unknown().describe("Feature Experiment config. Must include `deploymentKey`. When present, the experiment plugin from @amplitude/unified is configured with the provided options.").optional(),engagement:r.unknown().describe("Guides & Surveys config. Pass `true` for defaults, or an options object for custom configuration. Enabled via @amplitude/unified.").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, device, session, 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 of objects, 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).").optional(),groupIdentify:s.unknown().describe("Group properties. Resolves to { type, name, set?, setOnce?, ... } → amplitude.groupIdentify(type, name, identify).").optional(),reset:s.unknown().describe("Logout trigger. Resolves to a truthy value → amplitude.reset() (clears userId, regenerates deviceId). Typically used with silent: true on a user logout rule.").optional()}),d=n(a),p=n(o),u={};t(u,{env:()=>l,step:()=>I});var l={};t(l,{init:()=>g,push:()=>h,simulation:()=>f});var c=()=>{},m=()=>({promise:Promise.resolve()}),v=class{constructor(){this._ops={}}_record(e,t,i){return this._ops[e]||(this._ops[e]={}),this._ops[e][t]=i,this}set(e,t){return this._record("set",e,t)}setOnce(e,t){return this._record("setOnce",e,t)}add(e,t){return this._record("add",e,t)}append(e,t){return this._record("append",e,t)}prepend(e,t){return this._record("prepend",e,t)}preInsert(e,t){return this._record("preInsert",e,t)}postInsert(e,t){return this._record("postInsert",e,t)}remove(e,t){return this._record("remove",e,t)}unset(e){return this._record("unset",e)}clearAll(){return this._ops.clearAll={},this}toJSON(){return this._ops}},y=class{constructor(){this._data={}}setProductId(e){return this._data.productId=e,this}setPrice(e){return this._data.price=e,this}setQuantity(e){return this._data.quantity=e,this}setRevenueType(e){return this._data.revenueType=e,this}setCurrency(e){return this._data.currency=e,this}setRevenue(e){return this._data.revenue=e,this}setReceipt(e){return this._data.receipt=e,this}setReceiptSig(e){return this._data.receiptSig=e,this}setEventProperties(e){return this._data.eventProperties=e,this}toJSON(){return this._data}},g={amplitude:{initAll:()=>Promise.resolve(),track:c,identify:c,revenue:c,reset:c,setOptOut:c,setUserId:c,setDeviceId:c,setSessionId:c,setGroup:c,groupIdentify:c,flush:m,add:m,Identify:v,Revenue:y}},h={amplitude:{initAll:()=>Promise.resolve(),track:c,identify:c,revenue:c,reset:c,setOptOut:c,setUserId:c,setDeviceId:c,setSessionId:c,setGroup:c,groupIdentify:c,flush:m,add:m,Identify:v,Revenue:y}},f=["call:amplitude.initAll","call:amplitude.track","call:amplitude.identify","call:amplitude.revenue","call:amplitude.reset","call:amplitude.setOptOut","call:amplitude.setUserId","call:amplitude.setDeviceId","call:amplitude.setSessionId","call:amplitude.setGroup","call:amplitude.groupIdentify"],I={};t(I,{consentGrantOptIn:()=>G,consentRevokeOptOut:()=>E,defaultEventForwarding:()=>_,destinationLevelIdentify:()=>O,destinationLevelInclude:()=>k,groupAssignmentWithProperties:()=>D,orderCompleteMultiProduct:()=>P,ruleIncludeReplaces:()=>A,subscriptionRenewRevenue:()=>U,userLoginIdentify:()=>R,userLogoutReset:()=>S,wildcardIgnored:()=>w});import{getEvent as b}from"@walkeros/core";var _={title:"Default track",description:"A walker event is forwarded to Amplitude as an amplitude.track call with the event name and empty properties.",in:b("product view",{timestamp:1700000100}),out:[["amplitude.track","product view",{}]]},w={public:!1,in:b("debug noise",{timestamp:1700000101}),mapping:{ignore:!0},out:[]},k={title:"Include data",description:"Destination-level include flattens the event data section into prefixed event_properties on every track call.",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}]]},A={title:"Rule include overrides",description:"A per-rule include replaces the destination-level include for the matched event, here using only globals.",in:b("order complete",{timestamp:1700000103}),configInclude:["data"],mapping:{include:["globals"]},out:[["amplitude.track","order complete",{globals_pagegroup:"shop"}]]},O={title:"Destination identify",description:"Destination-level identify sets userId, deviceId, and sessionId on the Amplitude client before sending events; setters only re-fire when the resolved values change (cached values are not re-applied on subsequent pushes).",in:b("page view",{timestamp:1700000104}),settings:{identify:{map:{user:"user.id",device:"user.device",session:"user.session"}}},out:[["amplitude.setUserId","us3r"],["amplitude.setDeviceId","c00k13"],["amplitude.setSessionId",394324160],["amplitude.track","page view",{}]]},R={title:"User login identify",description:"A user login sets the Amplitude userId and runs identify with set, setOnce, and add operations.",in:b("user login",{timestamp:1700000105,data:{user_id:"new-user-123",plan:"premium",company:"Acme",email:"user@acme.com"}}),mapping:{silent:!0,settings:{identify:{map:{user:"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.setUserId","new-user-123"],["amplitude.identify",{set:{plan:"premium",company:"Acme",email:"user@acme.com"},setOnce:{first_login:1700000105},add:{login_count:1}}]]},S={title:"User logout reset",description:"A user logout calls amplitude.reset to clear the userId and regenerate the deviceId.",in:b("user logout",{timestamp:1700000106}),mapping:{silent:!0,settings:{reset:!0}},out:[["amplitude.reset"]]},U={title:"Subscription revenue",description:"A subscription renewal fires a single amplitude.revenue call with productId, price, and currency fallback.",in:b("subscription renew",{timestamp:1700000107,data:{plan_id:"plan-pro",amount:9.99}}),mapping:{silent:!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"}]]},P={title:"Multi-product order",description:"An order fires one amplitude.revenue call per nested product plus a single track for the order totals.",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"}]]},D={title:"Group assignment",description:"A company update assigns the user to a group and sets group properties via setGroup and groupIdentify.",in:b("company update",{timestamp:1700000109,data:{company:"Acme",industry:"tech",employee_count:50,founded_year:2020}}),mapping:{silent:!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}}]]},E={title:"Consent revoked",description:"A walker consent command with analytics denied opts out of Amplitude tracking via setOptOut(true).",command:"consent",before:{analytics:!0},in:{analytics:!1},settings:{},out:[["amplitude.setOptOut",!1],["amplitude.setOptOut",!0]]},G={title:"Consent granted",description:"A walker consent command with analytics granted opts back into Amplitude tracking via setOptOut(false).",command:"consent",in:{analytics:!0},settings:{},out:[["amplitude.setOptOut",!1]]};export{u as examples,i as schemas};//# sourceMappingURL=dev.mjs.map
|
package/dist/dev.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/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\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n 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\" (like a1b2c3d4e5f6789012345678abcdef12).',\n ),\n serverZone: z\n .enum(['US', 'EU'])\n .describe('Amplitude server zone. Default: US.')\n .optional(),\n flushIntervalMillis: z\n .number()\n .int()\n .positive()\n .describe('How often (in ms) to flush the event queue. Default: 1000.')\n .optional(),\n flushQueueSize: z\n .number()\n .int()\n .positive()\n .describe('Max queued events before a flush. Default: 30.')\n .optional(),\n flushMaxRetries: z\n .number()\n .int()\n .nonnegative()\n .describe('Max retries on failed flush. Default: 5.')\n .optional(),\n transport: z\n .enum(['fetch', 'xhr', 'beacon'])\n .describe('HTTP transport. Default: fetch.')\n .optional(),\n useBatch: z\n .boolean()\n .describe(\n 'Use the Amplitude batch endpoint instead of the standard endpoint. Default: false.',\n )\n .optional(),\n appVersion: z\n .string()\n .describe('Application version; tagged onto every event.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to an identity object. Keys: user, device, session, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.',\n )\n .optional(),\n sessionReplay: z\n .unknown()\n .describe(\n 'Session Replay options. When present, session replay is enabled via @amplitude/unified with the provided options.',\n )\n .optional(),\n experiment: z\n .unknown()\n .describe(\n 'Feature Experiment config. Must include `deploymentKey`. When present, the experiment plugin from @amplitude/unified is configured with the provided options.',\n )\n .optional(),\n engagement: z\n .unknown()\n .describe(\n 'Guides & Surveys config. Pass `true` for defaults, or an options object for custom configuration. Enabled via @amplitude/unified.',\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, device, session, 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 of objects, 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).',\n )\n .optional(),\n groupIdentify: z\n .unknown()\n .describe(\n 'Group properties. Resolves to { type, name, set?, setOnce?, ... } → amplitude.groupIdentify(type, name, identify).',\n )\n .optional(),\n reset: z\n .unknown()\n .describe(\n 'Logout trigger. Resolves to a truthy value → amplitude.reset() (clears userId, regenerates deviceId). Typically used with silent: true on a user logout 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\n/**\n * Example environment configurations for the Amplitude destination.\n *\n * Tests clone `push` and replace individual methods with jest spies.\n * Production leaves `env.amplitude` undefined — the destination falls back\n * to the real `@amplitude/unified` module namespace.\n */\n\nconst noop = () => {};\nconst noopPromise = () => ({ promise: Promise.resolve() });\n\n/**\n * Minimal chainable Identify mock. The real SDK class has the same shape.\n * Tests spy by replacing these methods with jest.fn() in the test runner.\n */\nclass MockIdentify implements IdentifyInstance {\n _ops: Record<string, Record<string, unknown>> = {};\n\n private _record(op: string, prop: string, value?: unknown) {\n if (!this._ops[op]) this._ops[op] = {};\n this._ops[op][prop] = value;\n return this;\n }\n\n set(prop: string, value: unknown) {\n return this._record('set', prop, value);\n }\n setOnce(prop: string, value: unknown) {\n return this._record('setOnce', prop, value);\n }\n add(prop: string, value: unknown) {\n return this._record('add', prop, value);\n }\n append(prop: string, value: unknown) {\n return this._record('append', prop, value);\n }\n prepend(prop: string, value: unknown) {\n return this._record('prepend', prop, value);\n }\n preInsert(prop: string, value: unknown) {\n return this._record('preInsert', prop, value);\n }\n postInsert(prop: string, value: unknown) {\n return this._record('postInsert', prop, value);\n }\n remove(prop: string, value: unknown) {\n return this._record('remove', prop, value);\n }\n unset(prop: string) {\n return this._record('unset', prop);\n }\n clearAll() {\n this._ops['clearAll'] = {};\n return this;\n }\n\n toJSON() {\n return this._ops;\n }\n}\n\n/** Minimal chainable Revenue mock. */\nclass MockRevenue implements RevenueInstance {\n _data: Record<string, unknown> = {};\n\n setProductId(v: string) {\n this._data.productId = v;\n return this;\n }\n setPrice(v: number) {\n this._data.price = v;\n return this;\n }\n setQuantity(v: number) {\n this._data.quantity = v;\n return this;\n }\n setRevenueType(v: string) {\n this._data.revenueType = v;\n return this;\n }\n setCurrency(v: string) {\n this._data.currency = v;\n return this;\n }\n setRevenue(v: number) {\n this._data.revenue = v;\n return this;\n }\n setReceipt(v: string) {\n this._data.receipt = v;\n return this;\n }\n setReceiptSig(v: string) {\n this._data.receiptSig = v;\n return this;\n }\n setEventProperties(v: unknown) {\n this._data.eventProperties = v;\n return this;\n }\n\n toJSON() {\n return this._data;\n }\n}\n\n/**\n * Pre-init env — all methods are no-ops until the test runner wires spies.\n */\nexport const init: Env | undefined = {\n amplitude: {\n initAll: () => Promise.resolve(),\n track: noop,\n identify: noop,\n revenue: noop,\n reset: noop,\n setOptOut: noop,\n setUserId: noop,\n setDeviceId: noop,\n setSessionId: noop,\n setGroup: noop,\n groupIdentify: noop,\n flush: noopPromise,\n add: noopPromise,\n Identify: MockIdentify,\n Revenue: MockRevenue,\n },\n};\n\n/**\n * Post-init env — same shape. The test runner clones this and replaces\n * individual methods with jest.fn() so it can assert on calls.\n */\nexport const push: Env = {\n amplitude: {\n initAll: () => Promise.resolve(),\n track: noop,\n identify: noop,\n revenue: noop,\n reset: noop,\n setOptOut: noop,\n setUserId: noop,\n setDeviceId: noop,\n setSessionId: noop,\n setGroup: noop,\n groupIdentify: noop,\n flush: noopPromise,\n add: noopPromise,\n Identify: MockIdentify,\n Revenue: MockRevenue,\n },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:amplitude.initAll',\n 'call:amplitude.track',\n 'call:amplitude.identify',\n 'call:amplitude.revenue',\n 'call:amplitude.reset',\n 'call:amplitude.setOptOut',\n 'call:amplitude.setUserId',\n 'call:amplitude.setDeviceId',\n 'call:amplitude.setSessionId',\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 * Examples may optionally carry destination-level settings and/or an\n * `await` hint for async scenarios. The test runner reads `settings`\n * from the example and merges it into the base destination settings\n * on top of the fixed apiKey. `configInclude` is passed as config-level\n * include when registering the destination.\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 title: 'Default track',\n description:\n 'A walker event is forwarded to Amplitude as an amplitude.track call with the event name and empty properties.',\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 public: false,\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 title: 'Include data',\n description:\n 'Destination-level include flattens the event data section into prefixed event_properties on every track call.',\n in: getEvent('product view', { timestamp: 1700000102 }),\n configInclude: ['data'],\n out: [\n [\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/**\n * Per-rule settings.include REPLACES destination-level include for the\n * matched rule. Here destination-level sends `data`, but the rule\n * overrides it with `globals` only.\n */\nexport const ruleIncludeReplaces: AmplitudeStepExample = {\n title: 'Rule include overrides',\n description:\n 'A per-rule include replaces the destination-level include for the matched event, here using only globals.',\n in: getEvent('order complete', { timestamp: 1700000103 }),\n configInclude: ['data'],\n mapping: {\n include: ['globals'],\n },\n out: [\n [\n 'amplitude.track',\n 'order complete',\n {\n globals_pagegroup: 'shop',\n },\n ],\n ],\n};\n\n/**\n * Destination-level settings.identify fires on the first push (once the\n * state cache is empty). The destination sets user/device/session IDs\n * and tracks them in runtime state; subsequent pushes with unchanged\n * values do NOT re-fire the setters.\n *\n * This example represents the first push in a fresh session. user.id,\n * user.device, user.session come from the walkerOS session fixture.\n *\n * The walkerOS fixture's user.session is 's3ss10n' (string). The\n * destination deterministically hashes non-numeric session strings via\n * djb2 so the same walkerOS session always maps to the same Amplitude\n * session number (cross-page-load consistency). djb2('s3ss10n') = 394324160.\n */\nexport const destinationLevelIdentify: AmplitudeStepExample = {\n title: 'Destination identify',\n description:\n 'Destination-level identify sets userId, deviceId, and sessionId on the Amplitude client before sending events; setters only re-fire when the resolved values change (cached values are not re-applied on subsequent pushes).',\n in: getEvent('page view', { timestamp: 1700000104 }),\n settings: {\n identify: {\n map: {\n user: 'user.id',\n device: 'user.device',\n session: 'user.session',\n },\n },\n },\n out: [\n ['amplitude.setUserId', 'us3r'],\n ['amplitude.setDeviceId', 'c00k13'],\n ['amplitude.setSessionId', 394324160],\n ['amplitude.track', 'page view', {}],\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. `silent: true`\n * suppresses the default amplitude.track() call because we're running\n * identity side effects only.\n */\nexport const userLoginIdentify: AmplitudeStepExample = {\n title: 'User login identify',\n description:\n 'A user login sets the Amplitude userId and runs identify with set, setOnce, and add operations.',\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 silent: true,\n settings: {\n identify: {\n map: {\n user: '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.setUserId', 'new-user-123'],\n [\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 ],\n};\n\n/**\n * User logout - reset: true fires amplitude.reset(), which clears userId\n * and regenerates deviceId. `silent: true` because we're only running the\n * reset side effect, no default track().\n */\nexport const userLogoutReset: AmplitudeStepExample = {\n title: 'User logout reset',\n description:\n 'A user logout calls amplitude.reset to clear the userId and regenerate the deviceId.',\n in: getEvent('user logout', { timestamp: 1700000106 }),\n mapping: {\n silent: true,\n settings: {\n reset: true,\n },\n },\n out: [['amplitude.reset']],\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 walkerOS default event has no data.currency, so the fallback fires.\n */\nexport const subscriptionRenewRevenue: AmplitudeStepExample = {\n title: 'Subscription revenue',\n description:\n 'A subscription renewal fires a single amplitude.revenue call with productId, price, and currency fallback.',\n in: getEvent('subscription renew', {\n timestamp: 1700000107,\n data: {\n plan_id: 'plan-pro',\n amount: 9.99,\n },\n }),\n mapping: {\n silent: 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 [\n 'amplitude.revenue',\n {\n productId: 'plan-pro',\n price: 9.99,\n revenueType: 'renewal',\n currency: 'EUR',\n },\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 title: 'Multi-product order',\n description:\n 'An order fires one amplitude.revenue call per nested product plus a single track for the order totals.',\n in: getEvent('order complete', { timestamp: 1700000108 }),\n mapping: {\n include: ['data', 'globals'],\n settings: {\n revenue: {\n loop: [\n 'nested',\n {\n // Only iterate nested entries that have a price field (products).\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 title: 'Group assignment',\n description:\n 'A company update assigns the user to a group and sets group properties via setGroup and groupIdentify.',\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 silent: 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 * 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 title: 'Consent revoked',\n description:\n 'A walker consent command with analytics denied opts out of Amplitude tracking via setOptOut(true).',\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 title: 'Consent granted',\n description:\n 'A walker consent command with analytics granted opts back into Amplitude tracking via setOptOut(false).',\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;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,QAAQ,EACL,OAAO,EACP,IAA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BAAuB,KAAK,CAAC;AACtC;","names":["z"]}
|
|
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\n// JSON Schema\nexport const settings = zodToSchema(SettingsSchema);\nexport const mapping = zodToSchema(MappingSchema);\n","import { z } from '@walkeros/core/dev';\n\nexport const SettingsSchema = z.object({\n 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\" (like a1b2c3d4e5f6789012345678abcdef12).',\n ),\n serverZone: z\n .enum(['US', 'EU'])\n .describe('Amplitude server zone. Default: US.')\n .optional(),\n flushIntervalMillis: z\n .number()\n .int()\n .positive()\n .describe('How often (in ms) to flush the event queue. Default: 1000.')\n .optional(),\n flushQueueSize: z\n .number()\n .int()\n .positive()\n .describe('Max queued events before a flush. Default: 30.')\n .optional(),\n flushMaxRetries: z\n .number()\n .int()\n .nonnegative()\n .describe('Max retries on failed flush. Default: 5.')\n .optional(),\n transport: z\n .enum(['fetch', 'xhr', 'beacon'])\n .describe('HTTP transport. Default: fetch.')\n .optional(),\n useBatch: z\n .boolean()\n .describe(\n 'Use the Amplitude batch endpoint instead of the standard endpoint. Default: false.',\n )\n .optional(),\n appVersion: z\n .string()\n .describe('Application version; tagged onto every event.')\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to an identity object. Keys: user, device, session, set, setOnce, add, append, prepend, preInsert, postInsert, remove, unset, clearAll.',\n )\n .optional(),\n sessionReplay: z\n .unknown()\n .describe(\n 'Session Replay options. When present, session replay is enabled via @amplitude/unified with the provided options.',\n )\n .optional(),\n experiment: z\n .unknown()\n .describe(\n 'Feature Experiment config. Must include `deploymentKey`. When present, the experiment plugin from @amplitude/unified is configured with the provided options.',\n )\n .optional(),\n engagement: z\n .unknown()\n .describe(\n 'Guides & Surveys config. Pass `true` for defaults, or an options object for custom configuration. Enabled via @amplitude/unified.',\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, device, session, 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 of objects, 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).',\n )\n .optional(),\n groupIdentify: z\n .unknown()\n .describe(\n 'Group properties. Resolves to { type, name, set?, setOnce?, ... } → amplitude.groupIdentify(type, name, identify).',\n )\n .optional(),\n reset: z\n .unknown()\n .describe(\n 'Logout trigger. Resolves to a truthy value → amplitude.reset() (clears userId, regenerates deviceId). Typically used with silent: true on a user logout 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\n/**\n * Example environment configurations for the Amplitude destination.\n *\n * Tests clone `push` and replace individual methods with jest spies.\n * Production leaves `env.amplitude` undefined — the destination falls back\n * to the real `@amplitude/unified` module namespace.\n */\n\nconst noop = () => {};\nconst noopPromise = () => ({ promise: Promise.resolve() });\n\n/**\n * Minimal chainable Identify mock. The real SDK class has the same shape.\n * Tests spy by replacing these methods with jest.fn() in the test runner.\n */\nclass MockIdentify implements IdentifyInstance {\n _ops: Record<string, Record<string, unknown>> = {};\n\n private _record(op: string, prop: string, value?: unknown) {\n if (!this._ops[op]) this._ops[op] = {};\n this._ops[op][prop] = value;\n return this;\n }\n\n set(prop: string, value: unknown) {\n return this._record('set', prop, value);\n }\n setOnce(prop: string, value: unknown) {\n return this._record('setOnce', prop, value);\n }\n add(prop: string, value: unknown) {\n return this._record('add', prop, value);\n }\n append(prop: string, value: unknown) {\n return this._record('append', prop, value);\n }\n prepend(prop: string, value: unknown) {\n return this._record('prepend', prop, value);\n }\n preInsert(prop: string, value: unknown) {\n return this._record('preInsert', prop, value);\n }\n postInsert(prop: string, value: unknown) {\n return this._record('postInsert', prop, value);\n }\n remove(prop: string, value: unknown) {\n return this._record('remove', prop, value);\n }\n unset(prop: string) {\n return this._record('unset', prop);\n }\n clearAll() {\n this._ops['clearAll'] = {};\n return this;\n }\n\n toJSON() {\n return this._ops;\n }\n}\n\n/** Minimal chainable Revenue mock. */\nclass MockRevenue implements RevenueInstance {\n _data: Record<string, unknown> = {};\n\n setProductId(v: string) {\n this._data.productId = v;\n return this;\n }\n setPrice(v: number) {\n this._data.price = v;\n return this;\n }\n setQuantity(v: number) {\n this._data.quantity = v;\n return this;\n }\n setRevenueType(v: string) {\n this._data.revenueType = v;\n return this;\n }\n setCurrency(v: string) {\n this._data.currency = v;\n return this;\n }\n setRevenue(v: number) {\n this._data.revenue = v;\n return this;\n }\n setReceipt(v: string) {\n this._data.receipt = v;\n return this;\n }\n setReceiptSig(v: string) {\n this._data.receiptSig = v;\n return this;\n }\n setEventProperties(v: unknown) {\n this._data.eventProperties = v;\n return this;\n }\n\n toJSON() {\n return this._data;\n }\n}\n\n/**\n * Pre-init env — all methods are no-ops until the test runner wires spies.\n */\nexport const init: Env | undefined = {\n amplitude: {\n initAll: () => Promise.resolve(),\n track: noop,\n identify: noop,\n revenue: noop,\n reset: noop,\n setOptOut: noop,\n setUserId: noop,\n setDeviceId: noop,\n setSessionId: noop,\n setGroup: noop,\n groupIdentify: noop,\n flush: noopPromise,\n add: noopPromise,\n Identify: MockIdentify,\n Revenue: MockRevenue,\n },\n};\n\n/**\n * Post-init env — same shape. The test runner clones this and replaces\n * individual methods with jest.fn() so it can assert on calls.\n */\nexport const push: Env = {\n amplitude: {\n initAll: () => Promise.resolve(),\n track: noop,\n identify: noop,\n revenue: noop,\n reset: noop,\n setOptOut: noop,\n setUserId: noop,\n setDeviceId: noop,\n setSessionId: noop,\n setGroup: noop,\n groupIdentify: noop,\n flush: noopPromise,\n add: noopPromise,\n Identify: MockIdentify,\n Revenue: MockRevenue,\n },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:amplitude.initAll',\n 'call:amplitude.track',\n 'call:amplitude.identify',\n 'call:amplitude.revenue',\n 'call:amplitude.reset',\n 'call:amplitude.setOptOut',\n 'call:amplitude.setUserId',\n 'call:amplitude.setDeviceId',\n 'call:amplitude.setSessionId',\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 * Examples may optionally carry destination-level settings and/or an\n * `await` hint for async scenarios. The test runner reads `settings`\n * from the example and merges it into the base destination settings\n * on top of the fixed apiKey. `configInclude` is passed as config-level\n * include when registering the destination.\n */\nexport type AmplitudeStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n /** Consent granted before `in` so a gated destination is loaded first. */\n before?: WalkerOS.Consent;\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 title: 'Default track',\n description:\n 'A walker event is forwarded to Amplitude as an amplitude.track call with the event name and empty properties.',\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 public: false,\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 title: 'Include data',\n description:\n 'Destination-level include flattens the event data section into prefixed event_properties on every track call.',\n in: getEvent('product view', { timestamp: 1700000102 }),\n configInclude: ['data'],\n out: [\n [\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/**\n * Per-rule settings.include REPLACES destination-level include for the\n * matched rule. Here destination-level sends `data`, but the rule\n * overrides it with `globals` only.\n */\nexport const ruleIncludeReplaces: AmplitudeStepExample = {\n title: 'Rule include overrides',\n description:\n 'A per-rule include replaces the destination-level include for the matched event, here using only globals.',\n in: getEvent('order complete', { timestamp: 1700000103 }),\n configInclude: ['data'],\n mapping: {\n include: ['globals'],\n },\n out: [\n [\n 'amplitude.track',\n 'order complete',\n {\n globals_pagegroup: 'shop',\n },\n ],\n ],\n};\n\n/**\n * Destination-level settings.identify fires on the first push (once the\n * state cache is empty). The destination sets user/device/session IDs\n * and tracks them in runtime state; subsequent pushes with unchanged\n * values do NOT re-fire the setters.\n *\n * This example represents the first push in a fresh session. user.id,\n * user.device, user.session come from the walkerOS session fixture.\n *\n * The walkerOS fixture's user.session is 's3ss10n' (string). The\n * destination deterministically hashes non-numeric session strings via\n * djb2 so the same walkerOS session always maps to the same Amplitude\n * session number (cross-page-load consistency). djb2('s3ss10n') = 394324160.\n */\nexport const destinationLevelIdentify: AmplitudeStepExample = {\n title: 'Destination identify',\n description:\n 'Destination-level identify sets userId, deviceId, and sessionId on the Amplitude client before sending events; setters only re-fire when the resolved values change (cached values are not re-applied on subsequent pushes).',\n in: getEvent('page view', { timestamp: 1700000104 }),\n settings: {\n identify: {\n map: {\n user: 'user.id',\n device: 'user.device',\n session: 'user.session',\n },\n },\n },\n out: [\n ['amplitude.setUserId', 'us3r'],\n ['amplitude.setDeviceId', 'c00k13'],\n ['amplitude.setSessionId', 394324160],\n ['amplitude.track', 'page view', {}],\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. `silent: true`\n * suppresses the default amplitude.track() call because we're running\n * identity side effects only.\n */\nexport const userLoginIdentify: AmplitudeStepExample = {\n title: 'User login identify',\n description:\n 'A user login sets the Amplitude userId and runs identify with set, setOnce, and add operations.',\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 silent: true,\n settings: {\n identify: {\n map: {\n user: '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.setUserId', 'new-user-123'],\n [\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 ],\n};\n\n/**\n * User logout - reset: true fires amplitude.reset(), which clears userId\n * and regenerates deviceId. `silent: true` because we're only running the\n * reset side effect, no default track().\n */\nexport const userLogoutReset: AmplitudeStepExample = {\n title: 'User logout reset',\n description:\n 'A user logout calls amplitude.reset to clear the userId and regenerate the deviceId.',\n in: getEvent('user logout', { timestamp: 1700000106 }),\n mapping: {\n silent: true,\n settings: {\n reset: true,\n },\n },\n out: [['amplitude.reset']],\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 walkerOS default event has no data.currency, so the fallback fires.\n */\nexport const subscriptionRenewRevenue: AmplitudeStepExample = {\n title: 'Subscription revenue',\n description:\n 'A subscription renewal fires a single amplitude.revenue call with productId, price, and currency fallback.',\n in: getEvent('subscription renew', {\n timestamp: 1700000107,\n data: {\n plan_id: 'plan-pro',\n amount: 9.99,\n },\n }),\n mapping: {\n silent: 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 [\n 'amplitude.revenue',\n {\n productId: 'plan-pro',\n price: 9.99,\n revenueType: 'renewal',\n currency: 'EUR',\n },\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 title: 'Multi-product order',\n description:\n 'An order fires one amplitude.revenue call per nested product plus a single track for the order totals.',\n in: getEvent('order complete', { timestamp: 1700000108 }),\n mapping: {\n include: ['data', 'globals'],\n settings: {\n revenue: {\n loop: [\n 'nested',\n {\n // Only iterate nested entries that have a price field (products).\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 title: 'Group assignment',\n description:\n 'A company update assigns the user to a group and sets group properties via setGroup and groupIdentify.',\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 silent: 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 * 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 title: 'Consent revoked',\n description:\n 'A walker consent command with analytics denied opts out of Amplitude tracking via setOptOut(true).',\n command: 'consent',\n before: { analytics: true },\n in: { analytics: false } as WalkerOS.Consent,\n settings: {} as Partial<Settings>,\n out: [\n ['amplitude.setOptOut', false],\n ['amplitude.setOptOut', true],\n ],\n};\n\n/**\n * Consent granted → amplitude.setOptOut(false).\n */\nexport const consentGrantOptIn: AmplitudeStepExample = {\n title: 'Consent granted',\n description:\n 'A walker consent command with analytics granted opts back into Amplitude tracking via setOptOut(false).',\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;;;ACA5B,SAAS,SAAS;AAEX,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,QAAQ,EACL,OAAO,EACP,IAAI,CAAC,EACL;AAAA,IACC;AAAA,EACF;AAAA,EACF,YAAY,EACT,KAAK,CAAC,MAAM,IAAI,CAAC,EACjB,SAAS,qCAAqC,EAC9C,SAAS;AAAA,EACZ,qBAAqB,EAClB,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,4DAA4D,EACrE,SAAS;AAAA,EACZ,gBAAgB,EACb,OAAO,EACP,IAAI,EACJ,SAAS,EACT,SAAS,gDAAgD,EACzD,SAAS;AAAA,EACZ,iBAAiB,EACd,OAAO,EACP,IAAI,EACJ,YAAY,EACZ,SAAS,0CAA0C,EACnD,SAAS;AAAA,EACZ,WAAW,EACR,KAAK,CAAC,SAAS,OAAO,QAAQ,CAAC,EAC/B,SAAS,iCAAiC,EAC1C,SAAS;AAAA,EACZ,UAAU,EACP,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,YAAY,EACT,OAAO,EACP,SAAS,+CAA+C,EACxD,SAAS;AAAA,EACZ,UAAU,EACP,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,eAAe,EACZ,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,YAAY,EACT,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,YA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S;AAAA,UACP,SAAS;AAAA,QACX;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAWO,IAAM,sBAA4C;AAAA,EACvD,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,QAAQ,EAAE,WAAW,KAAK;AAAA,EAC1B,IAAI,EAAE,WAAW,MAAM;AAAA,EACvB,UAAU,CAAC;AAAA,EACX,KAAK;AAAA,IACH,CAAC,uBAAuB,KAAK;AAAA,IAC7B,CAAC,uBAAuB,IAAI;AAAA,EAC9B;AACF;AAKO,IAAM,oBAA0C;AAAA,EACrD,OAAO;AAAA,EACP,aACE;AAAA,EACF,SAAS;AAAA,EACT,IAAI,EAAE,WAAW,KAAK;AAAA,EACtB,UAAU,CAAC;AAAA,EACX,KAAK,CAAC,CAAC,uBAAuB,KAAK,CAAC;AACtC;","names":["z"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mapping, Flow } from '@walkeros/core';
|
|
1
|
+
import { Mapping, Flow, WalkerOS } from '@walkeros/core';
|
|
2
2
|
import { DestinationWeb } from '@walkeros/web-core';
|
|
3
3
|
import { Types } from '@amplitude/unified';
|
|
4
4
|
import { SessionReplayOptions } from '@amplitude/plugin-session-replay-browser';
|
|
@@ -125,6 +125,8 @@ declare namespace env {
|
|
|
125
125
|
type AmplitudeStepExample = Flow.StepExample & {
|
|
126
126
|
settings?: Partial<Settings>;
|
|
127
127
|
configInclude?: string[];
|
|
128
|
+
/** Consent granted before `in` so a gated destination is loaded first. */
|
|
129
|
+
before?: WalkerOS.Consent;
|
|
128
130
|
};
|
|
129
131
|
/**
|
|
130
132
|
* Default event forwarding - every walkerOS event becomes
|
package/dist/examples/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mapping, Flow } from '@walkeros/core';
|
|
1
|
+
import { Mapping, Flow, WalkerOS } from '@walkeros/core';
|
|
2
2
|
import { DestinationWeb } from '@walkeros/web-core';
|
|
3
3
|
import { Types } from '@amplitude/unified';
|
|
4
4
|
import { SessionReplayOptions } from '@amplitude/plugin-session-replay-browser';
|
|
@@ -125,6 +125,8 @@ declare namespace env {
|
|
|
125
125
|
type AmplitudeStepExample = Flow.StepExample & {
|
|
126
126
|
settings?: Partial<Settings>;
|
|
127
127
|
configInclude?: string[];
|
|
128
|
+
/** Consent granted before `in` so a gated destination is loaded first. */
|
|
129
|
+
before?: WalkerOS.Consent;
|
|
128
130
|
};
|
|
129
131
|
/**
|
|
130
132
|
* Default event forwarding - every walkerOS event becomes
|
package/dist/examples/index.js
CHANGED
|
@@ -493,9 +493,13 @@ var consentRevokeOptOut = {
|
|
|
493
493
|
title: "Consent revoked",
|
|
494
494
|
description: "A walker consent command with analytics denied opts out of Amplitude tracking via setOptOut(true).",
|
|
495
495
|
command: "consent",
|
|
496
|
+
before: { analytics: true },
|
|
496
497
|
in: { analytics: false },
|
|
497
498
|
settings: {},
|
|
498
|
-
out: [
|
|
499
|
+
out: [
|
|
500
|
+
["amplitude.setOptOut", false],
|
|
501
|
+
["amplitude.setOptOut", true]
|
|
502
|
+
]
|
|
499
503
|
};
|
|
500
504
|
var consentGrantOptIn = {
|
|
501
505
|
title: "Consent granted",
|
package/dist/examples/index.mjs
CHANGED
|
@@ -472,9 +472,13 @@ var consentRevokeOptOut = {
|
|
|
472
472
|
title: "Consent revoked",
|
|
473
473
|
description: "A walker consent command with analytics denied opts out of Amplitude tracking via setOptOut(true).",
|
|
474
474
|
command: "consent",
|
|
475
|
+
before: { analytics: true },
|
|
475
476
|
in: { analytics: false },
|
|
476
477
|
settings: {},
|
|
477
|
-
out: [
|
|
478
|
+
out: [
|
|
479
|
+
["amplitude.setOptOut", false],
|
|
480
|
+
["amplitude.setOptOut", true]
|
|
481
|
+
]
|
|
478
482
|
};
|
|
479
483
|
var consentGrantOptIn = {
|
|
480
484
|
title: "Consent granted",
|
package/dist/walkerOS.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$meta": {
|
|
3
3
|
"package": "@walkeros/web-destination-amplitude",
|
|
4
|
-
"version": "4.2.
|
|
4
|
+
"version": "4.2.1-next-1781538735002",
|
|
5
5
|
"type": "destination",
|
|
6
6
|
"platform": [
|
|
7
7
|
"web"
|
|
@@ -237,11 +237,18 @@
|
|
|
237
237
|
"title": "Consent revoked",
|
|
238
238
|
"description": "A walker consent command with analytics denied opts out of Amplitude tracking via setOptOut(true).",
|
|
239
239
|
"command": "consent",
|
|
240
|
+
"before": {
|
|
241
|
+
"analytics": true
|
|
242
|
+
},
|
|
240
243
|
"in": {
|
|
241
244
|
"analytics": false
|
|
242
245
|
},
|
|
243
246
|
"settings": {},
|
|
244
247
|
"out": [
|
|
248
|
+
[
|
|
249
|
+
"amplitude.setOptOut",
|
|
250
|
+
false
|
|
251
|
+
],
|
|
245
252
|
[
|
|
246
253
|
"amplitude.setOptOut",
|
|
247
254
|
true
|
|
@@ -281,7 +288,7 @@
|
|
|
281
288
|
"consent": {
|
|
282
289
|
"functional": true
|
|
283
290
|
},
|
|
284
|
-
"id": "
|
|
291
|
+
"id": "bc226691de76829b",
|
|
285
292
|
"trigger": "load",
|
|
286
293
|
"entity": "product",
|
|
287
294
|
"action": "view",
|
|
@@ -341,7 +348,7 @@
|
|
|
341
348
|
"consent": {
|
|
342
349
|
"functional": true
|
|
343
350
|
},
|
|
344
|
-
"id": "
|
|
351
|
+
"id": "fa30c648cdcfbc75",
|
|
345
352
|
"trigger": "load",
|
|
346
353
|
"entity": "page",
|
|
347
354
|
"action": "view",
|
|
@@ -414,7 +421,7 @@
|
|
|
414
421
|
"consent": {
|
|
415
422
|
"functional": true
|
|
416
423
|
},
|
|
417
|
-
"id": "
|
|
424
|
+
"id": "3aa912d447ac1371",
|
|
418
425
|
"trigger": "load",
|
|
419
426
|
"entity": "product",
|
|
420
427
|
"action": "view",
|
|
@@ -481,7 +488,7 @@
|
|
|
481
488
|
"consent": {
|
|
482
489
|
"functional": true
|
|
483
490
|
},
|
|
484
|
-
"id": "
|
|
491
|
+
"id": "d11d8aafe1145b04",
|
|
485
492
|
"trigger": "test",
|
|
486
493
|
"entity": "company",
|
|
487
494
|
"action": "update",
|
|
@@ -626,7 +633,7 @@
|
|
|
626
633
|
"consent": {
|
|
627
634
|
"functional": true
|
|
628
635
|
},
|
|
629
|
-
"id": "
|
|
636
|
+
"id": "6f1772d5f0bd077e",
|
|
630
637
|
"trigger": "load",
|
|
631
638
|
"entity": "order",
|
|
632
639
|
"action": "complete",
|
|
@@ -785,7 +792,7 @@
|
|
|
785
792
|
"consent": {
|
|
786
793
|
"functional": true
|
|
787
794
|
},
|
|
788
|
-
"id": "
|
|
795
|
+
"id": "b62a5268ccfd4438",
|
|
789
796
|
"trigger": "load",
|
|
790
797
|
"entity": "order",
|
|
791
798
|
"action": "complete",
|
|
@@ -851,7 +858,7 @@
|
|
|
851
858
|
"consent": {
|
|
852
859
|
"functional": true
|
|
853
860
|
},
|
|
854
|
-
"id": "
|
|
861
|
+
"id": "70e7b813d1a9ef04",
|
|
855
862
|
"trigger": "test",
|
|
856
863
|
"entity": "subscription",
|
|
857
864
|
"action": "renew",
|
|
@@ -931,7 +938,7 @@
|
|
|
931
938
|
"consent": {
|
|
932
939
|
"functional": true
|
|
933
940
|
},
|
|
934
|
-
"id": "
|
|
941
|
+
"id": "e0f495ac4e1a8d0c",
|
|
935
942
|
"trigger": "test",
|
|
936
943
|
"entity": "user",
|
|
937
944
|
"action": "login",
|
|
@@ -1037,7 +1044,7 @@
|
|
|
1037
1044
|
"consent": {
|
|
1038
1045
|
"functional": true
|
|
1039
1046
|
},
|
|
1040
|
-
"id": "
|
|
1047
|
+
"id": "7010255357a7e660",
|
|
1041
1048
|
"trigger": "test",
|
|
1042
1049
|
"entity": "user",
|
|
1043
1050
|
"action": "logout",
|
|
@@ -1102,7 +1109,7 @@
|
|
|
1102
1109
|
"consent": {
|
|
1103
1110
|
"functional": true
|
|
1104
1111
|
},
|
|
1105
|
-
"id": "
|
|
1112
|
+
"id": "eb55000f2e257342",
|
|
1106
1113
|
"trigger": "test",
|
|
1107
1114
|
"entity": "debug",
|
|
1108
1115
|
"action": "noise",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/web-destination-amplitude",
|
|
3
3
|
"description": "Amplitude web destination for walkerOS (analytics, session replay, experiments, guides & surveys)",
|
|
4
|
-
"version": "4.2.
|
|
4
|
+
"version": "4.2.1-next-1781538735002",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@amplitude/unified": "^1.0.16",
|
|
42
|
-
"@walkeros/core": "4.2.
|
|
43
|
-
"@walkeros/web-core": "4.2.
|
|
42
|
+
"@walkeros/core": "4.2.1-next-1781538735002",
|
|
43
|
+
"@walkeros/web-core": "4.2.1-next-1781538735002"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@walkeros/collector": "4.2.
|
|
46
|
+
"@walkeros/collector": "4.2.1-next-1781538735002"
|
|
47
47
|
},
|
|
48
48
|
"repository": {
|
|
49
49
|
"url": "git+https://github.com/elbwalker/walkerOS.git",
|