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BP,EAAxBO,WAAYC,EAAYR,EAAZQ,QACxCC,EAAOC,GAAAA,CAAIF,EAAS,WAAY,eAChCG,EAASD,GAAAA,CAAIF,EAAS,YAAaJ,GACnCQ,EAAkBpE,SAASc,cAC/B,0CACAC,QACIsD,EAAUrE,SAASc,cAAc,kCACpCC,QAEH,IACEuD,MAAM,oCACgCD,EADjC,wBACgED,EACnE,CACEG,OAAQ,OACRC,KAAMC,KAAKC,UAAU,CACnBC,KAAM,CACJ,CACEC,SAAUd,EACVe,WAAYV,EACZW,WAAY,IAAIC,KAAKlB,EAAKmB,WAAWC,cACrCC,cAAe,UACfC,iBAAkBtD,OAAO4B,SAASC,KAClC0B,UAAW,CACTC,GAAI,CAAC,MACLC,kBAAmBzD,OAAO0D,UAAUC,UACpCC,kBAAmB,MAErBC,YAAa3B,QAMvB,MAAO4B,GACPC,QAAQD,MAAMA,GAGhB,OAAO9D,OAAOY,IAAIwB,EAAME,EAAQJ,KAElC8B,SAAU,YAAkB,IAAfrC,EAAc,EAAdA,QACX,GAAK3B,OAAOY,IAAZ,CAEA,IAAQqD,EAAgCtC,EAAhCsC,OAAQhC,EAAwBN,EAAxBM,YAAaiC,EAAWvC,EAAXuC,OAC7B,OAAOlE,OAAOY,IAAI,cAAe,WAAY,CAC3CqB,YAAAA,EACAgC,OAAAA,EACAC,OAAAA,MAGJhD,OAAQ,mBAAQlB,OAAOY,S","sources":["webpack://clear-works/./app/javascript/v2/analytics/ sync ^\\.\\/.*$","webpack://clear-works/./app/javascript/packs/analytics.js","webpack://clear-works/./app/javascript/v2/analytics/index.js","webpack://clear-works/./app/javascript/v2/analytics/plugins/facebookPixel.js"],"sourcesContent":["var map = {\n\t\"./\": 88670,\n\t\"./index\": 88670,\n\t\"./index.js\": 88670,\n\t\"./plugins/facebookPixel\": 98693,\n\t\"./plugins/facebookPixel.js\": 98693\n};\n\n\nfunction webpackContext(req) {\n\tvar id = webpackContextResolve(req);\n\treturn __webpack_require__(id);\n}\nfunction webpackContextResolve(req) {\n\tif(!__webpack_require__.o(map, req)) {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\treturn map[req];\n}\nwebpackContext.keys = function webpackContextKeys() {\n\treturn Object.keys(map);\n};\nwebpackContext.resolve = webpackContextResolve;\nmodule.exports = webpackContext;\nwebpackContext.id = 1120;","var analytics = require.context('v2/analytics', true)\nanalytics.keys().forEach(analytics)\n","import Analytics from 'analytics'\nimport googleAnalytics from '@analytics/google-analytics'\nimport googleTagManager from '@analytics/google-tag-manager'\nimport facebookPixel from './plugins/facebookPixel'\n\ndocument.addEventListener('DOMContentLoaded', async () => {\n const googleAnalyticsId = document.querySelector(\n 'meta[name=\"google-analytics-id\"]'\n )?.content\n const facebookPixelId = document.querySelector(\n 'meta[name=\"facebook-pixel-id\"]'\n )?.content\n const tagManagerId = document.querySelector('meta[name=\"tag-manager-key\"]')\n ?.content\n\n let plugins = []\n\n if (googleAnalyticsId) {\n plugins.push(\n googleAnalytics({\n measurementIds: [googleAnalyticsId],\n })\n )\n }\n\n if (tagManagerId) {\n plugins.push(googleTagManager({ containerId: googleTagManager }))\n }\n\n if (facebookPixelId) {\n plugins.push(facebookPixel({ trackingId: facebookPixelId }))\n }\n\n const analytics = Analytics({\n app: 'Clearworks',\n plugins,\n })\n\n analytics.page()\n window.analytics = analytics\n\n function getGaClientId() {\n const cookies = document.cookie.split(';').reduce((acc, cookie) => {\n const [key, value] = cookie.split('=').map(c => c.trim())\n acc[key] = value\n return acc\n }, {})\n\n return cookies['_ga'] ? cookies['_ga'].substring(6) : ''\n }\n\n const clientIdInput = document.getElementById('hidden-google-client-id')\n if (clientIdInput) {\n clientIdInput.value = getGaClientId()\n }\n})\n","import get from 'lodash/get'\n\nconst facebookPixel = userConfig => {\n // return object for analytics to use\n return {\n /* All plugins require a name */\n name: 'facebook-pixel',\n /* Everything else below this is optional depending on your plugin requirements */\n config: {\n trackingId: userConfig.trackingId,\n },\n initialize: ({ config }) => {\n if (!config.trackingId)\n throw new Error('No Facebook Pixel trackingId defined')\n\n !(function(f, b, e, v, n, t, s) {\n if (f.fbq) return\n n = f.fbq = function() {\n n.callMethod\n ? n.callMethod.apply(n, arguments)\n : n.queue.push(arguments)\n }\n if (!f._fbq) f._fbq = n\n n.push = n\n n.loaded = !0\n n.version = '2.0'\n n.queue = []\n t = b.createElement(e)\n t.async = !0\n t.src = v\n s = b.getElementsByTagName(e)[0]\n s.parentNode.insertBefore(t, s)\n })(\n window,\n document,\n 'script',\n 'https://connect.facebook.net/en_US/fbevents.js'\n )\n\n window.fbq('init', config.trackingId)\n\n return window.fbq\n },\n page: () => {\n if (!window.fbq) return\n return window.fbq('track', 'PageView')\n },\n track: ({ payload }) => {\n if (!window.fbq) return\n\n if (\n window.location.href.indexOf('-staging.xyz') >= 0 ||\n window.location.href.indexOf('.lvh.me:') >= 0\n )\n return\n\n const { event, meta, anonymousId, properties, options } = payload\n const mode = get(options, 'fbq.mode', 'trackCustom')\n const _event = get(options, 'fbq.event', event)\n const tokenConversion = document.querySelector(\n 'meta[name=\"facebook-conversion-token\"]'\n ).content\n const pixelId = document.querySelector('meta[name=\"facebook-pixel-id\"]')\n .content\n\n try {\n fetch(\n `https://graph.facebook.com/v13.0/${pixelId}/events?access_token=${tokenConversion}`,\n {\n method: 'POST',\n body: JSON.stringify({\n data: [\n {\n event_id: anonymousId,\n event_name: _event,\n event_time: new Date(meta.timestamp).toISOString(),\n action_source: 'website',\n event_source_url: window.location.href,\n user_data: {\n ph: [null],\n client_user_agent: window.navigator.userAgent,\n client_ip_address: null,\n },\n custom_data: properties,\n },\n ],\n }),\n }\n )\n } catch (error) {\n console.error(error)\n }\n\n return window.fbq(mode, _event, properties)\n },\n identify: ({ payload }) => {\n if (!window.fbq) return\n\n const { userId, anonymousId, traits } = payload\n return window.fbq('trackCustom', 'identify', {\n anonymousId,\n userId,\n traits,\n })\n },\n loaded: () => !!window.fbq,\n }\n}\n\nexport default facebookPixel\n"],"names":["map","webpackContext","req","id","webpackContextResolve","__webpack_require__","o","e","Error","code","keys","Object","resolve","module","exports","analytics","require","forEach","document","addEventListener","getGaClientId","cookies","cookie","split","reduce","acc","c","trim","key","value","substring","googleAnalyticsId","querySelector","content","facebookPixelId","tagManagerId","plugins","push","googleAnalytics","measurementIds","googleTagManager","containerId","facebookPixel","trackingId","Analytics","app","page","window","clientIdInput","getElementById","userConfig","name","config","initialize","f","b","n","t","s","fbq","callMethod","apply","arguments","queue","_fbq","loaded","version","createElement","async","src","getElementsByTagName","parentNode","insertBefore","track","payload","location","href","indexOf","event","meta","anonymousId","properties","options","mode","get","_event","tokenConversion","pixelId","fetch","method","body","JSON","stringify","data","event_id","event_name","event_time","Date","timestamp","toISOString","action_source","event_source_url","user_data","ph","client_user_agent","navigator","userAgent","client_ip_address","custom_data","error","console","identify","userId","traits"],"sourceRoot":""}