@funnelsgrove/runtime 0.1.61 → 0.1.63
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.
|
@@ -22,6 +22,15 @@ const EVENT_ATTRIBUTION_CLICK_ID_KEYS = new Set([
|
|
|
22
22
|
'twclid',
|
|
23
23
|
'wbraid',
|
|
24
24
|
]);
|
|
25
|
+
const EVENT_ATTRIBUTION_FILTER_KEYS = new Set([
|
|
26
|
+
'utm_source',
|
|
27
|
+
'utm_medium',
|
|
28
|
+
'utm_campaign',
|
|
29
|
+
'utm_content',
|
|
30
|
+
'utm_term',
|
|
31
|
+
'adset_id',
|
|
32
|
+
]);
|
|
33
|
+
const MAX_EVENT_ATTRIBUTION_FILTER_VALUE_CODE_POINTS = 256;
|
|
25
34
|
const POSTHOG_CONTEXT_MAPPINGS = {
|
|
26
35
|
$geoip_city_name: 'cityName',
|
|
27
36
|
$geoip_country_code: 'countryCode',
|
|
@@ -57,12 +66,18 @@ const normalizeTouch = (value) => {
|
|
|
57
66
|
return [[normalizedKey, normalizedValue]];
|
|
58
67
|
}));
|
|
59
68
|
};
|
|
60
|
-
const isEventAttributionKey = (key) => {
|
|
61
|
-
const normalizedKey = key.trim().toLowerCase();
|
|
62
|
-
return normalizedKey.startsWith('utm_') || EVENT_ATTRIBUTION_CLICK_ID_KEYS.has(normalizedKey);
|
|
63
|
-
};
|
|
64
69
|
const normalizeEventAttributionTouch = (value) => {
|
|
65
|
-
return Object.fromEntries(Object.entries(normalizeTouch(value)).
|
|
70
|
+
return Object.fromEntries(Object.entries(normalizeTouch(value)).flatMap(([key, normalizedValue]) => {
|
|
71
|
+
const canonicalKey = key.toLowerCase();
|
|
72
|
+
if (EVENT_ATTRIBUTION_FILTER_KEYS.has(canonicalKey)) {
|
|
73
|
+
return Array.from(normalizedValue).length <= MAX_EVENT_ATTRIBUTION_FILTER_VALUE_CODE_POINTS
|
|
74
|
+
? [[canonicalKey, normalizedValue]]
|
|
75
|
+
: [];
|
|
76
|
+
}
|
|
77
|
+
return EVENT_ATTRIBUTION_CLICK_ID_KEYS.has(canonicalKey)
|
|
78
|
+
? [[key, normalizedValue]]
|
|
79
|
+
: [];
|
|
80
|
+
}));
|
|
66
81
|
};
|
|
67
82
|
const normalizeContext = (value) => {
|
|
68
83
|
if (!isRecord(value)) {
|
|
@@ -179,7 +179,7 @@ export const applyGeneratedOfferSetToPlanCatalog = (baseCatalog, mode, offerSet)
|
|
|
179
179
|
if (!key) {
|
|
180
180
|
continue;
|
|
181
181
|
}
|
|
182
|
-
nextCatalog[key] = Object.assign(Object.assign({}, ((_c = nextCatalog[key]) !== null && _c !== void 0 ? _c : {})), buildGeneratedPlanOverrides(item, mode, getOfferSetItemKind(item) === 'plan' && key === defaultPlanKey));
|
|
182
|
+
nextCatalog[key] = Object.assign(Object.assign(Object.assign({}, ((_c = nextCatalog[key]) !== null && _c !== void 0 ? _c : {})), { offerSetKey: offerSet.key }), buildGeneratedPlanOverrides(item, mode, getOfferSetItemKind(item) === 'plan' && key === defaultPlanKey));
|
|
183
183
|
}
|
|
184
184
|
return nextCatalog;
|
|
185
185
|
};
|
|
@@ -72,6 +72,7 @@ export type FunnelSdkUploadPhotoInput = {
|
|
|
72
72
|
};
|
|
73
73
|
export type FunnelSdkCreateHostedCheckoutSessionInput = {
|
|
74
74
|
planId: string;
|
|
75
|
+
offerSetKey?: string | null;
|
|
75
76
|
amountCents: number;
|
|
76
77
|
successUrl: string;
|
|
77
78
|
cancelUrl: string;
|
|
@@ -94,6 +95,7 @@ export type FunnelSdkCreateHostedCheckoutSessionResponse = {
|
|
|
94
95
|
};
|
|
95
96
|
export type FunnelSdkCreateSubscriptionCheckoutInput = {
|
|
96
97
|
planId: string;
|
|
98
|
+
offerSetKey?: string | null;
|
|
97
99
|
amountCents: number;
|
|
98
100
|
returnUrl: string;
|
|
99
101
|
analyticsMetadata?: Record<string, unknown> | null;
|
|
@@ -122,6 +124,7 @@ export type FunnelSdkCreateSubscriptionCheckoutResponse = {
|
|
|
122
124
|
};
|
|
123
125
|
export type FunnelSdkCreateOneTimeCheckoutInput = {
|
|
124
126
|
planId: string;
|
|
127
|
+
offerSetKey?: string | null;
|
|
125
128
|
amountCents: number;
|
|
126
129
|
returnUrl: string;
|
|
127
130
|
analyticsMetadata?: Record<string, unknown> | null;
|
|
@@ -143,6 +146,7 @@ export type FunnelSdkCreateOneTimeCheckoutResponse = {
|
|
|
143
146
|
export type FunnelSdkUpdateSubscriptionCheckoutPlanInput = {
|
|
144
147
|
checkoutSessionId: string;
|
|
145
148
|
planId: string;
|
|
149
|
+
offerSetKey?: string | null;
|
|
146
150
|
amountCents: number;
|
|
147
151
|
analyticsMetadata?: Record<string, unknown> | null;
|
|
148
152
|
billingInterval?: string | null;
|
|
@@ -201,6 +201,7 @@ class FunnelSdkService {
|
|
|
201
201
|
return this.postJson('/sdk/public/payments/checkout-session', {
|
|
202
202
|
runtimeConfig: input.runtimeConfig,
|
|
203
203
|
body: {
|
|
204
|
+
offerSetKey: input.offerSetKey,
|
|
204
205
|
planId: input.planId,
|
|
205
206
|
providerPlanId: input.providerPlanId,
|
|
206
207
|
title: input.title,
|
|
@@ -223,6 +224,7 @@ class FunnelSdkService {
|
|
|
223
224
|
return this.postJson('/sdk/public/payments/subscriptions', {
|
|
224
225
|
runtimeConfig: input.runtimeConfig,
|
|
225
226
|
body: {
|
|
227
|
+
offerSetKey: input.offerSetKey,
|
|
226
228
|
planId: input.planId,
|
|
227
229
|
providerPlanId: input.providerPlanId,
|
|
228
230
|
title: input.title,
|
|
@@ -249,6 +251,7 @@ class FunnelSdkService {
|
|
|
249
251
|
return this.postJson('/sdk/public/payments/one-time-checkout', {
|
|
250
252
|
runtimeConfig: input.runtimeConfig,
|
|
251
253
|
body: {
|
|
254
|
+
offerSetKey: input.offerSetKey,
|
|
252
255
|
planId: input.planId,
|
|
253
256
|
providerPlanId: input.providerPlanId,
|
|
254
257
|
title: input.title,
|
|
@@ -269,6 +272,7 @@ class FunnelSdkService {
|
|
|
269
272
|
runtimeConfig: input.runtimeConfig,
|
|
270
273
|
body: {
|
|
271
274
|
checkoutSessionId: input.checkoutSessionId,
|
|
275
|
+
offerSetKey: input.offerSetKey,
|
|
272
276
|
planId: input.planId,
|
|
273
277
|
providerPlanId: input.providerPlanId,
|
|
274
278
|
title: input.title,
|