@economist/web-apple-pay 1.9.4 → 1.9.5

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
@@ -1304,11 +1304,11 @@ var redirectToCheckoutFallback = (params) => {
1304
1304
  };
1305
1305
 
1306
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;
1307
+ var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
1308
+ ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
1309
+ ApplePayEntryPoint2["REGWALL"] = "article_regwall";
1310
+ ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
1311
+ return ApplePayEntryPoint2;
1312
1312
  })(ApplePayEntryPoint || {});
1313
1313
  var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
1314
1314
  var APPLE_PAY_EXPRESS_VARIANTS = {
@@ -2003,6 +2003,10 @@ var getExperimentKeyFromNextData = (flagKey) => {
2003
2003
  return typeof experimentKey === "string" ? experimentKey : void 0;
2004
2004
  };
2005
2005
 
2006
+ // src/utils/applePayExpressEligibility.ts
2007
+ var isApplePayExpressHomepage = (pathname = window.location.pathname) => pathname === "/";
2008
+ var isEligibleForApplePayExpressExperiment = () => isApplePayExpressHomepage() && isAppleDeviceOrSafari();
2009
+
2006
2010
  // src/apple-pay-button.ts
2007
2011
  var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
2008
2012
  var TOTAL_LABEL = "The Economist";
@@ -2034,6 +2038,12 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2034
2038
  * `window.experimentIntegration`. Once all consumers are migrated, the URL param
2035
2039
  * fallback will be removed.
2036
2040
  *
2041
+ * **SMA-3301 eligibility:** the homepage + Safari/iPhone eligibility gate
2042
+ * only applies to the `DUAL_OFFER_BANNER` entry point (or when `entryPoint`
2043
+ * is omitted). `PAYWALL`/`REGWALL` entry points render on article pages and
2044
+ * keep their pre-SMA-3301 behaviour unaffected. Anonymous is assumed because
2045
+ * the dual-offer banner is only mounted for anonymous visitors.
2046
+ *
2037
2047
  * @param offer - The offer to display in the Apple Pay flow.
2038
2048
  * @param country - The user's country code.
2039
2049
  * @param entryPoint - Where the button is being rendered (e.g. paywall, banner).
@@ -2045,19 +2055,29 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2045
2055
  if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
2046
2056
  return null;
2047
2057
  }
2058
+ const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2059
+ FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
2060
+ );
2061
+ const isBannerEntryPoint = !entryPoint || entryPoint === "dual_offer_banner" /* DUAL_OFFER_BANNER */;
2062
+ const isEligible = !isBannerEntryPoint || isEligibleForApplePayExpressExperiment();
2063
+ if (isBannerEntryPoint && !hasUrlParamFlag && !bypassApplePayChecks() && !isEligible) {
2064
+ return null;
2065
+ }
2048
2066
  const experimentValue = window.experimentIntegration?.getVariant?.(
2049
2067
  APPLE_PAY_EXPRESS_EXPERIMENT_KEY
2050
2068
  );
2051
- if (experimentValue) {
2052
- trackApplePayExperimentExposure(
2053
- experimentValue,
2054
- getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
2055
- );
2069
+ const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2070
+ if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
2071
+ void isApplePayAvailable().then((available) => {
2072
+ if (available) {
2073
+ trackApplePayExperimentExposure(
2074
+ experimentValue,
2075
+ getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
2076
+ );
2077
+ }
2078
+ });
2056
2079
  }
2057
2080
  const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2058
- const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2059
- FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
2060
- );
2061
2081
  if (!isTreatment && !hasUrlParamFlag) {
2062
2082
  return null;
2063
2083
  }
@@ -20,6 +20,12 @@ export declare class ApplePayButton extends HTMLElement {
20
20
  * `window.experimentIntegration`. Once all consumers are migrated, the URL param
21
21
  * fallback will be removed.
22
22
  *
23
+ * **SMA-3301 eligibility:** the homepage + Safari/iPhone eligibility gate
24
+ * only applies to the `DUAL_OFFER_BANNER` entry point (or when `entryPoint`
25
+ * is omitted). `PAYWALL`/`REGWALL` entry points render on article pages and
26
+ * keep their pre-SMA-3301 behaviour unaffected. Anonymous is assumed because
27
+ * the dual-offer banner is only mounted for anonymous visitors.
28
+ *
23
29
  * @param offer - The offer to display in the Apple Pay flow.
24
30
  * @param country - The user's country code.
25
31
  * @param entryPoint - Where the button is being rendered (e.g. paywall, banner).
@@ -1992,6 +1992,10 @@ var getExperimentKeyFromNextData = (flagKey) => {
1992
1992
  return typeof experimentKey === "string" ? experimentKey : void 0;
1993
1993
  };
1994
1994
 
1995
+ // src/utils/applePayExpressEligibility.ts
1996
+ var isApplePayExpressHomepage = (pathname = window.location.pathname) => pathname === "/";
1997
+ var isEligibleForApplePayExpressExperiment = () => isApplePayExpressHomepage() && isAppleDeviceOrSafari();
1998
+
1995
1999
  // src/apple-pay-button.ts
1996
2000
  var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
1997
2001
  var TOTAL_LABEL = "The Economist";
@@ -2023,6 +2027,12 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2023
2027
  * `window.experimentIntegration`. Once all consumers are migrated, the URL param
2024
2028
  * fallback will be removed.
2025
2029
  *
2030
+ * **SMA-3301 eligibility:** the homepage + Safari/iPhone eligibility gate
2031
+ * only applies to the `DUAL_OFFER_BANNER` entry point (or when `entryPoint`
2032
+ * is omitted). `PAYWALL`/`REGWALL` entry points render on article pages and
2033
+ * keep their pre-SMA-3301 behaviour unaffected. Anonymous is assumed because
2034
+ * the dual-offer banner is only mounted for anonymous visitors.
2035
+ *
2026
2036
  * @param offer - The offer to display in the Apple Pay flow.
2027
2037
  * @param country - The user's country code.
2028
2038
  * @param entryPoint - Where the button is being rendered (e.g. paywall, banner).
@@ -2034,19 +2044,29 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2034
2044
  if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
2035
2045
  return null;
2036
2046
  }
2047
+ const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2048
+ FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
2049
+ );
2050
+ const isBannerEntryPoint = !entryPoint || entryPoint === "dual_offer_banner" /* DUAL_OFFER_BANNER */;
2051
+ const isEligible = !isBannerEntryPoint || isEligibleForApplePayExpressExperiment();
2052
+ if (isBannerEntryPoint && !hasUrlParamFlag && !bypassApplePayChecks() && !isEligible) {
2053
+ return null;
2054
+ }
2037
2055
  const experimentValue = window.experimentIntegration?.getVariant?.(
2038
2056
  APPLE_PAY_EXPRESS_EXPERIMENT_KEY
2039
2057
  );
2040
- if (experimentValue) {
2041
- trackApplePayExperimentExposure(
2042
- experimentValue,
2043
- getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
2044
- );
2058
+ const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2059
+ if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
2060
+ void isApplePayAvailable().then((available) => {
2061
+ if (available) {
2062
+ trackApplePayExperimentExposure(
2063
+ experimentValue,
2064
+ getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
2065
+ );
2066
+ }
2067
+ });
2045
2068
  }
2046
2069
  const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2047
- const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2048
- FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
2049
- );
2050
2070
  if (!isTreatment && !hasUrlParamFlag) {
2051
2071
  return null;
2052
2072
  }
@@ -2000,6 +2000,10 @@ var getExperimentKeyFromNextData = (flagKey) => {
2000
2000
  return typeof experimentKey === "string" ? experimentKey : void 0;
2001
2001
  };
2002
2002
 
2003
+ // src/utils/applePayExpressEligibility.ts
2004
+ var isApplePayExpressHomepage = (pathname = window.location.pathname) => pathname === "/";
2005
+ var isEligibleForApplePayExpressExperiment = () => isApplePayExpressHomepage() && isAppleDeviceOrSafari();
2006
+
2003
2007
  // src/apple-pay-button.ts
2004
2008
  var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
2005
2009
  var TOTAL_LABEL = "The Economist";
@@ -2031,6 +2035,12 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2031
2035
  * `window.experimentIntegration`. Once all consumers are migrated, the URL param
2032
2036
  * fallback will be removed.
2033
2037
  *
2038
+ * **SMA-3301 eligibility:** the homepage + Safari/iPhone eligibility gate
2039
+ * only applies to the `DUAL_OFFER_BANNER` entry point (or when `entryPoint`
2040
+ * is omitted). `PAYWALL`/`REGWALL` entry points render on article pages and
2041
+ * keep their pre-SMA-3301 behaviour unaffected. Anonymous is assumed because
2042
+ * the dual-offer banner is only mounted for anonymous visitors.
2043
+ *
2034
2044
  * @param offer - The offer to display in the Apple Pay flow.
2035
2045
  * @param country - The user's country code.
2036
2046
  * @param entryPoint - Where the button is being rendered (e.g. paywall, banner).
@@ -2042,19 +2052,29 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2042
2052
  if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
2043
2053
  return null;
2044
2054
  }
2055
+ const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2056
+ FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
2057
+ );
2058
+ const isBannerEntryPoint = !entryPoint || entryPoint === "dual_offer_banner" /* DUAL_OFFER_BANNER */;
2059
+ const isEligible = !isBannerEntryPoint || isEligibleForApplePayExpressExperiment();
2060
+ if (isBannerEntryPoint && !hasUrlParamFlag && !bypassApplePayChecks() && !isEligible) {
2061
+ return null;
2062
+ }
2045
2063
  const experimentValue = window.experimentIntegration?.getVariant?.(
2046
2064
  APPLE_PAY_EXPRESS_EXPERIMENT_KEY
2047
2065
  );
2048
- if (experimentValue) {
2049
- trackApplePayExperimentExposure(
2050
- experimentValue,
2051
- getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
2052
- );
2066
+ const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2067
+ if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
2068
+ void isApplePayAvailable().then((available) => {
2069
+ if (available) {
2070
+ trackApplePayExperimentExposure(
2071
+ experimentValue,
2072
+ getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
2073
+ );
2074
+ }
2075
+ });
2053
2076
  }
2054
2077
  const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2055
- const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2056
- FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
2057
- );
2058
2078
  if (!isTreatment && !hasUrlParamFlag) {
2059
2079
  return null;
2060
2080
  }
@@ -1992,6 +1992,10 @@ var getExperimentKeyFromNextData = (flagKey) => {
1992
1992
  return typeof experimentKey === "string" ? experimentKey : void 0;
1993
1993
  };
1994
1994
 
1995
+ // src/utils/applePayExpressEligibility.ts
1996
+ var isApplePayExpressHomepage = (pathname = window.location.pathname) => pathname === "/";
1997
+ var isEligibleForApplePayExpressExperiment = () => isApplePayExpressHomepage() && isAppleDeviceOrSafari();
1998
+
1995
1999
  // src/apple-pay-button.ts
1996
2000
  var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
1997
2001
  var TOTAL_LABEL = "The Economist";
@@ -2023,6 +2027,12 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2023
2027
  * `window.experimentIntegration`. Once all consumers are migrated, the URL param
2024
2028
  * fallback will be removed.
2025
2029
  *
2030
+ * **SMA-3301 eligibility:** the homepage + Safari/iPhone eligibility gate
2031
+ * only applies to the `DUAL_OFFER_BANNER` entry point (or when `entryPoint`
2032
+ * is omitted). `PAYWALL`/`REGWALL` entry points render on article pages and
2033
+ * keep their pre-SMA-3301 behaviour unaffected. Anonymous is assumed because
2034
+ * the dual-offer banner is only mounted for anonymous visitors.
2035
+ *
2026
2036
  * @param offer - The offer to display in the Apple Pay flow.
2027
2037
  * @param country - The user's country code.
2028
2038
  * @param entryPoint - Where the button is being rendered (e.g. paywall, banner).
@@ -2034,19 +2044,29 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2034
2044
  if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
2035
2045
  return null;
2036
2046
  }
2047
+ const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2048
+ FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
2049
+ );
2050
+ const isBannerEntryPoint = !entryPoint || entryPoint === "dual_offer_banner" /* DUAL_OFFER_BANNER */;
2051
+ const isEligible = !isBannerEntryPoint || isEligibleForApplePayExpressExperiment();
2052
+ if (isBannerEntryPoint && !hasUrlParamFlag && !bypassApplePayChecks() && !isEligible) {
2053
+ return null;
2054
+ }
2037
2055
  const experimentValue = window.experimentIntegration?.getVariant?.(
2038
2056
  APPLE_PAY_EXPRESS_EXPERIMENT_KEY
2039
2057
  );
2040
- if (experimentValue) {
2041
- trackApplePayExperimentExposure(
2042
- experimentValue,
2043
- getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
2044
- );
2058
+ const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2059
+ if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
2060
+ void isApplePayAvailable().then((available) => {
2061
+ if (available) {
2062
+ trackApplePayExperimentExposure(
2063
+ experimentValue,
2064
+ getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
2065
+ );
2066
+ }
2067
+ });
2045
2068
  }
2046
2069
  const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2047
- const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2048
- FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
2049
- );
2050
2070
  if (!isTreatment && !hasUrlParamFlag) {
2051
2071
  return null;
2052
2072
  }
package/dist/src/index.js CHANGED
@@ -1304,11 +1304,11 @@ var redirectToCheckoutFallback = (params) => {
1304
1304
  };
1305
1305
 
1306
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;
1307
+ var ApplePayEntryPoint = /* @__PURE__ */ ((ApplePayEntryPoint2) => {
1308
+ ApplePayEntryPoint2["PAYWALL"] = "article_paywall";
1309
+ ApplePayEntryPoint2["REGWALL"] = "article_regwall";
1310
+ ApplePayEntryPoint2["DUAL_OFFER_BANNER"] = "dual_offer_banner";
1311
+ return ApplePayEntryPoint2;
1312
1312
  })(ApplePayEntryPoint || {});
1313
1313
  var APPLE_PAY_EXPRESS_EXPERIMENT_KEY = "apple-pay-express-checkout-on-banners";
1314
1314
  var APPLE_PAY_EXPRESS_VARIANTS = {
@@ -2003,6 +2003,10 @@ var getExperimentKeyFromNextData = (flagKey) => {
2003
2003
  return typeof experimentKey === "string" ? experimentKey : void 0;
2004
2004
  };
2005
2005
 
2006
+ // src/utils/applePayExpressEligibility.ts
2007
+ var isApplePayExpressHomepage = (pathname = window.location.pathname) => pathname === "/";
2008
+ var isEligibleForApplePayExpressExperiment = () => isApplePayExpressHomepage() && isAppleDeviceOrSafari();
2009
+
2006
2010
  // src/apple-pay-button.ts
2007
2011
  var FEATURE_APPLE_PAY_EXPRESS_CHECKOUT = "FEATURE_APPLE_PAY_EXPRESS_CHECKOUT";
2008
2012
  var TOTAL_LABEL = "The Economist";
@@ -2034,6 +2038,12 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2034
2038
  * `window.experimentIntegration`. Once all consumers are migrated, the URL param
2035
2039
  * fallback will be removed.
2036
2040
  *
2041
+ * **SMA-3301 eligibility:** the homepage + Safari/iPhone eligibility gate
2042
+ * only applies to the `DUAL_OFFER_BANNER` entry point (or when `entryPoint`
2043
+ * is omitted). `PAYWALL`/`REGWALL` entry points render on article pages and
2044
+ * keep their pre-SMA-3301 behaviour unaffected. Anonymous is assumed because
2045
+ * the dual-offer banner is only mounted for anonymous visitors.
2046
+ *
2037
2047
  * @param offer - The offer to display in the Apple Pay flow.
2038
2048
  * @param country - The user's country code.
2039
2049
  * @param entryPoint - Where the button is being rendered (e.g. paywall, banner).
@@ -2045,19 +2055,29 @@ var ApplePayButton = class _ApplePayButton extends HTMLElement {
2045
2055
  if (APPLE_PAY_EXCLUDED_VARIANTS.includes(offer.product?.variant)) {
2046
2056
  return null;
2047
2057
  }
2058
+ const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2059
+ FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
2060
+ );
2061
+ const isBannerEntryPoint = !entryPoint || entryPoint === "dual_offer_banner" /* DUAL_OFFER_BANNER */;
2062
+ const isEligible = !isBannerEntryPoint || isEligibleForApplePayExpressExperiment();
2063
+ if (isBannerEntryPoint && !hasUrlParamFlag && !bypassApplePayChecks() && !isEligible) {
2064
+ return null;
2065
+ }
2048
2066
  const experimentValue = window.experimentIntegration?.getVariant?.(
2049
2067
  APPLE_PAY_EXPRESS_EXPERIMENT_KEY
2050
2068
  );
2051
- if (experimentValue) {
2052
- trackApplePayExperimentExposure(
2053
- experimentValue,
2054
- getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
2055
- );
2069
+ const isExperimentVariant = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.CONTROL || experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2070
+ if (isExperimentVariant && isEligible && !bypassApplePayChecks() && !hasUrlParamFlag) {
2071
+ void isApplePayAvailable().then((available) => {
2072
+ if (available) {
2073
+ trackApplePayExperimentExposure(
2074
+ experimentValue,
2075
+ getExperimentKeyFromNextData(APPLE_PAY_EXPRESS_EXPERIMENT_KEY)
2076
+ );
2077
+ }
2078
+ });
2056
2079
  }
2057
2080
  const isTreatment = experimentValue === APPLE_PAY_EXPRESS_VARIANTS.TREATMENT;
2058
- const hasUrlParamFlag = new URLSearchParams(window.location.search).has(
2059
- FEATURE_APPLE_PAY_EXPRESS_CHECKOUT
2060
- );
2061
2081
  if (!isTreatment && !hasUrlParamFlag) {
2062
2082
  return null;
2063
2083
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Host-side eligibility for Apple Pay Express Feature Experiment (SMA-3301).
3
+ *
4
+ * Gates createIfEnabled before getVariant / $exposure so only the intended
5
+ * population (homepage + Safari/iPhone) participates. Anonymous is assumed
6
+ * because the dual-offer banner is only mounted for anonymous visitors.
7
+ * Exposure is further gated on isApplePayAvailable() (BYPASS_APPLE_PAY_CHECKS
8
+ * respected). Amplitude audience targeting uses generic user_properties from
9
+ * Engagement.
10
+ */
11
+ export declare const isApplePayExpressHomepage: (pathname?: string) => boolean;
12
+ /**
13
+ * True when the visitor may enter the Apple Pay Express experiment path
14
+ * (assignment read + $exposure + optional treatment button).
15
+ */
16
+ export declare const isEligibleForApplePayExpressExperiment: () => boolean;
@@ -0,0 +1,14 @@
1
+ // src/clients/payment-checkout/detects.ts
2
+ var isAppleDeviceOrSafari = () => {
3
+ const isIOSOrMacTouchDevice = /iPad|iPhone|iPod/.test(navigator.userAgent) || navigator.maxTouchPoints > 1 && /Macintosh/.test(navigator.userAgent);
4
+ const isSafariBrowser = navigator.userAgent.indexOf("Safari") > -1 && navigator.userAgent.indexOf("Chrome") === -1;
5
+ return isIOSOrMacTouchDevice || isSafariBrowser;
6
+ };
7
+
8
+ // src/utils/applePayExpressEligibility.ts
9
+ var isApplePayExpressHomepage = (pathname = window.location.pathname) => pathname === "/";
10
+ var isEligibleForApplePayExpressExperiment = () => isApplePayExpressHomepage() && isAppleDeviceOrSafari();
11
+ export {
12
+ isApplePayExpressHomepage,
13
+ isEligibleForApplePayExpressExperiment
14
+ };
@@ -50,10 +50,10 @@ export type ImpressionMetadata = {
50
50
  /**
51
51
  * Amplitude Experiment exposure for Apple Pay Express (SMA-3301).
52
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. Includes experiment_key from Engagement
56
- * SSR (__NEXT_DATA__) when present for Feature Experiment run attribution.
53
+ * Fired from createIfEnabled only after isApplePayAvailable() succeeds
54
+ * (control or treatment). Deduped per pathname + variant so repeated banner
55
+ * renders on the same page do not over-count. Includes experiment_key from
56
+ * Engagement SSR (__NEXT_DATA__) when present for run attribution.
57
57
  */
58
58
  export declare const trackApplePayExperimentExposure: (variant: string, experimentKey?: string) => void;
59
59
  /** Wallet button displayed — emits all 5 required analytics dimensions. */
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.4",
4
+ "version": "1.9.5",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",