@funnelsgrove/runtime 0.11.0 → 0.11.2

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/README.md CHANGED
@@ -62,6 +62,11 @@ documented in [`docs/product-specs/funnel-template-runtime.md`](../../docs/produ
62
62
  `useBrowserLocationSearch`; the shared controller also notifies it after
63
63
  `history.pushState` and `history.replaceState` navigation.
64
64
  - Keep env mapping centralized in `config/env.config.ts`.
65
+ - V2 checkout selection requires the offer set, payment profile, provider, provider
66
+ plan and plan key. `runtimeConfigRevisionId` is optional and must not gate the
67
+ request; a deployment does not invalidate an otherwise unchanged offer. Continue
68
+ forwarding a supplied revision for older API versions. Deploy the compatible
69
+ API before rolling out SDK callers that omit it.
65
70
 
66
71
  ## Build, Test, Publish
67
72
 
@@ -68,6 +68,39 @@ const asTrimmedString = (value) => {
68
68
  const trimmed = value.trim();
69
69
  return trimmed || null;
70
70
  };
71
+ const readCookieValue = (name) => {
72
+ var _a;
73
+ if (typeof document === 'undefined') {
74
+ return null;
75
+ }
76
+ let cookieHeader;
77
+ try {
78
+ cookieHeader = document.cookie;
79
+ }
80
+ catch (_b) {
81
+ return null;
82
+ }
83
+ const encodedValue = (_a = cookieHeader
84
+ .split(';')
85
+ .map((part) => part.trim())
86
+ .find((part) => part.startsWith(`${name}=`))) === null || _a === void 0 ? void 0 : _a.slice(name.length + 1);
87
+ if (!encodedValue) {
88
+ return null;
89
+ }
90
+ try {
91
+ const value = asTrimmedString(decodeURIComponent(encodedValue));
92
+ return value && value.length <= 2048 ? value : null;
93
+ }
94
+ catch (_c) {
95
+ const value = asTrimmedString(encodedValue);
96
+ return value && value.length <= 2048 ? value : null;
97
+ }
98
+ };
99
+ const collectMetaCookieTouch = () => {
100
+ const fbc = readCookieValue('_fbc');
101
+ const fbp = readCookieValue('_fbp');
102
+ return Object.assign(Object.assign({}, (fbc ? { fbc } : {})), (fbp ? { fbp } : {}));
103
+ };
71
104
  const isRecord = (value) => {
72
105
  return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
73
106
  };
@@ -242,7 +275,7 @@ export const collectCurrentFunnelAttribution = (input = {}) => {
242
275
  const timeZone = asTrimmedString(input.timeZone) || browserContext.timeZone;
243
276
  const currentUrl = toUrl(href);
244
277
  const referrerUrl = toUrl(referrer);
245
- const firstTouch = collectTouchFromUrl(currentUrl);
278
+ const firstTouch = Object.assign(Object.assign({}, collectMetaCookieTouch()), collectTouchFromUrl(currentUrl));
246
279
  const posthogContext = collectPostHogContext(resolvePostHogProperties(input.posthogProperties));
247
280
  return {
248
281
  firstTouch,
@@ -8,12 +8,12 @@ export type PublishedStripeSelectionInput = {
8
8
  runtimeConfigRevisionId?: string | null;
9
9
  };
10
10
  export declare const toV2CheckoutSelection: (input: PublishedStripeSelectionInput) => {
11
- runtimeConfigRevisionId: string | undefined;
12
11
  offerSetId: string | undefined;
13
12
  paymentProfileId: string | undefined;
14
13
  provider: "stripe" | null | undefined;
15
14
  providerPlanId: string | undefined;
16
15
  planKey: string | undefined;
16
+ runtimeConfigRevisionId: string | undefined;
17
17
  };
18
18
  export declare const toV2CheckoutSessionRequest: (input: PublishedStripeSelectionInput & {
19
19
  couponId?: string | null;
@@ -35,10 +35,10 @@ export declare const toV2CheckoutSessionRequest: (input: PublishedStripeSelectio
35
35
  anonymousUserId: string | null | undefined;
36
36
  idempotencyKey: string | null | undefined;
37
37
  environment: "test" | "live" | undefined;
38
- runtimeConfigRevisionId: string | undefined;
39
38
  offerSetId: string | undefined;
40
39
  paymentProfileId: string | undefined;
41
40
  provider: "stripe" | null | undefined;
42
41
  providerPlanId: string | undefined;
43
42
  planKey: string | undefined;
43
+ runtimeConfigRevisionId: string | undefined;
44
44
  };
@@ -1,16 +1,17 @@
1
1
  export const toV2CheckoutSelection = (input) => {
2
2
  var _a, _b, _c, _d, _e, _f;
3
3
  const selection = {
4
- runtimeConfigRevisionId: (_a = input.runtimeConfigRevisionId) === null || _a === void 0 ? void 0 : _a.trim(),
5
- offerSetId: (_b = input.offerSetId) === null || _b === void 0 ? void 0 : _b.trim(),
6
- paymentProfileId: (_c = input.paymentProfileId) === null || _c === void 0 ? void 0 : _c.trim(),
4
+ offerSetId: (_a = input.offerSetId) === null || _a === void 0 ? void 0 : _a.trim(),
5
+ paymentProfileId: (_b = input.paymentProfileId) === null || _b === void 0 ? void 0 : _b.trim(),
7
6
  provider: input.provider,
8
- providerPlanId: (_d = input.providerPlanId) === null || _d === void 0 ? void 0 : _d.trim(),
9
- planKey: ((_e = input.planKey) === null || _e === void 0 ? void 0 : _e.trim()) || ((_f = input.planId) === null || _f === void 0 ? void 0 : _f.trim()),
7
+ providerPlanId: (_c = input.providerPlanId) === null || _c === void 0 ? void 0 : _c.trim(),
8
+ planKey: ((_d = input.planKey) === null || _d === void 0 ? void 0 : _d.trim()) || ((_e = input.planId) === null || _e === void 0 ? void 0 : _e.trim()),
10
9
  };
11
10
  if (selection.provider !== 'stripe' || Object.values(selection).some((value) => !value)) {
12
11
  throw new Error('Published Stripe checkout selection is incomplete');
13
12
  }
14
- return selection;
13
+ return Object.assign({
14
+ // Retained for older API versions, but not required to identify an offer.
15
+ runtimeConfigRevisionId: ((_f = input.runtimeConfigRevisionId) === null || _f === void 0 ? void 0 : _f.trim()) || undefined }, selection);
15
16
  };
16
17
  export const toV2CheckoutSessionRequest = (input, checkoutType) => (Object.assign(Object.assign({}, toV2CheckoutSelection(input)), { checkoutType, uiMode: 'custom', couponId: input.couponId, analyticsMetadata: input.analyticsMetadata, customerEmail: input.customerEmail, returnUrl: input.returnUrl, userId: input.userId, anonymousUserId: input.anonymousUserId, idempotencyKey: input.idempotencyKey, environment: input.environment }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/runtime",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/The-Solid-Grove/funnelsgrove.git",