From a341526946a64460918fc25dd99d7510f723ce68 Mon Sep 17 00:00:00 2001 From: dnson Date: Tue, 4 Oct 2022 19:11:31 +0700 Subject: [PATCH] fallback metrics (#237) --- dist/td.js | 1134 ------------------------------------------ dist/td.min.js | 18 - lib/plugins/track.js | 8 + 3 files changed, 8 insertions(+), 1152 deletions(-) delete mode 100644 dist/td.js delete mode 100644 dist/td.min.js diff --git a/dist/td.js b/dist/td.js deleted file mode 100644 index 54769e13..00000000 --- a/dist/td.js +++ /dev/null @@ -1,1134 +0,0 @@ -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "./lib/index.js"); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ "./lib/config.js": -/*!***********************!*\ - !*** ./lib/config.js ***! - \***********************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("module.exports = {\n GLOBAL: 'Treasure',\n VERSION: '3.1.1',\n HOST: 'in.treasuredata.com',\n DATABASE: '',\n PATHNAME: '/js/v3/event/'\n};\n\n//# sourceURL=webpack:///./lib/config.js?"); - -/***/ }), - -/***/ "./lib/configurator.js": -/*!*****************************!*\ - !*** ./lib/configurator.js ***! - \*****************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("/*\n * Treasure Configurator\n */\n// Modules\nvar _ = __webpack_require__(/*! ./utils/lodash */ \"./lib/utils/lodash.js\");\n\nvar invariant = __webpack_require__(/*! ./utils/misc */ \"./lib/utils/misc.js\").invariant;\n\nvar config = __webpack_require__(/*! ./config */ \"./lib/config.js\");\n\nvar cookie = __webpack_require__(/*! ./vendor/js-cookies */ \"./lib/vendor/js-cookies.js\"); // Helpers\n\n\nfunction validateOptions(options) {\n // options must be an object\n invariant(_.isObject(options), 'Check out our JavaScript SDK Usage Guide: ' + 'https://github.com/treasure-data/td-js-sdk#api');\n invariant(_.isString(options.writeKey), 'Must provide a writeKey');\n invariant(_.isString(options.database), 'Must provide a database');\n invariant(/^[a-z0-9_]{3,255}$/.test(options.database), 'Database must be between 3 and 255 characters and must ' + 'consist only of lower case letters, numbers, and _');\n}\n\nvar defaultSSCCookieDomain = function defaultSSCCookieDomain() {\n var domainChunks = document.location.hostname.split('.');\n\n for (var i = domainChunks.length - 2; i >= 1; i--) {\n var domain = domainChunks.slice(i).join('.');\n var name = '_td_domain_' + domain; // append domain name to avoid race condition\n\n cookie.setItem(name, domain, 3600, '/', domain);\n\n if (cookie.getItem(name) === domain) {\n return domain;\n }\n }\n\n return document.location.hostname;\n}; // Default config for library values\n\n\nexports.DEFAULT_CONFIG = {\n database: config.DATABASE,\n development: false,\n useNewJavaScriptEndpoint: false,\n globalIdCookie: '_td_global',\n host: config.HOST,\n logging: true,\n pathname: config.PATHNAME,\n requestType: 'fetch',\n jsonpTimeout: 10000,\n startInSignedMode: false,\n useServerSideCookie: false,\n sscDomain: defaultSSCCookieDomain,\n sscServer: function sscServer(cookieDomain) {\n return ['ssc', cookieDomain].join('.');\n },\n storeConsentByLocalStorage: false\n};\n/*\n * Initial configurator\n * Checks validity\n * Creates and sets up client object\n *\n * Modify DEFAULT_CONFIG to change any defaults\n * Protocol defaults to auto-detection but can be set manually\n * host defaults to in.treasuredata.com\n * pathname defaults to /js/v3/event/\n * requestType is always fetch\n *\n * */\n\nexports.configure = function configure(options) {\n this.client = _.assign({\n globals: {}\n }, exports.DEFAULT_CONFIG, options, {\n requestType: 'fetch'\n });\n validateOptions(this.client);\n\n if (this.client.useNewJavaScriptEndpoint) {\n this.client.pathname = '/';\n }\n\n if (!this.client.endpoint) {\n this.client.endpoint = 'https://' + this.client.host + this.client.pathname;\n }\n\n return this;\n};\n/**\n * Useful when you want to set multiple values.\n * Table value setter\n * When you set mutliple attributes, the object is iterated and values are set on the table\n * Attributes are not recursively set on the table\n *\n * @param {string} table - table name\n * @param {object} properties - Object with keys and values that you wish applies on the table each time a record is sent\n *\n * @example\n * var td = new Treasure({...})\n * td.set('table', {foo: 'foo', bar: 'bar'});\n * td.addRecord('table', {baz: 'baz'});\n * // Sends:\n * // {\n * // \"foo\": \"foo\",\n * // \"bar\": \"bar\",\n * // \"baz\": \"baz\"\n * // }\n */\n\n\nexports.set = function set(table, property, value) {\n if (_.isObject(table)) {\n property = table;\n table = '$global';\n }\n\n this.client.globals[table] = this.client.globals[table] || {};\n\n if (_.isObject(property)) {\n _.assign(this.client.globals[table], property);\n } else {\n this.client.globals[table][property] = value;\n }\n\n return this;\n};\n/**\n * Takes a table name and returns an object with its default values.\n * If the table does not exist, its object gets created\n *\n * NOTE: This is only available once the library has loaded. Wrap any getter with a Treasure#ready callback to ensure the library is loaded.\n *\n * @param {string} table - table name\n * @param {string} [key] - Optional key to get from the table\n *\n * @example Getting all rows in a table\n * var td = new Treasure({..});\n * td.set('table', 'foo', 'bar');\n * td.get('table');\n * // {foo: 'bar'}\n *\n * @example Getting a single attribute\n * var td = new Treasure({..});\n * td.get('table', 'foo')\n * // > 'bar'\n */\n\n\nexports.get = function get(table, key) {\n // If no table, show $global\n table = table || '$global';\n this.client.globals[table] = this.client.globals[table] || {};\n return key ? this.client.globals[table][key] : this.client.globals[table];\n};\n\nexports.isGlobalIdEnabled = function () {\n return this.get(null, 'td_global_id') === 'td_global_id';\n};\n\n//# sourceURL=webpack:///./lib/configurator.js?"); - -/***/ }), - -/***/ "./lib/index.js": -/*!**********************!*\ - !*** ./lib/index.js ***! - \**********************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("/*\n * Treasure Index\n */\nvar Treasure = __webpack_require__(/*! ./treasure.js */ \"./lib/treasure.js\");\n\nvar window = __webpack_require__(/*! global/window */ \"./node_modules/global/window.js\");\n\nvar GLOBAL = __webpack_require__(/*! ./config */ \"./lib/config.js\").GLOBAL; // Load all cached clients\n\n\n__webpack_require__(/*! ./loadClients */ \"./lib/loadClients.js\")(Treasure, GLOBAL); // Expose the library on the window\n\n\nwindow[GLOBAL] = Treasure;\n\n//# sourceURL=webpack:///./lib/index.js?"); - -/***/ }), - -/***/ "./lib/loadClients.js": -/*!****************************!*\ - !*** ./lib/loadClients.js ***! - \****************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("/*\n * Treasure Client Loader\n */\n// Modules\nvar _ = __webpack_require__(/*! ./utils/lodash */ \"./lib/utils/lodash.js\");\n\nvar window = __webpack_require__(/*! global/window */ \"./node_modules/global/window.js\"); // Helpers\n\n\nfunction applyToClient(client, method) {\n var _method = '_' + method;\n\n if (client[_method]) {\n var arr = client[_method] || [];\n\n while (arr.length) {\n client[method].apply(client, arr.shift());\n }\n\n delete client[_method];\n }\n} // Constants\n\n\nvar TREASURE_KEYS = ['init', 'set', 'blockEvents', 'unblockEvents', 'setSignedMode', 'setAnonymousMode', 'resetUUID', 'addRecord', 'fetchGlobalID', 'trackPageview', 'trackEvent', 'trackClicks', 'fetchUserSegments', 'fetchServerCookie', 'ready'];\n/*\n * Load clients\n */\n\nmodule.exports = function loadClients(Treasure, name) {\n if (_.isObject(window[name])) {\n var snippet = window[name];\n var clients = snippet.clients; // Copy over Treasure.prototype functions over to snippet's prototype\n // This allows already-instanciated clients to work\n\n _.forIn(Treasure.prototype, function (value, key) {\n snippet.prototype[key] = value;\n }); // Iterate over each client instance\n\n\n _.forEach(clients, function (client) {\n // Call each key and with any stored values\n _.forEach(TREASURE_KEYS, function (value) {\n applyToClient(client, value);\n });\n });\n }\n};\n\n//# sourceURL=webpack:///./lib/loadClients.js?"); - -/***/ }), - -/***/ "./lib/plugins/clicks.js": -/*!*******************************!*\ - !*** ./lib/plugins/clicks.js ***! - \*******************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -eval("var window = __webpack_require__(/*! global/window */ \"./node_modules/global/window.js\");\n\nvar elementUtils = __webpack_require__(/*! ../utils/element */ \"./lib/utils/element.js\");\n\nvar assign = __webpack_require__(/*! ../utils/lodash */ \"./lib/utils/lodash.js\").assign;\n\nvar disposable = __webpack_require__(/*! ../utils/misc */ \"./lib/utils/misc.js\").disposable;\n\nfunction defaultExtendClickData(event, data) {\n return data;\n}\n\nfunction configure() {\n this._clickTrackingInstalled = false;\n}\n/**\n * Setup an event listener to automatically log clicks.\n * The event will be hooked only follows\n * - `role=button` or `role=link`\n * - ``\n * - `