{"version":3,"sources":["webpack:///scripts/plugin--ga-tracking-event--a364311db46caf2d98ac.js","webpack:///./client/src/core/components/ga-tracking-event/ga-tracking-event.js"],"names":["webpackJsonpHairCare","D:\\a\\1\\s\\node_modules\\babel-loader\\lib\\index.js??ref--12-0!D:\\a\\1\\s\\node_modules\\eslint-loader\\index.js??ref--12-1!D:\\a\\1\\s\\client\\src\\core\\components\\ga-tracking-event\\ga-tracking-event.js","module","exports","__webpack_require__","_interopRequireDefault","obj","__esModule","default","_classCallCheck","instance","Constructor","TypeError","Object","defineProperty","value","_createClass","defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","key","protoProps","staticProps","prototype","_jquery2","_jquery","_lib","_debug2","_debug","GaTrackingEvent","element","options","this","$element","currency","data","type","watch","product","window","datalayerDataSource","dataItemList","GAServices","getItemListName","item_id","dataTracking","event","ecommerce","items","item","assign","quantity","undefined","status","push","trackingGA","find","each","index","color","on","e","newData","getAttributesWithPrefix","colorData","saveListItemsName","klaviyoProduct","klaviyoDataSource","KlaviyoServices","trackingKlaviyo","cartInfo","savedOrderId","localStorage","getItem","JSON","parse","setItem","transaction_id","url","orderId","urlPost","token","val","fetch","method","body","stringify","__RequestVerificationToken","headers","then","response","removeItem","DEFAULTS"],"mappings":"AAAAA,sBAAsB,8BAEhBC,sNACA,SAAUC,EAAQC,EAASC,GAEjC,YAyBA,SAASC,GAAuBC,GAAO,MAAOA,IAAOA,EAAIC,WAAaD,GAAQE,QAASF,GAEvF,QAASG,GAAgBC,EAAUC,GAAe,KAAMD,YAAoBC,IAAgB,KAAM,IAAIC,WAAU,qCAxBhHC,OAAOC,eAAeX,EAAS,cAC9BY,OAAO,GAGR,IAAIC,GAAe,WAAc,QAASC,GAAiBC,EAAQC,GAAS,IAAK,GAAIC,GAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CAAE,GAAIE,GAAaH,EAAMC,EAAIE,GAAWC,WAAaD,EAAWC,aAAc,EAAOD,EAAWE,cAAe,EAAU,SAAWF,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AC1C,GAAMkC,GAAW/B,OAAOC,oBAClB+B,EAAeC,aAAaC,QAAQ,kBAC1C,IAAIH,IAAaC,EAAc,CAC9B,GAAMpC,GAAOuC,KAAKC,MAAMH,aAAaC,QAAQ,wBAC7CH,GAAStB,MAAQb,CACjB,IAAMU,IACLC,MAAO,WACPC,UAAWuB,EAEZ5B,cAAWa,WAAWV,GACtB2B,aAAaI,QAAQ,kBAAmBN,EAASO,eACjD,IAAMC,GAAM9C,KAAKC,SAASE,KAAK,4BACzB4C,EAAU/C,KAAKC,SAASE,KAAK,YAC7B6C,EAAUF,sBAA0BC,EAA1B,WACVE,GAAQ,aAAE,mEAAmEC,KACnFC,OAAMH,GACLI,OAAQ,OACRC,KAAMX,KAAKY,WACVC,2BAA4BN,IAE7BO,SACC,eAAgB,sBAEfC,KAAK,SAACC,GACRlB,aAAamB,WAAW,sBACxBnB,aAAamB,WAAW,oBACxBnB,aAAamB,WAAW,mCDuCrB9D,IChCRA,GAAgB+D,YDqChB/F,EAAQK,QCnCO2B","file":"scripts/plugin--ga-tracking-event--a364311db46caf2d98ac.js","sourcesContent":["webpackJsonpHairCare([\"plugin--ga-tracking-event\"],{\n\n/***/ \"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\client\\\\src\\\\core\\\\components\\\\ga-tracking-event\\\\ga-tracking-event.js\":\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n\tvalue: true\n});\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _jquery = __webpack_require__(\"external \\\"jQuery\\\"\");\n\nvar _jquery2 = _interopRequireDefault(_jquery);\n\nvar _lib = __webpack_require__(\"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\client\\\\src\\\\core\\\\plugins\\\\lib\\\\index.js\");\n\nvar _lib2 = _interopRequireDefault(_lib);\n\nvar _debug = __webpack_require__(\"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\debug\\\\src\\\\browser.js\");\n\nvar _debug2 = _interopRequireDefault(_debug);\n\nvar _gaServices = __webpack_require__(\"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\client\\\\src\\\\core\\\\services\\\\ga-services.js\");\n\nvar _klaviyoServices = __webpack_require__(\"D:\\\\a\\\\1\\\\s\\\\node_modules\\\\babel-loader\\\\lib\\\\index.js??ref--12-0!D:\\\\a\\\\1\\\\s\\\\node_modules\\\\eslint-loader\\\\index.js??ref--12-1!D:\\\\a\\\\1\\\\s\\\\client\\\\src\\\\core\\\\services\\\\klaviyo-services.js\");\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar MODULE_NAME = 'app.core/modules/ga-tracking-event';\nvar log = (0, _debug2.default)(MODULE_NAME);\n\nlog('registerd');\n\nvar GaTrackingEvent = function () {\n\tfunction GaTrackingEvent(element, options) {\n\t\t_classCallCheck(this, GaTrackingEvent);\n\n\t\tthis.element = element;\n\t\tthis.$element = (0, _jquery2.default)(element);\n\t\tthis.currency = (0, _jquery2.default)('body').data('currency');\n\t\tthis.type = this.$element.data('type');\n\t\tthis.watch();\n\t}\n\n\t_createClass(GaTrackingEvent, [{\n\t\tkey: \"watch\",\n\t\tvalue: function watch() {\n\t\t\tif (this.type === 'PDP') {\n\t\t\t\tvar product = window.datalayerDataSource;\n\t\t\t\tif (product) {\n\t\t\t\t\tvar dataItemList = _gaServices.GAServices.getItemListName(product.item_id);\n\t\t\t\t\tvar dataTracking = {\n\t\t\t\t\t\tevent: 'view_item',\n\t\t\t\t\t\tecommerce: {\n\t\t\t\t\t\t\tcurrency: this.currency,\n\t\t\t\t\t\t\titems: []\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t\tvar item = Object.assign({}, product, dataItemList);\n\t\t\t\t\titem.quantity = undefined;\n\t\t\t\t\titem.status = item.status || undefined;\n\t\t\t\t\tdataTracking.ecommerce.items.push(item);\n\t\t\t\t\t_gaServices.GAServices.trackingGA(dataTracking);\n\n\t\t\t\t\t// Click event on select color\n\t\t\t\t\tvar $colours = this.$element.find('[ga-tracking-link]');\n\t\t\t\t\t$colours.each(function (index, color) {\n\t\t\t\t\t\t(0, _jquery2.default)(color).on('click', function (e) {\n\t\t\t\t\t\t\tvar newData = _gaServices.GAServices.getAttributesWithPrefix((0, _jquery2.default)(color), 'data-ga-');\n\t\t\t\t\t\t\tvar colorData = Object.assign({}, item, newData);\n\t\t\t\t\t\t\t_gaServices.GAServices.saveListItemsName(colorData);\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\t// Klaviyo track Viewed Product event\n\t\t\t\tvar klaviyoProduct = window.klaviyoDataSource;\n\t\t\t\tif (klaviyoProduct) {\n\t\t\t\t\t_klaviyoServices.KlaviyoServices.trackingKlaviyo('Viewed Product', klaviyoProduct);\n\t\t\t\t}\n\t\t\t} else if (this.type === 'Cart Submitted') {\n\t\t\t\tvar cartInfo = window.datalayerDataSource;\n\t\t\t\tvar savedOrderId = localStorage.getItem('orderIdTracking');\n\t\t\t\tif (cartInfo && !savedOrderId) {\n\t\t\t\t\tvar data = JSON.parse(localStorage.getItem('cartTrackingData')) || [];\n\t\t\t\t\tcartInfo.items = data;\n\t\t\t\t\tvar _dataTracking = {\n\t\t\t\t\t\tevent: 'purchase',\n\t\t\t\t\t\tecommerce: cartInfo\n\t\t\t\t\t};\n\t\t\t\t\t_gaServices.GAServices.trackingGA(_dataTracking);\n\t\t\t\t\tlocalStorage.setItem('orderIdTracking', cartInfo.transaction_id);\n\t\t\t\t\tvar url = this.$element.data('ga-tracking-sent-api-url');\n\t\t\t\t\tvar orderId = this.$element.data('order-id');\n\t\t\t\t\tvar urlPost = url + (\"?purchaseOrderId=\" + orderId + \"&value=1\");\n\t\t\t\t\tvar token = (0, _jquery2.default)('#__AjaxAntiForgeryForm input[name=\"__RequestVerificationToken\"]').val();\n\t\t\t\t\tfetch(urlPost, {\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\t\t__RequestVerificationToken: token\n\t\t\t\t\t\t}),\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\"Content-Type\": \"application/json\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}).then(function (response) {\n\t\t\t\t\t\tlocalStorage.removeItem('selectTrackingData');\n\t\t\t\t\t\tlocalStorage.removeItem('cartTrackingData');\n\t\t\t\t\t\tlocalStorage.removeItem('cartKlaviyoTrackingData');\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}]);\n\n\treturn GaTrackingEvent;\n}();\n\nGaTrackingEvent.DEFAULTS = {};\n\nexports.default = GaTrackingEvent;\n\n/***/ })\n\n});\n\n\n// WEBPACK FOOTER //\n// scripts/plugin--ga-tracking-event--a364311db46caf2d98ac.js","import $ from \"jquery\";\r\nimport plugin from '@core/plugins/lib';\r\nimport debug from \"debug\";\r\nimport { GAServices } from \"../../services/ga-services\";\r\nimport { KlaviyoServices } from \"../../services/klaviyo-services\";\r\nconst MODULE_NAME = 'app.core/modules/ga-tracking-event';\r\nconst log = debug(MODULE_NAME);\r\n\r\nlog('registerd');\r\n\r\nclass GaTrackingEvent {\r\n\tconstructor(element, options) {\r\n\t\tthis.element = element;\r\n\t\tthis.$element = $(element);\r\n\t\tthis.currency = $('body').data('currency');\r\n\t\tthis.type = this.$element.data('type');\r\n\t\tthis.watch();\r\n\t}\r\n\r\n\twatch () {\r\n\t\tif (this.type === 'PDP') {\r\n\t\t\tconst product = window.datalayerDataSource;\r\n\t\t\tif (product) {\r\n\t\t\t\tconst dataItemList = GAServices.getItemListName(product.item_id);\r\n\t\t\t\tconst dataTracking = {\r\n\t\t\t\t\tevent: 'view_item',\r\n\t\t\t\t\tecommerce: {\r\n\t\t\t\t\t\tcurrency: this.currency,\r\n\t\t\t\t\t\titems: [],\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tconst item = Object.assign({}, product, dataItemList);\r\n\t\t\t\titem.quantity = undefined;\r\n\t\t\t\titem.status = item.status || undefined;\r\n\t\t\t\tdataTracking.ecommerce.items.push(item);\r\n\t\t\t\tGAServices.trackingGA(dataTracking);\r\n\r\n\t\t\t\t// Click event on select color\r\n\t\t\t\tconst $colours = this.$element.find('[ga-tracking-link]');\r\n\t\t\t\t$colours.each((index, color) => {\r\n\t\t\t\t\t$(color).on('click', (e) => {\r\n\t\t\t\t\t\tconst newData = GAServices.getAttributesWithPrefix($(color), 'data-ga-');\r\n\t\t\t\t\t\tconst colorData = Object.assign({}, item, newData);\r\n\t\t\t\t\t\tGAServices.saveListItemsName(colorData);\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\t// Klaviyo track Viewed Product event\r\n\t\t\tconst klaviyoProduct = window.klaviyoDataSource;\r\n\t\t\tif(klaviyoProduct) {\r\n\t\t\t\tKlaviyoServices.trackingKlaviyo('Viewed Product', klaviyoProduct);\r\n\t\t\t}\r\n\r\n\t\t} else if (this.type === 'Cart Submitted') {\r\n\t\t\tconst cartInfo = window.datalayerDataSource;\r\n\t\t\tconst savedOrderId = localStorage.getItem('orderIdTracking');\r\n\t\t\tif (cartInfo && !savedOrderId) {\r\n\t\t\t\tconst data = JSON.parse(localStorage.getItem('cartTrackingData')) || [];\r\n\t\t\t\tcartInfo.items = data;\r\n\t\t\t\tconst dataTracking = {\r\n\t\t\t\t\tevent: 'purchase',\r\n\t\t\t\t\tecommerce: cartInfo,\r\n\t\t\t\t};\r\n\t\t\t\tGAServices.trackingGA(dataTracking);\r\n\t\t\t\tlocalStorage.setItem('orderIdTracking', cartInfo.transaction_id);\r\n\t\t\t\tconst url = this.$element.data('ga-tracking-sent-api-url');\r\n\t\t\t\tconst orderId = this.$element.data('order-id');\r\n\t\t\t\tconst urlPost = url + `?purchaseOrderId=${orderId}&value=1`;\r\n\t\t\t\tconst token = $('#__AjaxAntiForgeryForm input[name=\"__RequestVerificationToken\"]').val();\r\n\t\t\t\tfetch(urlPost, {\r\n\t\t\t\t\tmethod: \"POST\",\r\n\t\t\t\t\tbody: JSON.stringify({\r\n\t\t\t\t\t\t__RequestVerificationToken: token,\r\n\t\t\t\t\t}),\r\n\t\t\t\t\theaders: {\r\n\t\t\t\t\t\t\"Content-Type\": \"application/json\",\r\n\t\t\t\t\t},\r\n\t\t\t\t}).then((response) => {\r\n\t\t\t\t\tlocalStorage.removeItem('selectTrackingData');\r\n\t\t\t\t\tlocalStorage.removeItem('cartTrackingData');\r\n\t\t\t\t\tlocalStorage.removeItem('cartKlaviyoTrackingData');\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\nGaTrackingEvent.DEFAULTS = {};\r\n\r\nexport default GaTrackingEvent;\r\n\n\n\n// WEBPACK FOOTER //\n// ./client/src/core/components/ga-tracking-event/ga-tracking-event.js"],"sourceRoot":""}