@funnelsgrove/analytics 0.1.17 → 0.1.19
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.
|
@@ -4,6 +4,7 @@ export type PublicSdkTrackEventInput = {
|
|
|
4
4
|
occurredAt?: string;
|
|
5
5
|
stepId?: string;
|
|
6
6
|
stepName?: string;
|
|
7
|
+
stepType?: string;
|
|
7
8
|
startedAt?: string;
|
|
8
9
|
endedAt?: string;
|
|
9
10
|
selected?: Record<string, unknown>;
|
|
@@ -15,12 +16,14 @@ export type PublicSdkTrackEventInput = {
|
|
|
15
16
|
export type PublicSdkStepStartInput = {
|
|
16
17
|
stepId: string;
|
|
17
18
|
stepName: string;
|
|
19
|
+
stepType?: string;
|
|
18
20
|
startedAt: string;
|
|
19
21
|
featureFlags?: Record<string, string | null | undefined>;
|
|
20
22
|
};
|
|
21
23
|
export type PublicSdkStepEndInput = {
|
|
22
24
|
stepId: string;
|
|
23
25
|
stepName: string;
|
|
26
|
+
stepType?: string;
|
|
24
27
|
startedAt: string;
|
|
25
28
|
endedAt: string;
|
|
26
29
|
selected?: Record<string, unknown>;
|
|
@@ -29,6 +32,7 @@ export type PublicSdkStepEndInput = {
|
|
|
29
32
|
export type PublicSdkStepEngagedInput = {
|
|
30
33
|
stepId: string;
|
|
31
34
|
stepName: string;
|
|
35
|
+
stepType?: string;
|
|
32
36
|
startedAt: string;
|
|
33
37
|
engagedAt: string;
|
|
34
38
|
durationMs: number;
|
|
@@ -40,6 +44,7 @@ export type PublicSdkConversionCallbackInput = {
|
|
|
40
44
|
occurredAt?: string;
|
|
41
45
|
stepId?: string;
|
|
42
46
|
stepName?: string;
|
|
47
|
+
stepType?: string;
|
|
43
48
|
metadata?: Record<string, unknown>;
|
|
44
49
|
featureFlags?: Record<string, string | null | undefined>;
|
|
45
50
|
};
|
|
@@ -82,6 +87,8 @@ export declare class PublicAnalyticsSdkService {
|
|
|
82
87
|
trackCheckoutStarted(input: PublicSdkConversionCallbackInput): string | null;
|
|
83
88
|
trackPaymentInfoSubmitted(input: PublicSdkConversionCallbackInput): string | null;
|
|
84
89
|
trackCheckoutCompleted(input: PublicSdkConversionCallbackInput): string | null;
|
|
90
|
+
trackPaymentCheckoutSucceeded(input: PublicSdkConversionCallbackInput): string | null;
|
|
91
|
+
trackPaymentCheckoutReturned(input: PublicSdkConversionCallbackInput): string | null;
|
|
85
92
|
flush(): Promise<number>;
|
|
86
93
|
private ensureUserId;
|
|
87
94
|
private resolveBootstrapUserId;
|
|
@@ -229,7 +229,7 @@ export class PublicAnalyticsSdkService {
|
|
|
229
229
|
}
|
|
230
230
|
const eventId = asString(event.eventId) || buildEventId();
|
|
231
231
|
const metadata = buildEventMetadata(eventType, asRecord(event.metadata));
|
|
232
|
-
const providerMetadata = buildDefinedRecord(Object.assign(Object.assign({}, metadata), { stepId: asString(event.stepId) || metadata.stepId, stepName: asString(event.stepName) || metadata.stepName }));
|
|
232
|
+
const providerMetadata = buildDefinedRecord(Object.assign(Object.assign({}, metadata), { stepId: asString(event.stepId) || metadata.stepId, stepName: asString(event.stepName) || metadata.stepName, stepType: asString(event.stepType) || metadata.stepType }));
|
|
233
233
|
const metaPixelEvent = mapAnalyticsEventToMetaPixelEvent({
|
|
234
234
|
eventType,
|
|
235
235
|
eventId,
|
|
@@ -255,6 +255,7 @@ export class PublicAnalyticsSdkService {
|
|
|
255
255
|
occurredAt: toIsoOrNow(event.occurredAt),
|
|
256
256
|
stepId: asString(event.stepId),
|
|
257
257
|
stepName: asString(event.stepName),
|
|
258
|
+
stepType: asString(event.stepType) || asString(metadata.stepType) || asString(metadata.step_type),
|
|
258
259
|
startedAt: asString(event.startedAt),
|
|
259
260
|
endedAt: asString(event.endedAt),
|
|
260
261
|
durationMs: (_b = toFiniteNumber((_a = event.metadata) === null || _a === void 0 ? void 0 : _a.durationMs)) !== null && _b !== void 0 ? _b : null,
|
|
@@ -278,6 +279,7 @@ export class PublicAnalyticsSdkService {
|
|
|
278
279
|
eventType: 'step_start',
|
|
279
280
|
stepId: input.stepId,
|
|
280
281
|
stepName: input.stepName,
|
|
282
|
+
stepType: input.stepType,
|
|
281
283
|
startedAt: input.startedAt,
|
|
282
284
|
occurredAt: input.startedAt,
|
|
283
285
|
featureFlags: input.featureFlags,
|
|
@@ -291,6 +293,7 @@ export class PublicAnalyticsSdkService {
|
|
|
291
293
|
eventType: 'step_end',
|
|
292
294
|
stepId: input.stepId,
|
|
293
295
|
stepName: input.stepName,
|
|
296
|
+
stepType: input.stepType,
|
|
294
297
|
startedAt: startedAt || input.startedAt,
|
|
295
298
|
endedAt: endedAt || input.endedAt,
|
|
296
299
|
occurredAt: input.endedAt,
|
|
@@ -306,6 +309,7 @@ export class PublicAnalyticsSdkService {
|
|
|
306
309
|
eventType: 'step_engaged',
|
|
307
310
|
stepId: input.stepId,
|
|
308
311
|
stepName: input.stepName,
|
|
312
|
+
stepType: input.stepType,
|
|
309
313
|
startedAt: input.startedAt,
|
|
310
314
|
endedAt: input.engagedAt,
|
|
311
315
|
occurredAt: input.engagedAt,
|
|
@@ -323,6 +327,7 @@ export class PublicAnalyticsSdkService {
|
|
|
323
327
|
occurredAt: input.occurredAt,
|
|
324
328
|
stepId: input.stepId,
|
|
325
329
|
stepName: input.stepName,
|
|
330
|
+
stepType: input.stepType,
|
|
326
331
|
metadata: input.metadata,
|
|
327
332
|
featureFlags: input.featureFlags,
|
|
328
333
|
});
|
|
@@ -334,6 +339,7 @@ export class PublicAnalyticsSdkService {
|
|
|
334
339
|
occurredAt: input.occurredAt,
|
|
335
340
|
stepId: input.stepId,
|
|
336
341
|
stepName: input.stepName,
|
|
342
|
+
stepType: input.stepType,
|
|
337
343
|
metadata: input.metadata,
|
|
338
344
|
featureFlags: input.featureFlags,
|
|
339
345
|
});
|
|
@@ -345,6 +351,7 @@ export class PublicAnalyticsSdkService {
|
|
|
345
351
|
occurredAt: input.occurredAt,
|
|
346
352
|
stepId: input.stepId,
|
|
347
353
|
stepName: input.stepName,
|
|
354
|
+
stepType: input.stepType,
|
|
348
355
|
metadata: input.metadata,
|
|
349
356
|
featureFlags: input.featureFlags,
|
|
350
357
|
});
|
|
@@ -356,6 +363,7 @@ export class PublicAnalyticsSdkService {
|
|
|
356
363
|
occurredAt: input.occurredAt,
|
|
357
364
|
stepId: input.stepId,
|
|
358
365
|
stepName: input.stepName,
|
|
366
|
+
stepType: input.stepType,
|
|
359
367
|
metadata: input.metadata,
|
|
360
368
|
featureFlags: input.featureFlags,
|
|
361
369
|
});
|
|
@@ -367,6 +375,7 @@ export class PublicAnalyticsSdkService {
|
|
|
367
375
|
occurredAt: input.occurredAt,
|
|
368
376
|
stepId: input.stepId,
|
|
369
377
|
stepName: input.stepName,
|
|
378
|
+
stepType: input.stepType,
|
|
370
379
|
metadata: input.metadata,
|
|
371
380
|
featureFlags: input.featureFlags,
|
|
372
381
|
});
|
|
@@ -378,6 +387,7 @@ export class PublicAnalyticsSdkService {
|
|
|
378
387
|
occurredAt: input.occurredAt,
|
|
379
388
|
stepId: input.stepId,
|
|
380
389
|
stepName: input.stepName,
|
|
390
|
+
stepType: input.stepType,
|
|
381
391
|
metadata: input.metadata,
|
|
382
392
|
featureFlags: input.featureFlags,
|
|
383
393
|
});
|
|
@@ -389,6 +399,7 @@ export class PublicAnalyticsSdkService {
|
|
|
389
399
|
occurredAt: input.occurredAt,
|
|
390
400
|
stepId: input.stepId,
|
|
391
401
|
stepName: input.stepName,
|
|
402
|
+
stepType: input.stepType,
|
|
392
403
|
metadata: input.metadata,
|
|
393
404
|
featureFlags: input.featureFlags,
|
|
394
405
|
});
|
|
@@ -400,6 +411,31 @@ export class PublicAnalyticsSdkService {
|
|
|
400
411
|
occurredAt: input.occurredAt,
|
|
401
412
|
stepId: input.stepId,
|
|
402
413
|
stepName: input.stepName,
|
|
414
|
+
stepType: input.stepType,
|
|
415
|
+
metadata: input.metadata,
|
|
416
|
+
featureFlags: input.featureFlags,
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
trackPaymentCheckoutSucceeded(input) {
|
|
420
|
+
return this.track({
|
|
421
|
+
eventType: 'payment_checkout_succeeded',
|
|
422
|
+
eventId: input.eventId,
|
|
423
|
+
occurredAt: input.occurredAt,
|
|
424
|
+
stepId: input.stepId,
|
|
425
|
+
stepName: input.stepName,
|
|
426
|
+
stepType: input.stepType,
|
|
427
|
+
metadata: input.metadata,
|
|
428
|
+
featureFlags: input.featureFlags,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
trackPaymentCheckoutReturned(input) {
|
|
432
|
+
return this.track({
|
|
433
|
+
eventType: 'payment_checkout_returned',
|
|
434
|
+
eventId: input.eventId,
|
|
435
|
+
occurredAt: input.occurredAt,
|
|
436
|
+
stepId: input.stepId,
|
|
437
|
+
stepName: input.stepName,
|
|
438
|
+
stepType: input.stepType,
|
|
403
439
|
metadata: input.metadata,
|
|
404
440
|
featureFlags: input.featureFlags,
|
|
405
441
|
});
|
|
@@ -486,7 +522,7 @@ export class PublicAnalyticsSdkService {
|
|
|
486
522
|
event: toPostHogEventName(event.eventType),
|
|
487
523
|
properties: buildDefinedRecord(Object.assign(Object.assign({ distinct_id: this.ensureUserId(), $groups: {
|
|
488
524
|
project: PROJECT_ID,
|
|
489
|
-
}, $insert_id: event.eventId, project_id: PROJECT_ID, funnel_id: FUNNEL_ID || undefined, funnel_version_id: FUNNEL_VERSION_ID || undefined, environment: resolveAnalyticsEnvironment(), test: isRuntimeTestMode() || undefined, step_id: event.stepId || undefined, step_name: event.stepName || undefined, started_at: event.startedAt || undefined, ended_at: event.endedAt || undefined, duration_ms: (_a = event.durationMs) !== null && _a !== void 0 ? _a : undefined, engagement_threshold_ms: (_b = event.engagementThresholdMs) !== null && _b !== void 0 ? _b : undefined, event_source: 'client' }, buildFeatureFlagProperties(event.featureFlags)), { selected: Object.keys(event.selected).length > 0 ? event.selected : undefined, payload: Object.keys(event.payload).length > 0 ? event.payload : undefined, context: Object.keys(event.context).length > 0 ? event.context : undefined, metadata: Object.keys(event.metadata).length > 0 ? event.metadata : undefined })),
|
|
525
|
+
}, $insert_id: event.eventId, project_id: PROJECT_ID, funnel_id: FUNNEL_ID || undefined, funnel_version_id: FUNNEL_VERSION_ID || undefined, environment: resolveAnalyticsEnvironment(), test: isRuntimeTestMode() || undefined, step_id: event.stepId || undefined, step_name: event.stepName || undefined, step_type: event.stepType || undefined, started_at: event.startedAt || undefined, ended_at: event.endedAt || undefined, duration_ms: (_a = event.durationMs) !== null && _a !== void 0 ? _a : undefined, engagement_threshold_ms: (_b = event.engagementThresholdMs) !== null && _b !== void 0 ? _b : undefined, event_source: 'client' }, buildFeatureFlagProperties(event.featureFlags)), { selected: Object.keys(event.selected).length > 0 ? event.selected : undefined, payload: Object.keys(event.payload).length > 0 ? event.payload : undefined, context: Object.keys(event.context).length > 0 ? event.context : undefined, metadata: Object.keys(event.metadata).length > 0 ? event.metadata : undefined })),
|
|
490
526
|
timestamp: event.occurredAt,
|
|
491
527
|
});
|
|
492
528
|
});
|