@funnelsgrove/runtime 0.1.49 → 0.1.50

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.
@@ -7,6 +7,7 @@ export type FunnelStepOrderGraph = {
7
7
  entryPointStepIds?: readonly string[];
8
8
  edgesByStepId?: Partial<Record<string, readonly {
9
9
  toStepId: string;
10
+ conditionId?: string | null;
10
11
  }[]>>;
11
12
  };
12
13
  export declare const getFunnelStepSequence: (manifest: FunnelManifest) => FunnelStepId[];
@@ -17,7 +17,10 @@ export const getFunnelStepIdsByEdgeOrder = (graph) => {
17
17
  }
18
18
  visitedStepIds.add(stepId);
19
19
  orderedStepIds.push(stepId);
20
- for (const edge of ((_a = graph.edgesByStepId) === null || _a === void 0 ? void 0 : _a[stepId]) || []) {
20
+ const edges = [...(((_a = graph.edgesByStepId) === null || _a === void 0 ? void 0 : _a[stepId]) || [])].sort((left, right) => {
21
+ return Number(Boolean(left.conditionId)) - Number(Boolean(right.conditionId));
22
+ });
23
+ for (const edge of edges) {
21
24
  visit(edge.toStepId);
22
25
  }
23
26
  };
@@ -31,18 +31,6 @@ type FunnelFlowAnalyticsAdapter = {
31
31
  selected?: Record<string, unknown>;
32
32
  featureFlags?: Record<string, string>;
33
33
  }) => string | null;
34
- trackStepEngaged?: (input: {
35
- userId?: string;
36
- environment?: 'test' | 'live';
37
- stepId: string;
38
- stepName: string;
39
- stepType?: string;
40
- startedAt: string;
41
- engagedAt: string;
42
- durationMs: number;
43
- engagementThresholdMs: number;
44
- featureFlags?: Record<string, string>;
45
- }) => string | null;
46
34
  trackFunnelStarted?: (input: {
47
35
  userId?: string;
48
36
  environment?: 'test' | 'live';
@@ -13,7 +13,6 @@ import { resolveUrlUserAttributes } from './url-user-attributes.js';
13
13
  import { bootstrapPostHog, identifyPostHog, isPostHogReady, resolveExperimentVariant, } from './posthog-flags.js';
14
14
  import { getRuntimeMode, isEditorEnabled, useRuntimeMode } from '../services/runtime-mode.service.js';
15
15
  import { isPreviewFrameRuntime } from '../services/preview-frame.service.js';
16
- const FIRST_STEP_ENGAGEMENT_THRESHOLD_MS = 1000;
17
16
  export function computeRenderSuspended(input) {
18
17
  var _a;
19
18
  if (input.isPreviewRuntime || input.postHogReady) {
@@ -121,8 +120,6 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
121
120
  const prevStepIdRef = useRef(null);
122
121
  const firstStepViewedTrackedRef = useRef(false);
123
122
  const stepStartedAtByIdRef = useRef({});
124
- const engagedStepIdsRef = useRef(new Set());
125
- const firstStepEngagementTimerRef = useRef(null);
126
123
  const currentUserIdRef = useRef(user.id);
127
124
  const safeActiveStepId = useMemo(() => { var _a; return (_a = resolveRenderableStepId(activeStepId)) !== null && _a !== void 0 ? _a : safeInitialStepId; }, [activeStepId, resolveRenderableStepId, safeInitialStepId]);
128
125
  const activeStepMeta = stepById[safeActiveStepId];
@@ -453,37 +450,6 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
453
450
  occurredAt: startedAt,
454
451
  featureFlags: postHogFeatureFlagsRef.current,
455
452
  });
456
- if (!engagedStepIdsRef.current.has(renderedStepId)) {
457
- if (firstStepEngagementTimerRef.current !== null) {
458
- window.clearTimeout(firstStepEngagementTimerRef.current);
459
- }
460
- const engagedStepId = renderedStepId;
461
- const engagedStartedAt = startedAt;
462
- const engagedStepName = stepName;
463
- const engagedStepType = stepType;
464
- firstStepEngagementTimerRef.current = window.setTimeout(() => {
465
- var _a;
466
- firstStepEngagementTimerRef.current = null;
467
- if (prevStepIdRef.current !== engagedStepId ||
468
- engagedStepIdsRef.current.has(engagedStepId)) {
469
- return;
470
- }
471
- engagedStepIdsRef.current.add(engagedStepId);
472
- const engagedAt = new Date().toISOString();
473
- (_a = analytics === null || analytics === void 0 ? void 0 : analytics.trackStepEngaged) === null || _a === void 0 ? void 0 : _a.call(analytics, {
474
- userId: currentUserIdRef.current,
475
- environment: analyticsRuntimeMode,
476
- stepId: engagedStepId,
477
- stepName: engagedStepName,
478
- stepType: engagedStepType,
479
- startedAt: engagedStartedAt,
480
- engagedAt,
481
- durationMs: FIRST_STEP_ENGAGEMENT_THRESHOLD_MS,
482
- engagementThresholdMs: FIRST_STEP_ENGAGEMENT_THRESHOLD_MS,
483
- featureFlags: postHogFeatureFlagsRef.current,
484
- });
485
- }, FIRST_STEP_ENGAGEMENT_THRESHOLD_MS);
486
- }
487
453
  }
488
454
  }
489
455
  attributesAtStepStart.current = Object.assign({}, attributesRef.current);
@@ -501,12 +467,6 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
501
467
  renderedStepMeta === null || renderedStepMeta === void 0 ? void 0 : renderedStepMeta.type,
502
468
  safeActiveStepId,
503
469
  ]);
504
- useEffect(() => () => {
505
- if (firstStepEngagementTimerRef.current !== null) {
506
- window.clearTimeout(firstStepEngagementTimerRef.current);
507
- firstStepEngagementTimerRef.current = null;
508
- }
509
- }, []);
510
470
  useEffect(() => {
511
471
  setActiveStepId(safeInitialStepId);
512
472
  }, [safeInitialStepId]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.1.49",
3
+ "version": "0.1.50",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",