(()=>{"use strict";const e=e=>{const t=document.createElement("script");t.innerHTML=e,document.head.appendChild(t)};function t(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var n,i;!function(e){e.FIRST_IMPRESSION_UTM="firstImpressionsUTMs",e.HAD_FIRST_VISIT="hadFirstVisit",e.IS_FIRST_VISIT="isFirstVisit",e.ALREADY_REGISTERED="alreadyRegistered",e.REGISTERED_IN_THIS_SESSION="registeredInThisSession",e.SESSION_DATA_KEY="sessionData",e.COOKIE_POLICY="cookie_policy"}(n||(n={})),function(e){e.DIRECT="organicdirect",e.INTERNAL="organicinternaldirect",e.GOOGLE="organicgoogle",e.BING="organicbing",e.YOUTUBE="organicyoutube",e.SOCIAL="organicsocial",e.ORGANIC="organicreferrer"}(i||(i={}));const o={[i.DIRECT]:[],[i.INTERNAL]:["slide.ly"],[i.GOOGLE]:["google"],[i.BING]:["bing"],[i.YOUTUBE]:["youtube"],[i.SOCIAL]:["facebook","twitter","t.co","linkedin","instagram"],[i.ORGANIC]:[]},a={utm_source:"source",source:"source",utm_campaign:"campaign",utm_camp_id:"camp_id",utm_content:"clickedOn",utm_medium:"utm_medium",utm_term:"utm_term",utm_term_id:"utm_term_id",utm_creative:"utm_creative",utm_creative_id:"utm_creative_id",utm_kw:"utm_kw",utm_extension_id:"utm_extension_id"};class s{constructor(){t(this,"defaultParams",{}),t(this,"ezReportsQueue",[]),t(this,"isReportingDisabledByGdpr",!0)}async init(){return(await window.slidelySdk).init({appId:s.getSdkClientIdByEnv()}),s.isDebugEnabled()&&(window.analitycDebug={scheduled:[],sent:[]}),await this.initGlobalParams(),this.isReportingDisabledByGdpr=!localStorage.getItem(n.COOKIE_POLICY),await(async()=>{const{mixpanel:t}=(await window.promoConfig).reporting.analytics,n=`\nvar mixpanelConfig = {\n upgrade: true,\n opt_out_tracking_by_default:true\n};\n;(function(e, a) {\n if (!a.__SV) {\n var b = window;\n try {\n var c, l, i;\n var j = b.location;\n var g = j.hash;\n c = function(a, b) {\n return (l = a.match(RegExp(b + "=([^&]*)"))) ? l[1] : null;\n };\n g &&\n c(g, "state") &&\n ((i = JSON.parse(decodeURIComponent(c(g, "state")))),\n "mpeditor" === i.action &&\n (b.sessionStorage.setItem("_mpcehash", g),\n history.replaceState(\n i.desiredHash || "",\n e.title,\n j.pathname + j.search\n )));\n } catch (m) {}\n\n var k, h;\n window.mixpanel = a;\n a._i = [];\n a.init = function(b, c, f) {\n function e(b, a) {\n var c = a.split(".");\n 2 == c.length && ((b = b[c[0]]), (a = c[1]));\n b[a] = function() {\n b.push([a].concat(Array.prototype.slice.call(arguments, 0)));\n };\n }\n var d = a;\n "undefined" !== typeof f ? (d = a[f] = []) : (f = "mixpanel");\n d.people = d.people || [];\n d.toString = function(b) {\n var a = "mixpanel";\n "mixpanel" !== f && (a += "." + f);\n b || (a += " (stub)");\n return a;\n };\n d.people.toString = function() {\n return d.toString(1) + ".people(stub)";\n };\n k = "disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(\n " "\n );\n for (h = 0; h < k.length; h++) e(d, k[h]);\n a._i.push([b, c, f]);\n };\n a.__SV = 1.2;\n b = e.createElement("script");\n b.type = "text/javascript";\n b.async = !0;\n b.src =\n "undefined" !== typeof MIXPANEL_CUSTOM_LIB_URL\n ? MIXPANEL_CUSTOM_LIB_URL\n : "file:" === e.location.protocol &&\n "//cdn4.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\\/\\//)\n ? "https://cdn4.mxpnl.com/libs/mixpanel-2-latest.min.js"\n : "//cdn4.mxpnl.com/libs/mixpanel-2-latest.min.js";\n c = e.getElementsByTagName("script")[0];\n c.parentNode.insertBefore(b, c);\n }\n})(document, window.mixpanel || []);\nmixpanel.init('${t.accountId}', mixpanelConfig);\n`;e(n)})(),await(async()=>{const{google:e}=(await window.promoConfig).reporting.analytics;function t(){for(var e=arguments.length,t=new Array(e),n=0;n{const t=document.createElement("script");t.async=!0,t.src=e,document.head.appendChild(t)})(`https://www.googletagmanager.com/gtag/js?id=${e.accountId}`),window[`ga-disable-${e.accountId}`]=!0,e.adwordsAccountId&&(window[`ga-disable-${e.adwordsAccountId}`]=!0),e.newAdwordsAccountId&&(window[`ga-disable-${e.newAdwordsAccountId}`]=!0),window.dataLayer=window.dataLayer||[],t("js",new Date),window.gtag=t})(),e("\n!function(f,b,e,v,n,t,s)\n{if(f.fbq)return;n=f.fbq=function(){n.callMethod?\nn.callMethod.apply(n,arguments):n.queue.push(arguments)};\nif(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';\nn.queue=[];t=b.createElement(e);t.async=!0;\nt.src=v;s=b.getElementsByTagName(e)[0];\ns.parentNode.insertBefore(t,s)}(window, document,'script',\n'https://connect.facebook.net/en_US/fbevents.js');\n"),this.isReportingDisabledByGdpr?await this.initReportingDisabledByGdprFromSessionData():this.enableReporting(),this}static getSdkClientIdByEnv(){return-1!==window.location.origin.indexOf("local")?"test":"53luithergkht536klgjerlgd135231042"}async initGlobalParams(){const e={asset:(await window.promoConfig).asset};let t=window.location.search;if(t&&(t=t.substring(1),t.split("&").forEach((t=>{const n=t.split("=");if(!n.length)return;const[i,o]=n;Object.keys(a).includes(i)&&(e[a[i]]=o)})),localStorage.getItem(n.HAD_FIRST_VISIT)&&(localStorage.setItem(n.HAD_FIRST_VISIT,"true"),sessionStorage.setItem(n.IS_FIRST_VISIT,"true")),!(await window.slidelySdk).getLoggedIn()&&!localStorage.getItem(n.FIRST_IMPRESSION_UTM))){const t={firstVisit_source:e.source,firstVisit_campaign:e.campaign,firstVisit_media:e.utm_medium,firstVisit_term:e.utm_term,firstVisit_creative:e.utm_creative,firstVisit_asset:(await window.promoConfig).asset,firstVisit_camp_id:e.camp_id,firstVisit_kw:e.utm_kw,firstVisit_term_id:e.utm_term_id,firstVisit_creative_id:e.utm_creative_id,firstVisit_extension_id:e.utm_extension_id};localStorage.setItem(n.FIRST_IMPRESSION_UTM,JSON.stringify(t))}this.mergeGlobalParams(e)}mergeGlobalParams(e){let t={...e},n=s.getCookieData();if(n){const e=JSON.parse(n);t=Object.assign(e,t)}else if(n=s.getCookieData("ezRI"),n){const e=JSON.parse(n);t=Object.assign(e,t)}t.source?t.source.replace(/ /g,""):t.source=s.getOrganicTrafficSource(),this.defaultParams=Object.assign(this.defaultParams,t);const i={...this.defaultParams};return delete i.clickedOn,this.setCookie("ezExtRI",JSON.stringify(i),28),this.defaultParams}static getOrganicTrafficSource(){if(!document.referrer)return i.DIRECT;const e=new URL(document.referrer).hostname;if(e.includes("promo.com"))return null;const[t]=Object.entries(o).find((t=>{let[,n]=t;return n.find((t=>e.indexOf(t)>=0))}))||[];return t||i.ORGANIC}static getCookieData(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ezExtRI";const t=(window.cookieBackup||document.cookie).split(";");for(let n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if(!window.gtag)return;if(this.isReportingDisabledByGdpr)return void this.queueReport("googleAnalytics",[e,t]);const n=t.category||"default",i={non_interaction:t.nonInteraction,event_category:n,event_label:e};window.gtag("event",e,i),s.isDebugEnabled()&&(console.log("[web: google] reported",e,t),window.analitycDebug.sent.push({service:"google",eventName:e,eventData:i}))}mixpanelReport(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.isReportingDisabledByGdpr)return void this.queueReport("mixpanel",[e,t]);const i=JSON.parse(JSON.stringify(this.defaultParams)),o=Object.assign(i,t);o.isAlreadyRegistered=!!localStorage.getItem(n.ALREADY_REGISTERED),o.isFirstSession=!!sessionStorage.getItem(n.IS_FIRST_VISIT),o.isFirstSession&&o.isAlreadyRegistered&&!s.hasRegisteredInThisSession()&&(o.isFirstSession=!1),window.mixpanel.track(e,o),s.isDebugEnabled()&&(console.log("[web: mixpanel] reported",e,o),window.analitycDebug.sent.push({service:"mixpanel",eventName:e,eventData:o}))}static setPeopleProperties(e){window.mixpanel.people.set(e)}queueReport(e,t){this.ezReportsQueue.push({type:e,args:t}),s.isDebugEnabled()&&(console.log("[web] scheduled",e,t),window.analitycDebug.scheduled.push({type:e,args:t}))}enableReporting(){this.isReportingDisabledByGdpr=!1,window.mixpanel.opt_in_tracking(),(async()=>{const{google:e}=(await window.promoConfig).reporting.analytics;window[`ga-disable-${e.accountId}`]=!1,window.gtag("config",e.accountId),e.adwordsAccountId&&(window[`ga-disable-${e.adwordsAccountId}`]=!1,window.gtag("config",e.adwordsAccountId)),e.newAdwordsAccountId&&(window[`ga-disable-${e.newAdwordsAccountId}`]=!1,window.gtag("config",e.newAdwordsAccountId))})(),(async()=>{const{tagApiPixelId:e}=(await window.promoConfig).reporting.facebook;fbq("init",e),fbq("track","PageView")})(),this.flushReportsQueue()}onAcceptCookiePolicy(){window.localStorage.setItem(n.COOKIE_POLICY,"1"),this.enableReporting()}flushReportsQueue(){this.ezReportsQueue.forEach((e=>{switch(e.type){case"mixpanel":this.mixpanelReport(...e.args);break;case"googleAnalytics":this.googleAnalyticsReport(...e.args)}})),this.ezReportsQueue.length=0}async initReportingDisabledByGdprFromSessionData(){const e=await(await fetch("/promoVideos/config/get-promo-next-page-config")).json();e.response.success&&(this.isReportingDisabledByGdpr&&!e.response.body.reporting.isReportingDisabledByGdpr&&this.enableReporting(),sessionStorage.setItem(n.SESSION_DATA_KEY,JSON.stringify(e)))}static hasRegisteredInThisSession(){return"1"===s.getCookieData("ez_prm_ugr")||!!sessionStorage.getItem(n.REGISTERED_IN_THIS_SESSION)}static isDebugEnabled(){return null!==s.getCookieData("analyticDebug")}}window.promoConfig.then((()=>{const e=new s;window.resolvePromoReporting(e.init())}))})(); //# sourceMappingURL=reporting.js.map