{"version":3,"file":"checkoutTrackingService-g5awEx5p.js","sources":["../../../../Coloplast.UI/src/shared/services/tracking/checkoutTrackingService.ts"],"sourcesContent":["import { trackEcommerce } from './core';\r\nimport { buildEcommerceSectionFromBasketDto } from './utils';\r\nimport { trackingEventNames } from 'shared/settings/constants';\r\nimport { IBasket } from './interfaces/IBasket';\r\nimport { snakeCase } from 'lodash';\r\n\r\nexport type PaymentMethod = 'ndis_self' | 'ndis_plan' | 'ndis_ndia' | 'own';\r\nexport type ConsentDecision = 'opt_out' | 'opt_in';\r\n\r\nexport function track_sample_consent(basket: IBasket, decision: ConsentDecision) {\r\n\tconst event = {\r\n\t\tevent: trackingEventNames.SAMPLE_CONSENT,\r\n\t\t...buildEcommerceSectionFromBasketDto(basket, {\r\n\t\t\tsample_consent_decision: decision,\r\n\t\t}),\r\n\t};\r\n\ttrackEcommerce(event);\r\n}\r\n\r\nexport function track_marketing_consent(\r\n\tbasket: IBasket,\r\n\tdecision: ConsentDecision,\r\n\tcallback?: (containerId?: string) => void\r\n) {\r\n\tconst event = {\r\n\t\tevent: trackingEventNames.MARKETING_CONSENT,\r\n\t\t...buildEcommerceSectionFromBasketDto(basket, {\r\n\t\t\tmarketing_consent_decision: decision,\r\n\t\t}),\r\n\t};\r\n\r\n\tif (callback) event.eventCallback = callback;\r\n\r\n\ttrackEcommerce(event);\r\n}\r\n\r\nexport function track_order_summary(basket: IBasket) {\r\n\tconst event = {\r\n\t\tevent: trackingEventNames.ORDER_SUMMARY,\r\n\t\t...buildEcommerceSectionFromBasketDto(basket),\r\n\t};\r\n\ttrackEcommerce(event);\r\n}\r\n\r\nexport function track_order_consent(basket: IBasket, decision: ConsentDecision) {\r\n\tconst event = {\r\n\t\tevent: trackingEventNames.ORDER_CONSENT,\r\n\t\t...buildEcommerceSectionFromBasketDto(basket, {\r\n\t\t\torder_consent_decision: decision\r\n\t\t}),\r\n\t};\r\n\ttrackEcommerce(event);\r\n}\r\n\r\n\r\nexport function track_ndis_funding(basket: IBasket) {\r\n\tconst event = {\r\n\t\tevent: trackingEventNames.NDIS_FUNDING,\r\n\t\t...buildEcommerceSectionFromBasketDto(basket)\r\n\t}\r\n\ttrackEcommerce(event);\r\n}\r\n\r\nexport function track_order_changes(basket: IBasket, reason: string) {\r\n\tconst event = {\r\n\t\tevent: trackingEventNames.ORDER_CHANGES,\r\n\t\t...buildEcommerceSectionFromBasketDto(basket, {\r\n\t\t\tchange_reason: reason?.toLowerCase().replace(/\\s/g, '_'),\r\n\t\t}),\r\n\t};\r\n\ttrackEcommerce(event);\r\n}\r\n\r\nexport function track_address_change(\r\n\taddressAction: 'swap_to' | 'edit' | 'added' | 'delete',\r\n\taddressType: 'shippingAddress' | 'mailingAddress' | 'otherAddress'\r\n) {\r\n\tconst type = addressType === 'shippingAddress' ? 'primary' : 'alternative';\r\n\r\n\tconst event = {\r\n\t\tevent: trackingEventNames.ADDRESS_CHANGE,\r\n\t\taddress_action: addressAction,\r\n\t\taddress_type: type,\r\n\t};\r\n\ttrackEcommerce(event);\r\n}\r\n\r\nexport function track_prescription_information(\r\n\tbasket: IBasket,\r\n\tprescriptionChoice: 'you_have_my_prescription' | 'sent_my_prescription_later' | 'prescription_submitted'\r\n) {\r\n\tconst event = {\r\n\t\tevent: trackingEventNames.PRESCRIPTION_INFORMATION,\r\n\t\t...buildEcommerceSectionFromBasketDto(basket, {\r\n\t\t\tprescription_choice: prescriptionChoice,\r\n\t\t}),\r\n\t};\r\n\ttrackEcommerce(event);\r\n}\r\n\r\nexport function track_complementary_products(basket: IBasket, complementaryChoice: 'add_free_products' | 'no_thanks') {\r\n\tconst event = {\r\n\t\tevent: trackingEventNames.COMPLEMENTARY_PRODUCTS,\r\n\t\t...buildEcommerceSectionFromBasketDto(basket, {\r\n\t\t\tcomplementary_choice: complementaryChoice,\r\n\t\t}),\r\n\t};\r\n\r\n\ttrackEcommerce(event);\r\n}\r\n\r\nexport function track_reimbursement(basket: IBasket, exemptStatus: string = 'no_data') {\r\n\tconst event = {\r\n\t\tevent: trackingEventNames.REIMBURSEMENT,\r\n\t\t...buildEcommerceSectionFromBasketDto(basket, {\r\n\t\t\texempt_status: snakeCase(exemptStatus),\r\n\t\t}),\r\n\t};\r\n\r\n\ttrackEcommerce(event);\r\n}\r\n\r\nexport function track_payment_method(basket: IBasket, paymentMethod: PaymentMethod) {\r\n\tconst event = {\r\n\t\tevent: trackingEventNames.PAYMENT_METHOD,\r\n\t\t...buildEcommerceSectionFromBasketDto(basket, {\r\n\t\t\tpayment_method_choosen: paymentMethod,\r\n\t\t}),\r\n\t};\r\n\r\n\ttrackEcommerce(event);\r\n}\r\n\r\n"],"names":["track_sample_consent","basket","decision","event","trackingEventNames","buildEcommerceSectionFromBasketDto","trackEcommerce","track_marketing_consent","callback","track_order_summary","track_order_consent","track_order_changes","reason","track_address_change","addressAction","addressType","type","track_prescription_information","prescriptionChoice","track_complementary_products","complementaryChoice","track_reimbursement","exemptStatus","snakeCase","track_payment_method","paymentMethod"],"mappings":"uLASgB,SAAAA,EAAqBC,EAAiBC,EAA2B,CAChF,MAAMC,EAAQ,CACb,MAAOC,EAAmB,eAC1B,GAAGC,EAAmCJ,EAAQ,CAC7C,wBAAyBC,CAAA,CACzB,CAAA,EAEFI,EAAeH,CAAK,CACrB,CAEgB,SAAAI,EACfN,EACAC,EACAM,EACC,CACD,MAAML,EAAQ,CACb,MAAOC,EAAmB,kBAC1B,GAAGC,EAAmCJ,EAAQ,CAC7C,2BAA4BC,CAAA,CAC5B,CAAA,EAGEM,MAAgB,cAAgBA,GAEpCF,EAAeH,CAAK,CACrB,CAEO,SAASM,EAAoBR,EAAiB,CACpD,MAAME,EAAQ,CACb,MAAOC,EAAmB,cAC1B,GAAGC,EAAmCJ,CAAM,CAAA,EAE7CK,EAAeH,CAAK,CACrB,CAEgB,SAAAO,EAAoBT,EAAiBC,EAA2B,CAC/E,MAAMC,EAAQ,CACb,MAAOC,EAAmB,cAC1B,GAAGC,EAAmCJ,EAAQ,CAC7C,uBAAwBC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