@rawdash/connector-mixpanel 0.0.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseConnector, ConnectorContext, SyncOptions, StorageHandle, SyncResult, MetricSample } from '@rawdash/core';
1
+ import { BaseConnector, ConnectorCost, ConnectorContext, SyncOptions, StorageHandle, SyncResult, MetricSample, ConnectorDoc } from '@rawdash/core';
2
2
  import { z } from 'zod';
3
3
 
4
4
  declare const configFields: z.ZodObject<{
@@ -20,6 +20,8 @@ declare const configFields: z.ZodObject<{
20
20
  activeUserEvent: z.ZodOptional<z.ZodString>;
21
21
  lookbackDays: z.ZodOptional<z.ZodNumber>;
22
22
  }, z.core.$strip>;
23
+ declare const doc: ConnectorDoc;
24
+ declare const cost: ConnectorCost;
23
25
  interface MixpanelFunnelSpec {
24
26
  id: string | number;
25
27
  name?: string;
@@ -87,12 +89,375 @@ interface RetentionCohort {
87
89
  counts: number[];
88
90
  }
89
91
  type RetentionResponse = Record<string, RetentionCohort>;
92
+ declare const mixpanelResources: {
93
+ readonly mixpanel_dau: {
94
+ readonly shape: "metric";
95
+ readonly description: "Daily active users - unique-user counts for the active-user event, one sample per day.";
96
+ readonly endpoint: "GET /api/2.0/segmentation (type=unique, unit=day)";
97
+ readonly unit: "users";
98
+ readonly granularity: "day";
99
+ readonly notes: "Each metric is rewritten in full per sync (idempotent replace).";
100
+ readonly dimensions: [{
101
+ readonly name: "unit";
102
+ readonly description: "Active-user window: always `day`.";
103
+ }, {
104
+ readonly name: "event";
105
+ readonly description: "The event the active-user count is based on.";
106
+ }];
107
+ readonly responses: {
108
+ readonly dau: z.ZodObject<{
109
+ legend_size: z.ZodOptional<z.ZodNumber>;
110
+ data: z.ZodObject<{
111
+ series: z.ZodArray<z.ZodString>;
112
+ values: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
113
+ }, z.core.$strip>;
114
+ }, z.core.$strip>;
115
+ };
116
+ };
117
+ readonly mixpanel_wau: {
118
+ readonly shape: "metric";
119
+ readonly description: "Weekly active users - unique-user counts for the active-user event, one sample per week.";
120
+ readonly endpoint: "GET /api/2.0/segmentation (type=unique, unit=week)";
121
+ readonly unit: "users";
122
+ readonly granularity: "week";
123
+ readonly notes: "Each metric is rewritten in full per sync (idempotent replace).";
124
+ readonly dimensions: [{
125
+ readonly name: "unit";
126
+ readonly description: "Active-user window: always `week`.";
127
+ }, {
128
+ readonly name: "event";
129
+ readonly description: "The event the active-user count is based on.";
130
+ }];
131
+ readonly responses: {
132
+ readonly wau: z.ZodObject<{
133
+ legend_size: z.ZodOptional<z.ZodNumber>;
134
+ data: z.ZodObject<{
135
+ series: z.ZodArray<z.ZodString>;
136
+ values: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
137
+ }, z.core.$strip>;
138
+ }, z.core.$strip>;
139
+ };
140
+ };
141
+ readonly mixpanel_mau: {
142
+ readonly shape: "metric";
143
+ readonly description: "Monthly active users - unique-user counts for the active-user event, one sample per month.";
144
+ readonly endpoint: "GET /api/2.0/segmentation (type=unique, unit=month)";
145
+ readonly unit: "users";
146
+ readonly granularity: "month";
147
+ readonly notes: "Each metric is rewritten in full per sync (idempotent replace).";
148
+ readonly dimensions: [{
149
+ readonly name: "unit";
150
+ readonly description: "Active-user window: always `month`.";
151
+ }, {
152
+ readonly name: "event";
153
+ readonly description: "The event the active-user count is based on.";
154
+ }];
155
+ readonly responses: {
156
+ readonly mau: z.ZodObject<{
157
+ legend_size: z.ZodOptional<z.ZodNumber>;
158
+ data: z.ZodObject<{
159
+ series: z.ZodArray<z.ZodString>;
160
+ values: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
161
+ }, z.core.$strip>;
162
+ }, z.core.$strip>;
163
+ };
164
+ };
165
+ readonly mixpanel_events_per_day: {
166
+ readonly shape: "metric";
167
+ readonly description: "Per-day volume for each configured event. The sample value is the total event count; unique-user count is carried as an attribute.";
168
+ readonly endpoint: "GET /api/2.0/segmentation (type=general and type=unique)";
169
+ readonly unit: "events";
170
+ readonly granularity: "day";
171
+ readonly notes: "Each metric is rewritten in full per sync (idempotent replace).";
172
+ readonly dimensions: [{
173
+ readonly name: "event";
174
+ readonly description: "The configured event name.";
175
+ }, {
176
+ readonly name: "count";
177
+ readonly description: "Total event count for the day (equals the value).";
178
+ }, {
179
+ readonly name: "uniqueUsers";
180
+ readonly description: "Distinct users who triggered the event that day.";
181
+ }];
182
+ readonly responses: {
183
+ readonly events_per_day: z.ZodObject<{
184
+ legend_size: z.ZodOptional<z.ZodNumber>;
185
+ data: z.ZodObject<{
186
+ series: z.ZodArray<z.ZodString>;
187
+ values: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
188
+ }, z.core.$strip>;
189
+ }, z.core.$strip>;
190
+ };
191
+ };
192
+ readonly mixpanel_funnel_results: {
193
+ readonly shape: "metric";
194
+ readonly description: "Per-day funnel conversion. One sample per (date, step); the value is the user count reaching that step.";
195
+ readonly endpoint: "GET /api/2.0/funnels (unit=day)";
196
+ readonly unit: "users";
197
+ readonly granularity: "day";
198
+ readonly notes: "Each metric is rewritten in full per sync (idempotent replace).";
199
+ readonly dimensions: [{
200
+ readonly name: "funnelId";
201
+ readonly description: "The configured Mixpanel funnel ID.";
202
+ }, {
203
+ readonly name: "funnelName";
204
+ readonly description: "Optional display name from config (present when set).";
205
+ }, {
206
+ readonly name: "step";
207
+ readonly description: "Zero-based step index in the funnel.";
208
+ }, {
209
+ readonly name: "stepLabel";
210
+ readonly description: "Human-readable step label or event name.";
211
+ }, {
212
+ readonly name: "users";
213
+ readonly description: "Users reaching this step.";
214
+ }, {
215
+ readonly name: "conversionRate";
216
+ readonly description: "Overall conversion ratio from the first step.";
217
+ }, {
218
+ readonly name: "stepConversionRate";
219
+ readonly description: "Conversion ratio from the previous step.";
220
+ }];
221
+ readonly responses: {
222
+ readonly funnel_results: z.ZodObject<{
223
+ meta: z.ZodOptional<z.ZodObject<{
224
+ dates: z.ZodOptional<z.ZodArray<z.ZodString>>;
225
+ }, z.core.$strip>>;
226
+ data: z.ZodRecord<z.ZodString, z.ZodObject<{
227
+ steps: z.ZodArray<z.ZodObject<{
228
+ step_label: z.ZodOptional<z.ZodString>;
229
+ goal: z.ZodOptional<z.ZodString>;
230
+ event: z.ZodOptional<z.ZodString>;
231
+ count: z.ZodNumber;
232
+ overall_conv_ratio: z.ZodOptional<z.ZodNumber>;
233
+ step_conv_ratio: z.ZodOptional<z.ZodNumber>;
234
+ }, z.core.$strip>>;
235
+ analysis: z.ZodOptional<z.ZodObject<{
236
+ completion: z.ZodOptional<z.ZodNumber>;
237
+ starting_amount: z.ZodOptional<z.ZodNumber>;
238
+ steps: z.ZodOptional<z.ZodNumber>;
239
+ worst: z.ZodOptional<z.ZodNumber>;
240
+ }, z.core.$strip>>;
241
+ }, z.core.$strip>>;
242
+ }, z.core.$strip>;
243
+ };
244
+ };
245
+ readonly mixpanel_retention: {
246
+ readonly shape: "metric";
247
+ readonly description: "Cohort retention for the retention event. One sample per (cohort date, period); the value is the retained user count.";
248
+ readonly endpoint: "GET /api/2.0/retention (retention_type=birth, unit=day)";
249
+ readonly unit: "users";
250
+ readonly granularity: "day";
251
+ readonly notes: "Each metric is rewritten in full per sync (idempotent replace).";
252
+ readonly dimensions: [{
253
+ readonly name: "event";
254
+ readonly description: "The retention (born) event.";
255
+ }, {
256
+ readonly name: "period";
257
+ readonly description: "Days since the cohort birth date (period index).";
258
+ }, {
259
+ readonly name: "cohortSize";
260
+ readonly description: "Number of users in the cohort at birth.";
261
+ }, {
262
+ readonly name: "retentionRate";
263
+ readonly description: "Retained users divided by cohort size.";
264
+ }];
265
+ readonly responses: {
266
+ readonly retention: z.ZodRecord<z.ZodString, z.ZodObject<{
267
+ first: z.ZodNumber;
268
+ counts: z.ZodArray<z.ZodNumber>;
269
+ }, z.core.$strip>>;
270
+ };
271
+ };
272
+ };
90
273
  declare function buildActiveUserSamples(response: SegmentationResponse, metricName: string, unit: 'day' | 'week' | 'month', event: string): MetricSample[];
91
274
  declare function buildEventsPerDaySamples(generalResponse: SegmentationResponse, uniqueResponse: SegmentationResponse, event: string): MetricSample[];
92
275
  declare function buildFunnelSamples(response: FunnelResponse, funnel: MixpanelFunnelSpec): MetricSample[];
93
276
  declare function buildRetentionSamples(response: RetentionResponse, event: string): MetricSample[];
277
+ declare const id = "mixpanel";
94
278
  declare class MixpanelConnector extends BaseConnector<MixpanelSettings, MixpanelCredentials> {
95
279
  static readonly id = "mixpanel";
280
+ static readonly resources: {
281
+ readonly mixpanel_dau: {
282
+ readonly shape: "metric";
283
+ readonly description: "Daily active users - unique-user counts for the active-user event, one sample per day.";
284
+ readonly endpoint: "GET /api/2.0/segmentation (type=unique, unit=day)";
285
+ readonly unit: "users";
286
+ readonly granularity: "day";
287
+ readonly notes: "Each metric is rewritten in full per sync (idempotent replace).";
288
+ readonly dimensions: [{
289
+ readonly name: "unit";
290
+ readonly description: "Active-user window: always `day`.";
291
+ }, {
292
+ readonly name: "event";
293
+ readonly description: "The event the active-user count is based on.";
294
+ }];
295
+ readonly responses: {
296
+ readonly dau: z.ZodObject<{
297
+ legend_size: z.ZodOptional<z.ZodNumber>;
298
+ data: z.ZodObject<{
299
+ series: z.ZodArray<z.ZodString>;
300
+ values: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
301
+ }, z.core.$strip>;
302
+ }, z.core.$strip>;
303
+ };
304
+ };
305
+ readonly mixpanel_wau: {
306
+ readonly shape: "metric";
307
+ readonly description: "Weekly active users - unique-user counts for the active-user event, one sample per week.";
308
+ readonly endpoint: "GET /api/2.0/segmentation (type=unique, unit=week)";
309
+ readonly unit: "users";
310
+ readonly granularity: "week";
311
+ readonly notes: "Each metric is rewritten in full per sync (idempotent replace).";
312
+ readonly dimensions: [{
313
+ readonly name: "unit";
314
+ readonly description: "Active-user window: always `week`.";
315
+ }, {
316
+ readonly name: "event";
317
+ readonly description: "The event the active-user count is based on.";
318
+ }];
319
+ readonly responses: {
320
+ readonly wau: z.ZodObject<{
321
+ legend_size: z.ZodOptional<z.ZodNumber>;
322
+ data: z.ZodObject<{
323
+ series: z.ZodArray<z.ZodString>;
324
+ values: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
325
+ }, z.core.$strip>;
326
+ }, z.core.$strip>;
327
+ };
328
+ };
329
+ readonly mixpanel_mau: {
330
+ readonly shape: "metric";
331
+ readonly description: "Monthly active users - unique-user counts for the active-user event, one sample per month.";
332
+ readonly endpoint: "GET /api/2.0/segmentation (type=unique, unit=month)";
333
+ readonly unit: "users";
334
+ readonly granularity: "month";
335
+ readonly notes: "Each metric is rewritten in full per sync (idempotent replace).";
336
+ readonly dimensions: [{
337
+ readonly name: "unit";
338
+ readonly description: "Active-user window: always `month`.";
339
+ }, {
340
+ readonly name: "event";
341
+ readonly description: "The event the active-user count is based on.";
342
+ }];
343
+ readonly responses: {
344
+ readonly mau: z.ZodObject<{
345
+ legend_size: z.ZodOptional<z.ZodNumber>;
346
+ data: z.ZodObject<{
347
+ series: z.ZodArray<z.ZodString>;
348
+ values: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
349
+ }, z.core.$strip>;
350
+ }, z.core.$strip>;
351
+ };
352
+ };
353
+ readonly mixpanel_events_per_day: {
354
+ readonly shape: "metric";
355
+ readonly description: "Per-day volume for each configured event. The sample value is the total event count; unique-user count is carried as an attribute.";
356
+ readonly endpoint: "GET /api/2.0/segmentation (type=general and type=unique)";
357
+ readonly unit: "events";
358
+ readonly granularity: "day";
359
+ readonly notes: "Each metric is rewritten in full per sync (idempotent replace).";
360
+ readonly dimensions: [{
361
+ readonly name: "event";
362
+ readonly description: "The configured event name.";
363
+ }, {
364
+ readonly name: "count";
365
+ readonly description: "Total event count for the day (equals the value).";
366
+ }, {
367
+ readonly name: "uniqueUsers";
368
+ readonly description: "Distinct users who triggered the event that day.";
369
+ }];
370
+ readonly responses: {
371
+ readonly events_per_day: z.ZodObject<{
372
+ legend_size: z.ZodOptional<z.ZodNumber>;
373
+ data: z.ZodObject<{
374
+ series: z.ZodArray<z.ZodString>;
375
+ values: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
376
+ }, z.core.$strip>;
377
+ }, z.core.$strip>;
378
+ };
379
+ };
380
+ readonly mixpanel_funnel_results: {
381
+ readonly shape: "metric";
382
+ readonly description: "Per-day funnel conversion. One sample per (date, step); the value is the user count reaching that step.";
383
+ readonly endpoint: "GET /api/2.0/funnels (unit=day)";
384
+ readonly unit: "users";
385
+ readonly granularity: "day";
386
+ readonly notes: "Each metric is rewritten in full per sync (idempotent replace).";
387
+ readonly dimensions: [{
388
+ readonly name: "funnelId";
389
+ readonly description: "The configured Mixpanel funnel ID.";
390
+ }, {
391
+ readonly name: "funnelName";
392
+ readonly description: "Optional display name from config (present when set).";
393
+ }, {
394
+ readonly name: "step";
395
+ readonly description: "Zero-based step index in the funnel.";
396
+ }, {
397
+ readonly name: "stepLabel";
398
+ readonly description: "Human-readable step label or event name.";
399
+ }, {
400
+ readonly name: "users";
401
+ readonly description: "Users reaching this step.";
402
+ }, {
403
+ readonly name: "conversionRate";
404
+ readonly description: "Overall conversion ratio from the first step.";
405
+ }, {
406
+ readonly name: "stepConversionRate";
407
+ readonly description: "Conversion ratio from the previous step.";
408
+ }];
409
+ readonly responses: {
410
+ readonly funnel_results: z.ZodObject<{
411
+ meta: z.ZodOptional<z.ZodObject<{
412
+ dates: z.ZodOptional<z.ZodArray<z.ZodString>>;
413
+ }, z.core.$strip>>;
414
+ data: z.ZodRecord<z.ZodString, z.ZodObject<{
415
+ steps: z.ZodArray<z.ZodObject<{
416
+ step_label: z.ZodOptional<z.ZodString>;
417
+ goal: z.ZodOptional<z.ZodString>;
418
+ event: z.ZodOptional<z.ZodString>;
419
+ count: z.ZodNumber;
420
+ overall_conv_ratio: z.ZodOptional<z.ZodNumber>;
421
+ step_conv_ratio: z.ZodOptional<z.ZodNumber>;
422
+ }, z.core.$strip>>;
423
+ analysis: z.ZodOptional<z.ZodObject<{
424
+ completion: z.ZodOptional<z.ZodNumber>;
425
+ starting_amount: z.ZodOptional<z.ZodNumber>;
426
+ steps: z.ZodOptional<z.ZodNumber>;
427
+ worst: z.ZodOptional<z.ZodNumber>;
428
+ }, z.core.$strip>>;
429
+ }, z.core.$strip>>;
430
+ }, z.core.$strip>;
431
+ };
432
+ };
433
+ readonly mixpanel_retention: {
434
+ readonly shape: "metric";
435
+ readonly description: "Cohort retention for the retention event. One sample per (cohort date, period); the value is the retained user count.";
436
+ readonly endpoint: "GET /api/2.0/retention (retention_type=birth, unit=day)";
437
+ readonly unit: "users";
438
+ readonly granularity: "day";
439
+ readonly notes: "Each metric is rewritten in full per sync (idempotent replace).";
440
+ readonly dimensions: [{
441
+ readonly name: "event";
442
+ readonly description: "The retention (born) event.";
443
+ }, {
444
+ readonly name: "period";
445
+ readonly description: "Days since the cohort birth date (period index).";
446
+ }, {
447
+ readonly name: "cohortSize";
448
+ readonly description: "Number of users in the cohort at birth.";
449
+ }, {
450
+ readonly name: "retentionRate";
451
+ readonly description: "Retained users divided by cohort size.";
452
+ }];
453
+ readonly responses: {
454
+ readonly retention: z.ZodRecord<z.ZodString, z.ZodObject<{
455
+ first: z.ZodNumber;
456
+ counts: z.ZodArray<z.ZodNumber>;
457
+ }, z.core.$strip>>;
458
+ };
459
+ };
460
+ };
96
461
  static readonly schemas: {
97
462
  readonly dau: z.ZodObject<{
98
463
  legend_size: z.ZodOptional<z.ZodNumber>;
@@ -101,6 +466,7 @@ declare class MixpanelConnector extends BaseConnector<MixpanelSettings, Mixpanel
101
466
  values: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
102
467
  }, z.core.$strip>;
103
468
  }, z.core.$strip>;
469
+ } & {
104
470
  readonly wau: z.ZodObject<{
105
471
  legend_size: z.ZodOptional<z.ZodNumber>;
106
472
  data: z.ZodObject<{
@@ -108,6 +474,7 @@ declare class MixpanelConnector extends BaseConnector<MixpanelSettings, Mixpanel
108
474
  values: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
109
475
  }, z.core.$strip>;
110
476
  }, z.core.$strip>;
477
+ } & {
111
478
  readonly mau: z.ZodObject<{
112
479
  legend_size: z.ZodOptional<z.ZodNumber>;
113
480
  data: z.ZodObject<{
@@ -115,6 +482,7 @@ declare class MixpanelConnector extends BaseConnector<MixpanelSettings, Mixpanel
115
482
  values: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
116
483
  }, z.core.$strip>;
117
484
  }, z.core.$strip>;
485
+ } & {
118
486
  readonly events_per_day: z.ZodObject<{
119
487
  legend_size: z.ZodOptional<z.ZodNumber>;
120
488
  data: z.ZodObject<{
@@ -122,6 +490,7 @@ declare class MixpanelConnector extends BaseConnector<MixpanelSettings, Mixpanel
122
490
  values: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodNumber>>;
123
491
  }, z.core.$strip>;
124
492
  }, z.core.$strip>;
493
+ } & {
125
494
  readonly funnel_results: z.ZodObject<{
126
495
  meta: z.ZodOptional<z.ZodObject<{
127
496
  dates: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -143,11 +512,13 @@ declare class MixpanelConnector extends BaseConnector<MixpanelSettings, Mixpanel
143
512
  }, z.core.$strip>>;
144
513
  }, z.core.$strip>>;
145
514
  }, z.core.$strip>;
515
+ } & {
146
516
  readonly retention: z.ZodRecord<z.ZodString, z.ZodObject<{
147
517
  first: z.ZodNumber;
148
518
  counts: z.ZodArray<z.ZodNumber>;
149
519
  }, z.core.$strip>>;
150
- };
520
+ } & Readonly<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
521
+ static readonly cost: ConnectorCost;
151
522
  static create(input: unknown, ctx?: ConnectorContext): MixpanelConnector;
152
523
  readonly id = "mixpanel";
153
524
  readonly credentials: {
@@ -174,4 +545,4 @@ declare class MixpanelConnector extends BaseConnector<MixpanelSettings, Mixpanel
174
545
  sync(options: SyncOptions, storage: StorageHandle, signal?: AbortSignal): Promise<SyncResult>;
175
546
  }
176
547
 
177
- export { MixpanelConnector, type MixpanelFunnelSpec, type MixpanelPhase, type MixpanelResource, type MixpanelSettings, buildActiveUserSamples, buildEventsPerDaySamples, buildFunnelSamples, buildRetentionSamples, configFields, MixpanelConnector as default, getDateRange };
548
+ export { MixpanelConnector, type MixpanelFunnelSpec, type MixpanelPhase, type MixpanelResource, type MixpanelSettings, buildActiveUserSamples, buildEventsPerDaySamples, buildFunnelSamples, buildRetentionSamples, configFields, cost, MixpanelConnector as default, doc, getDateRange, id, mixpanelResources as resources };
package/dist/index.js CHANGED
@@ -8,7 +8,10 @@ function connectorUserAgent(connectorId) {
8
8
  // src/mixpanel.ts
9
9
  import {
10
10
  BaseConnector,
11
- defineConfigFields
11
+ defineConfigFields,
12
+ defineConnectorDoc,
13
+ defineResources,
14
+ schemasFromResources
12
15
  } from "@rawdash/core";
13
16
  import { z } from "zod";
14
17
  var funnelSpec = z.object({
@@ -64,6 +67,34 @@ var configFields = defineConfigFields(
64
67
  })
65
68
  })
66
69
  );
70
+ var doc = defineConnectorDoc({
71
+ displayName: "Mixpanel",
72
+ category: "analytics",
73
+ brandColor: "#7856FF",
74
+ tagline: "Sync Mixpanel active-user counts, per-event volume, funnel conversion, and cohort retention as metric time series.",
75
+ vendor: {
76
+ name: "Mixpanel",
77
+ apiDocs: "https://developer.mixpanel.com/reference/query-api",
78
+ website: "https://mixpanel.com"
79
+ },
80
+ auth: {
81
+ summary: "Authenticate with a Mixpanel service account (username + secret) over HTTP Basic auth, scoped to a numeric project ID.",
82
+ setup: [
83
+ "In Mixpanel, open Project settings \u2192 Service Accounts and create a service account with at least read access to the project.",
84
+ "Copy the generated username (e.g. `rawdash-reader.abcdef.mp-service-account`) and the secret shown once at creation.",
85
+ "Find the numeric project ID under Project settings \u2192 Overview and set it as `projectId`.",
86
+ 'Store the secret and reference it from config as `secret: secret("MIXPANEL_SECRET")`, alongside the `username`.',
87
+ 'For EU-resident projects, set `region: "eu"`.'
88
+ ]
89
+ },
90
+ rateLimit: "Mixpanel's Query API quota is 60 queries/hour per project (default); requests are retried with backoff.",
91
+ limitations: [
92
+ "Incremental syncs refetch a 3-day overlap because Mixpanel can re-attribute late-arriving events."
93
+ ]
94
+ });
95
+ var cost = {
96
+ warning: "Each configured event and funnel costs one or more queries per sync against Mixpanel quotas; adding many events/funnels or syncing frequently can exhaust the quota."
97
+ };
67
98
  var mixpanelCredentials = {
68
99
  username: {
69
100
  description: "Mixpanel service account username",
@@ -196,6 +227,131 @@ var retentionSchema = z.record(
196
227
  counts: z.array(finiteNumber)
197
228
  })
198
229
  );
230
+ var METRIC_NOTES = "Each metric is rewritten in full per sync (idempotent replace).";
231
+ var mixpanelResources = defineResources({
232
+ mixpanel_dau: {
233
+ shape: "metric",
234
+ description: "Daily active users - unique-user counts for the active-user event, one sample per day.",
235
+ endpoint: "GET /api/2.0/segmentation (type=unique, unit=day)",
236
+ unit: "users",
237
+ granularity: "day",
238
+ notes: METRIC_NOTES,
239
+ dimensions: [
240
+ { name: "unit", description: "Active-user window: always `day`." },
241
+ {
242
+ name: "event",
243
+ description: "The event the active-user count is based on."
244
+ }
245
+ ],
246
+ responses: { dau: segmentationSchema }
247
+ },
248
+ mixpanel_wau: {
249
+ shape: "metric",
250
+ description: "Weekly active users - unique-user counts for the active-user event, one sample per week.",
251
+ endpoint: "GET /api/2.0/segmentation (type=unique, unit=week)",
252
+ unit: "users",
253
+ granularity: "week",
254
+ notes: METRIC_NOTES,
255
+ dimensions: [
256
+ { name: "unit", description: "Active-user window: always `week`." },
257
+ {
258
+ name: "event",
259
+ description: "The event the active-user count is based on."
260
+ }
261
+ ],
262
+ responses: { wau: segmentationSchema }
263
+ },
264
+ mixpanel_mau: {
265
+ shape: "metric",
266
+ description: "Monthly active users - unique-user counts for the active-user event, one sample per month.",
267
+ endpoint: "GET /api/2.0/segmentation (type=unique, unit=month)",
268
+ unit: "users",
269
+ granularity: "month",
270
+ notes: METRIC_NOTES,
271
+ dimensions: [
272
+ { name: "unit", description: "Active-user window: always `month`." },
273
+ {
274
+ name: "event",
275
+ description: "The event the active-user count is based on."
276
+ }
277
+ ],
278
+ responses: { mau: segmentationSchema }
279
+ },
280
+ mixpanel_events_per_day: {
281
+ shape: "metric",
282
+ description: "Per-day volume for each configured event. The sample value is the total event count; unique-user count is carried as an attribute.",
283
+ endpoint: "GET /api/2.0/segmentation (type=general and type=unique)",
284
+ unit: "events",
285
+ granularity: "day",
286
+ notes: METRIC_NOTES,
287
+ dimensions: [
288
+ { name: "event", description: "The configured event name." },
289
+ {
290
+ name: "count",
291
+ description: "Total event count for the day (equals the value)."
292
+ },
293
+ {
294
+ name: "uniqueUsers",
295
+ description: "Distinct users who triggered the event that day."
296
+ }
297
+ ],
298
+ responses: { events_per_day: segmentationSchema }
299
+ },
300
+ mixpanel_funnel_results: {
301
+ shape: "metric",
302
+ description: "Per-day funnel conversion. One sample per (date, step); the value is the user count reaching that step.",
303
+ endpoint: "GET /api/2.0/funnels (unit=day)",
304
+ unit: "users",
305
+ granularity: "day",
306
+ notes: METRIC_NOTES,
307
+ dimensions: [
308
+ { name: "funnelId", description: "The configured Mixpanel funnel ID." },
309
+ {
310
+ name: "funnelName",
311
+ description: "Optional display name from config (present when set)."
312
+ },
313
+ { name: "step", description: "Zero-based step index in the funnel." },
314
+ {
315
+ name: "stepLabel",
316
+ description: "Human-readable step label or event name."
317
+ },
318
+ { name: "users", description: "Users reaching this step." },
319
+ {
320
+ name: "conversionRate",
321
+ description: "Overall conversion ratio from the first step."
322
+ },
323
+ {
324
+ name: "stepConversionRate",
325
+ description: "Conversion ratio from the previous step."
326
+ }
327
+ ],
328
+ responses: { funnel_results: funnelSchema }
329
+ },
330
+ mixpanel_retention: {
331
+ shape: "metric",
332
+ description: "Cohort retention for the retention event. One sample per (cohort date, period); the value is the retained user count.",
333
+ endpoint: "GET /api/2.0/retention (retention_type=birth, unit=day)",
334
+ unit: "users",
335
+ granularity: "day",
336
+ notes: METRIC_NOTES,
337
+ dimensions: [
338
+ { name: "event", description: "The retention (born) event." },
339
+ {
340
+ name: "period",
341
+ description: "Days since the cohort birth date (period index)."
342
+ },
343
+ {
344
+ name: "cohortSize",
345
+ description: "Number of users in the cohort at birth."
346
+ },
347
+ {
348
+ name: "retentionRate",
349
+ description: "Retained users divided by cohort size."
350
+ }
351
+ ],
352
+ responses: { retention: retentionSchema }
353
+ }
354
+ });
199
355
  function buildActiveUserSamples(response, metricName, unit, event) {
200
356
  const samples = [];
201
357
  const seriesByEvent = response.data.values;
@@ -316,16 +472,12 @@ function encodeBasicAuth(username, secret) {
316
472
  function regionHost(region) {
317
473
  return region === "eu" ? "eu.mixpanel.com" : "mixpanel.com";
318
474
  }
475
+ var id = "mixpanel";
319
476
  var MixpanelConnector = class _MixpanelConnector extends BaseConnector {
320
- static id = "mixpanel";
321
- static schemas = {
322
- dau: segmentationSchema,
323
- wau: segmentationSchema,
324
- mau: segmentationSchema,
325
- events_per_day: segmentationSchema,
326
- funnel_results: funnelSchema,
327
- retention: retentionSchema
328
- };
477
+ static id = id;
478
+ static resources = mixpanelResources;
479
+ static schemas = schemasFromResources(mixpanelResources);
480
+ static cost = cost;
329
481
  static create(input, ctx) {
330
482
  const parsed = configFields.parse(input);
331
483
  return new _MixpanelConnector(
@@ -345,7 +497,7 @@ var MixpanelConnector = class _MixpanelConnector extends BaseConnector {
345
497
  ctx
346
498
  );
347
499
  }
348
- id = "mixpanel";
500
+ id = id;
349
501
  credentials = mixpanelCredentials;
350
502
  get apiBase() {
351
503
  return `https://${regionHost(this.settings.region)}/api/2.0`;
@@ -567,7 +719,11 @@ export {
567
719
  buildFunnelSamples,
568
720
  buildRetentionSamples,
569
721
  configFields,
722
+ cost,
570
723
  index_default as default,
571
- getDateRange
724
+ doc,
725
+ getDateRange,
726
+ id,
727
+ mixpanelResources as resources
572
728
  };
573
729
  //# sourceMappingURL=index.js.map