@funnelsgrove/runtime 0.7.3 → 0.7.5

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.
@@ -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: () => {
@@ -1,11 +1,9 @@
1
1
  import type { FunnelExperimentDefinition } from '../config/funnel.experiments.types.js';
2
2
  import type { GeneratedOfferSet } from '../runtime/offer-set-runtime.js';
3
3
  export type FunnelRuntimeConfig = {
4
- schemaVersion: number;
4
+ schemaVersion: 2;
5
5
  funnelId: string;
6
6
  projectId: string;
7
- /** Present only on historical schema-v1 artifacts. */
8
- plans?: unknown[];
9
7
  offerSets: unknown[];
10
8
  experiments: unknown[];
11
9
  };
@@ -21,7 +19,7 @@ export type PublishedFunnelRuntimeConfig = {
21
19
  revisionId: string;
22
20
  sourceDeploymentId: string;
23
21
  sourceVersionId: string;
24
- schemaVersion: number;
22
+ schemaVersion: 2;
25
23
  publishedAt: string;
26
24
  config: FunnelRuntimeConfig;
27
25
  };
@@ -25,20 +25,7 @@ const deepFreeze = (value) => {
25
25
  }
26
26
  return value;
27
27
  };
28
- const getLegacyPlanById = (plans, projectBillingPlanId) => {
29
- var _a;
30
- return (projectBillingPlanId
31
- ? (_a = plans.find((plan) => pickString(plan, 'id') === projectBillingPlanId)) !== null && _a !== void 0 ? _a : null
32
- : null);
33
- };
34
- const getLegacyProviderMapping = (plan, mode) => {
35
- var _a;
36
- return ((_a = readRecordArray(plan === null || plan === void 0 ? void 0 : plan.providerMappings)
37
- .find((mapping) => (pickString(mapping, 'environment') === mode
38
- && pickBoolean(mapping, 'isActive', 'is_active') !== false))) !== null && _a !== void 0 ? _a : null);
39
- };
40
- const buildPlanModeConfig = (item, mode, legacyPlan = null) => {
41
- var _a, _b;
28
+ const buildPlanModeConfig = (item, mode) => {
42
29
  const metadata = isRecord(item.metadata) ? item.metadata : {};
43
30
  const directMappings = isRecord(item.providerMappingsByMode)
44
31
  ? item.providerMappingsByMode
@@ -51,20 +38,16 @@ const buildPlanModeConfig = (item, mode, legacyPlan = null) => {
51
38
  : isRecord(metadataMappings[mode])
52
39
  ? metadataMappings[mode]
53
40
  : {};
54
- const legacyMapping = getLegacyProviderMapping(legacyPlan, mode);
55
41
  const prefix = mode === 'test' ? 'test' : 'live';
56
42
  const providerPlanId = (pickString(item, `${prefix}ProviderPlanId`, `${prefix}_provider_plan_id`)
57
- || pickString(modeMapping, 'providerPlanId')
58
- || (legacyMapping ? pickString(legacyMapping, 'providerPlanId', 'provider_plan_id') : null));
43
+ || pickString(modeMapping, 'providerPlanId'));
59
44
  if (!providerPlanId) {
60
45
  return null;
61
46
  }
62
- const amountMinor = (_a = pickNumber(modeMapping, 'amountCents')) !== null && _a !== void 0 ? _a : (legacyMapping ? pickNumber(legacyMapping, 'amountMinor', 'amount_minor') : null);
63
- const interval = pickString(modeMapping, 'billingInterval')
64
- || (legacyMapping ? pickString(legacyMapping, 'interval') : null);
65
- const intervalCount = (_b = pickNumber(modeMapping, 'billingIntervalCount')) !== null && _b !== void 0 ? _b : (legacyMapping ? pickNumber(legacyMapping, 'intervalCount', 'interval_count') : null);
66
- const currency = pickString(modeMapping, 'currency')
67
- || (legacyMapping ? pickString(legacyMapping, 'currency') : null);
47
+ const amountMinor = pickNumber(modeMapping, 'amountCents');
48
+ const interval = pickString(modeMapping, 'billingInterval');
49
+ const intervalCount = pickNumber(modeMapping, 'billingIntervalCount');
50
+ const currency = pickString(modeMapping, 'currency');
68
51
  const amountMajor = amountMinor === null ? null : amountMinor / 100;
69
52
  const priceLabel = pickString(modeMapping, 'priceLabel') || (amountMajor === null
70
53
  ? null
@@ -90,7 +73,6 @@ const buildPlanModeConfig = (item, mode, legacyPlan = null) => {
90
73
  }).format(amountMajor)} today` })), (interval ? { billingInterval: interval } : {})), (intervalCount === null ? {} : { billingIntervalCount: intervalCount }));
91
74
  };
92
75
  const normalizePublishedOfferSets = (config) => {
93
- const legacyPlans = readRecordArray(config.plans);
94
76
  return readRecordArray(config.offerSets).map((offerSet) => {
95
77
  var _a;
96
78
  const key = pickString(offerSet, 'key');
@@ -105,15 +87,12 @@ const normalizePublishedOfferSets = (config) => {
105
87
  throw new Error(`Published runtime offer set "${key}" has an item without a plan key`);
106
88
  }
107
89
  const projectBillingPlanId = pickString(item, 'projectBillingPlanId', 'project_billing_plan_id');
108
- const legacyPlan = getLegacyPlanById(legacyPlans, projectBillingPlanId);
109
- const testMapping = buildPlanModeConfig(item, 'test', legacyPlan);
110
- const liveMapping = buildPlanModeConfig(item, 'live', legacyPlan);
90
+ const testMapping = buildPlanModeConfig(item, 'test');
91
+ const liveMapping = buildPlanModeConfig(item, 'live');
111
92
  const title = pickString(item, 'title', 'displayNameOverride', 'display_name_override')
112
- || pickString(metadata, 'title', 'publicPlanName', 'public_plan_name')
113
- || (legacyPlan ? pickString(legacyPlan, 'displayName', 'display_name') : null);
93
+ || pickString(metadata, 'title', 'publicPlanName', 'public_plan_name');
114
94
  const description = pickString(item, 'description')
115
- || pickString(metadata, 'description')
116
- || (legacyPlan ? pickString(legacyPlan, 'description') : null);
95
+ || pickString(metadata, 'description');
117
96
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ funnelPlanKey }, (pickString(metadata, 'runtimePlanKey', 'planKey', 'billingPlanKey')
118
97
  ? { runtimePlanKey: pickString(metadata, 'runtimePlanKey', 'planKey', 'billingPlanKey') }
119
98
  : {})), (projectBillingPlanId ? { projectBillingPlanId } : {})), (pickString(item, 'testProviderPlanId', 'test_provider_plan_id')
@@ -251,14 +230,13 @@ const parsePublishedRuntimeConfig = (value) => {
251
230
  if (typeof value.revisionId !== 'string'
252
231
  || typeof value.sourceDeploymentId !== 'string'
253
232
  || typeof value.sourceVersionId !== 'string'
254
- || typeof value.schemaVersion !== 'number'
233
+ || value.schemaVersion !== 2
255
234
  || typeof value.publishedAt !== 'string'
256
- || (schemaVersion !== 1 && schemaVersion !== 2)
235
+ || schemaVersion !== 2
257
236
  || typeof config.funnelId !== 'string'
258
237
  || typeof config.projectId !== 'string'
259
238
  || !Array.isArray(config.offerSets)
260
- || !Array.isArray(config.experiments)
261
- || (schemaVersion === 1 && !Array.isArray(config.plans))) {
239
+ || !Array.isArray(config.experiments)) {
262
240
  throw new Error('Funnel runtime config response is invalid');
263
241
  }
264
242
  return value;
@@ -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.3",
3
+ "version": "0.7.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",