@funnelsgrove/runtime 0.7.15 → 0.7.18

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.
@@ -37,6 +37,7 @@ function ActiveFunnelRuntimeConfigBoundary({ funnelId, funnelVersionId, children
37
37
  const refresh = () => loadFunnelRuntimeConfig(funnelId, { versionId: funnelVersionId })
38
38
  .then((published) => resolvePublishedFunnelRuntimeConfig(published, {
39
39
  expectedFunnelVersionId: funnelVersionId,
40
+ hostname: window.location.hostname,
40
41
  }))
41
42
  .then((config) => {
42
43
  if (!active)
@@ -81,6 +81,7 @@ export type OfferSetRuntimeDiscount = {
81
81
  export type OfferSetRuntimePlanOverrides = {
82
82
  offerSetId?: string;
83
83
  offerSetKey?: string;
84
+ funnelPlanKey?: string;
84
85
  projectPlanId?: string;
85
86
  providerPlanId?: string;
86
87
  paymentMode?: 'one_time';
@@ -181,7 +181,7 @@ const buildGeneratedPlanOverrides = (item, mode, isDefault) => {
181
181
  const analyticsPurchaseValue = (_o = readFiniteNumber(item.analyticsPurchaseValue)) !== null && _o !== void 0 ? _o : readFiniteNumberField(metadata, ['analyticsPurchaseValue']);
182
182
  const featuredTag = (_p = readString(item.featuredTag)) !== null && _p !== void 0 ? _p : readStringField(metadata, ['featuredTag']);
183
183
  const oldPriceLabel = (_q = readString(item.oldPriceLabel)) !== null && _q !== void 0 ? _q : readStringField(metadata, ['oldPriceLabel']);
184
- 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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (projectPlanId ? { projectPlanId } : {})), (providerPlanId ? { providerPlanId } : {})), (paymentMode ? { paymentMode } : {})), (analyticsPurchaseValue !== null ? { analyticsPurchaseValue } : {})), (title ? { title } : {})), (description ? { description } : {})), (priceLabel ? { priceLabel } : {})), (perDayAmount ? { perDayAmount } : {})), (perDayLabel ? { perDayLabel } : {})), (amountCents !== null ? { amountCents: Math.max(0, Math.round(amountCents)) } : {})), (checkoutSummaryLabel ? { checkoutSummaryLabel } : {})), (billingInterval ? { billingInterval } : {})), (billingIntervalCount !== null ? { billingIntervalCount: Math.max(1, Math.round(billingIntervalCount)) } : {})), (followUpProviderPlanId ? { followUpProviderPlanId } : {})), (followUpPlanTitle ? { followUpPlanTitle } : {})), (followUpBillingInterval ? { followUpBillingInterval } : {})), (followUpBillingIntervalCount !== null ? { followUpBillingIntervalCount: Math.max(1, Math.round(followUpBillingIntervalCount)) } : {})), (introIterations !== null ? { introIterations: Math.max(1, Math.round(introIterations)) } : {})), (featuredTag ? { featuredTag } : {})), (oldPriceLabel ? { oldPriceLabel } : {})), (isDefault ? { isDefault: true } : {}));
184
+ 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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ funnelPlanKey: item.funnelPlanKey }, (projectPlanId ? { projectPlanId } : {})), (providerPlanId ? { providerPlanId } : {})), (paymentMode ? { paymentMode } : {})), (analyticsPurchaseValue !== null ? { analyticsPurchaseValue } : {})), (title ? { title } : {})), (description ? { description } : {})), (priceLabel ? { priceLabel } : {})), (perDayAmount ? { perDayAmount } : {})), (perDayLabel ? { perDayLabel } : {})), (amountCents !== null ? { amountCents: Math.max(0, Math.round(amountCents)) } : {})), (checkoutSummaryLabel ? { checkoutSummaryLabel } : {})), (billingInterval ? { billingInterval } : {})), (billingIntervalCount !== null ? { billingIntervalCount: Math.max(1, Math.round(billingIntervalCount)) } : {})), (followUpProviderPlanId ? { followUpProviderPlanId } : {})), (followUpPlanTitle ? { followUpPlanTitle } : {})), (followUpBillingInterval ? { followUpBillingInterval } : {})), (followUpBillingIntervalCount !== null ? { followUpBillingIntervalCount: Math.max(1, Math.round(followUpBillingIntervalCount)) } : {})), (introIterations !== null ? { introIterations: Math.max(1, Math.round(introIterations)) } : {})), (featuredTag ? { featuredTag } : {})), (oldPriceLabel ? { oldPriceLabel } : {})), (isDefault ? { isDefault: true } : {}));
185
185
  };
186
186
  export const applyGeneratedOfferSetToPlanCatalog = (baseCatalog, mode, offerSet) => {
187
187
  var _a, _b, _c, _d;
@@ -8,6 +8,8 @@ export type FunnelRuntimeConfig = {
8
8
  enabled?: unknown;
9
9
  sampleRate?: unknown;
10
10
  };
11
+ defaultOfferSetId?: string | null;
12
+ defaultOfferSetIdByDomain?: Record<string, unknown>;
11
13
  offerSets: unknown[];
12
14
  experiments: unknown[];
13
15
  };
@@ -21,6 +23,7 @@ export type ResolvedFunnelRuntimeConfig = {
21
23
  sourceVersionId: string;
22
24
  publishedAt: string;
23
25
  sessionReplay?: FunnelSessionReplayConfig;
26
+ defaultOfferSetId?: string | null;
24
27
  offerSets: readonly GeneratedOfferSet[];
25
28
  experiments: readonly FunnelExperimentDefinition[];
26
29
  };
@@ -35,6 +38,7 @@ export type PublishedFunnelRuntimeConfig = {
35
38
  type RuntimeConfigFetcher = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
36
39
  export declare const resolvePublishedFunnelRuntimeConfig: (published: PublishedFunnelRuntimeConfig, options?: {
37
40
  expectedFunnelVersionId?: string;
41
+ hostname?: string;
38
42
  }) => ResolvedFunnelRuntimeConfig;
39
43
  export declare const loadFunnelRuntimeConfig: (funnelId: string, options?: {
40
44
  fetcher?: RuntimeConfigFetcher;
@@ -237,17 +237,26 @@ const normalizePublishedExperiments = (config, publishedAt, offerSets) => readRe
237
237
  };
238
238
  });
239
239
  export const resolvePublishedFunnelRuntimeConfig = (published, options = {}) => {
240
+ var _a;
240
241
  if (options.expectedFunnelVersionId
241
242
  && published.sourceVersionId !== options.expectedFunnelVersionId) {
242
243
  throw new Error('Published runtime config belongs to a different funnel version');
243
244
  }
244
245
  const offerSets = normalizePublishedOfferSets(published.config);
246
+ const hostname = ((_a = options.hostname) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase().replace(/\.$/, '')) || '';
247
+ const domainDefaults = published.config.defaultOfferSetIdByDomain;
248
+ const hasDomainDefault = Boolean(hostname
249
+ && isRecord(domainDefaults)
250
+ && Object.prototype.hasOwnProperty.call(domainDefaults, hostname));
245
251
  return deepFreeze({
246
252
  revisionId: published.revisionId,
247
253
  sourceDeploymentId: published.sourceDeploymentId,
248
254
  sourceVersionId: published.sourceVersionId,
249
255
  publishedAt: published.publishedAt,
250
256
  sessionReplay: normalizeSessionReplay(published.config.sessionReplay),
257
+ defaultOfferSetId: hasDomainDefault && isRecord(domainDefaults)
258
+ ? readString(domainDefaults[hostname])
259
+ : readString(published.config.defaultOfferSetId),
251
260
  offerSets,
252
261
  experiments: normalizePublishedExperiments(published.config, published.publishedAt, offerSets),
253
262
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.7.15",
3
+ "version": "0.7.18",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",