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,QAAQnE,MAAM,KAC3CuE,EAAE,EAAEA,EAAIF,EAAGrB,OAAOuB,IAAK,CAE3B,IADA,IAAIC,EAAIH,EAAGE,GACY,MAAhBC,EAAEC,OAAO,IAAYD,EAAIA,EAAE1B,UAAU,EAAG0B,EAAExB,QACjD,GAA0B,IAAtBwB,EAAEjB,QAAQa,GAAe,OAAOI,EAAE1B,UAAUsB,EAAOpB,OAAQwB,EAAExB,QAGrE,OAAO,O,0BAGX,SAAoBhB,GAChBmB,SAASgB,OAASnC,EAAM,sD,qBAG5B,SAAed,GAEX,MADS,4JACCwD,KAAKxD,K,0BAGnB,SAAoBe,GAChB,OAAOnE,KAAK6G,QAAQ1C,QAAS2C,EAAY3C,M,yFAjU5B1E,G,EAAAA,EAAAA,WACC,CAAC,aAAc,aAAc,eAAgB,cAAe,WAAY,W,EADzEA,EAAAA,SAED,CAAC,SAAU,QAAS,QAAS,WAmUjDY,OAAOZ,UAAYA,G","sources":["webpack://OptimizeDashboard/webpack/bootstrap","webpack://OptimizeDashboard/webpack/runtime/define property getters","webpack://OptimizeDashboard/webpack/runtime/hasOwnProperty shorthand","webpack://OptimizeDashboard/./resources/assets/js/OP3Pixels.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","export default class OP3Pixels {\n    static utmTerms = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_content' ,'utm_term', 'fbclid'];\n    static utmIds = ['fbadid', 'gadid', 'padid', 'bingid'];\n\n    static fireFacebookEvent(eventId, eventName, eventData) {\n        let defaultEventTypes = [\n                'PageView',\n                'ViewContent',\n                'Search',\n                'AddToCart',\n                'AddToWishlist',\n                'InitiateCheckout',\n                'AddPaymentInfo',\n                'Purchase',\n                'Lead',\n                'Subscribe',\n            ],\n            trackType = 'track';\n\n        if (! defaultEventTypes.includes(eventName)) {\n            if (eventName === 'Scroll') {\n                trackType = 'trackCustom';\n            }\n        }\n\n        // checking if our events are present, otherwise\n        // do not fire events\n        if (! defaultEventTypes.includes(eventName) && eventName !== \"Scroll\") {\n            return;\n        }\n\n        // setup everything\n        this.setAllQueryVars();\n\n        // collect the data and merge with event data\n        let standardData = this.getInitialEventData();\n        eventData = {...standardData, ...eventData };\n\n        // for Lead event we are saving data in cookie for later use (matching)\n        if (eventName === 'Lead') {\n            var expires = parseInt(window.OPDashboardPixels.facebookFirstVisitCookieDuration);\n            this.setCookie('op3_matching', JSON.stringify(eventData), expires);\n        }\n\n        // track through pixel\n        fbq(trackType, eventName, eventData, {\"eventID\": eventId});\n\n        // track through CAPI (using AJAX) if enabled\n        if (window.OPDashboardPixels.enableCapi === \"1\" && window.OPDashboardPixels.capiAccessToken) {\n            var json = {\n                pixel: 'facebook',\n                pixelID: window.OPDashboardPixels.fbPixelId,\n                eventName: eventName,\n                eventData: eventData,\n                url: window.location.href,\n                eventID: eventId,\n            };\n\n            setTimeout(function(){\n                jQuery.post( {\n                    url: window.OPDashboardPixels.capiRestUrl,\n                    data: json,\n                    headers: {\n                        'Cache-Control': 'no-cache'\n                    },\n                    success: function(){},\n                });\n            },500)\n        }\n    }\n\n    static getInitialEventData() {\n        let initialData =  window.OPDashboardPixels.standardParams;\n        let dateTime = this.getDateTime();\n\n        initialData.landing_page = window.location.href.split('?')[0];\n        initialData.traffic_source = this.getTrafficSource();\n        initialData.event_time = dateTime[0];\n        initialData.event_day = dateTime[1];\n        initialData.event_month = dateTime[2];\n        initialData.event_day_in_month = dateTime[3];\n\n        let utmTerms = this.getUTMs(window.OPDashboardPixels.facebookAttribution === \"last_visit\");\n\n        this.utmTerms.forEach(function (term, index) {\n            if (term in utmTerms) {\n                initialData[term] = utmTerms[term];\n            }\n        });\n\n        return initialData;\n    }\n\n    static getMatchingDataFromCookie() {\n        let cookieValue = this.getCookie('op3_matching');\n        let result = {};\n\n        if (cookieValue) {\n            let temp = JSON.parse(cookieValue);\n            if (temp.email)\n                result.email = temp.email;\n            if (temp.first_name)\n                result.first_name = temp.first_name;\n            if (temp.last_name)\n                result.last_name = temp.last_name;\n        }\n\n        return result;\n    }\n\n    static getDateTime() {\n        let dateTime = [];\n        let date = new Date(),\n            days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],\n            months = ['January', 'February', 'March', 'April', 'May', 'June',\n                'July', 'August', 'September', 'October', 'November', 'December'\n            ],\n            hours = ['00-01', '01-02', '02-03', '03-04', '04-05', '05-06', '06-07', '07-08',\n                '08-09', '09-10', '10-11', '11-12', '12-13', '13-14', '14-15', '15-16', '16-17',\n                '17-18', '18-19', '19-20', '20-21', '21-22', '22-23', '23-24'\n            ];\n\n        dateTime.push(hours[date.getHours()]);\n        dateTime.push(days[date.getDay()]);\n        dateTime.push(months[date.getMonth()]);\n        dateTime.push(date.getDate());\n\n        return dateTime;\n    }\n\n    /**\n     * Return UTM terms from cookies.\n     */\n    static getUTMs(useLast = false) {\n        try {\n            let cookiePrefix = 'op_'\n            let _this = this;\n            if (useLast) {\n                cookiePrefix = 'last_op_'\n            }\n            let terms = [];\n            this.utmTerms.forEach(function (name, index) {\n                // check in Cookie\n                if (_this.getCookie(cookiePrefix + name)) {\n                    let value = _this.getCookie(cookiePrefix + name);\n                    terms[name] = _this.filterEmails(value);\n                }\n            });\n\n            return terms;\n\n        } catch (e) {\n            console.error(e);\n            return [];\n        }\n    }\n\n    static setAllQueryVars() {\n        let expires = parseInt(window.OPDashboardPixels.facebookFirstVisitCookieDuration);\n        let queryVars = this.getQueryVars();\n        let landing = window.location.href.split('?')[0];\n        let _this = this;\n\n        try {\n            // save data for first visit\n            if (this.getCookie('op_first_visit') === null) {\n                this.setCookie('op_first_visit', true, expires);\n                this.setCookie('op_traffic_source', this.getTrafficSource(), expires);\n                this.setCookie('op_landing_page', landing, expires);\n                _this.utmTerms.forEach(function (name, index) {\n                    if (queryVars.hasOwnProperty(name)) {\n                        _this.setCookie('op_' + name, queryVars[name], expires);\n                    } else {\n                        _this.deleteCookie('op_' + name)\n                    }\n                });\n                _this.utmIds.forEach(function(name, index) {\n                    if (queryVars.hasOwnProperty(name)) {\n                        _this.setCookie('op_' + name, queryVars[name], expires);\n                    } else {\n                        _this.deleteCookie('op_' + name)\n                    }\n                })\n            }\n\n            // save data for last visit if it is a new session\n            if (this.checkSession()) {\n                this.setCookie('last_op_traffic_source', this.getTrafficSource(), expires);\n                this.utmTerms.forEach(function (name, index) {\n                    if (queryVars.hasOwnProperty(name)) {\n                        _this.setCookie('last_op_' + name, queryVars[name], expires);\n                    } else {\n                        _this.deleteCookie('last_op_' + name);\n                    }\n                });\n                this.utmIds.forEach(function(name, index) {\n                    if (queryVars.hasOwnProperty(name)) {\n                        _this.setCookie('last_op_' + name, queryVars[name], expires);\n                    } else {\n                        _this.deleteCookie('last_op_' + name);\n                    }\n                })\n\n                this.setCookie('last_op_landing_page', landing, expires);\n            }\n        } catch (e) {\n            console.error(e);\n        }\n    }\n\n    static getQueryVars() {\n        try {\n            var result = {},\n                tmp = [];\n\n            window.location.search\n                .substring(1)\n                .split(\"&\")\n                .forEach(function (item) {\n                    tmp = item.split('=');\n\n                    if (tmp.length > 1) {\n                        result[tmp[0]] = tmp[1];\n                    }\n\n                });\n\n            return result;\n\n        } catch (e) {\n            console.error(e);\n            return {};\n        }\n    }\n\n    static getTrafficSource() {\n        try {\n\n            let referrer = document.referrer.toString(),\n                source;\n\n            let direct = referrer.length === 0;\n            let internal = direct ? false : referrer.indexOf(OP3.Meta.siteUrl) === 0;\n            let external = ! direct && ! internal;\n\n            if (external === false) {\n                source = 'direct';\n            } else {\n                source = referrer;\n            }\n\n            if (source !== 'direct') {\n                return this.getDomain(source);\n            } else {\n                return source;\n            }\n\n        } catch (e) {\n            console.error(e);\n            return 'direct';\n        }\n    }\n\n    static getDomain(url) {\n        url = url.replace(/(https?:\\/\\/)?(www.)?/i, '');\n\n        if (url.indexOf('/') !== -1) {\n            return url.split('/')[0];\n        }\n\n        return url;\n    }\n\n    static checkSession() {\n        let duration = window.OPDashboardPixels.facebookLastVisitCookieDuration / 1440;\n\n        if (this.getCookie('op_start_session') === null ||\n            this.getCookie('op_session_limit') === null) {\n            this.setCookie('op_session_limit', true, duration);\n            this.setCookie('op_start_session', true);\n\n            return true;\n        }\n\n        return false;\n\n    }\n\n    static setCookie(name, value, days) {\n        var expires = \"\";\n        if (days) {\n            var date = new Date();\n            date.setTime(date.getTime() + (days*24*60*60*1000));\n            expires = \"; expires=\" + date.toUTCString();\n        }\n\n        document.cookie = name + \"=\" + (value || \"\")  + expires + \"; path=/\";\n    }\n\n    static getCookie(name) {\n        var nameEQ = name + \"=\";\n        var ca = decodeURIComponent(document.cookie).split(';');\n        for(var i=0;i < ca.length;i++) {\n            var c = ca[i];\n            while (c.charAt(0) === ' ') c = c.substring(1, c.length);\n            if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n        }\n\n        return null;\n    }\n\n    static deleteCookie(name) {\n        document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';\n    }\n\n    static isEmail(email) {\n        var re = /^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/;\n        return re.test(email);\n    }\n\n    static filterEmails(value) {\n        return this.isEmail(value) ? undefined : value;\n    }\n}\n\nwindow.OP3Pixels = OP3Pixels;"],"names":["__webpack_require__","d","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","OP3Pixels","eventId","eventName","eventData","defaultEventTypes","trackType","includes","this","setAllQueryVars","getInitialEventData","expires","parseInt","window","OPDashboardPixels","facebookFirstVisitCookieDuration","setCookie","JSON","stringify","fbq","enableCapi","capiAccessToken","json","pixel","pixelID","fbPixelId","url","location","href","eventID","setTimeout","jQuery","post","capiRestUrl","data","headers","success","initialData","standardParams","dateTime","getDateTime","landing_page","split","traffic_source","getTrafficSource","event_time","event_day","event_month","event_day_in_month","utmTerms","getUTMs","facebookAttribution","forEach","term","index","cookieValue","getCookie","result","temp","parse","email","first_name","last_name","date","Date","push","getHours","getDay","getMonth","getDate","useLast","cookiePrefix","_this","terms","name","value","filterEmails","e","console","error","queryVars","getQueryVars","landing","deleteCookie","utmIds","checkSession","tmp","search","substring","item","length","source","referrer","document","toString","direct","internal","indexOf","OP3","Meta","siteUrl","getDomain","replace","duration","facebookLastVisitCookieDuration","days","setTime","getTime","toUTCString","cookie","nameEQ","ca","decodeURIComponent","i","c","charAt","test","isEmail","undefined"],"sourceRoot":""}