@funnelsgrove/runtime 0.1.49 → 0.1.51
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.
- package/dist/config/env.config.d.ts +2 -0
- package/dist/config/env.config.js +4 -0
- package/dist/runtime/funnel-runtime.d.ts +1 -0
- package/dist/runtime/funnel-runtime.js +4 -1
- package/dist/runtime/use-funnel-flow-controller.d.ts +0 -12
- package/dist/runtime/use-funnel-flow-controller.js +0 -40
- package/dist/services/project-env.d.ts +2 -0
- package/dist/services/project-env.js +4 -0
- package/package.json +1 -1
|
@@ -37,6 +37,8 @@ export declare const RUNTIME_ENV_KEYS: {
|
|
|
37
37
|
readonly googleAnalyticsId: "NEXT_PUBLIC_GOOGLE_ANALYTICS_ID";
|
|
38
38
|
readonly googleTagManagerId: "NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID";
|
|
39
39
|
readonly googleTagEventTarget: "NEXT_PUBLIC_GOOGLE_TAG_EVENT_TARGET";
|
|
40
|
+
readonly googleTagLeadSendTo: "NEXT_PUBLIC_GOOGLE_TAG_LEAD_SEND_TO";
|
|
41
|
+
readonly googleTagPurchaseSendTo: "NEXT_PUBLIC_GOOGLE_TAG_PURCHASE_SEND_TO";
|
|
40
42
|
readonly funnelCustomDomain: "FUNNEL_CUSTOM_DOMAIN";
|
|
41
43
|
readonly claimbeeWeeklyPriceId: "NEXT_PUBLIC_CLAIMBEE_WEEKLY_PRICE_ID";
|
|
42
44
|
readonly claimbeeMonthlyPriceId: "NEXT_PUBLIC_CLAIMBEE_MONTHLY_PRICE_ID";
|
|
@@ -48,6 +48,8 @@ export const RUNTIME_ENV_KEYS = {
|
|
|
48
48
|
googleAnalyticsId: 'NEXT_PUBLIC_GOOGLE_ANALYTICS_ID',
|
|
49
49
|
googleTagManagerId: 'NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID',
|
|
50
50
|
googleTagEventTarget: 'NEXT_PUBLIC_GOOGLE_TAG_EVENT_TARGET',
|
|
51
|
+
googleTagLeadSendTo: 'NEXT_PUBLIC_GOOGLE_TAG_LEAD_SEND_TO',
|
|
52
|
+
googleTagPurchaseSendTo: 'NEXT_PUBLIC_GOOGLE_TAG_PURCHASE_SEND_TO',
|
|
51
53
|
funnelCustomDomain: 'FUNNEL_CUSTOM_DOMAIN',
|
|
52
54
|
claimbeeWeeklyPriceId: 'NEXT_PUBLIC_CLAIMBEE_WEEKLY_PRICE_ID',
|
|
53
55
|
claimbeeMonthlyPriceId: 'NEXT_PUBLIC_CLAIMBEE_MONTHLY_PRICE_ID',
|
|
@@ -105,6 +107,8 @@ const RUNTIME_ENV_VALUES = {
|
|
|
105
107
|
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID: readRuntimeEnv(() => process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID),
|
|
106
108
|
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID: readRuntimeEnv(() => process.env.NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID),
|
|
107
109
|
NEXT_PUBLIC_GOOGLE_TAG_EVENT_TARGET: readRuntimeEnv(() => process.env.NEXT_PUBLIC_GOOGLE_TAG_EVENT_TARGET),
|
|
110
|
+
NEXT_PUBLIC_GOOGLE_TAG_LEAD_SEND_TO: readRuntimeEnv(() => process.env.NEXT_PUBLIC_GOOGLE_TAG_LEAD_SEND_TO),
|
|
111
|
+
NEXT_PUBLIC_GOOGLE_TAG_PURCHASE_SEND_TO: readRuntimeEnv(() => process.env.NEXT_PUBLIC_GOOGLE_TAG_PURCHASE_SEND_TO),
|
|
108
112
|
NEXT_PUBLIC_CLAIMBEE_WEEKLY_PRICE_ID: readRuntimeEnv(() => process.env.NEXT_PUBLIC_CLAIMBEE_WEEKLY_PRICE_ID),
|
|
109
113
|
NEXT_PUBLIC_CLAIMBEE_MONTHLY_PRICE_ID: readRuntimeEnv(() => process.env.NEXT_PUBLIC_CLAIMBEE_MONTHLY_PRICE_ID),
|
|
110
114
|
NEXT_PUBLIC_CLAIMBEE_YEARLY_PRICE_ID: readRuntimeEnv(() => process.env.NEXT_PUBLIC_CLAIMBEE_YEARLY_PRICE_ID),
|
|
@@ -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
|
-
|
|
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]);
|
|
@@ -37,6 +37,8 @@ export declare const PROJECT_ENV_STANDARD_KEYS: {
|
|
|
37
37
|
readonly googleAnalyticsId: "NEXT_PUBLIC_GOOGLE_ANALYTICS_ID";
|
|
38
38
|
readonly googleTagManagerId: "NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID";
|
|
39
39
|
readonly googleTagEventTarget: "NEXT_PUBLIC_GOOGLE_TAG_EVENT_TARGET";
|
|
40
|
+
readonly googleTagLeadSendTo: "NEXT_PUBLIC_GOOGLE_TAG_LEAD_SEND_TO";
|
|
41
|
+
readonly googleTagPurchaseSendTo: "NEXT_PUBLIC_GOOGLE_TAG_PURCHASE_SEND_TO";
|
|
40
42
|
};
|
|
41
43
|
export type ProjectEnvStandardKey = keyof typeof PROJECT_ENV_STANDARD_KEYS;
|
|
42
44
|
export type ProjectEnvStandardValues = Record<ProjectEnvStandardKey, string>;
|
|
@@ -37,6 +37,8 @@ export const PROJECT_ENV_STANDARD_KEYS = {
|
|
|
37
37
|
googleAnalyticsId: 'NEXT_PUBLIC_GOOGLE_ANALYTICS_ID',
|
|
38
38
|
googleTagManagerId: 'NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID',
|
|
39
39
|
googleTagEventTarget: 'NEXT_PUBLIC_GOOGLE_TAG_EVENT_TARGET',
|
|
40
|
+
googleTagLeadSendTo: 'NEXT_PUBLIC_GOOGLE_TAG_LEAD_SEND_TO',
|
|
41
|
+
googleTagPurchaseSendTo: 'NEXT_PUBLIC_GOOGLE_TAG_PURCHASE_SEND_TO',
|
|
40
42
|
};
|
|
41
43
|
export const normalizeProjectEnvValue = (value) => {
|
|
42
44
|
return (value === null || value === void 0 ? void 0 : value.trim()) || '';
|
|
@@ -108,6 +110,8 @@ const buildProjectStandardValues = (envMap) => {
|
|
|
108
110
|
googleAnalyticsId: getProjectEnvValue(envMap, PROJECT_ENV_STANDARD_KEYS.googleAnalyticsId),
|
|
109
111
|
googleTagManagerId: getProjectEnvValue(envMap, PROJECT_ENV_STANDARD_KEYS.googleTagManagerId),
|
|
110
112
|
googleTagEventTarget: getProjectEnvValue(envMap, PROJECT_ENV_STANDARD_KEYS.googleTagEventTarget),
|
|
113
|
+
googleTagLeadSendTo: getProjectEnvValue(envMap, PROJECT_ENV_STANDARD_KEYS.googleTagLeadSendTo),
|
|
114
|
+
googleTagPurchaseSendTo: getProjectEnvValue(envMap, PROJECT_ENV_STANDARD_KEYS.googleTagPurchaseSendTo),
|
|
111
115
|
};
|
|
112
116
|
};
|
|
113
117
|
export const parseProjectEnvVariables = (variables) => {
|