@economist/web-apple-pay 2.0.0-beta.2 → 2.0.0-beta.4
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 +20 -12
- package/dist/index.js +681 -361
- package/dist/src/apple-pay-button.d.ts +18 -16
- package/dist/src/apple-pay-button.js +670 -352
- package/dist/src/apple-pay-button.stories.js +667 -351
- package/dist/src/apple-pay-modal.js +44 -39
- package/dist/src/apple-pay-modal.stories.js +667 -351
- package/dist/src/clients/payment-checkout/apple-session.d.ts +14 -1
- package/dist/src/clients/payment-checkout/apple-session.js +66 -17
- package/dist/src/clients/payment-checkout/billing-contact-details.js +43 -0
- package/dist/src/clients/payment-checkout/delivery-contact-details.d.ts +16 -0
- package/dist/src/clients/payment-checkout/delivery-contact-details.js +397 -0
- package/dist/src/clients/payment-checkout/detects.d.ts +5 -0
- package/dist/src/clients/payment-checkout/detects.js +18 -14
- package/dist/src/clients/payment-checkout/messages.d.ts +6 -0
- package/dist/src/clients/payment-checkout/messages.js +7 -1
- package/dist/src/clients/payment-checkout/payment-handler.d.ts +10 -1
- package/dist/src/clients/payment-checkout/payment-handler.js +414 -36
- package/dist/src/clients/payment-checkout/session.js +13 -1
- package/dist/src/clients/payment-checkout/types.d.ts +11 -0
- package/dist/src/constants.d.ts +7 -28
- package/dist/src/constants.js +3 -7
- package/dist/src/index.d.ts +2 -4
- package/dist/src/index.js +681 -361
- package/dist/src/types/offer.types.d.ts +1 -1
- package/dist/src/utils/address-rules.d.ts +29 -0
- package/dist/src/utils/address-rules.js +260 -0
- package/dist/src/utils/addressParityFlag.d.ts +13 -0
- package/dist/src/utils/addressParityFlag.js +5 -0
- package/dist/src/utils/applePayExpressEligibility.d.ts +5 -6
- package/dist/src/utils/applePayExpressEligibility.js +2 -2
- package/dist/src/utils/billing-countries.js +46 -37
- package/dist/src/utils/buttonCopyFlag.d.ts +22 -0
- package/dist/src/utils/buttonCopyFlag.js +12 -0
- package/dist/src/utils/delivery-countries.d.ts +9 -0
- package/dist/src/utils/delivery-countries.js +255 -0
- package/dist/src/utils/expressCheckoutRedirect.d.ts +20 -2
- package/dist/src/utils/expressCheckoutRedirect.js +13 -1
- package/dist/src/utils/expressCheckoutTracking.d.ts +13 -20
- package/dist/src/utils/expressCheckoutTracking.js +22 -37
- package/dist/src/utils/latin-characters.d.ts +3 -0
- package/dist/src/utils/latin-characters.js +10 -0
- package/dist/src/utils/price-zones.d.ts +7 -0
- package/dist/src/utils/price-zones.js +212 -0
- package/dist/src/utils/print-variants.d.ts +5 -0
- package/dist/src/utils/print-variants.js +10 -0
- package/dist/src/utils/printOffersFlag.d.ts +11 -0
- package/dist/src/utils/printOffersFlag.js +5 -0
- package/dist/src/utils/recaptcha.d.ts +3 -2
- package/dist/src/utils/recaptcha.js +17 -8
- package/package.json +1 -1
- package/dist/src/apple-pay-logo.d.ts +0 -1
- package/dist/src/apple-pay-logo.js +0 -14
- package/dist/src/types/experiment-integration.d.js +0 -0
- package/dist/src/utils/getExperimentKeyFromNextData.d.ts +0 -8
- package/dist/src/utils/getExperimentKeyFromNextData.js +0 -9
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// src/data/price-zones.json
|
|
2
|
+
var price_zones_default = {
|
|
3
|
+
"AS-AS": [
|
|
4
|
+
"BD",
|
|
5
|
+
"BT",
|
|
6
|
+
"CK",
|
|
7
|
+
"FJ",
|
|
8
|
+
"ID",
|
|
9
|
+
"KH",
|
|
10
|
+
"KI",
|
|
11
|
+
"LA",
|
|
12
|
+
"LK",
|
|
13
|
+
"MH",
|
|
14
|
+
"MM",
|
|
15
|
+
"MN",
|
|
16
|
+
"MV",
|
|
17
|
+
"NC",
|
|
18
|
+
"NF",
|
|
19
|
+
"NP",
|
|
20
|
+
"NR",
|
|
21
|
+
"PF",
|
|
22
|
+
"PG",
|
|
23
|
+
"PK",
|
|
24
|
+
"PW",
|
|
25
|
+
"SB",
|
|
26
|
+
"TH",
|
|
27
|
+
"TL",
|
|
28
|
+
"TO",
|
|
29
|
+
"TV",
|
|
30
|
+
"VN",
|
|
31
|
+
"VU",
|
|
32
|
+
"WS"
|
|
33
|
+
],
|
|
34
|
+
"AS-AU": ["AU"],
|
|
35
|
+
"AS-CN": ["CN"],
|
|
36
|
+
"AS-HK": ["HK", "MO"],
|
|
37
|
+
"AS-IN": ["IN"],
|
|
38
|
+
"AS-JP": ["JP"],
|
|
39
|
+
"AS-KR": ["KR"],
|
|
40
|
+
"AS-MY": ["MY"],
|
|
41
|
+
"AS-NZ": ["NZ"],
|
|
42
|
+
"AS-PH": ["PH"],
|
|
43
|
+
"AS-SG": ["BN", "SG"],
|
|
44
|
+
"AS-TW": ["TW"],
|
|
45
|
+
"CE-AF": [
|
|
46
|
+
"DZ",
|
|
47
|
+
"AO",
|
|
48
|
+
"BJ",
|
|
49
|
+
"BW",
|
|
50
|
+
"BF",
|
|
51
|
+
"BI",
|
|
52
|
+
"CM",
|
|
53
|
+
"CV",
|
|
54
|
+
"CF",
|
|
55
|
+
"TD",
|
|
56
|
+
"CG",
|
|
57
|
+
"CD",
|
|
58
|
+
"CI",
|
|
59
|
+
"DJ",
|
|
60
|
+
"EG",
|
|
61
|
+
"GQ",
|
|
62
|
+
"ER",
|
|
63
|
+
"ET",
|
|
64
|
+
"GA",
|
|
65
|
+
"GM",
|
|
66
|
+
"GH",
|
|
67
|
+
"GN",
|
|
68
|
+
"GW",
|
|
69
|
+
"IL",
|
|
70
|
+
"JO",
|
|
71
|
+
"KE",
|
|
72
|
+
"LB",
|
|
73
|
+
"LS",
|
|
74
|
+
"LR",
|
|
75
|
+
"LY",
|
|
76
|
+
"MG",
|
|
77
|
+
"MW",
|
|
78
|
+
"ML",
|
|
79
|
+
"MR",
|
|
80
|
+
"MU",
|
|
81
|
+
"MA",
|
|
82
|
+
"MZ",
|
|
83
|
+
"NA",
|
|
84
|
+
"NE",
|
|
85
|
+
"NG",
|
|
86
|
+
"PS",
|
|
87
|
+
"RE",
|
|
88
|
+
"RW",
|
|
89
|
+
"ST",
|
|
90
|
+
"SN",
|
|
91
|
+
"SC",
|
|
92
|
+
"SL",
|
|
93
|
+
"ZA",
|
|
94
|
+
"SZ",
|
|
95
|
+
"TZ",
|
|
96
|
+
"TG",
|
|
97
|
+
"TN",
|
|
98
|
+
"UG",
|
|
99
|
+
"ZM",
|
|
100
|
+
"ZW"
|
|
101
|
+
],
|
|
102
|
+
"CE-CH": ["LI", "CH"],
|
|
103
|
+
"CE-DK": ["FO", "GL", "DK"],
|
|
104
|
+
"CE-EU": [
|
|
105
|
+
"AL",
|
|
106
|
+
"AD",
|
|
107
|
+
"AM",
|
|
108
|
+
"AT",
|
|
109
|
+
"AZ",
|
|
110
|
+
"BY",
|
|
111
|
+
"BE",
|
|
112
|
+
"BA",
|
|
113
|
+
"BG",
|
|
114
|
+
"HR",
|
|
115
|
+
"CY",
|
|
116
|
+
"CZ",
|
|
117
|
+
"EE",
|
|
118
|
+
"FI",
|
|
119
|
+
"FR",
|
|
120
|
+
"GE",
|
|
121
|
+
"DE",
|
|
122
|
+
"GI",
|
|
123
|
+
"GR",
|
|
124
|
+
"HU",
|
|
125
|
+
"IS",
|
|
126
|
+
"IE",
|
|
127
|
+
"IT",
|
|
128
|
+
"KZ",
|
|
129
|
+
"XK",
|
|
130
|
+
"KG",
|
|
131
|
+
"LV",
|
|
132
|
+
"LT",
|
|
133
|
+
"LU",
|
|
134
|
+
"MT",
|
|
135
|
+
"MD",
|
|
136
|
+
"MC",
|
|
137
|
+
"ME",
|
|
138
|
+
"NL",
|
|
139
|
+
"PL",
|
|
140
|
+
"PT",
|
|
141
|
+
"MK",
|
|
142
|
+
"RO",
|
|
143
|
+
"RS",
|
|
144
|
+
"SK",
|
|
145
|
+
"SI",
|
|
146
|
+
"ES",
|
|
147
|
+
"TJ",
|
|
148
|
+
"TR",
|
|
149
|
+
"TM",
|
|
150
|
+
"UA",
|
|
151
|
+
"UZ"
|
|
152
|
+
],
|
|
153
|
+
"CE-ME": ["AE", "BH", "KW", "OM", "QA", "SA"],
|
|
154
|
+
"CE-NO": ["NO"],
|
|
155
|
+
"CE-SE": ["SE"],
|
|
156
|
+
"LA-LA": [
|
|
157
|
+
"AI",
|
|
158
|
+
"AG",
|
|
159
|
+
"AR",
|
|
160
|
+
"AW",
|
|
161
|
+
"BS",
|
|
162
|
+
"BB",
|
|
163
|
+
"BZ",
|
|
164
|
+
"BM",
|
|
165
|
+
"BO",
|
|
166
|
+
"BR",
|
|
167
|
+
"KY",
|
|
168
|
+
"CL",
|
|
169
|
+
"CO",
|
|
170
|
+
"CR",
|
|
171
|
+
"DM",
|
|
172
|
+
"DO",
|
|
173
|
+
"EC",
|
|
174
|
+
"SV",
|
|
175
|
+
"FK",
|
|
176
|
+
"GF",
|
|
177
|
+
"GD",
|
|
178
|
+
"GT",
|
|
179
|
+
"GY",
|
|
180
|
+
"HT",
|
|
181
|
+
"HN",
|
|
182
|
+
"JM",
|
|
183
|
+
"MQ",
|
|
184
|
+
"MX",
|
|
185
|
+
"MS",
|
|
186
|
+
"NI",
|
|
187
|
+
"MP",
|
|
188
|
+
"PA",
|
|
189
|
+
"PY",
|
|
190
|
+
"PE",
|
|
191
|
+
"KN",
|
|
192
|
+
"LC",
|
|
193
|
+
"VC",
|
|
194
|
+
"SR",
|
|
195
|
+
"TT",
|
|
196
|
+
"TC",
|
|
197
|
+
"UY",
|
|
198
|
+
"VG",
|
|
199
|
+
"VI"
|
|
200
|
+
],
|
|
201
|
+
"NA-CA": ["CA"],
|
|
202
|
+
"NA-US": ["AS", "GU", "FM", "PR", "US"],
|
|
203
|
+
"UK-UK": ["GB"]
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
// src/data/no-delivery-countries.json
|
|
207
|
+
var no_delivery_countries_default = [
|
|
208
|
+
"KH",
|
|
209
|
+
"MM",
|
|
210
|
+
"PK",
|
|
211
|
+
"BI",
|
|
212
|
+
"CV",
|
|
213
|
+
"CF",
|
|
214
|
+
"TD",
|
|
215
|
+
"CG",
|
|
216
|
+
"DJ",
|
|
217
|
+
"EG",
|
|
218
|
+
"GM",
|
|
219
|
+
"GN",
|
|
220
|
+
"GW",
|
|
221
|
+
"LB",
|
|
222
|
+
"LR",
|
|
223
|
+
"LY",
|
|
224
|
+
"ML",
|
|
225
|
+
"MU",
|
|
226
|
+
"RE",
|
|
227
|
+
"SL",
|
|
228
|
+
"AZ",
|
|
229
|
+
"BY",
|
|
230
|
+
"UA",
|
|
231
|
+
"BM",
|
|
232
|
+
"BO",
|
|
233
|
+
"KY",
|
|
234
|
+
"EC",
|
|
235
|
+
"HN",
|
|
236
|
+
"PA",
|
|
237
|
+
"PE",
|
|
238
|
+
"UY"
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
// src/utils/delivery-countries.ts
|
|
242
|
+
var priceZones = price_zones_default;
|
|
243
|
+
var noDeliveryCountries = no_delivery_countries_default;
|
|
244
|
+
var getSupportedDeliveryCountries = (offerCountry) => {
|
|
245
|
+
const zone = Object.keys(priceZones).find(
|
|
246
|
+
(key) => priceZones[key].includes(offerCountry)
|
|
247
|
+
);
|
|
248
|
+
if (!zone) return [];
|
|
249
|
+
return priceZones[zone].filter(
|
|
250
|
+
(country) => !noDeliveryCountries.includes(country)
|
|
251
|
+
);
|
|
252
|
+
};
|
|
253
|
+
export {
|
|
254
|
+
getSupportedDeliveryCountries
|
|
255
|
+
};
|
|
@@ -7,7 +7,23 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Matches sma-checkout: src/lib/navigate-to-checkout/index.tsx
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* What the post-checkout "return to" target (`checkout-redirect`, read by the onboarding app once the user has
|
|
12
|
+
* finished onboarding) should be. Chosen per entry point in `ENTRY_POINT_CONFIG` (apple-pay-button.ts).
|
|
13
|
+
*/
|
|
14
|
+
export declare enum ReturnUrlPolicy {
|
|
15
|
+
/** Return the user to the page the button is on, e.g. the article behind a paywall. */
|
|
16
|
+
CURRENT_PAGE = "current_page",
|
|
17
|
+
/**
|
|
18
|
+
* Leave `checkout-redirect` untouched: the host owns it. sma-checkout's /subscribe pages store the article the
|
|
19
|
+
* user arrived from (and never themselves), so overwriting it would send the user back to the offers page.
|
|
20
|
+
* With nothing stored, onboarding returns the user to the home page.
|
|
21
|
+
*/
|
|
22
|
+
HOST_MANAGED = "host_managed"
|
|
23
|
+
}
|
|
24
|
+
export declare const resolveCheckoutRedirectUrl: (policy: ReturnUrlPolicy, currentPageUrl: string) => string | null;
|
|
25
|
+
/** Persists the return target. `null` (see `ReturnUrlPolicy.HOST_MANAGED`) leaves the stored value as it is. */
|
|
26
|
+
export declare const writeCheckoutRedirect: (originUrl: string | null) => void;
|
|
11
27
|
/**
|
|
12
28
|
* Captures the current page URL (the article the user is reading).
|
|
13
29
|
* Must be called before any redirect occurs.
|
|
@@ -42,7 +58,9 @@ export declare const decodeSku: (sku: string) => string;
|
|
|
42
58
|
* Always appended when non-empty to preserve geo-context across the redirect.
|
|
43
59
|
*
|
|
44
60
|
* The origin article URL is written to localStorage by the caller via
|
|
45
|
-
* writeCheckoutRedirect()
|
|
61
|
+
* writeCheckoutRedirect(). sma-checkout uses that, plus the wall's
|
|
62
|
+
* checkout-return-to-article opt-in when present, to send the reader
|
|
63
|
+
* back to the article or onboarding.
|
|
46
64
|
*/
|
|
47
65
|
export declare const redirectToCheckoutComplete: (params: {
|
|
48
66
|
basketId: string;
|
|
@@ -10,8 +10,18 @@ function isAllowedRedirectUrl(url) {
|
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
var ReturnUrlPolicy = /* @__PURE__ */ ((ReturnUrlPolicy2) => {
|
|
14
|
+
ReturnUrlPolicy2["CURRENT_PAGE"] = "current_page";
|
|
15
|
+
ReturnUrlPolicy2["HOST_MANAGED"] = "host_managed";
|
|
16
|
+
return ReturnUrlPolicy2;
|
|
17
|
+
})(ReturnUrlPolicy || {});
|
|
18
|
+
var CHECKOUT_REDIRECT_BY_POLICY = {
|
|
19
|
+
["current_page" /* CURRENT_PAGE */]: (currentPageUrl) => currentPageUrl,
|
|
20
|
+
["host_managed" /* HOST_MANAGED */]: () => null
|
|
21
|
+
};
|
|
22
|
+
var resolveCheckoutRedirectUrl = (policy, currentPageUrl) => CHECKOUT_REDIRECT_BY_POLICY[policy](currentPageUrl);
|
|
13
23
|
var writeCheckoutRedirect = (originUrl) => {
|
|
14
|
-
if (!isAllowedRedirectUrl(originUrl)) return;
|
|
24
|
+
if (originUrl === null || !isAllowedRedirectUrl(originUrl)) return;
|
|
15
25
|
try {
|
|
16
26
|
localStorage.setItem(CHECKOUT_REDIRECT_KEY, originUrl);
|
|
17
27
|
} catch {
|
|
@@ -53,10 +63,12 @@ var redirectToCheckoutFallback = (params) => {
|
|
|
53
63
|
return url.pathname + url.search;
|
|
54
64
|
};
|
|
55
65
|
export {
|
|
66
|
+
ReturnUrlPolicy,
|
|
56
67
|
buildQueryString,
|
|
57
68
|
captureOriginUrl,
|
|
58
69
|
decodeSku,
|
|
59
70
|
redirectToCheckoutComplete,
|
|
60
71
|
redirectToCheckoutFallback,
|
|
72
|
+
resolveCheckoutRedirectUrl,
|
|
61
73
|
writeCheckoutRedirect
|
|
62
74
|
};
|
|
@@ -11,14 +11,12 @@
|
|
|
11
11
|
*
|
|
12
12
|
* Event names are aligned to the PRD spec (section 10 — Tracking & Analytics).
|
|
13
13
|
*/
|
|
14
|
-
import { type ApplePayExperimentFlagKey } from '../constants';
|
|
15
14
|
declare global {
|
|
16
15
|
interface Window {
|
|
17
16
|
tedl?: {
|
|
18
17
|
events?: Record<string, unknown>[];
|
|
19
18
|
[key: string]: unknown;
|
|
20
19
|
};
|
|
21
|
-
__applePayExperimentExposures?: Record<string, boolean>;
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
22
|
export declare const EXPRESS_CHECKOUT_EVENTS: {
|
|
@@ -48,19 +46,6 @@ export type ImpressionMetadata = {
|
|
|
48
46
|
/** ISO 3166-1 alpha-2 country code of the offer (e.g. 'GB', 'US'). */
|
|
49
47
|
country: string;
|
|
50
48
|
};
|
|
51
|
-
/**
|
|
52
|
-
* Amplitude Experiment exposure for Apple Pay Express (SMA-3301).
|
|
53
|
-
*
|
|
54
|
-
* Fired from createIfEnabled only after isApplePayAvailable() succeeds
|
|
55
|
-
* (control or treatment). Deduped per pathname + flag_key + variant so
|
|
56
|
-
* repeated renders on the same page do not over-count. Includes
|
|
57
|
-
* experiment_key from Engagement SSR (__NEXT_DATA__) when present for run
|
|
58
|
-
* attribution.
|
|
59
|
-
*
|
|
60
|
-
* @param flagKey - Amplitude flag_key (required). Callers must pass an
|
|
61
|
-
* explicit key such as {@link APPLE_PAY_EXPRESS_PAYWALLS_EXPERIMENT_KEY}.
|
|
62
|
-
*/
|
|
63
|
-
export declare const trackApplePayExperimentExposure: (variant: string, experimentKey: string | undefined, flagKey: ApplePayExperimentFlagKey) => void;
|
|
64
49
|
/** Wallet button displayed — emits all 5 required analytics dimensions. */
|
|
65
50
|
export declare const trackExpressWalletImpression: (skuId: string, { entryPoint, country }: ImpressionMetadata) => void;
|
|
66
51
|
/**
|
|
@@ -72,17 +57,25 @@ export type ClickMetadata = {
|
|
|
72
57
|
/** Entry point where the Apple Pay button was clicked — e.g. 'free_trial_banner'. */
|
|
73
58
|
entryPoint?: string;
|
|
74
59
|
};
|
|
60
|
+
/**
|
|
61
|
+
* Entry point the Apple Pay button was rendered for. Added to every funnel event so the full
|
|
62
|
+
* funnel can be split per surface, not just the impression and click. Omitted when unset so
|
|
63
|
+
* payloads from hosts that do not pass an entry point are unchanged.
|
|
64
|
+
*/
|
|
65
|
+
export type EntryPointMetadata = {
|
|
66
|
+
entryPoint?: string;
|
|
67
|
+
};
|
|
75
68
|
/** Wallet button clicked */
|
|
76
69
|
export declare const trackExpressWalletClick: (skuId: string, { entryPoint }?: ClickMetadata) => void;
|
|
77
70
|
/** Apple Pay sheet opened (session.begin() called) */
|
|
78
|
-
export declare const trackWalletPaymentSheetOpen: (skuId: string) => void;
|
|
71
|
+
export declare const trackWalletPaymentSheetOpen: (skuId: string, metadata?: EntryPointMetadata) => void;
|
|
79
72
|
/** Payment authorised by the user in the Apple Pay sheet */
|
|
80
|
-
export declare const trackWalletPaymentAuthorised: (skuId: string) => void;
|
|
73
|
+
export declare const trackWalletPaymentAuthorised: (skuId: string, metadata?: EntryPointMetadata) => void;
|
|
81
74
|
/** Purchase completed — BFF returned success */
|
|
82
|
-
export declare const trackWalletPaymentSuccess: (skuId: string, basketId: string) => void;
|
|
75
|
+
export declare const trackWalletPaymentSuccess: (skuId: string, basketId: string, metadata?: EntryPointMetadata) => void;
|
|
83
76
|
/** Payment failed — BFF returned an error */
|
|
84
|
-
export declare const trackWalletPaymentFailure: (skuId: string, reason: string) => void;
|
|
77
|
+
export declare const trackWalletPaymentFailure: (skuId: string, reason: string, metadata?: EntryPointMetadata) => void;
|
|
85
78
|
/** Redirect to standard checkout triggered */
|
|
86
|
-
export declare const trackFallbackCheckout: (skuId: string) => void;
|
|
79
|
+
export declare const trackFallbackCheckout: (skuId: string, metadata?: EntryPointMetadata) => void;
|
|
87
80
|
/** Billing/shipping field failed validation (emitted per-field when Apple Pay sheet stays open) */
|
|
88
81
|
export declare const trackValidationFieldError: (field: string, errorType: string) => void;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
// src/constants.ts
|
|
2
|
-
var APPLE_PAY_EXPRESS_VARIANTS = {
|
|
3
|
-
CONTROL: "control",
|
|
4
|
-
TREATMENT: "treatment"
|
|
5
|
-
};
|
|
6
|
-
|
|
7
1
|
// src/utils/expressCheckoutTracking.ts
|
|
8
2
|
var EXPRESS_CHECKOUT_EVENTS = {
|
|
9
3
|
/** Wallet button displayed */
|
|
@@ -41,26 +35,6 @@ var track = (action, extra) => {
|
|
|
41
35
|
...extra
|
|
42
36
|
});
|
|
43
37
|
};
|
|
44
|
-
var trackApplePayExperimentExposure = (variant, experimentKey, flagKey) => {
|
|
45
|
-
const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
|
|
46
|
-
if (!isActiveVariant) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const exposures = window.__applePayExperimentExposures ?? {};
|
|
50
|
-
window.__applePayExperimentExposures = exposures;
|
|
51
|
-
const pathname = window.location?.pathname ?? "";
|
|
52
|
-
const dedupeKey = `${pathname}:${flagKey}:${variant}`;
|
|
53
|
-
if (exposures[dedupeKey]) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
exposures[dedupeKey] = true;
|
|
57
|
-
emitTedlEvent({
|
|
58
|
-
name: "$exposure",
|
|
59
|
-
flag_key: flagKey,
|
|
60
|
-
variant,
|
|
61
|
-
...experimentKey ? { experiment_key: experimentKey } : {}
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
38
|
var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
65
39
|
track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
|
|
66
40
|
wallet_type: "apple_pay",
|
|
@@ -70,39 +44,50 @@ var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
|
|
|
70
44
|
device: getDevice()
|
|
71
45
|
});
|
|
72
46
|
};
|
|
47
|
+
var withEntryPoint = ({ entryPoint } = {}) => entryPoint ? { entry_point: entryPoint } : {};
|
|
73
48
|
var trackExpressWalletClick = (skuId, { entryPoint } = {}) => {
|
|
74
49
|
track(EXPRESS_CHECKOUT_EVENTS.BUTTON_CLICK, {
|
|
75
50
|
sku_id: skuId,
|
|
76
51
|
...entryPoint ? { entry_point: entryPoint } : {}
|
|
77
52
|
});
|
|
78
53
|
};
|
|
79
|
-
var trackWalletPaymentSheetOpen = (skuId) => {
|
|
80
|
-
track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, {
|
|
54
|
+
var trackWalletPaymentSheetOpen = (skuId, metadata) => {
|
|
55
|
+
track(EXPRESS_CHECKOUT_EVENTS.SHEET_OPEN, {
|
|
56
|
+
sku_id: skuId,
|
|
57
|
+
...withEntryPoint(metadata)
|
|
58
|
+
});
|
|
81
59
|
};
|
|
82
|
-
var trackWalletPaymentAuthorised = (skuId) => {
|
|
83
|
-
track(EXPRESS_CHECKOUT_EVENTS.AUTHORISED, {
|
|
60
|
+
var trackWalletPaymentAuthorised = (skuId, metadata) => {
|
|
61
|
+
track(EXPRESS_CHECKOUT_EVENTS.AUTHORISED, {
|
|
62
|
+
sku_id: skuId,
|
|
63
|
+
...withEntryPoint(metadata)
|
|
64
|
+
});
|
|
84
65
|
};
|
|
85
|
-
var trackWalletPaymentSuccess = (skuId, basketId) => {
|
|
66
|
+
var trackWalletPaymentSuccess = (skuId, basketId, metadata) => {
|
|
86
67
|
track(EXPRESS_CHECKOUT_EVENTS.SUCCESS, {
|
|
87
68
|
sku_id: skuId,
|
|
88
|
-
basket_id: basketId
|
|
69
|
+
basket_id: basketId,
|
|
70
|
+
...withEntryPoint(metadata)
|
|
89
71
|
});
|
|
90
72
|
};
|
|
91
|
-
var trackWalletPaymentFailure = (skuId, reason) => {
|
|
73
|
+
var trackWalletPaymentFailure = (skuId, reason, metadata) => {
|
|
92
74
|
track(EXPRESS_CHECKOUT_EVENTS.FAILURE, {
|
|
93
75
|
sku_id: skuId,
|
|
94
|
-
failure_reason: reason
|
|
76
|
+
failure_reason: reason,
|
|
77
|
+
...withEntryPoint(metadata)
|
|
95
78
|
});
|
|
96
79
|
};
|
|
97
|
-
var trackFallbackCheckout = (skuId) => {
|
|
98
|
-
track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, {
|
|
80
|
+
var trackFallbackCheckout = (skuId, metadata) => {
|
|
81
|
+
track(EXPRESS_CHECKOUT_EVENTS.FALLBACK_CHECKOUT, {
|
|
82
|
+
sku_id: skuId,
|
|
83
|
+
...withEntryPoint(metadata)
|
|
84
|
+
});
|
|
99
85
|
};
|
|
100
86
|
var trackValidationFieldError = (field, errorType) => {
|
|
101
87
|
track(`validation_${field}_${errorType}`, {});
|
|
102
88
|
};
|
|
103
89
|
export {
|
|
104
90
|
EXPRESS_CHECKOUT_EVENTS,
|
|
105
|
-
trackApplePayExperimentExposure,
|
|
106
91
|
trackExpressWalletClick,
|
|
107
92
|
trackExpressWalletImpression,
|
|
108
93
|
trackFallbackCheckout,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// src/utils/latin-characters.ts
|
|
2
|
+
var SUPPORTED_DIACRITICS = "\xE0\xE1\xE2\u0101\u0103\u0105\u0227\u01CE\u0201\u0203\xC0\xC1\xC2\u0100\u0102\u0104\u0226\u01CD\u0200\u0202\xE3\xE4\xC3\xC4\xE6\xC6\xE5\xC5\xE8\xE9\xEA\u1EBD\xEB\u0113\u0115\u0119\u0117\u011B\u0205\u0207\xC8\xC9\xCA\u1EBC\xCB\u0112\u0114\u0118\u0116\u011A\u0204\u0206\xEC\xED\xEE\u0129\xEF\u012B\u012D\u012F\u01D0\u0209\u020B\xCC\xCD\xCE\u0128\xCF\u012A\u012C\u012E\u01CF\u0208\u020A\xF2\xF3\xF4\xF5\u014D\u014F\u01EB\u022F\u0151\u01D2\u020D\u020F\xD2\xD3\xD4\xD5\u014C\u014E\u01EA\u022E\u0150\u01D1\u020C\u020E\xF6\xD6\xF8\xD8\u016F\xF9\xFA\xFB\u0169\u016B\u016D\u0173\u0171\u01D4\u0215\u0217\u016E\xD9\xDA\xDB\u0168\u016A\u016C\u0172\u0170\u01D3\u0214\u0216\xFC\xDC\u1EF3\xFD\u0177\u1EF9\xFF\u0233\u1E8F\u1EF2\xDD\u0176\u1EF8\u0178\u0232\u1E8E\xE7\xC7\u0107\u010D\u0106\u010C\xDF\xFE\xDE\xAA\u0159\u0155\u0158\u0154\u0142\u013E\u013A\u013C\u0141\u013D\u0139\u013B\xF1\u0144\u0148\u0146\xD1\u0143\u0147\u0145\u015B\u0161\u015A\u0160\u015F\u0219\u015E\u0218\u017A\u017C\u017E\u0179\u017B\u017D\u010F\xF0\u010E\xD0\u0165\u021B\u0164\u021A\u011F\u0123\u011E\u0122\u0137\u0136\u2019";
|
|
3
|
+
var LATIN_CHARACTERS_REGEX = new RegExp(
|
|
4
|
+
`^[\\x20-\\x7E${SUPPORTED_DIACRITICS}]*$`
|
|
5
|
+
);
|
|
6
|
+
var isLatinCharacters = (value) => LATIN_CHARACTERS_REGEX.test(value);
|
|
7
|
+
export {
|
|
8
|
+
LATIN_CHARACTERS_REGEX,
|
|
9
|
+
isLatinCharacters
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const priceZones: Readonly<Record<string, readonly string[]>>;
|
|
2
|
+
/**
|
|
3
|
+
* Returns the price-zone key that contains the given country code, or null if
|
|
4
|
+
* the country is not present in any known zone. The single lookup shared by
|
|
5
|
+
* billing countries, delivery countries and the delivery address rules.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getZoneByCountry: (country: string) => string | null;
|