import biLogger from 'web-bi-logger'; interface BIEvent { evid: number; paymentCategory?: string; paymentProvider?: string; paymentMethodType?: string; paymentMethod?: string; duration?: string; source?: string; errorDesc?: string; status?: boolean; payWith?: string; transactionId?: string; transactionStatus?: string; } interface BIInit { appId: string; appInstanceId: string; orderSnapshotId?: string; msid?: string; visitorId?: string; } class BiLogger { private logger; init = ({appId, appInstanceId, orderSnapshotId, visitorId, msid}) => { this.logger = biLogger.factory({ endpoint: 'cashier-ugc' }).setDefaults({ src: 64, appId, appInstanceId, orderSnapshotId, visitorId, msid, buyerComponent: 'react', ownerId: 'undefined', roles: '' }).logger(); } log = ({ evid, ...rest}: BIEvent) => this.logger.log({ evid, ...rest }); creditCardLoaded = ({duration, paymentCategory, paymentProvider, source}) => { // when credit card completly loaded and displayed in iframe const evid = 100; this.log({evid, paymentCategory, paymentProvider, duration, source}); } submitOrder = ({errorDesc, paymentMethodType, status, paymentProvider}) => {//TODO // when user clicked submit order, place order, tokenize? const evid = 104; this.log({evid, errorDesc, paymentMethodType, status: Boolean(status), paymentProvider}); } buyerChoosedPaymentMethod = ({paymentMethod}) => { // when user choosed some payment method(click on radio button) const evid = 105; this.log({evid, paymentMethod}); } buyerLoadStart = ({duration}) => { // when load of component started const evid = 125; this.log({evid, duration}); } buyerLoadCompleted = ({duration, status}) => { // when load of component started const evid = 126; this.log({evid, duration, status: Boolean(status)}); } transactionStatus = ({paymentMethodType, paymentProvider, transactionId, transactionStatus}) => { // TODO // when load of component started const evid = 103; this.log({evid, paymentMethodType, paymentProvider, transactionId, transactionStatus}); } } export default (new BiLogger());