@funnelsgrove/runtime 0.1.30 → 0.1.31
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.
|
@@ -354,6 +354,7 @@ export function useFunnelFlowController({ analytics, initialStepId, lockToInitia
|
|
|
354
354
|
completedAt: new Date().toISOString(),
|
|
355
355
|
choices,
|
|
356
356
|
};
|
|
357
|
+
const stepType = meta.type;
|
|
357
358
|
const startedAt = stepStartedAtByIdRef.current[meta.id] || record.completedAt;
|
|
358
359
|
const durationMs = Math.max(0, new Date(record.completedAt).getTime() - new Date(startedAt).getTime());
|
|
359
360
|
dispatchWindowCustomEvent('funnel:step-completed', record);
|
|
@@ -362,11 +363,12 @@ export function useFunnelFlowController({ analytics, initialStepId, lockToInitia
|
|
|
362
363
|
userId: currentUserIdRef.current,
|
|
363
364
|
stepId: record.stepId,
|
|
364
365
|
stepName: record.stepName,
|
|
366
|
+
stepType,
|
|
365
367
|
startedAt,
|
|
366
368
|
endedAt: record.completedAt,
|
|
367
369
|
selected: record.choices,
|
|
368
370
|
});
|
|
369
|
-
capturePostHogStepEvent('step_completed', Object.assign({ distinct_id: currentUserIdRef.current, funnel_id: FUNNEL_ID || undefined, funnel_version_id: FUNNEL_VERSION_ID || undefined, project_id: PROJECT_ID || undefined, environment: runtimeMode, step_id: record.stepId, step_name: record.stepName, started_at: startedAt, ended_at: record.completedAt, duration_ms: Number.isFinite(durationMs) ? durationMs : undefined, selected: record.choices }, buildFeatureFlagProperties(postHogFeatureFlagsRef.current)));
|
|
371
|
+
capturePostHogStepEvent('step_completed', Object.assign({ distinct_id: currentUserIdRef.current, funnel_id: FUNNEL_ID || undefined, funnel_version_id: FUNNEL_VERSION_ID || undefined, project_id: PROJECT_ID || undefined, environment: runtimeMode, step_id: record.stepId, step_name: record.stepName, step_type: stepType, started_at: startedAt, ended_at: record.completedAt, duration_ms: Number.isFinite(durationMs) ? durationMs : undefined, selected: record.choices }, buildFeatureFlagProperties(postHogFeatureFlagsRef.current)));
|
|
370
372
|
}
|
|
371
373
|
setUser((prev) => {
|
|
372
374
|
var _a, _b;
|
|
@@ -412,15 +414,17 @@ export function useFunnelFlowController({ analytics, initialStepId, lockToInitia
|
|
|
412
414
|
}
|
|
413
415
|
const startedAt = new Date().toISOString();
|
|
414
416
|
const stepName = (renderedStepMeta === null || renderedStepMeta === void 0 ? void 0 : renderedStepMeta.name) || (renderedStepMeta === null || renderedStepMeta === void 0 ? void 0 : renderedStepMeta.title) || renderedStepId;
|
|
417
|
+
const stepType = renderedStepMeta === null || renderedStepMeta === void 0 ? void 0 : renderedStepMeta.type;
|
|
415
418
|
stepStartedAtByIdRef.current[renderedStepId] = startedAt;
|
|
416
419
|
if (!isPreviewRuntime) {
|
|
417
420
|
apiService.trackStepStarted({
|
|
418
421
|
userId: currentUserIdRef.current,
|
|
419
422
|
stepId: renderedStepId,
|
|
420
423
|
stepName,
|
|
424
|
+
stepType,
|
|
421
425
|
startedAt,
|
|
422
426
|
});
|
|
423
|
-
capturePostHogStepEvent('step_started', Object.assign({ distinct_id: currentUserIdRef.current, funnel_id: FUNNEL_ID || undefined, funnel_version_id: FUNNEL_VERSION_ID || undefined, project_id: PROJECT_ID || undefined, environment: runtimeMode, step_id: renderedStepId, step_name: stepName, started_at: startedAt }, buildFeatureFlagProperties(postHogFeatureFlagsRef.current)));
|
|
427
|
+
capturePostHogStepEvent('step_started', Object.assign({ distinct_id: currentUserIdRef.current, funnel_id: FUNNEL_ID || undefined, funnel_version_id: FUNNEL_VERSION_ID || undefined, project_id: PROJECT_ID || undefined, environment: runtimeMode, step_id: renderedStepId, step_name: stepName, step_type: stepType, started_at: startedAt }, buildFeatureFlagProperties(postHogFeatureFlagsRef.current)));
|
|
424
428
|
if (!firstStepViewedTrackedRef.current && safeActiveStepId === defaultStepId) {
|
|
425
429
|
firstStepViewedTrackedRef.current = true;
|
|
426
430
|
(_a = analytics === null || analytics === void 0 ? void 0 : analytics.trackFirstStepViewed) === null || _a === void 0 ? void 0 : _a.call(analytics, {
|
|
@@ -441,6 +445,7 @@ export function useFunnelFlowController({ analytics, initialStepId, lockToInitia
|
|
|
441
445
|
const engagedStepId = renderedStepId;
|
|
442
446
|
const engagedStartedAt = startedAt;
|
|
443
447
|
const engagedStepName = stepName;
|
|
448
|
+
const engagedStepType = stepType;
|
|
444
449
|
const timer = window.setTimeout(() => {
|
|
445
450
|
if (prevStepIdRef.current !== engagedStepId || engagedStepIdsRef.current.has(engagedStepId)) {
|
|
446
451
|
return;
|
|
@@ -452,6 +457,7 @@ export function useFunnelFlowController({ analytics, initialStepId, lockToInitia
|
|
|
452
457
|
eventType: 'step_engaged',
|
|
453
458
|
stepId: engagedStepId,
|
|
454
459
|
stepName: engagedStepName,
|
|
460
|
+
stepType: engagedStepType,
|
|
455
461
|
startedAt: engagedStartedAt,
|
|
456
462
|
endedAt: engagedAt,
|
|
457
463
|
metadata: {
|
|
@@ -459,7 +465,7 @@ export function useFunnelFlowController({ analytics, initialStepId, lockToInitia
|
|
|
459
465
|
engagementThresholdMs: FIRST_STEP_ENGAGEMENT_THRESHOLD_MS,
|
|
460
466
|
},
|
|
461
467
|
});
|
|
462
|
-
capturePostHogStepEvent('step_engaged', Object.assign({ distinct_id: currentUserIdRef.current, funnel_id: FUNNEL_ID || undefined, funnel_version_id: FUNNEL_VERSION_ID || undefined, project_id: PROJECT_ID || undefined, environment: runtimeMode, step_id: engagedStepId, step_name: engagedStepName, started_at: engagedStartedAt, ended_at: engagedAt, duration_ms: FIRST_STEP_ENGAGEMENT_THRESHOLD_MS, engagement_threshold_ms: FIRST_STEP_ENGAGEMENT_THRESHOLD_MS }, buildFeatureFlagProperties(postHogFeatureFlagsRef.current)));
|
|
468
|
+
capturePostHogStepEvent('step_engaged', Object.assign({ distinct_id: currentUserIdRef.current, funnel_id: FUNNEL_ID || undefined, funnel_version_id: FUNNEL_VERSION_ID || undefined, project_id: PROJECT_ID || undefined, environment: runtimeMode, step_id: engagedStepId, step_name: engagedStepName, step_type: engagedStepType, started_at: engagedStartedAt, ended_at: engagedAt, duration_ms: FIRST_STEP_ENGAGEMENT_THRESHOLD_MS, engagement_threshold_ms: FIRST_STEP_ENGAGEMENT_THRESHOLD_MS }, buildFeatureFlagProperties(postHogFeatureFlagsRef.current)));
|
|
463
469
|
}, FIRST_STEP_ENGAGEMENT_THRESHOLD_MS);
|
|
464
470
|
return () => window.clearTimeout(timer);
|
|
465
471
|
}, [
|
|
@@ -16,6 +16,7 @@ export type FunnelEvent = {
|
|
|
16
16
|
eventType: string;
|
|
17
17
|
stepId?: string;
|
|
18
18
|
stepName?: string;
|
|
19
|
+
stepType?: string;
|
|
19
20
|
startedAt?: string;
|
|
20
21
|
endedAt?: string;
|
|
21
22
|
selected?: Record<string, unknown>;
|
|
@@ -25,6 +26,7 @@ export type StepCompletionEvent = {
|
|
|
25
26
|
userId: string;
|
|
26
27
|
stepId: string;
|
|
27
28
|
stepName: string;
|
|
29
|
+
stepType?: string;
|
|
28
30
|
startedAt: string;
|
|
29
31
|
endedAt: string;
|
|
30
32
|
selected: Record<string, unknown>;
|
|
@@ -104,6 +106,7 @@ declare class ApiService {
|
|
|
104
106
|
userId: string;
|
|
105
107
|
stepId: string;
|
|
106
108
|
stepName: string;
|
|
109
|
+
stepType?: string;
|
|
107
110
|
startedAt: string;
|
|
108
111
|
}): void;
|
|
109
112
|
trackStepCompleted(event: StepCompletionEvent): void;
|
|
@@ -493,6 +493,7 @@ class ApiService {
|
|
|
493
493
|
eventType: 'step_start',
|
|
494
494
|
stepId: input.stepId,
|
|
495
495
|
stepName: input.stepName,
|
|
496
|
+
stepType: input.stepType,
|
|
496
497
|
startedAt: input.startedAt,
|
|
497
498
|
});
|
|
498
499
|
}
|
|
@@ -502,6 +503,7 @@ class ApiService {
|
|
|
502
503
|
eventType: 'step_end',
|
|
503
504
|
stepId: event.stepId,
|
|
504
505
|
stepName: event.stepName,
|
|
506
|
+
stepType: event.stepType,
|
|
505
507
|
startedAt: event.startedAt,
|
|
506
508
|
endedAt: event.endedAt,
|
|
507
509
|
selected: event.selected,
|