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BJ,EAAAA,EAAcO,KAAK,CAAEC,MAAO,iBAAkBH,aAAY,EA3ErDN,EA8EMuB,mCAAsCC,IAAiC,IAAAC,EAClF,MAAMC,EACFF,EAAOG,QAAU9B,EAAAA,GACXA,EAAAA,GACA2B,EAAOI,cAAgBjC,EAAAA,GACrBA,EAAAA,GACAG,EAAAA,GAOZ,OALK0B,EAAOK,sBACRC,EAAAA,EAAgBC,aAAa,4CAADC,OAA6CR,EAAOS,KAChFT,EAAOK,oBAAsB,IAG1B,CACHK,QAASV,EAAOS,GAChBE,UAAWX,EAAOY,KAClBC,YAAaX,EACbY,WAAYd,EAAOK,oBAAoBU,KAAK,MAC5CC,cAAehB,EAAOiB,cACtBC,eAAgBlB,EAAOmB,OACvBC,eAAgBpB,EAAOqB,MACvBC,aAActB,EAAOG,MAErBoB,MAAmB,QAAdtB,EAAED,EAAOuB,aAAK,IAAAtB,EAAAA,EAAI,IACvBuB,SAAU,EACb,C,wDCzHF,MAAMlB,GAAAA,EACKC,aAAgBkB,IAC1BC,QAAQD,MAAMA,GAEd,MAAM,YAAEE,GAAgBC,OAExBD,SAAAA,EAAaE,eAAe,IAAIC,MAAML,GAAO,EANxCnB,EASKmB,MAASA,IACnBC,QAAQD,MAAMA,GAEd,MAAM,YAAEE,GAAgBC,OAExBD,SAAAA,EAAaE,eAAe,IAAIC,MAAM,GAADtB,OAAIiB,IAAS,C","sources":["webpack://Kristiania.Web/./Features/Partials/GoogleTagManager/AnalyticsConstants.ts","webpack://Kristiania.Web/./Features/Partials/GoogleTagManager/GtmCommerceEventsHandler.ts","webpack://Kristiania.Web/./Features/Utils/Logging/TelemetryLogger.ts"],"sourcesContent":["export const OnlineStudyBrand = 'Nettstudier';\n\nexport const SingleSubject = 'Enkeltemne';\n\nexport const VocationalSchoolBrand = 'Fagskole';\n\nexport const CampusBrand = 'Stedsbasert';\n\nexport const SchoolName = 'Høyskolen Kristiania';\n","import type { ApplicationChoiceDto } from '../../Search/ApplicationChoice/Controller/ApplicationChoiceDto.csharp';\nimport { CampusBrand, OnlineStudyBrand, VocationalSchoolBrand } from '~/Partials/GoogleTagManager/AnalyticsConstants';\nimport { TelemetryLogger } from '~/Utils/Logging/TelemetryLogger';\nimport type {\n GoogleTagManagerEcommerceAdd,\n GoogleTagManagerEcommerceBaseActionField,\n GoogleTagManagerEcommerceBeginCheckout,\n GoogleTagManagerEcommerceCheckout,\n GoogleTagManagerEcommerceCheckoutActionField,\n GoogleTagManagerEcommerceCheckoutOption,\n GoogleTagManagerEcommerceProduct,\n GoogleTagManagerEcommerceProductDetail,\n GoogleTagManagerEcommercePurchase,\n GoogleTagManagerEcommercePurchaseActionField,\n GoogleTagManagerEcommerceRemove,\n} from './GoogleTagManagerModels';\nimport { GtmEventsBase } from './GtmEventsBase';\n\nexport class GtmCommerceEventsHandler extends GtmEventsBase {\n public static pushPurchase = (\n items: GoogleTagManagerEcommerceProduct[],\n actionField: GoogleTagManagerEcommercePurchaseActionField\n ) => {\n const ecommerce: GoogleTagManagerEcommercePurchase = {\n ...actionField,\n items,\n };\n\n GtmEventsBase.push({ event: 'purchase', ecommerce });\n };\n\n public static pushAddProducts = (\n items: GoogleTagManagerEcommerceProduct[],\n actionField: GoogleTagManagerEcommerceBaseActionField\n ) => {\n const ecommerce: GoogleTagManagerEcommerceAdd = {\n ...actionField,\n items,\n };\n GtmEventsBase.push({ event: 'add_to_cart', ecommerce });\n };\n\n public static pushRemoveProducts = (\n items: GoogleTagManagerEcommerceProduct[],\n actionField: GoogleTagManagerEcommerceBaseActionField\n ) => {\n const ecommerce: GoogleTagManagerEcommerceRemove = {\n ...actionField,\n items,\n };\n GtmEventsBase.push({ event: 'remove_from_cart', ecommerce });\n };\n\n public static pushBeginCheckout = (\n items: GoogleTagManagerEcommerceProduct[],\n actionField: GoogleTagManagerEcommerceBaseActionField\n ) => {\n const ecommerce: GoogleTagManagerEcommerceBeginCheckout = {\n ...actionField,\n items,\n };\n GtmEventsBase.push({ event: 'begin_checkout', ecommerce });\n };\n\n public static pushCheckout = (\n items: GoogleTagManagerEcommerceProduct[],\n actionField: GoogleTagManagerEcommerceCheckoutActionField\n ) => {\n const ecommerce: GoogleTagManagerEcommerceCheckout = {\n ...actionField,\n items,\n };\n GtmEventsBase.push({ event: 'checkout', ecommerce });\n };\n\n public static pushCheckoutOption = (checkout_step: number, option?: string) => {\n const eventName = 'checkout_option';\n const ecommerce: GoogleTagManagerEcommerceCheckoutOption = {\n checkout_option: {\n actionField: { checkout_step, option: option || eventName },\n },\n };\n\n GtmEventsBase.push({ event: eventName, ecommerce });\n };\n\n public static pushProductDetail = (newChoices: ApplicationChoiceDto[]) => {\n const ecommerce = {\n detail: {\n items: newChoices.map(GtmCommerceEventsHandler.createProductFromApplicationChoice),\n actionField: '',\n },\n } satisfies GoogleTagManagerEcommerceProductDetail;\n GtmEventsBase.push({ event: 'product_detail', ecommerce });\n };\n\n private static createProductFromApplicationChoice = (choice: ApplicationChoiceDto) => {\n const studyType =\n choice.level === VocationalSchoolBrand\n ? VocationalSchoolBrand\n : choice.variantCity === OnlineStudyBrand\n ? OnlineStudyBrand\n : CampusBrand;\n\n if (!choice.educationCategories) {\n TelemetryLogger.errorMessage(`Missing education categories for subject ${choice.id}`);\n choice.educationCategories = [];\n }\n\n return {\n item_id: choice.id,\n item_name: choice.name,\n affiliation: studyType,\n item_brand: choice.educationCategories.join(', '),\n item_category: choice.studyFormType,\n item_category2: choice.points,\n item_category3: choice.label,\n item_variant: choice.level,\n // default values set on a base of consultations with client\n price: choice.price ?? 100,\n quantity: 1,\n } satisfies GoogleTagManagerEcommerceProduct;\n };\n}\n","export class TelemetryLogger {\n public static errorMessage = (error: string) => {\n console.error(error);\n\n const { appInsights } = window as any;\n\n appInsights?.trackException(new Error(error));\n };\n\n public static error = (error: unknown) => {\n console.error(error);\n\n const { appInsights } = window as any;\n\n appInsights?.trackException(new Error(`${error}`));\n };\n}\n"],"names":["OnlineStudyBrand","SingleSubject","VocationalSchoolBrand","CampusBrand","SchoolName","GtmCommerceEventsHandler","GtmEventsBase","_GtmCommerceEventsHandler","pushPurchase","items","actionField","ecommerce","_objectSpread","push","event","pushAddProducts","pushRemoveProducts","pushBeginCheckout","pushCheckout","pushCheckoutOption","checkout_step","option","eventName","checkout_option","pushProductDetail","newChoices","detail","map","createProductFromApplicationChoice","choice","_choice$price","studyType","level","variantCity","educationCategories","TelemetryLogger","errorMessage","concat","id","item_id","item_name","name","affiliation","item_brand","join","item_category","studyFormType","item_category2","points","item_category3","label","item_variant","price","quantity","error","console","appInsights","window","trackException","Error"],"sourceRoot":""}