@funnelsgrove/runtime 0.1.28 → 0.1.30

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.
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useMemo, useState } from 'react';
4
4
  import { clearPaywallStateValue } from '../services/funnel-state.service.js';
5
5
  import { RUNTIME_PUBLIC_ENV_KEYS, runtimePublicConfig, } from '../services/public-env.js';
6
+ import { isPreviewFrameRuntimeSearch } from '../services/preview-frame.service.js';
6
7
  const normalizeDisplayValue = (value) => {
7
8
  if (value === null || typeof value === 'undefined' || value === '') {
8
9
  return '(empty)';
@@ -19,6 +20,19 @@ const runtimePublicConfigEntries = () => {
19
20
  const canUseDom = () => {
20
21
  return typeof window !== 'undefined';
21
22
  };
23
+ const isRuntimeDevInfoHidden = () => {
24
+ if (!canUseDom()) {
25
+ return false;
26
+ }
27
+ try {
28
+ const search = window.location.search;
29
+ return (new URLSearchParams(search).get('hideRuntimeDevTools') === '1' ||
30
+ isPreviewFrameRuntimeSearch(search));
31
+ }
32
+ catch (_a) {
33
+ return false;
34
+ }
35
+ };
22
36
  export const copyRuntimeDevInfoValue = async (value) => {
23
37
  var _a, _b;
24
38
  if (!value || value === '(empty)') {
@@ -65,7 +79,7 @@ export function RuntimeDevInfoBox({ runtimeMode, user, onSwitchToLiveMode, confi
65
79
  const [copiedKey, setCopiedKey] = useState(null);
66
80
  const [resetDone, setResetDone] = useState(false);
67
81
  const configItems = useMemo(() => [...configValues, ...runtimePublicConfigEntries()], [configValues]);
68
- if (runtimeMode !== 'test') {
82
+ if (runtimeMode !== 'test' || isRuntimeDevInfoHidden()) {
69
83
  return null;
70
84
  }
71
85
  const markCopied = (key) => {
@@ -4,6 +4,8 @@ type BootstrapConfig = {
4
4
  apiKey: string;
5
5
  apiHost: string;
6
6
  distinctId: string;
7
+ projectId?: string;
8
+ funnelId?: string;
7
9
  };
8
10
  export declare const bootstrapPostHog: (config: BootstrapConfig) => Promise<void>;
9
11
  export declare const isPostHogReady: () => boolean;
@@ -2,6 +2,19 @@ import posthog from 'posthog-js';
2
2
  let initialized = false;
3
3
  let readyPromise = null;
4
4
  export const POSTHOG_FEATURE_FLAG_READY_TIMEOUT_MS = 2500;
5
+ const buildFlagScopeProperties = (config) => {
6
+ var _a, _b;
7
+ const properties = {};
8
+ const projectId = (_a = config.projectId) === null || _a === void 0 ? void 0 : _a.trim();
9
+ const funnelId = (_b = config.funnelId) === null || _b === void 0 ? void 0 : _b.trim();
10
+ if (projectId) {
11
+ properties.project_id = projectId;
12
+ }
13
+ if (funnelId) {
14
+ properties.funnel_id = funnelId;
15
+ }
16
+ return properties;
17
+ };
5
18
  export const bootstrapPostHog = (config) => {
6
19
  if (readyPromise) {
7
20
  return readyPromise;
@@ -27,13 +40,19 @@ export const bootstrapPostHog = (config) => {
27
40
  api_host: config.apiHost,
28
41
  persistence: 'localStorage+cookie',
29
42
  person_profiles: 'identified_only',
43
+ advanced_disable_feature_flags_on_first_load: true,
30
44
  bootstrap: { distinctID: config.distinctId },
31
45
  loaded: () => {
46
+ const scopeProperties = buildFlagScopeProperties(config);
47
+ if (Object.keys(scopeProperties).length > 0) {
48
+ posthog.setPersonPropertiesForFlags(scopeProperties, false);
49
+ }
32
50
  let unsubscribe = null;
33
51
  unsubscribe = posthog.onFeatureFlags(() => {
34
52
  unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe();
35
53
  markReady();
36
54
  });
55
+ posthog.reloadFeatureFlags();
37
56
  },
38
57
  });
39
58
  });
@@ -275,6 +275,8 @@ export function useFunnelFlowController({ analytics, initialStepId, lockToInitia
275
275
  apiKey: POSTHOG_PROJECT_API_KEY,
276
276
  apiHost: POSTHOG_API_HOST,
277
277
  distinctId: localUserId,
278
+ projectId: PROJECT_ID,
279
+ funnelId: FUNNEL_ID,
278
280
  })
279
281
  .then(() => setPostHogReady(true))
280
282
  .catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.1.28",
3
+ "version": "0.1.30",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",