@funnelsgrove/runtime 0.1.42 → 0.1.44

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.
@@ -11,7 +11,7 @@ import { resolveExperimentAssignment } from './experiment-assignment.js';
11
11
  import { collectCurrentFunnelAttribution } from './funnel-attribution.js';
12
12
  import { resolveUrlUserAttributes } from './url-user-attributes.js';
13
13
  import { bootstrapPostHog, identifyPostHog, isPostHogReady, resolveExperimentVariant, } from './posthog-flags.js';
14
- import { isEditorEnabled, useRuntimeMode } from '../services/runtime-mode.service.js';
14
+ import { getRuntimeMode, isEditorEnabled, useRuntimeMode } from '../services/runtime-mode.service.js';
15
15
  import { isPreviewFrameRuntime } from '../services/preview-frame.service.js';
16
16
  const FIRST_STEP_ENGAGEMENT_THRESHOLD_MS = 1000;
17
17
  export function computeRenderSuspended(input) {
@@ -325,9 +325,10 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
325
325
  const startedAt = stepStartedAtByIdRef.current[meta.id] || record.completedAt;
326
326
  dispatchWindowCustomEvent('funnel:step-completed', record);
327
327
  if (!isPreviewRuntime) {
328
+ const analyticsRuntimeMode = getRuntimeMode();
328
329
  (_a = analytics === null || analytics === void 0 ? void 0 : analytics.trackStepCompleted) === null || _a === void 0 ? void 0 : _a.call(analytics, {
329
330
  userId: currentUserIdRef.current,
330
- environment: runtimeMode,
331
+ environment: analyticsRuntimeMode,
331
332
  stepId: record.stepId,
332
333
  stepName: record.stepName,
333
334
  stepType,
@@ -358,7 +359,7 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
358
359
  }
359
360
  return updatedUser;
360
361
  });
361
- }, [analytics, isPreviewRuntime, runtimeMode, stepById]);
362
+ }, [analytics, isPreviewRuntime, stepById]);
362
363
  const completeStep = useCallback((stepId, choices) => {
363
364
  recordStepCompletion(stepId, choices);
364
365
  }, [recordStepCompletion]);
@@ -383,10 +384,11 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
383
384
  const stepName = (renderedStepMeta === null || renderedStepMeta === void 0 ? void 0 : renderedStepMeta.name) || (renderedStepMeta === null || renderedStepMeta === void 0 ? void 0 : renderedStepMeta.title) || renderedStepId;
384
385
  const stepType = renderedStepMeta === null || renderedStepMeta === void 0 ? void 0 : renderedStepMeta.type;
385
386
  stepStartedAtByIdRef.current[renderedStepId] = startedAt;
387
+ const analyticsRuntimeMode = getRuntimeMode();
386
388
  if (!isPreviewRuntime) {
387
389
  (_a = analytics === null || analytics === void 0 ? void 0 : analytics.trackStepStarted) === null || _a === void 0 ? void 0 : _a.call(analytics, {
388
390
  userId: currentUserIdRef.current,
389
- environment: runtimeMode,
391
+ environment: analyticsRuntimeMode,
390
392
  stepId: renderedStepId,
391
393
  stepName,
392
394
  stepType,
@@ -397,7 +399,7 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
397
399
  firstStepViewedTrackedRef.current = true;
398
400
  (_b = analytics === null || analytics === void 0 ? void 0 : analytics.trackFunnelStarted) === null || _b === void 0 ? void 0 : _b.call(analytics, {
399
401
  userId: currentUserIdRef.current,
400
- environment: runtimeMode,
402
+ environment: analyticsRuntimeMode,
401
403
  stepId: renderedStepId,
402
404
  stepName,
403
405
  stepType,
@@ -406,7 +408,7 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
406
408
  });
407
409
  (_c = analytics === null || analytics === void 0 ? void 0 : analytics.trackFirstStepViewed) === null || _c === void 0 ? void 0 : _c.call(analytics, {
408
410
  userId: currentUserIdRef.current,
409
- environment: runtimeMode,
411
+ environment: analyticsRuntimeMode,
410
412
  stepId: renderedStepId,
411
413
  stepName,
412
414
  stepType,
@@ -435,7 +437,7 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
435
437
  const engagedAt = new Date().toISOString();
436
438
  (_a = analytics === null || analytics === void 0 ? void 0 : analytics.trackStepEngaged) === null || _a === void 0 ? void 0 : _a.call(analytics, {
437
439
  userId: currentUserIdRef.current,
438
- environment: runtimeMode,
440
+ environment: analyticsRuntimeMode,
439
441
  stepId: engagedStepId,
440
442
  stepName: engagedStepName,
441
443
  stepType: engagedStepType,
@@ -458,7 +460,6 @@ export function useFunnelFlowController({ analytics, initialStepId, initialAttri
458
460
  renderedStepMeta === null || renderedStepMeta === void 0 ? void 0 : renderedStepMeta.name,
459
461
  renderedStepMeta === null || renderedStepMeta === void 0 ? void 0 : renderedStepMeta.title,
460
462
  renderedStepMeta === null || renderedStepMeta === void 0 ? void 0 : renderedStepMeta.type,
461
- runtimeMode,
462
463
  safeActiveStepId,
463
464
  ]);
464
465
  useEffect(() => {
@@ -227,7 +227,7 @@ const subscribeRuntimeMode = (listener) => {
227
227
  };
228
228
  };
229
229
  export const useRuntimeMode = () => {
230
- const [mode, setMode] = useState(() => getRuntimeMode());
230
+ const [mode, setMode] = useState('live');
231
231
  useEffect(() => {
232
232
  const syncMode = () => {
233
233
  setMode(getRuntimeMode());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.1.42",
3
+ "version": "0.1.44",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",