@funnelsgrove/runtime 0.7.4 → 0.7.6

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.
@@ -119,18 +119,24 @@ const resolveOfferItemCatalogKey = (item, baseCatalog) => {
119
119
  const explicitKey = readOfferItemExplicitRuntimePlanKey(item);
120
120
  return ((_c = (_b = (_a = (explicitKey ? resolveCatalogKey(baseCatalog, explicitKey) : null)) !== null && _a !== void 0 ? _a : resolveCatalogKey(baseCatalog, item.funnelPlanKey)) !== null && _b !== void 0 ? _b : explicitKey) !== null && _c !== void 0 ? _c : readString(item.funnelPlanKey));
121
121
  };
122
- const readGeneratedPlanStringValue = (item, mode, itemKeys, metadataKeys = itemKeys) => {
123
- var _a, _b;
122
+ const readGeneratedPlanStringValue = (item, mode, itemKeys, metadataKeys = itemKeys, fallbackMode) => {
123
+ var _a, _b, _c;
124
124
  const modeConfig = readGeneratedModeConfig(item, mode);
125
+ const fallbackModeConfig = fallbackMode
126
+ ? readGeneratedModeConfig(item, fallbackMode)
127
+ : {};
125
128
  const metadata = readOfferItemMetadata(item);
126
- return ((_b = (_a = readStringField(modeConfig, metadataKeys)) !== null && _a !== void 0 ? _a : itemKeys.reduce((result, key) => result !== null && result !== void 0 ? result : readString(item[key]), null)) !== null && _b !== void 0 ? _b : readStringField(metadata, metadataKeys));
129
+ return ((_c = (_b = (_a = readStringField(modeConfig, metadataKeys)) !== null && _a !== void 0 ? _a : readStringField(fallbackModeConfig, metadataKeys)) !== null && _b !== void 0 ? _b : itemKeys.reduce((result, key) => result !== null && result !== void 0 ? result : readString(item[key]), null)) !== null && _c !== void 0 ? _c : readStringField(metadata, metadataKeys));
127
130
  };
128
- const readGeneratedPlanNumberValue = (item, mode, itemKeys, metadataKeys = itemKeys) => {
129
- var _a, _b;
131
+ const readGeneratedPlanNumberValue = (item, mode, itemKeys, metadataKeys = itemKeys, fallbackMode) => {
132
+ var _a, _b, _c;
130
133
  const modeConfig = readGeneratedModeConfig(item, mode);
134
+ const fallbackModeConfig = fallbackMode
135
+ ? readGeneratedModeConfig(item, fallbackMode)
136
+ : {};
131
137
  const metadata = readOfferItemMetadata(item);
132
138
  const itemValue = itemKeys.reduce((result, key) => (result !== null && result !== void 0 ? result : readFiniteNumber(item[key])), null);
133
- return ((_b = (_a = readFiniteNumberField(modeConfig, metadataKeys)) !== null && _a !== void 0 ? _a : itemValue) !== null && _b !== void 0 ? _b : readFiniteNumberField(metadata, metadataKeys));
139
+ return ((_c = (_b = (_a = readFiniteNumberField(modeConfig, metadataKeys)) !== null && _a !== void 0 ? _a : readFiniteNumberField(fallbackModeConfig, metadataKeys)) !== null && _b !== void 0 ? _b : itemValue) !== null && _c !== void 0 ? _c : readFiniteNumberField(metadata, metadataKeys));
134
140
  };
135
141
  const buildGeneratedPlanOverrides = (item, mode, isDefault) => {
136
142
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
@@ -140,17 +146,20 @@ const buildGeneratedPlanOverrides = (item, mode, isDefault) => {
140
146
  const projectPlanId = (_a = readString(item.projectBillingPlanId)) !== null && _a !== void 0 ? _a : readStringField(metadata, ['projectBillingPlanId', 'projectPlanId', 'project_billing_plan_id']);
141
147
  const title = (_c = (_b = readString(item.title)) !== null && _b !== void 0 ? _b : readString(item.displayNameOverride)) !== null && _c !== void 0 ? _c : readStringField(metadata, ['title', 'displayName', 'publicPlanName', 'public_plan_name']);
142
148
  const description = readGeneratedPlanStringValue(item, mode, ['description']);
143
- const priceLabel = readGeneratedPlanStringValue(item, mode, ['priceLabel']);
144
- const perDayAmount = readGeneratedPlanStringValue(item, mode, ['perDayAmount']);
145
- const perDayLabel = readGeneratedPlanStringValue(item, mode, ['perDayLabel']);
146
- const checkoutSummaryLabel = readGeneratedPlanStringValue(item, mode, ['checkoutSummaryLabel']);
147
- const billingInterval = readGeneratedPlanStringValue(item, mode, ['billingInterval']);
148
- const billingIntervalCount = readGeneratedPlanNumberValue(item, mode, ['billingIntervalCount']);
149
+ const priceDisplayFallbackMode = mode === 'live' ? 'test' : undefined;
150
+ const readPriceString = (key) => (readGeneratedPlanStringValue(item, mode, [key], [String(key)], priceDisplayFallbackMode));
151
+ const readPriceNumber = (key) => (readGeneratedPlanNumberValue(item, mode, [key], [String(key)], priceDisplayFallbackMode));
152
+ const priceLabel = readPriceString('priceLabel');
153
+ const perDayAmount = readPriceString('perDayAmount');
154
+ const perDayLabel = readPriceString('perDayLabel');
155
+ const checkoutSummaryLabel = readPriceString('checkoutSummaryLabel');
156
+ const billingInterval = readPriceString('billingInterval');
157
+ const billingIntervalCount = readPriceNumber('billingIntervalCount');
149
158
  const followUpPlanTitle = (_e = (_d = readString(item.followUpPlanTitle)) !== null && _d !== void 0 ? _d : readString(item.followUpTitle)) !== null && _e !== void 0 ? _e : readStringField(metadata, ['followUpPlanTitle', 'followUpTitle', 'follow_up_plan_title']);
150
159
  const followUpBillingInterval = readGeneratedPlanStringValue(item, mode, ['followUpBillingInterval'], ['followUpBillingInterval', 'follow_up_billing_interval']);
151
160
  const followUpBillingIntervalCount = readGeneratedPlanNumberValue(item, mode, ['followUpBillingIntervalCount'], ['followUpBillingIntervalCount', 'follow_up_billing_interval_count']);
152
161
  const introIterations = readGeneratedPlanNumberValue(item, mode, ['introIterations'], ['introIterations', 'intro_iterations']);
153
- const amountCents = readGeneratedPlanNumberValue(item, mode, ['amountCents']);
162
+ const amountCents = readPriceNumber('amountCents');
154
163
  const modeConfig = readGeneratedModeConfig(item, mode);
155
164
  const paymentMode = (_m = (_l = (_k = (_j = (_h = (_g = (_f = readOneTimePaymentMode(modeConfig.paymentMode)) !== null && _f !== void 0 ? _f : readOneTimePaymentMode(modeConfig.payment_mode)) !== null && _g !== void 0 ? _g : readOneTimePaymentMode(modeConfig.checkoutMode)) !== null && _h !== void 0 ? _h : readOneTimePaymentMode(modeConfig.checkout_mode)) !== null && _j !== void 0 ? _j : readOneTimePaymentMode(metadata.paymentMode)) !== null && _k !== void 0 ? _k : readOneTimePaymentMode(metadata.payment_mode)) !== null && _l !== void 0 ? _l : readOneTimePaymentMode(metadata.checkoutMode)) !== null && _m !== void 0 ? _m : readOneTimePaymentMode(metadata.checkout_mode);
156
165
  const analyticsPurchaseValue = (_o = readFiniteNumber(item.analyticsPurchaseValue)) !== null && _o !== void 0 ? _o : readFiniteNumberField(metadata, ['analyticsPurchaseValue']);
@@ -79,8 +79,18 @@ export const bootstrapPostHog = (config) => {
79
79
  primePostHogFlagScopePersistence(config.apiKey, scopeProperties);
80
80
  posthog.init(config.apiKey, {
81
81
  api_host: config.apiHost,
82
+ ui_host: 'https://us.posthog.com',
82
83
  persistence: 'localStorage+cookie',
83
84
  person_profiles: 'identified_only',
85
+ autocapture: false,
86
+ capture_pageview: false,
87
+ capture_pageleave: false,
88
+ capture_dead_clicks: false,
89
+ capture_exceptions: false,
90
+ capture_heatmaps: false,
91
+ capture_performance: false,
92
+ disable_session_recording: true,
93
+ disable_surveys: true,
84
94
  advanced_disable_feature_flags_on_first_load: true,
85
95
  bootstrap: { distinctID: config.distinctId },
86
96
  loaded: () => {
@@ -3,7 +3,7 @@ export declare const FUNNEL_SDK_PUBLISHABLE_KEY: string;
3
3
  export declare const FUNNEL_ID: string;
4
4
  export declare const FUNNEL_VERSION_ID: string;
5
5
  export declare const PROJECT_ID: string;
6
- export declare const POSTHOG_API_HOST = "https://us.i.posthog.com";
6
+ export declare const POSTHOG_API_HOST = "/ingest";
7
7
  export declare const POSTHOG_PROJECT_API_KEY: string;
8
8
  export declare const hasPostHogRuntimeConfig: () => boolean;
9
9
  export declare const hasRealFunnelSdkPublishableKey: (value?: string) => boolean;
@@ -22,7 +22,7 @@ export const FUNNEL_SDK_PUBLISHABLE_KEY = runtimePublicConfig.funnelSdkPublishab
22
22
  export const FUNNEL_ID = runtimePublicConfig.funnelId;
23
23
  export const FUNNEL_VERSION_ID = runtimePublicConfig.funnelVersionId;
24
24
  export const PROJECT_ID = runtimePublicConfig.projectId;
25
- export const POSTHOG_API_HOST = 'https://us.i.posthog.com';
25
+ export const POSTHOG_API_HOST = '/ingest';
26
26
  export const POSTHOG_PROJECT_API_KEY = runtimePublicConfig.posthogProjectApiKey;
27
27
  export const hasPostHogRuntimeConfig = () => {
28
28
  return Boolean(POSTHOG_API_HOST && POSTHOG_PROJECT_API_KEY && PROJECT_ID);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",