@economist/web-apple-pay 1.9.2 → 1.9.3

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/dist/index.js CHANGED
@@ -1303,6 +1303,19 @@ var redirectToCheckoutFallback = (params) => {
1303
1303
  return url.pathname + url.search;
1304
1304
  };
1305
1305
 
1306
+ // src/constants.ts
1307
+ var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint3) => {
1308
+ ApplePayEntryPoint3["PAYWALL"] = "article_paywall";
1309
+ ApplePayEntryPoint3["REGWALL"] = "article_regwall";
1310
+ ApplePayEntryPoint3["DUAL_OFFER_BANNER"] = "dual_offer_banner";
1311
+ return ApplePayEntryPoint3;
1312
+ })(ApplePayEntryPoint || {});
1313
+ var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
1314
+ var APPLE_PAY_EXPRESS_VARIANTS = {
1315
+ CONTROL: "control",
1316
+ TREATMENT: "treatment"
1317
+ };
1318
+
1306
1319
  // src/utils/expressCheckoutTracking.ts
1307
1320
  var EXPRESS_CHECKOUT_EVENTS = {
1308
1321
  /** Wallet button displayed */
@@ -1340,6 +1353,25 @@ var track = (action, extra) => {
1340
1353
  ...extra
1341
1354
  });
1342
1355
  };
1356
+ var trackApplePayExperimentExposure = (variant) => {
1357
+ const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
1358
+ if (!isActiveVariant) {
1359
+ return;
1360
+ }
1361
+ const exposures = window.__applePayExperimentExposures ?? {};
1362
+ window.__applePayExperimentExposures = exposures;
1363
+ const pathname = window.location?.pathname ?? "";
1364
+ const dedupeKey = `${pathname}:${APPLE_PAY_EXPRESS_EXPERIMENT_KEY}:${variant}`;
1365
+ if (exposures[dedupeKey]) {
1366
+ return;
1367
+ }
1368
+ exposures[dedupeKey] = true;
1369
+ emitTedlEvent({
1370
+ name: "$exposure",
1371
+ flag_key: APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
1372
+ variant
1373
+ });
1374
+ };
1343
1375
  var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
1344
1376
  track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
1345
1377
  wallet_type: "apple_pay",
@@ -1963,19 +1995,6 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
1963
1995
  return [...zoneCountries];
1964
1996
  };
1965
1997
 
1966
- // src/constants.ts
1967
- var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint3) => {
1968
- ApplePayEntryPoint3["PAYWALL"] = "article_paywall";
1969
- ApplePayEntryPoint3["REGWALL"] = "article_regwall";
1970
- ApplePayEntryPoint3["DUAL_OFFER_BANNER"] = "dual_offer_banner";
1971
- return ApplePayEntryPoint3;
1972
- })(ApplePayEntryPoint || {});
1973
- var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
1974
- var APPLE_PAY_EXPRESS_VARIANTS = {
1975
- CONTROL: "control",
1976
- TREATMENT: "treatment"
1977
- };
1978
-
1979
1998
  // src/apple-pay-button.ts
1980
1999
  var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
1981
2000
  var TOTAL_LABEL = "The Economist";
@@ -2021,6 +2040,9 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2021
2040
  const experimentValue = window.experimentIntegration?.getVariant?.(
2022
2041
  APPLE_PAY_EXPRESS_EXPERIMENT_KEY
2023
2042
  );
2043
+ if (experimentValue) {
2044
+ trackApplePayExperimentExposure(experimentValue);
2045
+ }
2024
2046
  const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2025
2047
  const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2026
2048
  FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
@@ -1298,6 +1298,13 @@ var redirectToCheckoutFallback = (params) => {
1298
1298
  return url.pathname + url.search;
1299
1299
  };
1300
1300
 
1301
+ // src/constants.ts
1302
+ var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
1303
+ var APPLE_PAY_EXPRESS_VARIANTS = {
1304
+ CONTROL: "control",
1305
+ TREATMENT: "treatment"
1306
+ };
1307
+
1301
1308
  // src/utils/expressCheckoutTracking.ts
1302
1309
  var EXPRESS_CHECKOUT_EVENTS = {
1303
1310
  /** Wallet button displayed */
@@ -1335,6 +1342,25 @@ var track = (action, extra) => {
1335
1342
  ...extra
1336
1343
  });
1337
1344
  };
1345
+ var trackApplePayExperimentExposure = (variant) => {
1346
+ const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
1347
+ if (!isActiveVariant) {
1348
+ return;
1349
+ }
1350
+ const exposures = window.__applePayExperimentExposures ?? {};
1351
+ window.__applePayExperimentExposures = exposures;
1352
+ const pathname = window.location?.pathname ?? "";
1353
+ const dedupeKey = `${pathname}:${APPLE_PAY_EXPRESS_EXPERIMENT_KEY}:${variant}`;
1354
+ if (exposures[dedupeKey]) {
1355
+ return;
1356
+ }
1357
+ exposures[dedupeKey] = true;
1358
+ emitTedlEvent({
1359
+ name: "$exposure",
1360
+ flag_key: APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
1361
+ variant
1362
+ });
1363
+ };
1338
1364
  var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
1339
1365
  track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
1340
1366
  wallet_type: "apple_pay",
@@ -1958,13 +1984,6 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
1958
1984
  return [...zoneCountries];
1959
1985
  };
1960
1986
 
1961
- // src/constants.ts
1962
- var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
1963
- var APPLE_PAY_EXPRESS_VARIANTS = {
1964
- CONTROL: "control",
1965
- TREATMENT: "treatment"
1966
- };
1967
-
1968
1987
  // src/apple-pay-button.ts
1969
1988
  var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
1970
1989
  var TOTAL_LABEL = "The Economist";
@@ -2010,6 +2029,9 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2010
2029
  const experimentValue = window.experimentIntegration?.getVariant?.(
2011
2030
  APPLE_PAY_EXPRESS_EXPERIMENT_KEY
2012
2031
  );
2032
+ if (experimentValue) {
2033
+ trackApplePayExperimentExposure(experimentValue);
2034
+ }
2013
2035
  const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2014
2036
  const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2015
2037
  FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
@@ -1306,6 +1306,13 @@ var redirectToCheckoutFallback = (params) => {
1306
1306
  return url.pathname + url.search;
1307
1307
  };
1308
1308
 
1309
+ // src/constants.ts
1310
+ var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
1311
+ var APPLE_PAY_EXPRESS_VARIANTS = {
1312
+ CONTROL: "control",
1313
+ TREATMENT: "treatment"
1314
+ };
1315
+
1309
1316
  // src/utils/expressCheckoutTracking.ts
1310
1317
  var EXPRESS_CHECKOUT_EVENTS = {
1311
1318
  /** Wallet button displayed */
@@ -1343,6 +1350,25 @@ var track = (action, extra) => {
1343
1350
  ...extra
1344
1351
  });
1345
1352
  };
1353
+ var trackApplePayExperimentExposure = (variant) => {
1354
+ const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
1355
+ if (!isActiveVariant) {
1356
+ return;
1357
+ }
1358
+ const exposures = window.__applePayExperimentExposures ?? {};
1359
+ window.__applePayExperimentExposures = exposures;
1360
+ const pathname = window.location?.pathname ?? "";
1361
+ const dedupeKey = `${pathname}:${APPLE_PAY_EXPRESS_EXPERIMENT_KEY}:${variant}`;
1362
+ if (exposures[dedupeKey]) {
1363
+ return;
1364
+ }
1365
+ exposures[dedupeKey] = true;
1366
+ emitTedlEvent({
1367
+ name: "$exposure",
1368
+ flag_key: APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
1369
+ variant
1370
+ });
1371
+ };
1346
1372
  var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
1347
1373
  track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
1348
1374
  wallet_type: "apple_pay",
@@ -1966,13 +1992,6 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
1966
1992
  return [...zoneCountries];
1967
1993
  };
1968
1994
 
1969
- // src/constants.ts
1970
- var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
1971
- var APPLE_PAY_EXPRESS_VARIANTS = {
1972
- CONTROL: "control",
1973
- TREATMENT: "treatment"
1974
- };
1975
-
1976
1995
  // src/apple-pay-button.ts
1977
1996
  var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
1978
1997
  var TOTAL_LABEL = "The Economist";
@@ -2018,6 +2037,9 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2018
2037
  const experimentValue = window.experimentIntegration?.getVariant?.(
2019
2038
  APPLE_PAY_EXPRESS_EXPERIMENT_KEY
2020
2039
  );
2040
+ if (experimentValue) {
2041
+ trackApplePayExperimentExposure(experimentValue);
2042
+ }
2021
2043
  const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2022
2044
  const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2023
2045
  FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
@@ -1298,6 +1298,13 @@ var redirectToCheckoutFallback = (params) => {
1298
1298
  return url.pathname + url.search;
1299
1299
  };
1300
1300
 
1301
+ // src/constants.ts
1302
+ var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
1303
+ var APPLE_PAY_EXPRESS_VARIANTS = {
1304
+ CONTROL: "control",
1305
+ TREATMENT: "treatment"
1306
+ };
1307
+
1301
1308
  // src/utils/expressCheckoutTracking.ts
1302
1309
  var EXPRESS_CHECKOUT_EVENTS = {
1303
1310
  /** Wallet button displayed */
@@ -1335,6 +1342,25 @@ var track = (action, extra) => {
1335
1342
  ...extra
1336
1343
  });
1337
1344
  };
1345
+ var trackApplePayExperimentExposure = (variant) => {
1346
+ const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
1347
+ if (!isActiveVariant) {
1348
+ return;
1349
+ }
1350
+ const exposures = window.__applePayExperimentExposures ?? {};
1351
+ window.__applePayExperimentExposures = exposures;
1352
+ const pathname = window.location?.pathname ?? "";
1353
+ const dedupeKey = `${pathname}:${APPLE_PAY_EXPRESS_EXPERIMENT_KEY}:${variant}`;
1354
+ if (exposures[dedupeKey]) {
1355
+ return;
1356
+ }
1357
+ exposures[dedupeKey] = true;
1358
+ emitTedlEvent({
1359
+ name: "$exposure",
1360
+ flag_key: APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
1361
+ variant
1362
+ });
1363
+ };
1338
1364
  var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
1339
1365
  track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
1340
1366
  wallet_type: "apple_pay",
@@ -1958,13 +1984,6 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
1958
1984
  return [...zoneCountries];
1959
1985
  };
1960
1986
 
1961
- // src/constants.ts
1962
- var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
1963
- var APPLE_PAY_EXPRESS_VARIANTS = {
1964
- CONTROL: "control",
1965
- TREATMENT: "treatment"
1966
- };
1967
-
1968
1987
  // src/apple-pay-button.ts
1969
1988
  var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
1970
1989
  var TOTAL_LABEL = "The Economist";
@@ -2010,6 +2029,9 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2010
2029
  const experimentValue = window.experimentIntegration?.getVariant?.(
2011
2030
  APPLE_PAY_EXPRESS_EXPERIMENT_KEY
2012
2031
  );
2032
+ if (experimentValue) {
2033
+ trackApplePayExperimentExposure(experimentValue);
2034
+ }
2013
2035
  const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2014
2036
  const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2015
2037
  FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
package/dist/src/index.js CHANGED
@@ -1303,6 +1303,19 @@ var redirectToCheckoutFallback = (params) => {
1303
1303
  return url.pathname + url.search;
1304
1304
  };
1305
1305
 
1306
+ // src/constants.ts
1307
+ var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint3) => {
1308
+ ApplePayEntryPoint3["PAYWALL"] = "article_paywall";
1309
+ ApplePayEntryPoint3["REGWALL"] = "article_regwall";
1310
+ ApplePayEntryPoint3["DUAL_OFFER_BANNER"] = "dual_offer_banner";
1311
+ return ApplePayEntryPoint3;
1312
+ })(ApplePayEntryPoint || {});
1313
+ var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
1314
+ var APPLE_PAY_EXPRESS_VARIANTS = {
1315
+ CONTROL: "control",
1316
+ TREATMENT: "treatment"
1317
+ };
1318
+
1306
1319
  // src/utils/expressCheckoutTracking.ts
1307
1320
  var EXPRESS_CHECKOUT_EVENTS = {
1308
1321
  /** Wallet button displayed */
@@ -1340,6 +1353,25 @@ var track = (action, extra) => {
1340
1353
  ...extra
1341
1354
  });
1342
1355
  };
1356
+ var trackApplePayExperimentExposure = (variant) => {
1357
+ const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
1358
+ if (!isActiveVariant) {
1359
+ return;
1360
+ }
1361
+ const exposures = window.__applePayExperimentExposures ?? {};
1362
+ window.__applePayExperimentExposures = exposures;
1363
+ const pathname = window.location?.pathname ?? "";
1364
+ const dedupeKey = `${pathname}:${APPLE_PAY_EXPRESS_EXPERIMENT_KEY}:${variant}`;
1365
+ if (exposures[dedupeKey]) {
1366
+ return;
1367
+ }
1368
+ exposures[dedupeKey] = true;
1369
+ emitTedlEvent({
1370
+ name: "$exposure",
1371
+ flag_key: APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
1372
+ variant
1373
+ });
1374
+ };
1343
1375
  var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
1344
1376
  track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
1345
1377
  wallet_type: "apple_pay",
@@ -1963,19 +1995,6 @@ var getSupportedBillingCountries = (offerCountry, offerVariant) => {
1963
1995
  return [...zoneCountries];
1964
1996
  };
1965
1997
 
1966
- // src/constants.ts
1967
- var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint3) => {
1968
- ApplePayEntryPoint3["PAYWALL"] = "article_paywall";
1969
- ApplePayEntryPoint3["REGWALL"] = "article_regwall";
1970
- ApplePayEntryPoint3["DUAL_OFFER_BANNER"] = "dual_offer_banner";
1971
- return ApplePayEntryPoint3;
1972
- })(ApplePayEntryPoint || {});
1973
- var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
1974
- var APPLE_PAY_EXPRESS_VARIANTS = {
1975
- CONTROL: "control",
1976
- TREATMENT: "treatment"
1977
- };
1978
-
1979
1998
  // src/apple-pay-button.ts
1980
1999
  var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
1981
2000
  var TOTAL_LABEL = "The Economist";
@@ -2021,6 +2040,9 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2021
2040
  const experimentValue = window.experimentIntegration?.getVariant?.(
2022
2041
  APPLE_PAY_EXPRESS_EXPERIMENT_KEY
2023
2042
  );
2043
+ if (experimentValue) {
2044
+ trackApplePayExperimentExposure(experimentValue);
2045
+ }
2024
2046
  const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2025
2047
  const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2026
2048
  FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
@@ -17,6 +17,7 @@ declare global {
17
17
  events?: Record<string, unknown>[];
18
18
  [key: string]: unknown;
19
19
  };
20
+ __applePayExperimentExposures?: Record<string, boolean>;
20
21
  }
21
22
  }
22
23
  export declare const EXPRESS_CHECKOUT_EVENTS: {
@@ -46,6 +47,14 @@ export type ImpressionMetadata = {
46
47
  /** ISO 3166-1 alpha-2 country code of the offer (e.g. 'GB', 'US'). */
47
48
  country: string;
48
49
  };
50
+ /**
51
+ * Amplitude Experiment exposure for Apple Pay Express (SMA-3301).
52
+ *
53
+ * Fired when createIfEnabled evaluates an assigned variant (control or
54
+ * treatment). Deduped per pathname + variant so repeated banner renders on
55
+ * the same page do not over-count.
56
+ */
57
+ export declare const trackApplePayExperimentExposure: (variant: string) => void;
49
58
  /** Wallet button displayed — emits all 5 required analytics dimensions. */
50
59
  export declare const trackExpressWalletImpression: (skuId: string, { entryPoint, country }: ImpressionMetadata) => void;
51
60
  /** Wallet button clicked */
@@ -1,3 +1,10 @@
1
+ // src/constants.ts
2
+ var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
3
+ var APPLE_PAY_EXPRESS_VARIANTS = {
4
+ CONTROL: "control",
5
+ TREATMENT: "treatment"
6
+ };
7
+
1
8
  // src/utils/expressCheckoutTracking.ts
2
9
  var EXPRESS_CHECKOUT_EVENTS = {
3
10
  /** Wallet button displayed */
@@ -35,6 +42,25 @@ var track = (action, extra) => {
35
42
  ...extra
36
43
  });
37
44
  };
45
+ var trackApplePayExperimentExposure = (variant) => {
46
+ const isActiveVariant = variant === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || variant === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
47
+ if (!isActiveVariant) {
48
+ return;
49
+ }
50
+ const exposures = window.__applePayExperimentExposures ?? {};
51
+ window.__applePayExperimentExposures = exposures;
52
+ const pathname = window.location?.pathname ?? "";
53
+ const dedupeKey = `${pathname}:${APPLE_PAY_EXPRESS_EXPERIMENT_KEY}:${variant}`;
54
+ if (exposures[dedupeKey]) {
55
+ return;
56
+ }
57
+ exposures[dedupeKey] = true;
58
+ emitTedlEvent({
59
+ name: "$exposure",
60
+ flag_key: APPLE_PAY_EXPRESS_EXPERIMENT_KEY,
61
+ variant
62
+ });
63
+ };
38
64
  var trackExpressWalletImpression = (skuId, { entryPoint, country }) => {
39
65
  track(EXPRESS_CHECKOUT_EVENTS.IMPRESSION, {
40
66
  wallet_type: "apple_pay",
@@ -73,6 +99,7 @@ var trackValidationFieldError = (field, errorType) => {
73
99
  };
74
100
  export {
75
101
  EXPRESS_CHECKOUT_EVENTS,
102
+ trackApplePayExperimentExposure,
76
103
  trackExpressWalletClick,
77
104
  trackExpressWalletImpression,
78
105
  trackFallbackCheckout,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@economist/web-apple-pay",
3
3
  "description": "Web component package for Apple Pay checkout UI",
4
- "version": "1.9.2",
4
+ "version": "1.9.3",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",