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) 1.53 kB
import t from"../Errors/AdyenCheckoutError.js";import{httpPost as e}from"../Services/http.js";function n(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}const o="v3/analytics";class r{async requestCheckoutAttemptId(n){const r={loadingContext:this.analyticsContext,path:`${o}?clientKey=${this.clientKey}`};try{const{checkoutAttemptId:t}=await e(r,n);return t}catch(e){throw new t("NETWORK_ERROR","requestCheckoutAttemptId() - failed to get checkout attempt ID",{cause:e})}}async sendEvents(n,r){if(!r)throw new t("IMPLEMENTATION_ERROR","sendEvents() - checkoutAttemptId is required");if(!n.info.length&&!n.errors.length&&!n.logs.length)return Promise.resolve();const i={loadingContext:this.analyticsContext,path:`${o}/${r}?clientKey=${this.clientKey}`};try{await e(i,n)}catch(e){throw new t("NETWORK_ERROR","sendEvents() - failed to send events",{cause:e})}}async reportIntegrationFlavor(n,r){if(!n||!r)throw new t("IMPLEMENTATION_ERROR","reportIntegrationFlavor() - flavor or checkoutAttemptId is required");const i={loadingContext:this.analyticsContext,path:`${o}?clientKey=${this.clientKey}`},a={flavor:n,checkoutAttemptId:r};try{await e(i,a)}catch(e){throw new t("NETWORK_ERROR","reportIntegrationFlavor() - failed to send flavor",{cause:e})}}constructor({clientKey:t,analyticsContext:e}){n(this,"clientKey",void 0),n(this,"analyticsContext",void 0),this.clientKey=t,this.analyticsContext=e}}export{r as AnalyticsService}; //# sourceMappingURL=AnalyticsService.js.map