UNPKG

@adyen/adyen-web

Version:

[![npm](https://img.shields.io/npm/v/@adyen/adyen-web.svg)](https://www.npmjs.com/package/@adyen/adyen-web)

3 lines (2 loc) 2.87 kB
import{ANALYTICS_EVENT as e,ANALYTICS_ACTION_STR as t,ANALYTICS_SUBMIT_STR as a,ANALYTICS_VALIDATION_ERROR_STR as n,ANALYTICS_SELECTED_STR as r,ANALYTICS_DOWNLOAD_STR as o,ANALYTICS_INPUT_STR as s,ANALYTICS_DISPLAYED_STR as c,ANALYTICS_UNFOCUS_STR as i,ANALYTICS_FOCUS_STR as p,ANALYTICS_CONFIGURED_STR as y,ANALYTICS_RENDERED_STR as l,ANALYTICS_EXPRESS_PAGES_ARRAY as m}from"./constants.js";import{THREEDS2_ERROR as d,THREEDS2_FULL as b}from"../../components/ThreeDS2/constants.js";import u,{SDK_ERROR as f}from"../Errors/AdyenCheckoutError.js";import{getCardConfigData as g}from"./utils.js";function v(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const E=E=>(h,k,A={})=>{const{type:P,target:j}=k;if(!P)throw new u(f,"You are trying to create an analytics event without a type");switch(P){case l:{const{isStoredPaymentMethod:t,brand:a,configData:n}=k,{isExpress:r,expressPage:o}=A,s=o&&m.includes(o),{type:c}=A;let i=null;"scheme"!==c&&"bcmc"!==c&&"customcard"!==c||(i=g(A));const p=function(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{},n=Object.keys(a);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(a).filter((function(e){return Object.getOwnPropertyDescriptor(a,e).enumerable})))),n.forEach((function(t){v(e,t,a[t])}))}return e}({component:h,type:P},"boolean"==typeof t&&{isStoredPaymentMethod:t},a&&{brand:a},"boolean"==typeof r&&{isExpress:r},!0===r&&s&&{expressPage:o},i&&{configData:i},n&&{configData:n});E.createAnalyticsEvent({event:e.info,data:p});break}case y:{const{isStoredPaymentMethod:t,brand:a}=k,n={component:h,type:P,isStoredPaymentMethod:t,brand:a};E.createAnalyticsEvent({event:e.info,data:n});break}case p:case i:case c:case s:case o:E.createAnalyticsEvent({event:e.info,data:{component:h,type:P,target:j}});break;case r:{const{issuer:t}=k;E.createAnalyticsEvent({event:e.info,data:{component:h,type:P,target:j,issuer:t}});break}case n:{const{validationErrorCode:t,validationErrorMessage:a}=k;E.createAnalyticsEvent({event:e.info,data:{component:h,type:P,target:j,validationErrorCode:t,validationErrorMessage:a}});break}case a:E.createAnalyticsEvent({event:e.log,data:{component:h,type:P,message:"Shopper clicked pay"}});break;case t:{const{subtype:t,message:a}=k;E.createAnalyticsEvent({event:e.log,data:{component:h,type:P,subtype:t,message:a}});break}case b:{const{message:t,metadata:a,subtype:n,result:r}=k;E.createAnalyticsEvent({event:e.log,data:{component:h,type:P,message:t,metadata:a,subtype:n,result:r}});break}case d:case e.error:{const{message:t,code:a,errorType:n}=k;E.createAnalyticsEvent({event:e.error,data:{component:h,type:P,message:t,code:a,errorType:n}});break}default:E.createAnalyticsEvent(k)}};export{E as analyticsPreProcessor}; //# sourceMappingURL=analyticsPreProcessor.js.map