@funnelsgrove/runtime 0.1.43 → 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.
@@ -1,6 +1,5 @@
1
1
  import type { PostHog } from 'posthog-js';
2
2
  export declare const POSTHOG_FEATURE_FLAG_READY_TIMEOUT_MS = 2500;
3
- export declare const POSTHOG_SCOPED_FLAG_RELOAD_RETRY_MS = 300;
4
3
  type BootstrapConfig = {
5
4
  apiKey: string;
6
5
  apiHost: string;
@@ -3,7 +3,6 @@ import { runtimePublicConfig } from '../services/public-env.js';
3
3
  let initialized = false;
4
4
  let readyPromise = null;
5
5
  export const POSTHOG_FEATURE_FLAG_READY_TIMEOUT_MS = 2500;
6
- export const POSTHOG_SCOPED_FLAG_RELOAD_RETRY_MS = 300;
7
6
  const STORED_PERSON_PROPERTIES_KEY = '$stored_person_properties';
8
7
  const buildFlagScopeProperties = (config) => {
9
8
  var _a, _b;
@@ -85,17 +84,7 @@ export const bootstrapPostHog = (config) => {
85
84
  bootstrap: { distinctID: config.distinctId },
86
85
  loaded: () => {
87
86
  let unsubscribe = null;
88
- let scopedReloadRetried = false;
89
- unsubscribe = posthog.onFeatureFlags((flags) => {
90
- if (Object.keys(scopeProperties).length > 0 &&
91
- flags.length === 0 &&
92
- !scopedReloadRetried) {
93
- scopedReloadRetried = true;
94
- setTimeout(() => {
95
- posthog.reloadFeatureFlags();
96
- }, POSTHOG_SCOPED_FLAG_RELOAD_RETRY_MS);
97
- return;
98
- }
87
+ unsubscribe = posthog.onFeatureFlags(() => {
99
88
  unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe();
100
89
  markReady();
101
90
  });
@@ -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(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.1.43",
3
+ "version": "0.1.44",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",