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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,145 @@
1
+ # @walkeros/server-destination-mixpanel
2
+
3
+ Server-side Mixpanel destination for walkerOS. Forwards events via the
4
+ `mixpanel` Node.js SDK, supporting track, import, people operations, group
5
+ analytics, and identity mapping.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @walkeros/server-destination-mixpanel
11
+ ```
12
+
13
+ ## Minimal Config
14
+
15
+ ```json
16
+ {
17
+ "destinations": {
18
+ "mixpanel": {
19
+ "package": "@walkeros/server-destination-mixpanel",
20
+ "config": {
21
+ "settings": {
22
+ "apiKey": "$env:MIXPANEL_TOKEN"
23
+ }
24
+ }
25
+ }
26
+ }
27
+ }
28
+ ```
29
+
30
+ ## Settings
31
+
32
+ | Setting | Type | Required | Default | Description |
33
+ | ----------- | -------- | -------- | ------------------ | --------------------------------------------------- |
34
+ | `apiKey` | string | Yes | - | Mixpanel project token |
35
+ | `secret` | string | No | - | API secret for /import endpoint |
36
+ | `host` | string | No | `api.mixpanel.com` | API host (EU: `api-eu.mixpanel.com`) |
37
+ | `protocol` | string | No | `https` | Request protocol |
38
+ | `keepAlive` | boolean | No | `true` | Reuse HTTP connections |
39
+ | `geolocate` | boolean | No | `false` | Parse IP for geolocation |
40
+ | `debug` | boolean | No | `false` | Enable SDK debug logging |
41
+ | `verbose` | boolean | No | `false` | Enable verbose request logging |
42
+ | `test` | boolean | No | `false` | Dry-run mode |
43
+ | `useImport` | boolean | No | `false` | Use /import instead of /track |
44
+ | `identify` | mapping | No | - | Identity mapping resolving `{ distinctId, alias? }` |
45
+ | `include` | string[] | No | - | Event sections to flatten into properties |
46
+ | `group` | mapping | No | - | Group association resolving `{ key, id }` |
47
+
48
+ ## Mapping Settings
49
+
50
+ Per-event settings configured in `mapping.<entity>.<action>.settings`:
51
+
52
+ | Key | Description |
53
+ | -------------- | ----------------------------------------------- |
54
+ | `identify` | Override destination-level identity |
55
+ | `people` | People profile operations (set, set_once, etc.) |
56
+ | `group` | Group association for this event |
57
+ | `groupProfile` | Group profile operations (set, set_once, etc.) |
58
+ | `useImport` | Use /import for this event |
59
+
60
+ ## Track vs Import
61
+
62
+ By default, events are sent via `/track` (real-time, last 5 days only). Set
63
+ `useImport: true` for historical data (any age, requires `secret`):
64
+
65
+ ```json
66
+ {
67
+ "settings": {
68
+ "apiKey": "$env:MIXPANEL_TOKEN",
69
+ "secret": "$env:MIXPANEL_API_SECRET",
70
+ "useImport": true
71
+ }
72
+ }
73
+ ```
74
+
75
+ ## People Operations
76
+
77
+ ```json
78
+ {
79
+ "mapping": {
80
+ "user": {
81
+ "login": {
82
+ "skip": true,
83
+ "settings": {
84
+ "identify": { "map": { "distinctId": "data.user_id" } },
85
+ "people": {
86
+ "map": {
87
+ "set": { "map": { "email": "data.email", "plan": "data.plan" } },
88
+ "set_once": { "map": { "first_login": "timestamp" } },
89
+ "increment": { "map": { "login_count": { "value": 1 } } }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ ```
98
+
99
+ Supported operations: `set`, `set_once`, `increment`, `append`, `union`,
100
+ `remove`, `unset`, `delete_user`.
101
+
102
+ ## Group Analytics
103
+
104
+ Attach group to events:
105
+
106
+ ```json
107
+ {
108
+ "settings": {
109
+ "group": {
110
+ "map": {
111
+ "key": { "value": "company_id" },
112
+ "id": "data.company_id"
113
+ }
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ Update group profiles:
120
+
121
+ ```json
122
+ {
123
+ "mapping": {
124
+ "company": {
125
+ "update": {
126
+ "skip": true,
127
+ "settings": {
128
+ "groupProfile": {
129
+ "map": {
130
+ "key": { "value": "company_id" },
131
+ "id": "data.company_id",
132
+ "set": {
133
+ "map": {
134
+ "name": "data.company_name",
135
+ "plan": "data.plan"
136
+ }
137
+ }
138
+ }
139
+ }
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+ ```
package/dist/dev.d.mts ADDED
@@ -0,0 +1,197 @@
1
+ import * as _walkeros_core_dev from '@walkeros/core/dev';
2
+ import { z } from '@walkeros/core/dev';
3
+ import { Mapping as Mapping$1, Flow } from '@walkeros/core';
4
+ import { DestinationServer } from '@walkeros/server-core';
5
+
6
+ declare const SettingsSchema: z.ZodObject<{
7
+ apiKey: z.ZodString;
8
+ secret: z.ZodOptional<z.ZodString>;
9
+ host: z.ZodOptional<z.ZodString>;
10
+ protocol: z.ZodOptional<z.ZodString>;
11
+ keepAlive: z.ZodOptional<z.ZodBoolean>;
12
+ geolocate: z.ZodOptional<z.ZodBoolean>;
13
+ debug: z.ZodOptional<z.ZodBoolean>;
14
+ verbose: z.ZodOptional<z.ZodBoolean>;
15
+ test: z.ZodOptional<z.ZodBoolean>;
16
+ useImport: z.ZodOptional<z.ZodBoolean>;
17
+ identify: z.ZodOptional<z.ZodUnknown>;
18
+ include: z.ZodOptional<z.ZodUnknown>;
19
+ }, z.core.$strip>;
20
+ type Settings$1 = z.infer<typeof SettingsSchema>;
21
+
22
+ declare const MappingSchema: z.ZodObject<{
23
+ identify: z.ZodOptional<z.ZodUnknown>;
24
+ people: z.ZodOptional<z.ZodUnknown>;
25
+ group: z.ZodOptional<z.ZodUnknown>;
26
+ groupProfile: z.ZodOptional<z.ZodUnknown>;
27
+ useImport: z.ZodOptional<z.ZodUnknown>;
28
+ }, z.core.$strip>;
29
+ type Mapping = z.infer<typeof MappingSchema>;
30
+
31
+ declare const settings: _walkeros_core_dev.JSONSchema;
32
+ declare const mapping: _walkeros_core_dev.JSONSchema;
33
+
34
+ type index$1_Mapping = Mapping;
35
+ declare const index$1_MappingSchema: typeof MappingSchema;
36
+ declare const index$1_SettingsSchema: typeof SettingsSchema;
37
+ declare const index$1_mapping: typeof mapping;
38
+ declare const index$1_settings: typeof settings;
39
+ declare namespace index$1 {
40
+ export { type index$1_Mapping as Mapping, index$1_MappingSchema as MappingSchema, type Settings$1 as Settings, index$1_SettingsSchema as SettingsSchema, index$1_mapping as mapping, index$1_settings as settings };
41
+ }
42
+
43
+ type MixpanelCallback = (err: Error | undefined) => void;
44
+ /**
45
+ * Subset of the Mixpanel People API used by the destination.
46
+ * Every method requires `distinct_id` as the first argument (stateless server SDK).
47
+ */
48
+ interface MixpanelPeople {
49
+ set(distinctId: string, properties: Record<string, unknown>, callback?: MixpanelCallback): void;
50
+ set_once(distinctId: string, properties: Record<string, unknown>, callback?: MixpanelCallback): void;
51
+ increment(distinctId: string, properties: Record<string, number>, callback?: MixpanelCallback): void;
52
+ append(distinctId: string, properties: Record<string, unknown>, callback?: MixpanelCallback): void;
53
+ union(distinctId: string, data: Record<string, unknown>, callback?: MixpanelCallback): void;
54
+ remove(distinctId: string, data: Record<string, unknown>, callback?: MixpanelCallback): void;
55
+ unset(distinctId: string, propertyName: string | string[], callback?: MixpanelCallback): void;
56
+ delete_user(distinctId: string, callback?: MixpanelCallback): void;
57
+ }
58
+ /**
59
+ * Subset of the Mixpanel Groups API used by the destination.
60
+ * Every method requires `(groupKey, groupId)` as the first two args.
61
+ */
62
+ interface MixpanelGroups {
63
+ set(groupKey: string, groupId: string, properties: Record<string, unknown>, callback?: MixpanelCallback): void;
64
+ set_once(groupKey: string, groupId: string, properties: Record<string, unknown>, callback?: MixpanelCallback): void;
65
+ union(groupKey: string, groupId: string, data: Record<string, unknown>, callback?: MixpanelCallback): void;
66
+ remove(groupKey: string, groupId: string, data: Record<string, unknown>, callback?: MixpanelCallback): void;
67
+ unset(groupKey: string, groupId: string, propertyName: string | string[], callback?: MixpanelCallback): void;
68
+ delete_group(groupKey: string, groupId: string, callback?: MixpanelCallback): void;
69
+ }
70
+ /**
71
+ * Subset of the Mixpanel SDK instance the destination uses.
72
+ */
73
+ interface MixpanelClient {
74
+ track(eventName: string, properties: Record<string, unknown>, callback?: MixpanelCallback): void;
75
+ import(eventName: string, time: Date | number, properties?: Record<string, unknown>, callback?: MixpanelCallback): void;
76
+ alias(distinctId: string, alias: string, callback?: MixpanelCallback): void;
77
+ people: MixpanelPeople;
78
+ groups: MixpanelGroups;
79
+ }
80
+ interface Settings {
81
+ apiKey: string;
82
+ secret?: string;
83
+ host?: string;
84
+ protocol?: string;
85
+ keepAlive?: boolean;
86
+ geolocate?: boolean;
87
+ debug?: boolean;
88
+ verbose?: boolean;
89
+ test?: boolean;
90
+ identify?: Mapping$1.Value;
91
+ group?: Mapping$1.Value;
92
+ include?: string[];
93
+ useImport?: boolean;
94
+ /** Initialized Mixpanel client instance — set during init(). */
95
+ client?: MixpanelClient;
96
+ }
97
+ /**
98
+ * Environment with optional Mixpanel constructor override for testing.
99
+ * Follows the same pattern as GCP BigQuery's `env.BigQuery`.
100
+ */
101
+ interface Env extends DestinationServer.Env {
102
+ Mixpanel?: {
103
+ init: (...args: unknown[]) => MixpanelClient;
104
+ };
105
+ }
106
+
107
+ /**
108
+ * Standard mock environment for push operations.
109
+ * The test runner clones this and replaces methods with spies.
110
+ */
111
+ declare const push: Env;
112
+ /** Simulation tracking paths for CLI --simulate. */
113
+ declare const simulation: string[];
114
+
115
+ declare const env_push: typeof push;
116
+ declare const env_simulation: typeof simulation;
117
+ declare namespace env {
118
+ export { env_push as push, env_simulation as simulation };
119
+ }
120
+
121
+ /**
122
+ * Step examples may carry destination-level settings and configInclude.
123
+ * The test runner reads these to configure the destination.
124
+ */
125
+ type MixpanelStepExample = Flow.StepExample & {
126
+ settings?: Partial<Settings>;
127
+ configInclude?: string[];
128
+ };
129
+ /**
130
+ * Default event forwarding — every walkerOS event becomes
131
+ * mp.track(event.name, { distinct_id, ...properties }).
132
+ * With default settings.identify resolving user.id.
133
+ */
134
+ declare const defaultEventForwarding: MixpanelStepExample;
135
+ /**
136
+ * Track with include — flattens walkerOS `data` section into
137
+ * prefixed track() properties.
138
+ */
139
+ declare const trackWithInclude: MixpanelStepExample;
140
+ /**
141
+ * Per-event identify — mapping-level settings.identify overrides
142
+ * destination-level default.
143
+ */
144
+ declare const perEventIdentify: MixpanelStepExample;
145
+ /**
146
+ * Track with group — group key/id attached as track property.
147
+ */
148
+ declare const trackWithGroup: MixpanelStepExample;
149
+ /**
150
+ * User login with people operations — skip: true suppresses track,
151
+ * only identity + people side effects fire.
152
+ */
153
+ declare const userLoginPeopleSet: MixpanelStepExample;
154
+ /**
155
+ * Full people operation vocabulary — exercises set, set_once, increment,
156
+ * append, union, remove, unset, delete_user.
157
+ */
158
+ declare const allPeopleOperations: MixpanelStepExample;
159
+ /**
160
+ * Group profile operations — settings.groupProfile with set and set_once.
161
+ */
162
+ declare const companyGroupProfile: MixpanelStepExample;
163
+ /**
164
+ * Historical import — useImport: true uses mp.import() instead of mp.track().
165
+ */
166
+ declare const historicalImport: MixpanelStepExample;
167
+ /**
168
+ * Alias — legacy identity merge. Fires mp.alias before track.
169
+ */
170
+ declare const aliasBeforeTrack: MixpanelStepExample;
171
+ /**
172
+ * Wildcard ignore — the rule matches but does nothing.
173
+ */
174
+ declare const wildcardIgnored: MixpanelStepExample;
175
+
176
+ type step_MixpanelStepExample = MixpanelStepExample;
177
+ declare const step_aliasBeforeTrack: typeof aliasBeforeTrack;
178
+ declare const step_allPeopleOperations: typeof allPeopleOperations;
179
+ declare const step_companyGroupProfile: typeof companyGroupProfile;
180
+ declare const step_defaultEventForwarding: typeof defaultEventForwarding;
181
+ declare const step_historicalImport: typeof historicalImport;
182
+ declare const step_perEventIdentify: typeof perEventIdentify;
183
+ declare const step_trackWithGroup: typeof trackWithGroup;
184
+ declare const step_trackWithInclude: typeof trackWithInclude;
185
+ declare const step_userLoginPeopleSet: typeof userLoginPeopleSet;
186
+ declare const step_wildcardIgnored: typeof wildcardIgnored;
187
+ declare namespace step {
188
+ export { type step_MixpanelStepExample as MixpanelStepExample, step_aliasBeforeTrack as aliasBeforeTrack, step_allPeopleOperations as allPeopleOperations, step_companyGroupProfile as companyGroupProfile, step_defaultEventForwarding as defaultEventForwarding, step_historicalImport as historicalImport, step_perEventIdentify as perEventIdentify, step_trackWithGroup as trackWithGroup, step_trackWithInclude as trackWithInclude, step_userLoginPeopleSet as userLoginPeopleSet, step_wildcardIgnored as wildcardIgnored };
189
+ }
190
+
191
+ declare const index_env: typeof env;
192
+ declare const index_step: typeof step;
193
+ declare namespace index {
194
+ export { index_env as env, index_step as step };
195
+ }
196
+
197
+ export { index as examples, index$1 as schemas };
package/dist/dev.d.ts ADDED
@@ -0,0 +1,197 @@
1
+ import * as _walkeros_core_dev from '@walkeros/core/dev';
2
+ import { z } from '@walkeros/core/dev';
3
+ import { Mapping as Mapping$1, Flow } from '@walkeros/core';
4
+ import { DestinationServer } from '@walkeros/server-core';
5
+
6
+ declare const SettingsSchema: z.ZodObject<{
7
+ apiKey: z.ZodString;
8
+ secret: z.ZodOptional<z.ZodString>;
9
+ host: z.ZodOptional<z.ZodString>;
10
+ protocol: z.ZodOptional<z.ZodString>;
11
+ keepAlive: z.ZodOptional<z.ZodBoolean>;
12
+ geolocate: z.ZodOptional<z.ZodBoolean>;
13
+ debug: z.ZodOptional<z.ZodBoolean>;
14
+ verbose: z.ZodOptional<z.ZodBoolean>;
15
+ test: z.ZodOptional<z.ZodBoolean>;
16
+ useImport: z.ZodOptional<z.ZodBoolean>;
17
+ identify: z.ZodOptional<z.ZodUnknown>;
18
+ include: z.ZodOptional<z.ZodUnknown>;
19
+ }, z.core.$strip>;
20
+ type Settings$1 = z.infer<typeof SettingsSchema>;
21
+
22
+ declare const MappingSchema: z.ZodObject<{
23
+ identify: z.ZodOptional<z.ZodUnknown>;
24
+ people: z.ZodOptional<z.ZodUnknown>;
25
+ group: z.ZodOptional<z.ZodUnknown>;
26
+ groupProfile: z.ZodOptional<z.ZodUnknown>;
27
+ useImport: z.ZodOptional<z.ZodUnknown>;
28
+ }, z.core.$strip>;
29
+ type Mapping = z.infer<typeof MappingSchema>;
30
+
31
+ declare const settings: _walkeros_core_dev.JSONSchema;
32
+ declare const mapping: _walkeros_core_dev.JSONSchema;
33
+
34
+ type index$1_Mapping = Mapping;
35
+ declare const index$1_MappingSchema: typeof MappingSchema;
36
+ declare const index$1_SettingsSchema: typeof SettingsSchema;
37
+ declare const index$1_mapping: typeof mapping;
38
+ declare const index$1_settings: typeof settings;
39
+ declare namespace index$1 {
40
+ export { type index$1_Mapping as Mapping, index$1_MappingSchema as MappingSchema, type Settings$1 as Settings, index$1_SettingsSchema as SettingsSchema, index$1_mapping as mapping, index$1_settings as settings };
41
+ }
42
+
43
+ type MixpanelCallback = (err: Error | undefined) => void;
44
+ /**
45
+ * Subset of the Mixpanel People API used by the destination.
46
+ * Every method requires `distinct_id` as the first argument (stateless server SDK).
47
+ */
48
+ interface MixpanelPeople {
49
+ set(distinctId: string, properties: Record<string, unknown>, callback?: MixpanelCallback): void;
50
+ set_once(distinctId: string, properties: Record<string, unknown>, callback?: MixpanelCallback): void;
51
+ increment(distinctId: string, properties: Record<string, number>, callback?: MixpanelCallback): void;
52
+ append(distinctId: string, properties: Record<string, unknown>, callback?: MixpanelCallback): void;
53
+ union(distinctId: string, data: Record<string, unknown>, callback?: MixpanelCallback): void;
54
+ remove(distinctId: string, data: Record<string, unknown>, callback?: MixpanelCallback): void;
55
+ unset(distinctId: string, propertyName: string | string[], callback?: MixpanelCallback): void;
56
+ delete_user(distinctId: string, callback?: MixpanelCallback): void;
57
+ }
58
+ /**
59
+ * Subset of the Mixpanel Groups API used by the destination.
60
+ * Every method requires `(groupKey, groupId)` as the first two args.
61
+ */
62
+ interface MixpanelGroups {
63
+ set(groupKey: string, groupId: string, properties: Record<string, unknown>, callback?: MixpanelCallback): void;
64
+ set_once(groupKey: string, groupId: string, properties: Record<string, unknown>, callback?: MixpanelCallback): void;
65
+ union(groupKey: string, groupId: string, data: Record<string, unknown>, callback?: MixpanelCallback): void;
66
+ remove(groupKey: string, groupId: string, data: Record<string, unknown>, callback?: MixpanelCallback): void;
67
+ unset(groupKey: string, groupId: string, propertyName: string | string[], callback?: MixpanelCallback): void;
68
+ delete_group(groupKey: string, groupId: string, callback?: MixpanelCallback): void;
69
+ }
70
+ /**
71
+ * Subset of the Mixpanel SDK instance the destination uses.
72
+ */
73
+ interface MixpanelClient {
74
+ track(eventName: string, properties: Record<string, unknown>, callback?: MixpanelCallback): void;
75
+ import(eventName: string, time: Date | number, properties?: Record<string, unknown>, callback?: MixpanelCallback): void;
76
+ alias(distinctId: string, alias: string, callback?: MixpanelCallback): void;
77
+ people: MixpanelPeople;
78
+ groups: MixpanelGroups;
79
+ }
80
+ interface Settings {
81
+ apiKey: string;
82
+ secret?: string;
83
+ host?: string;
84
+ protocol?: string;
85
+ keepAlive?: boolean;
86
+ geolocate?: boolean;
87
+ debug?: boolean;
88
+ verbose?: boolean;
89
+ test?: boolean;
90
+ identify?: Mapping$1.Value;
91
+ group?: Mapping$1.Value;
92
+ include?: string[];
93
+ useImport?: boolean;
94
+ /** Initialized Mixpanel client instance — set during init(). */
95
+ client?: MixpanelClient;
96
+ }
97
+ /**
98
+ * Environment with optional Mixpanel constructor override for testing.
99
+ * Follows the same pattern as GCP BigQuery's `env.BigQuery`.
100
+ */
101
+ interface Env extends DestinationServer.Env {
102
+ Mixpanel?: {
103
+ init: (...args: unknown[]) => MixpanelClient;
104
+ };
105
+ }
106
+
107
+ /**
108
+ * Standard mock environment for push operations.
109
+ * The test runner clones this and replaces methods with spies.
110
+ */
111
+ declare const push: Env;
112
+ /** Simulation tracking paths for CLI --simulate. */
113
+ declare const simulation: string[];
114
+
115
+ declare const env_push: typeof push;
116
+ declare const env_simulation: typeof simulation;
117
+ declare namespace env {
118
+ export { env_push as push, env_simulation as simulation };
119
+ }
120
+
121
+ /**
122
+ * Step examples may carry destination-level settings and configInclude.
123
+ * The test runner reads these to configure the destination.
124
+ */
125
+ type MixpanelStepExample = Flow.StepExample & {
126
+ settings?: Partial<Settings>;
127
+ configInclude?: string[];
128
+ };
129
+ /**
130
+ * Default event forwarding — every walkerOS event becomes
131
+ * mp.track(event.name, { distinct_id, ...properties }).
132
+ * With default settings.identify resolving user.id.
133
+ */
134
+ declare const defaultEventForwarding: MixpanelStepExample;
135
+ /**
136
+ * Track with include — flattens walkerOS `data` section into
137
+ * prefixed track() properties.
138
+ */
139
+ declare const trackWithInclude: MixpanelStepExample;
140
+ /**
141
+ * Per-event identify — mapping-level settings.identify overrides
142
+ * destination-level default.
143
+ */
144
+ declare const perEventIdentify: MixpanelStepExample;
145
+ /**
146
+ * Track with group — group key/id attached as track property.
147
+ */
148
+ declare const trackWithGroup: MixpanelStepExample;
149
+ /**
150
+ * User login with people operations — skip: true suppresses track,
151
+ * only identity + people side effects fire.
152
+ */
153
+ declare const userLoginPeopleSet: MixpanelStepExample;
154
+ /**
155
+ * Full people operation vocabulary — exercises set, set_once, increment,
156
+ * append, union, remove, unset, delete_user.
157
+ */
158
+ declare const allPeopleOperations: MixpanelStepExample;
159
+ /**
160
+ * Group profile operations — settings.groupProfile with set and set_once.
161
+ */
162
+ declare const companyGroupProfile: MixpanelStepExample;
163
+ /**
164
+ * Historical import — useImport: true uses mp.import() instead of mp.track().
165
+ */
166
+ declare const historicalImport: MixpanelStepExample;
167
+ /**
168
+ * Alias — legacy identity merge. Fires mp.alias before track.
169
+ */
170
+ declare const aliasBeforeTrack: MixpanelStepExample;
171
+ /**
172
+ * Wildcard ignore — the rule matches but does nothing.
173
+ */
174
+ declare const wildcardIgnored: MixpanelStepExample;
175
+
176
+ type step_MixpanelStepExample = MixpanelStepExample;
177
+ declare const step_aliasBeforeTrack: typeof aliasBeforeTrack;
178
+ declare const step_allPeopleOperations: typeof allPeopleOperations;
179
+ declare const step_companyGroupProfile: typeof companyGroupProfile;
180
+ declare const step_defaultEventForwarding: typeof defaultEventForwarding;
181
+ declare const step_historicalImport: typeof historicalImport;
182
+ declare const step_perEventIdentify: typeof perEventIdentify;
183
+ declare const step_trackWithGroup: typeof trackWithGroup;
184
+ declare const step_trackWithInclude: typeof trackWithInclude;
185
+ declare const step_userLoginPeopleSet: typeof userLoginPeopleSet;
186
+ declare const step_wildcardIgnored: typeof wildcardIgnored;
187
+ declare namespace step {
188
+ export { type step_MixpanelStepExample as MixpanelStepExample, step_aliasBeforeTrack as aliasBeforeTrack, step_allPeopleOperations as allPeopleOperations, step_companyGroupProfile as companyGroupProfile, step_defaultEventForwarding as defaultEventForwarding, step_historicalImport as historicalImport, step_perEventIdentify as perEventIdentify, step_trackWithGroup as trackWithGroup, step_trackWithInclude as trackWithInclude, step_userLoginPeopleSet as userLoginPeopleSet, step_wildcardIgnored as wildcardIgnored };
189
+ }
190
+
191
+ declare const index_env: typeof env;
192
+ declare const index_step: typeof step;
193
+ declare namespace index {
194
+ export { index_env as env, index_step as step };
195
+ }
196
+
197
+ export { index as examples, index$1 as schemas };
package/dist/dev.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e,t=Object.defineProperty,a=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,o=(e,a)=>{for(var i in a)t(e,i,{get:a[i],enumerable:!0})},p={};o(p,{examples:()=>v,schemas:()=>s}),module.exports=(e=p,((e,o,p,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let r of i(o))n.call(e,r)||r===p||t(e,r,{get:()=>o[r],enumerable:!(s=a(o,r))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s={};o(s,{MappingSchema:()=>m,SettingsSchema:()=>d,mapping:()=>g,settings:()=>u});var r=require("@walkeros/core/dev"),l=require("@walkeros/core/dev"),d=l.z.object({apiKey:l.z.string().min(1).describe("Your Mixpanel project token. Find it in Project Settings > Access Keys. Passed as the first argument to Mixpanel.init()."),secret:l.z.string().describe("API secret for the /import endpoint (historical data). Required when useImport is true.").optional(),host:l.z.string().describe("Mixpanel API host. Default: 'api.mixpanel.com' (US). Use 'api-eu.mixpanel.com' (EU) or 'api-in.mixpanel.com' (India).").optional(),protocol:l.z.string().describe("Protocol for API requests. Default: 'https'.").optional(),keepAlive:l.z.boolean().describe("Reuse HTTP connections. Default: true.").optional(),geolocate:l.z.boolean().describe("Parse IP for geolocation. Default: false. Server IP caveat: all users map to server location unless $ip is overridden.").optional(),debug:l.z.boolean().describe("Enable SDK debug logging. Default: false.").optional(),verbose:l.z.boolean().describe("Enable verbose request logging. Default: false.").optional(),test:l.z.boolean().describe("Enable dry-run mode. Default: false.").optional(),useImport:l.z.boolean().describe("Use /import endpoint instead of /track. Accepts events of any age (no 5-day limit). Requires secret for authentication.").optional(),identify:l.z.unknown().describe("walkerOS mapping value resolving to { distinctId, alias? }. distinctId is passed as distinct_id on every SDK call.").optional(),include:l.z.unknown().describe("Event data sections to flatten into track() properties. Example: ['data', 'globals']. Sections are prefixed (data_, globals_, etc.).").optional()}),c=require("@walkeros/core/dev"),m=c.z.object({identify:c.z.unknown().describe("Per-event identity mapping. Resolves to { distinctId, alias? }. distinctId is passed as distinct_id to all SDK calls.").optional(),people:c.z.unknown().describe("Per-event people operations. Resolves to an object with any of: set, set_once, increment, append, union, remove, unset, delete_user. Each key fires a separate mp.people.* call with distinct_id as first arg.").optional(),group:c.z.unknown().describe("Per-event group association. Resolves to { key, id }. The group key/id is added as a track() property.").optional(),groupProfile:c.z.unknown().describe("Per-event group profile operations. Resolves to { key, id, set?, set_once?, union?, remove?, unset?, delete? }. Fires mp.groups.* calls.").optional(),useImport:c.z.unknown().describe("Per-event import flag. When truthy, uses mp.import() instead of mp.track() for this rule.").optional()}),u=(0,r.zodToSchema)(d),g=(0,r.zodToSchema)(m),v={};o(v,{env:()=>_,step:()=>I});var _={};o(_,{push:()=>k,simulation:()=>w});var f=()=>{},y={set:f,set_once:f,increment:f,append:f,union:f,remove:f,unset:f,delete_user:f},b={set:f,set_once:f,union:f,remove:f,unset:f,delete_group:f};var k={Mixpanel:{init:function(){return{track:f,import:f,alias:f,people:{...y},groups:{...b}}}}},w=["call:Mixpanel.init","call:mp.track","call:mp.import","call:mp.alias","call:mp.people.set","call:mp.people.set_once","call:mp.people.increment","call:mp.people.append","call:mp.people.union","call:mp.people.remove","call:mp.people.unset","call:mp.people.delete_user","call:mp.groups.set","call:mp.groups.set_once","call:mp.groups.union","call:mp.groups.remove","call:mp.groups.unset","call:mp.groups.delete_group"],I={};o(I,{aliasBeforeTrack:()=>A,allPeopleOperations:()=>j,companyGroupProfile:()=>x,defaultEventForwarding:()=>P,historicalImport:()=>q,perEventIdentify:()=>E,trackWithGroup:()=>S,trackWithInclude:()=>z,userLoginPeopleSet:()=>D,wildcardIgnored:()=>O});var h=require("@walkeros/core"),P={in:(0,h.getEvent)("product view",{timestamp:1700000100}),settings:{identify:{map:{distinctId:"user.id"}}},out:["mp.track","product view",{distinct_id:"us3r"}]},z={in:(0,h.getEvent)("product view",{timestamp:1700000101}),settings:{identify:{map:{distinctId:"user.id"}}},configInclude:["data"],out:["mp.track","product view",{distinct_id:"us3r",data_id:"ers",data_name:"Everyday Ruck Snack",data_color:"black",data_size:"l",data_price:420}]},E={in:(0,h.getEvent)("user login",{timestamp:1700000102,data:{user_id:"resolved-id",plan:"premium"}}),mapping:{settings:{identify:{map:{distinctId:"data.user_id"}}}},out:["mp.track","user login",{distinct_id:"resolved-id"}]},S={in:(0,h.getEvent)("page view",{timestamp:1700000103,data:{company_id:"acme"}}),settings:{identify:{map:{distinctId:"user.id"}}},mapping:{settings:{group:{map:{key:{value:"company_id"},id:"data.company_id"}}}},out:["mp.track","page view",{distinct_id:"us3r",company_id:"acme"}]},D={in:(0,h.getEvent)("user login",{timestamp:1700000104,data:{user_id:"new-user-123",plan:"premium",company:"Acme",email:"user@acme.com"}}),mapping:{skip:!0,settings:{identify:{map:{distinctId:"data.user_id"}},people:{map:{set:{map:{plan:"data.plan",company:"data.company",email:"data.email"}},set_once:{map:{first_login:"timestamp"}},increment:{map:{login_count:{value:1}}}}}}},out:[["mp.people.set","new-user-123",{plan:"premium",company:"Acme",email:"user@acme.com"}],["mp.people.set_once","new-user-123",{first_login:1700000104}],["mp.people.increment","new-user-123",{login_count:1}]]},j={in:(0,h.getEvent)("profile update",{timestamp:1700000105,data:{name:"Jane Doe",email:"jane@acme.com",page:"/docs/getting-started",removed_tag:"trial",source:"referral"}}),mapping:{skip:!0,settings:{identify:{map:{distinctId:"user.id"}},people:{map:{set:{map:{name:"data.name",email:"data.email"}},set_once:{map:{signup_source:"data.source"}},increment:{map:{page_views:{value:1}}},append:{map:{visited_pages:"data.page"}},union:{map:{unique_tags:{value:["active"]}}},remove:{map:{tags:"data.removed_tag"}},unset:{value:["old_plan"]}}}}},out:[["mp.people.set","us3r",{name:"Jane Doe",email:"jane@acme.com"}],["mp.people.set_once","us3r",{signup_source:"referral"}],["mp.people.increment","us3r",{page_views:1}],["mp.people.append","us3r",{visited_pages:"/docs/getting-started"}],["mp.people.union","us3r",{unique_tags:["active"]}],["mp.people.remove","us3r",{tags:"trial"}],["mp.people.unset","us3r",["old_plan"]]]},x={in:(0,h.getEvent)("company update",{timestamp:1700000106,data:{company_id:"acme-inc",company_name:"Acme, Inc.",plan:"enterprise",employee_count:250,founded_year:2010}}),mapping:{skip:!0,settings:{groupProfile:{map:{key:{value:"company_id"},id:"data.company_id",set:{map:{name:"data.company_name",plan:"data.plan",employee_count:"data.employee_count"}},set_once:{map:{founded:"data.founded_year"}}}}}},out:[["mp.groups.set","company_id","acme-inc",{name:"Acme, Inc.",plan:"enterprise",employee_count:250}],["mp.groups.set_once","company_id","acme-inc",{founded:2010}]]},q={in:(0,h.getEvent)("order complete",{timestamp:1700000107,data:{total:99.99}}),settings:{useImport:!0,identify:{map:{distinctId:"user.id"}}},out:["mp.import","order complete",1700000107,{distinct_id:"us3r"}]},A={in:(0,h.getEvent)("user login",{timestamp:1700000108,data:{user_id:"new-user-456",anon_id:"anon-789"}}),mapping:{settings:{identify:{map:{distinctId:"data.user_id",alias:"data.anon_id"}}}},out:[["mp.alias","new-user-456","anon-789"],["mp.track","user login",{distinct_id:"new-user-456"}]]},O={in:(0,h.getEvent)("debug noise",{timestamp:1700000109}),mapping:{ignore:!0},out:[]};//# sourceMappingURL=dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dev.ts","../src/schemas/index.ts","../src/schemas/settings.ts","../src/schemas/mapping.ts","../src/examples/index.ts","../src/examples/env.ts","../src/examples/step.ts"],"sourcesContent":["export * as schemas from './schemas';\nexport * as examples from './examples';\n","import { zodToSchema } from '@walkeros/core/dev';\nimport { SettingsSchema } from './settings';\nimport { MappingSchema } from './mapping';\n\nexport { SettingsSchema, type Settings } from './settings';\nexport { MappingSchema, type Mapping } from './mapping';\n\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 Mixpanel project token. Find it in Project Settings > Access Keys. Passed as the first argument to Mixpanel.init().',\n ),\n secret: z\n .string()\n .describe(\n 'API secret for the /import endpoint (historical data). Required when useImport is true.',\n )\n .optional(),\n host: z\n .string()\n .describe(\n \"Mixpanel API host. Default: 'api.mixpanel.com' (US). Use 'api-eu.mixpanel.com' (EU) or 'api-in.mixpanel.com' (India).\",\n )\n .optional(),\n protocol: z\n .string()\n .describe(\"Protocol for API requests. Default: 'https'.\")\n .optional(),\n keepAlive: z\n .boolean()\n .describe('Reuse HTTP connections. Default: true.')\n .optional(),\n geolocate: z\n .boolean()\n .describe(\n 'Parse IP for geolocation. Default: false. Server IP caveat: all users map to server location unless $ip is overridden.',\n )\n .optional(),\n debug: z\n .boolean()\n .describe('Enable SDK debug logging. Default: false.')\n .optional(),\n verbose: z\n .boolean()\n .describe('Enable verbose request logging. Default: false.')\n .optional(),\n test: z.boolean().describe('Enable dry-run mode. Default: false.').optional(),\n useImport: z\n .boolean()\n .describe(\n 'Use /import endpoint instead of /track. Accepts events of any age (no 5-day limit). Requires secret for authentication.',\n )\n .optional(),\n identify: z\n .unknown()\n .describe(\n 'walkerOS mapping value resolving to { distinctId, alias? }. distinctId is passed as distinct_id on every SDK call.',\n )\n .optional(),\n include: z\n .unknown()\n .describe(\n \"Event data sections to flatten into track() properties. Example: ['data', 'globals']. Sections are prefixed (data_, globals_, etc.).\",\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 { distinctId, alias? }. distinctId is passed as distinct_id to all SDK calls.',\n )\n .optional(),\n people: z\n .unknown()\n .describe(\n 'Per-event people operations. Resolves to an object with any of: set, set_once, increment, append, union, remove, unset, delete_user. Each key fires a separate mp.people.* call with distinct_id as first arg.',\n )\n .optional(),\n group: z\n .unknown()\n .describe(\n 'Per-event group association. Resolves to { key, id }. The group key/id is added as a track() property.',\n )\n .optional(),\n groupProfile: z\n .unknown()\n .describe(\n 'Per-event group profile operations. Resolves to { key, id, set?, set_once?, union?, remove?, unset?, delete? }. Fires mp.groups.* calls.',\n )\n .optional(),\n useImport: z\n .unknown()\n .describe(\n 'Per-event import flag. When truthy, uses mp.import() instead of mp.track() for this rule.',\n )\n .optional(),\n});\n\nexport type Mapping = z.infer<typeof MappingSchema>;\n","export * as env from './env';\nexport * as step from './step';\n","import type {\n Env,\n MixpanelClient,\n MixpanelPeople,\n MixpanelGroups,\n} from '../types';\n\nconst noop = (() => {}) as (...args: unknown[]) => void;\n\nconst noopPeople: MixpanelPeople = {\n set: noop,\n set_once: noop,\n increment: noop,\n append: noop,\n union: noop,\n remove: noop,\n unset: noop,\n delete_user: noop,\n};\n\nconst noopGroups: MixpanelGroups = {\n set: noop,\n set_once: noop,\n union: noop,\n remove: noop,\n unset: noop,\n delete_group: noop,\n};\n\n/**\n * Mock Mixpanel factory that returns a no-op client instance.\n * Tests replace individual methods with spies.\n */\nfunction mockInit(): MixpanelClient {\n return {\n track: noop,\n import: noop,\n alias: noop,\n people: { ...noopPeople },\n groups: { ...noopGroups },\n };\n}\n\n/**\n * Standard mock environment for push operations.\n * The test runner clones this and replaces methods with spies.\n */\nexport const push: Env = {\n Mixpanel: { init: mockInit as (...args: unknown[]) => MixpanelClient },\n};\n\n/** Simulation tracking paths for CLI --simulate. */\nexport const simulation = [\n 'call:Mixpanel.init',\n 'call:mp.track',\n 'call:mp.import',\n 'call:mp.alias',\n 'call:mp.people.set',\n 'call:mp.people.set_once',\n 'call:mp.people.increment',\n 'call:mp.people.append',\n 'call:mp.people.union',\n 'call:mp.people.remove',\n 'call:mp.people.unset',\n 'call:mp.people.delete_user',\n 'call:mp.groups.set',\n 'call:mp.groups.set_once',\n 'call:mp.groups.union',\n 'call:mp.groups.remove',\n 'call:mp.groups.unset',\n 'call:mp.groups.delete_group',\n];\n","import type { Flow } from '@walkeros/core';\nimport { getEvent } from '@walkeros/core';\nimport type { Settings } from '../types';\n\n/**\n * Step examples may carry destination-level settings and configInclude.\n * The test runner reads these to configure the destination.\n */\nexport type MixpanelStepExample = Flow.StepExample & {\n settings?: Partial<Settings>;\n configInclude?: string[];\n};\n\n/**\n * Default event forwarding — every walkerOS event becomes\n * mp.track(event.name, { distinct_id, ...properties }).\n * With default settings.identify resolving user.id.\n */\nexport const defaultEventForwarding: MixpanelStepExample = {\n in: getEvent('product view', { timestamp: 1700000100 }),\n settings: {\n identify: {\n map: {\n distinctId: 'user.id',\n },\n },\n },\n out: ['mp.track', 'product view', { distinct_id: 'us3r' }],\n};\n\n/**\n * Track with include — flattens walkerOS `data` section into\n * prefixed track() properties.\n */\nexport const trackWithInclude: MixpanelStepExample = {\n in: getEvent('product view', { timestamp: 1700000101 }),\n settings: {\n identify: {\n map: {\n distinctId: 'user.id',\n },\n },\n },\n configInclude: ['data'],\n out: [\n 'mp.track',\n 'product view',\n {\n distinct_id: 'us3r',\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 * Per-event identify — mapping-level settings.identify overrides\n * destination-level default.\n */\nexport const perEventIdentify: MixpanelStepExample = {\n in: getEvent('user login', {\n timestamp: 1700000102,\n data: {\n user_id: 'resolved-id',\n plan: 'premium',\n },\n }),\n mapping: {\n settings: {\n identify: {\n map: {\n distinctId: 'data.user_id',\n },\n },\n },\n },\n out: [\n 'mp.track',\n 'user login',\n {\n distinct_id: 'resolved-id',\n },\n ],\n};\n\n/**\n * Track with group — group key/id attached as track property.\n */\nexport const trackWithGroup: MixpanelStepExample = {\n in: getEvent('page view', {\n timestamp: 1700000103,\n data: {\n company_id: 'acme',\n },\n }),\n settings: {\n identify: {\n map: {\n distinctId: 'user.id',\n },\n },\n },\n mapping: {\n settings: {\n group: {\n map: {\n key: { value: 'company_id' },\n id: 'data.company_id',\n },\n },\n },\n },\n out: [\n 'mp.track',\n 'page view',\n {\n distinct_id: 'us3r',\n company_id: 'acme',\n },\n ],\n};\n\n/**\n * User login with people operations — skip: true suppresses track,\n * only identity + people side effects fire.\n */\nexport const userLoginPeopleSet: MixpanelStepExample = {\n in: getEvent('user login', {\n timestamp: 1700000104,\n data: {\n user_id: 'new-user-123',\n plan: 'premium',\n company: 'Acme',\n email: 'user@acme.com',\n },\n }),\n mapping: {\n skip: true,\n settings: {\n identify: {\n map: {\n distinctId: 'data.user_id',\n },\n },\n people: {\n map: {\n set: {\n map: {\n plan: 'data.plan',\n company: 'data.company',\n email: 'data.email',\n },\n },\n set_once: {\n map: {\n first_login: 'timestamp',\n },\n },\n increment: {\n map: {\n login_count: { value: 1 },\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'mp.people.set',\n 'new-user-123',\n { plan: 'premium', company: 'Acme', email: 'user@acme.com' },\n ],\n ['mp.people.set_once', 'new-user-123', { first_login: 1700000104 }],\n ['mp.people.increment', 'new-user-123', { login_count: 1 }],\n ],\n};\n\n/**\n * Full people operation vocabulary — exercises set, set_once, increment,\n * append, union, remove, unset, delete_user.\n */\nexport const allPeopleOperations: MixpanelStepExample = {\n in: getEvent('profile update', {\n timestamp: 1700000105,\n data: {\n name: 'Jane Doe',\n email: 'jane@acme.com',\n page: '/docs/getting-started',\n removed_tag: 'trial',\n source: 'referral',\n },\n }),\n mapping: {\n skip: true,\n settings: {\n identify: {\n map: {\n distinctId: 'user.id',\n },\n },\n people: {\n map: {\n set: {\n map: {\n name: 'data.name',\n email: 'data.email',\n },\n },\n set_once: {\n map: {\n signup_source: 'data.source',\n },\n },\n increment: {\n map: {\n page_views: { value: 1 },\n },\n },\n append: {\n map: {\n visited_pages: 'data.page',\n },\n },\n union: {\n map: {\n unique_tags: { value: ['active'] },\n },\n },\n remove: {\n map: {\n tags: 'data.removed_tag',\n },\n },\n unset: { value: ['old_plan'] },\n },\n },\n },\n },\n out: [\n ['mp.people.set', 'us3r', { name: 'Jane Doe', email: 'jane@acme.com' }],\n ['mp.people.set_once', 'us3r', { signup_source: 'referral' }],\n ['mp.people.increment', 'us3r', { page_views: 1 }],\n ['mp.people.append', 'us3r', { visited_pages: '/docs/getting-started' }],\n ['mp.people.union', 'us3r', { unique_tags: ['active'] }],\n ['mp.people.remove', 'us3r', { tags: 'trial' }],\n ['mp.people.unset', 'us3r', ['old_plan']],\n ],\n};\n\n/**\n * Group profile operations — settings.groupProfile with set and set_once.\n */\nexport const companyGroupProfile: MixpanelStepExample = {\n in: getEvent('company update', {\n timestamp: 1700000106,\n data: {\n company_id: 'acme-inc',\n company_name: 'Acme, Inc.',\n plan: 'enterprise',\n employee_count: 250,\n founded_year: 2010,\n },\n }),\n mapping: {\n skip: true,\n settings: {\n groupProfile: {\n map: {\n key: { value: 'company_id' },\n id: 'data.company_id',\n set: {\n map: {\n name: 'data.company_name',\n plan: 'data.plan',\n employee_count: 'data.employee_count',\n },\n },\n set_once: {\n map: {\n founded: 'data.founded_year',\n },\n },\n },\n },\n },\n },\n out: [\n [\n 'mp.groups.set',\n 'company_id',\n 'acme-inc',\n { name: 'Acme, Inc.', plan: 'enterprise', employee_count: 250 },\n ],\n ['mp.groups.set_once', 'company_id', 'acme-inc', { founded: 2010 }],\n ],\n};\n\n/**\n * Historical import — useImport: true uses mp.import() instead of mp.track().\n */\nexport const historicalImport: MixpanelStepExample = {\n in: getEvent('order complete', {\n timestamp: 1700000107,\n data: {\n total: 99.99,\n },\n }),\n settings: {\n useImport: true,\n identify: {\n map: {\n distinctId: 'user.id',\n },\n },\n },\n out: ['mp.import', 'order complete', 1700000107, { distinct_id: 'us3r' }],\n};\n\n/**\n * Alias — legacy identity merge. Fires mp.alias before track.\n */\nexport const aliasBeforeTrack: MixpanelStepExample = {\n in: getEvent('user login', {\n timestamp: 1700000108,\n data: {\n user_id: 'new-user-456',\n anon_id: 'anon-789',\n },\n }),\n mapping: {\n settings: {\n identify: {\n map: {\n distinctId: 'data.user_id',\n alias: 'data.anon_id',\n },\n },\n },\n },\n out: [\n ['mp.alias', 'new-user-456', 'anon-789'],\n ['mp.track', 'user login', { distinct_id: 'new-user-456' }],\n ],\n};\n\n/**\n * Wildcard ignore — the rule matches but does nothing.\n */\nexport const wildcardIgnored: MixpanelStepExample = {\n in: getEvent('debug noise', { timestamp: 1700000109 }),\n mapping: { ignore: true },\n out: [],\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,QAAQ,aACL,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,MAAM,aACH,OAAO,EACP;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,UAAU,aACP,OAAO,EACP,SAAS,8CAA8C,EACvD,SAAS;AAAA,EACZ,WAAW,aACR,QAAQ,EACR,SAAS,wCAAwC,EACjD,SAAS;AAAA,EACZ,WAAW,aACR,QAAQ,EACR;AAAA,IACC;AAAA,EACF,EACC,SAAS;AAAA,EACZ,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ineProperty,a=(a,t)=>{for(var i in t)e(a,i,{get:t[i],enumerable:!0})},t={};a(t,{MappingSchema:()=>s,SettingsSchema:()=>o,mapping:()=>l,settings:()=>r});import{zodToSchema as i}from"@walkeros/core/dev";import{z as n}from"@walkeros/core/dev";var o=n.object({apiKey:n.string().min(1).describe("Your Mixpanel project token. Find it in Project Settings > Access Keys. Passed as the first argument to Mixpanel.init()."),secret:n.string().describe("API secret for the /import endpoint (historical data). Required when useImport is true.").optional(),host:n.string().describe("Mixpanel API host. Default: 'api.mixpanel.com' (US). Use 'api-eu.mixpanel.com' (EU) or 'api-in.mixpanel.com' (India).").optional(),protocol:n.string().describe("Protocol for API requests. Default: 'https'.").optional(),keepAlive:n.boolean().describe("Reuse HTTP connections. Default: true.").optional(),geolocate:n.boolean().describe("Parse IP for geolocation. Default: false. Server IP caveat: all users map to server location unless $ip is overridden.").optional(),debug:n.boolean().describe("Enable SDK debug logging. Default: false.").optional(),verbose:n.boolean().describe("Enable verbose request logging. Default: false.").optional(),test:n.boolean().describe("Enable dry-run mode. Default: false.").optional(),useImport:n.boolean().describe("Use /import endpoint instead of /track. Accepts events of any age (no 5-day limit). Requires secret for authentication.").optional(),identify:n.unknown().describe("walkerOS mapping value resolving to { distinctId, alias? }. distinctId is passed as distinct_id on every SDK call.").optional(),include:n.unknown().describe("Event data sections to flatten into track() properties. Example: ['data', 'globals']. Sections are prefixed (data_, globals_, etc.).").optional()});import{z as p}from"@walkeros/core/dev";var s=p.object({identify:p.unknown().describe("Per-event identity mapping. Resolves to { distinctId, alias? }. distinctId is passed as distinct_id to all SDK calls.").optional(),people:p.unknown().describe("Per-event people operations. Resolves to an object with any of: set, set_once, increment, append, union, remove, unset, delete_user. Each key fires a separate mp.people.* call with distinct_id as first arg.").optional(),group:p.unknown().describe("Per-event group association. Resolves to { key, id }. The group key/id is added as a track() property.").optional(),groupProfile:p.unknown().describe("Per-event group profile operations. Resolves to { key, id, set?, set_once?, union?, remove?, unset?, delete? }. Fires mp.groups.* calls.").optional(),useImport:p.unknown().describe("Per-event import flag. When truthy, uses mp.import() instead of mp.track() for this rule.").optional()}),r=i(o),l=i(s),m={};a(m,{env:()=>d,step:()=>f});var d={};a(d,{push:()=>_,simulation:()=>v});var c=()=>{},u={set:c,set_once:c,increment:c,append:c,union:c,remove:c,unset:c,delete_user:c},g={set:c,set_once:c,union:c,remove:c,unset:c,delete_group:c};var _={Mixpanel:{init:function(){return{track:c,import:c,alias:c,people:{...u},groups:{...g}}}}},v=["call:Mixpanel.init","call:mp.track","call:mp.import","call:mp.alias","call:mp.people.set","call:mp.people.set_once","call:mp.people.increment","call:mp.people.append","call:mp.people.union","call:mp.people.remove","call:mp.people.unset","call:mp.people.delete_user","call:mp.groups.set","call:mp.groups.set_once","call:mp.groups.union","call:mp.groups.remove","call:mp.groups.unset","call:mp.groups.delete_group"],f={};a(f,{aliasBeforeTrack:()=>D,allPeopleOperations:()=>P,companyGroupProfile:()=>S,defaultEventForwarding:()=>k,historicalImport:()=>x,perEventIdentify:()=>w,trackWithGroup:()=>I,trackWithInclude:()=>b,userLoginPeopleSet:()=>h,wildcardIgnored:()=>A});import{getEvent as y}from"@walkeros/core";var k={in:y("product view",{timestamp:1700000100}),settings:{identify:{map:{distinctId:"user.id"}}},out:["mp.track","product view",{distinct_id:"us3r"}]},b={in:y("product view",{timestamp:1700000101}),settings:{identify:{map:{distinctId:"user.id"}}},configInclude:["data"],out:["mp.track","product view",{distinct_id:"us3r",data_id:"ers",data_name:"Everyday Ruck Snack",data_color:"black",data_size:"l",data_price:420}]},w={in:y("user login",{timestamp:1700000102,data:{user_id:"resolved-id",plan:"premium"}}),mapping:{settings:{identify:{map:{distinctId:"data.user_id"}}}},out:["mp.track","user login",{distinct_id:"resolved-id"}]},I={in:y("page view",{timestamp:1700000103,data:{company_id:"acme"}}),settings:{identify:{map:{distinctId:"user.id"}}},mapping:{settings:{group:{map:{key:{value:"company_id"},id:"data.company_id"}}}},out:["mp.track","page view",{distinct_id:"us3r",company_id:"acme"}]},h={in:y("user login",{timestamp:1700000104,data:{user_id:"new-user-123",plan:"premium",company:"Acme",email:"user@acme.com"}}),mapping:{skip:!0,settings:{identify:{map:{distinctId:"data.user_id"}},people:{map:{set:{map:{plan:"data.plan",company:"data.company",email:"data.email"}},set_once:{map:{first_login:"timestamp"}},increment:{map:{login_count:{value:1}}}}}}},out:[["mp.people.set","new-user-123",{plan:"premium",company:"Acme",email:"user@acme.com"}],["mp.people.set_once","new-user-123",{first_login:1700000104}],["mp.people.increment","new-user-123",{login_count:1}]]},P={in:y("profile update",{timestamp:1700000105,data:{name:"Jane Doe",email:"jane@acme.com",page:"/docs/getting-started",removed_tag:"trial",source:"referral"}}),mapping:{skip:!0,settings:{identify:{map:{distinctId:"user.id"}},people:{map:{set:{map:{name:"data.name",email:"data.email"}},set_once:{map:{signup_source:"data.source"}},increment:{map:{page_views:{value:1}}},append:{map:{visited_pages:"data.page"}},union:{map:{unique_tags:{value:["active"]}}},remove:{map:{tags:"data.removed_tag"}},unset:{value:["old_plan"]}}}}},out:[["mp.people.set","us3r",{name:"Jane Doe",email:"jane@acme.com"}],["mp.people.set_once","us3r",{signup_source:"referral"}],["mp.people.increment","us3r",{page_views:1}],["mp.people.append","us3r",{visited_pages:"/docs/getting-started"}],["mp.people.union","us3r",{unique_tags:["active"]}],["mp.people.remove","us3r",{tags:"trial"}],["mp.people.unset","us3r",["old_plan"]]]},S={in:y("company update",{timestamp:1700000106,data:{company_id:"acme-inc",company_name:"Acme, Inc.",plan:"enterprise",employee_count:250,founded_year:2010}}),mapping:{skip:!0,settings:{groupProfile:{map:{key:{value:"company_id"},id:"data.company_id",set:{map:{name:"data.company_name",plan:"data.plan",employee_count:"data.employee_count"}},set_once:{map:{founded:"data.founded_year"}}}}}},out:[["mp.groups.set","company_id","acme-inc",{name:"Acme, Inc.",plan:"enterprise",employee_count:250}],["mp.groups.set_once","company_id","acme-inc",{founded:2010}]]},x={in:y("order complete",{timestamp:1700000107,data:{total:99.99}}),settings:{useImport:!0,identify:{map:{distinctId:"user.id"}}},out:["mp.import","order complete",1700000107,{distinct_id:"us3r"}]},D={in:y("user login",{timestamp:1700000108,data:{user_id:"new-user-456",anon_id:"anon-789"}}),mapping:{settings:{identify:{map:{distinctId:"data.user_id",alias:"data.anon_id"}}}},out:[["mp.alias","new-user-456","anon-789"],["mp.track","user login",{distinct_id:"new-user-456"}]]},A={in:y("debug noise",{timestamp:1700000109}),mapping:{ignore:!0},out:[]};export{m as examples,t as schemas};//# sourceMappingURL=dev.mjs.map