summaryrefslogtreecommitdiff
path: root/jitsi-meet/libs/analytics-ga.min.map
blob: f38b18bc808371142a6289e5e99ef8829d374066 (plain)
1
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./react/features/analytics/handlers/GoogleAnalyticsHandler.js","webpack:///./react/features/base/util/helpers.js","webpack:///./react/features/analytics/handlers/AbstractHandler.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","globalNS","window","JitsiMeetJS","app","analyticsHandlers","push","constructor","options","this","_enabled","_whiteListedEvents","whiteListedEvents","_blackListedEvents","blackListedEvents","_extractName","event","type","action","actionSubject","source","_shouldIgnore","Array","isArray","indexOf","super","_userProperties","googleAnalyticsTrackingId","Error","_initGoogleAnalytics","a","document","q","arguments","Date","createElement","getElementsByTagName","async","src","parentNode","insertBefore","ga","_extractValue","attributes","Math","round","parseFloat","_extractLabel","labelsArray","keys","map","_userPropertiesString","join","setUserProperties","userProps","filter","sendEvent","gaEvent","isNaN","eventValue"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA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AQ,YAafC,cAAc1B,GACV,IAAI9B,EAAQ8B,GAASA,EAAM2B,YAAc3B,EAAM2B,WAAWzD,MAK1D,OAFAA,EAAQ0D,KAAKC,MAAMC,WAAW5D,IAEvBA,EAYX6D,cAAc/B,GACV,MAAM,WAAE2B,EAAa,IAAO3B,EACtBgC,EACArE,OAAOsE,KAAKN,GAAYO,IAAI1D,GAAQ,GAAEA,KAAOmD,EAAWnD,MAI9D,OAFAwD,EAAY1C,KAAKG,KAAK0C,uBAEfH,EAAYI,KAAK,KAS5BC,kBAAkBC,EAAY,IAC1B,IAAK7C,KAAKC,SACN,OAMJ,MAAM6C,EAAS,CAAE,aAAc,kBAE/B9C,KAAK0C,sBACCxE,OAAOsE,KAAKK,GACTC,OAAO/D,IAAgC,IAAzB+D,EAAO/B,QAAQhC,IAC7B0D,IAAI1D,GAAQ,aAAYA,KAAO8D,EAAU9D,MACzC4D,KAAK,KAYlBI,UAAUxC,GACN,GAAIP,KAAKY,cAAcL,GACnB,OAGJ,MAAMyC,EAAU,CACZ,cAAiB,aACjB,YAAehD,KAAKM,aAAaC,GACjC,WAAcP,KAAKsC,cAAc/B,IAE/B9B,EAAQuB,KAAKiC,cAAc1B,GAE5B0C,MAAMxE,KACPuE,EAAQE,WAAazE,GAGzBuD,GAAG,OAAQ,QAASgB","file":"analytics-ga.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/libs/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/* global ga */\n\nimport { getJitsiMeetGlobalNS } from '../../base/util';\n\nimport AbstractHandler from './AbstractHandler';\n\n/**\n * Analytics handler for Google Analytics.\n */\nclass GoogleAnalyticsHandler extends AbstractHandler {\n\n    /**\n     * Creates new instance of the GA analytics handler.\n     *\n     * @param {Object} options -\n     * @param {string} options.googleAnalyticsTrackingId - The GA track id\n     * required by the GA API.\n     */\n    constructor(options) {\n        super(options);\n\n        this._userProperties = {};\n\n        if (!options.googleAnalyticsTrackingId) {\n            throw new Error('Failed to initialize Google Analytics handler, no tracking ID');\n        }\n\n        this._enabled = true;\n        this._initGoogleAnalytics(options);\n    }\n\n    /**\n     * Initializes the ga object.\n     *\n     * @param {Object} options -\n     * @param {string} options.googleAnalyticsTrackingId - The GA track id\n     * required by the GA API.\n     * @returns {void}\n     */\n    _initGoogleAnalytics(options) {\n        /**\n         * TODO: Keep this local, there's no need to add it to window.\n         */\n        /* eslint-disable */\n        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n        /* eslint-enable */\n        ga('create', options.googleAnalyticsTrackingId, 'auto');\n        ga('send', 'pageview');\n    }\n\n    /**\n     * Extracts the integer to use for a Google Analytics event's value field\n     * from a lib-jitsi-meet analytics event.\n     *\n     * @param {Object} event - The lib-jitsi-meet analytics event.\n     * @returns {number} - The integer to use for the 'value' of a Google\n     * analytics event, or NaN if the lib-jitsi-meet event doesn't contain a\n     * suitable value.\n     * @private\n     */\n    _extractValue(event) {\n        let value = event && event.attributes && event.attributes.value;\n\n        // Try to extract an integer from the \"value\" attribute.\n        value = Math.round(parseFloat(value));\n\n        return value;\n    }\n\n    /**\n     * Extracts the string to use for a Google Analytics event's label field\n     * from a lib-jitsi-meet analytics event.\n     *\n     * @param {Object} event - The lib-jitsi-meet analytics event.\n     * @returns {string} - The string to use for the 'label' of a Google\n     * analytics event.\n     * @private\n     */\n    _extractLabel(event) {\n        const { attributes = {} } = event;\n        const labelsArray\n            = Object.keys(attributes).map(key => `${key}=${attributes[key]}`);\n\n        labelsArray.push(this._userPropertiesString);\n\n        return labelsArray.join('&');\n    }\n\n    /**\n     * Sets the permanent properties for the current session.\n     *\n     * @param {Object} userProps - The permanent portperties.\n     * @returns {void}\n     */\n    setUserProperties(userProps = {}) {\n        if (!this._enabled) {\n            return;\n        }\n\n        // The label field is limited to 500B. We will concatenate all\n        // attributes of the event, except the user agent because it may be\n        // lengthy and is probably included from elsewhere.\n        const filter = [ 'user_agent', 'callstats_name' ];\n\n        this._userPropertiesString\n            = Object.keys(userProps)\n                .filter(key => filter.indexOf(key) === -1)\n                .map(key => `permanent_${key}=${userProps[key]}`)\n                .join('&');\n    }\n\n    /**\n     * This is the entry point of the API. The function sends an event to\n     * google analytics. The format of the event is described in\n     * analyticsAdapter in lib-jitsi-meet.\n     *\n     * @param {Object} event - The event in the format specified by\n     * lib-jitsi-meet.\n     * @returns {void}\n     */\n    sendEvent(event) {\n        if (this._shouldIgnore(event)) {\n            return;\n        }\n\n        const gaEvent = {\n            'eventCategory': 'jitsi-meet',\n            'eventAction': this._extractName(event),\n            'eventLabel': this._extractLabel(event)\n        };\n        const value = this._extractValue(event);\n\n        if (!isNaN(value)) {\n            gaEvent.eventValue = value;\n        }\n\n        ga('send', 'event', gaEvent);\n    }\n\n}\n\nconst globalNS = getJitsiMeetGlobalNS();\n\nglobalNS.analyticsHandlers = globalNS.analyticsHandlers || [];\nglobalNS.analyticsHandlers.push(GoogleAnalyticsHandler);\n","// @flow\n\n/**\n * A helper function that behaves similar to Object.assign, but only reassigns a\n * property in target if it's defined in source.\n *\n * @param {Object} target - The target object to assign the values into.\n * @param {Object} source - The source object.\n * @returns {Object}\n */\nexport function assignIfDefined(target: Object, source: Object) {\n    const to = Object(target);\n\n    for (const nextKey in source) {\n        if (source.hasOwnProperty(nextKey)) {\n            const value = source[nextKey];\n\n            if (typeof value !== 'undefined') {\n                to[nextKey] = value;\n            }\n        }\n    }\n\n    return to;\n}\n\n/**\n * Tries to copy a given text to the clipboard.\n * Returns true if the action succeeds.\n *\n * @param {string} textToCopy - Text to be copied.\n * @returns {boolean}\n */\nexport function copyText(textToCopy: string) {\n    const fakeTextArea = document.createElement('textarea');\n    let result;\n\n    // $FlowFixMe\n    document.body.appendChild(fakeTextArea);\n    fakeTextArea.value = textToCopy;\n    fakeTextArea.select();\n\n    try {\n        result = document.execCommand('copy');\n    } catch (err) {\n        result = false;\n    }\n\n    // $FlowFixMe\n    document.body.removeChild(fakeTextArea);\n\n    return result;\n}\n\n/**\n * Creates a deferred object.\n *\n * @returns {{promise, resolve, reject}}\n */\nexport function createDeferred(): Object {\n    const deferred = {};\n\n    deferred.promise = new Promise((resolve, reject) => {\n        deferred.resolve = resolve;\n        deferred.reject = reject;\n    });\n\n    return deferred;\n}\n\nconst MATCH_OPERATOR_REGEXP = /[|\\\\{}()[\\]^$+*?.-]/g;\n\n/**\n * Escape RegExp special characters.\n *\n * Based on https://github.com/sindresorhus/escape-string-regexp.\n *\n * @param {string} s - The regexp string to escape.\n * @returns {string}\n */\nexport function escapeRegexp(s: string) {\n    if (typeof s !== 'string') {\n        throw new TypeError('Expected a string');\n    }\n\n    return s.replace(MATCH_OPERATOR_REGEXP, '\\\\$&');\n}\n\n/**\n * Returns the base URL of the app.\n *\n * @param {Object} w - Window object to use instead of the built in one.\n * @returns {string}\n */\nexport function getBaseUrl(w: Object = window) {\n    const doc = w.document;\n    const base = doc.querySelector('base');\n\n    if (base && base.href) {\n        return base.href;\n    }\n\n    const { protocol, host } = w.location;\n\n    return `${protocol}//${host}`;\n}\n\n/**\n * Returns the namespace for all global variables, functions, etc that we need.\n *\n * @returns {Object} The namespace.\n *\n * NOTE: After React-ifying everything this should be the only global.\n */\nexport function getJitsiMeetGlobalNS() {\n    if (!window.JitsiMeetJS) {\n        window.JitsiMeetJS = {};\n    }\n\n    if (!window.JitsiMeetJS.app) {\n        window.JitsiMeetJS.app = {};\n    }\n\n    return window.JitsiMeetJS.app;\n}\n\n/**\n * Prints the error and reports it to the global error handler.\n *\n * @param {Error} e - The error object.\n * @param {string} msg - A custom message to print in addition to the error.\n * @returns {void}\n */\nexport function reportError(e: Object, msg: string = '') {\n    console.error(msg, e);\n    window.onerror && window.onerror(msg, null, null, null, e);\n}\n","/**\n * Abstract implementation of analytics handler\n */\nexport default class AbstractHandler {\n    /**\n     * Creates new instance.\n     *\n     * @param {Object} options - Optional parameters.\n     */\n    constructor(options = {}) {\n        this._enabled = false;\n        this._whiteListedEvents = options.whiteListedEvents;\n\n        // FIXME:\n        // Keeping the list with the very noisy events so that we don't flood with events whoever hasn't configured\n        // white/black lists yet. We need to solve this issue properly by either making these events not so noisy or\n        // by removing them completely from the code.\n        this._blackListedEvents = [\n            ...(options.blackListedEvents || []), // eslint-disable-line no-extra-parens\n            'e2e_rtt', 'rtp.stats', 'rtt.by.region', 'available.device', 'stream.switch.delay', 'ice.state.changed',\n            'ice.duration', 'peer.conn.status.duration'\n        ];\n    }\n\n    /**\n     * Extracts a name for the event from the event properties.\n     *\n     * @param {Object} event - The analytics event.\n     * @returns {string} - The extracted name.\n     */\n    _extractName(event) {\n        // Page events have a single 'name' field.\n        if (event.type === 'page') {\n            return event.name;\n        }\n\n        const {\n            action,\n            actionSubject,\n            source\n        } = event;\n\n        // All events have action, actionSubject, and source fields. All\n        // three fields are required, and often jitsi-meet and\n        // lib-jitsi-meet use the same value when separate values are not\n        // necessary (i.e. event.action == event.actionSubject).\n        // Here we concatenate these three fields, but avoid adding the same\n        // value twice, because it would only make the event's name harder\n        // to read.\n        let name = action;\n\n        if (actionSubject && actionSubject !== action) {\n            name = `${actionSubject}.${action}`;\n        }\n        if (source && source !== action) {\n            name = `${source}.${name}`;\n        }\n\n        return name;\n    }\n\n    /**\n     * Checks if an event should be ignored or not.\n     *\n     * @param {Object} event - The event.\n     * @returns {boolean}\n     */\n    _shouldIgnore(event) {\n        if (!event || !this._enabled) {\n            return true;\n        }\n\n        const name = this._extractName(event);\n\n        if (Array.isArray(this._whiteListedEvents)) {\n            return this._whiteListedEvents.indexOf(name) === -1;\n        }\n\n        if (Array.isArray(this._blackListedEvents)) {\n            return this._blackListedEvents.indexOf(name) !== -1;\n        }\n\n        return false;\n    }\n}\n"],"sourceRoot":""}