"use strict"; /** * This houses the utility for getting information regarding various Analytics details. Including but not strictly * limited to: Adobe DTM, Adobe Target, and Google Analytics. It also provides information about AdBlockers as they * can potentially inhibit the functionality of the aforementioned Analytics libraries. * * @type {{getAnalyticsDetails}} */ var ANALYTICS = function (window) { /** * This Function serves to check various integration points for our multiple Analytics * implementations. In every case listed, if the network call to the said servers fails, * or is blocked - the reference will be undefined. In the case of Adblock, all similar plugins * do not render banners with references to Ads in the classname as the most basic of features offered. * Checking 'sefrDFWFe' element is created or not from ad-blocker.js for determining if AdBlock (or anything similar) * is active. Recommended: Wrap the call to this function in a setTimeout so that the respective libraries have time * to load. The timeout amount should be an informed decision but currently google takes the longest and 2.5 * seconds covers most cases. * * @returns {string} * @private */ function _getAnalyticsDetails() { var _isAdBlockActive = !!!document.getElementById('sefrDFWFe'), _isGoogleAnalyticsActive = typeof window.gaGlobal !== 'undefined', _isAdobeSuiteActive = typeof window.adobe !== 'undefined', _isDtmActive = typeof window._satellite !== 'undefined'; return "{adBlockActive=" + _isAdBlockActive + ", adobeSuiteActive=" + _isAdobeSuiteActive + ", dtmActive=" + _isDtmActive + ", googleAnalyticsActive=" + _isGoogleAnalyticsActive + "}"; } ; return { getAnalyticsDetails: _getAnalyticsDetails }; }(ANALYTICS || window); function getAnalyticsToInitialize() { // Check support for promise mechanism so that original code will be used for unsupported browsers and promise will be used for all other browsers var promiseSupport = !!window.Promise; if (!promiseSupport) { // Log Analytics Initialization details, wrapped in a set time out to give network calls time to resolve. var waitForAnalyticsToInitialize = setTimeout(function () { window.pageData.analyticsDetails = window.ANALYTICS.getAnalyticsDetails(); window.log({ content: { category: 'analytics_info', message: window.pageData.analyticsDetails } }); clearTimeout(waitForAnalyticsToInitialize); }, 2500); } else { var myPromise = new Promise(function // The executor function is called with the ability to resolve or reject the promise (resolve, reject) { // Wrapped in a setTimeout to give network calls time to resolve setTimeout(function () { // fullfill the promise resolve(window.pageData.analyticsDetails = window.ANALYTICS.getAnalyticsDetails()); clearTimeout(waitForAnalyticsToInitialize); }, 2500); }); } }