From a41b3ef4099d5b8813e559f2b89a3b39564a5dfe Mon Sep 17 00:00:00 2001 From: dnson Date: Thu, 25 Jul 2024 10:46:44 +0700 Subject: [PATCH] release 4.0.2 (#273) --- CHANGELOG.md | 5 +++ dist/td.js | 101 +++++++++++++++++-------------------------------- dist/td.min.js | 8 ++-- lib/config.js | 2 +- package.json | 2 +- 5 files changed, 45 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e92a4a9d..0251cd03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 4.0.2 (2024-07-25) +* Update documentation +* Remove preinstall hook +* Update libs + ## 4.0.1 (2023-06-27) * Add `keepalive` option to POST requests diff --git a/dist/td.js b/dist/td.js index caee7388..19e70fd3 100644 --- a/dist/td.js +++ b/dist/td.js @@ -93,7 +93,7 @@ /*! no static exports found */ /***/ (function(module, exports) { -eval("module.exports = {\n GLOBAL: 'Treasure',\n VERSION: '4.0.1',\n HOST: 'in.treasuredata.com',\n DATABASE: '',\n PATHNAME: '/'\n};\n\n//# sourceURL=webpack:///./lib/config.js?"); +eval("module.exports = {\n GLOBAL: 'Treasure',\n VERSION: '4.0.2',\n HOST: 'in.treasuredata.com',\n DATABASE: '',\n PATHNAME: '/'\n};\n\n//# sourceURL=webpack:///./lib/config.js?"); /***/ }), @@ -104,7 +104,7 @@ eval("module.exports = {\n GLOBAL: 'Treasure',\n VERSION: '4.0.1',\n HOST: 'i /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("/*\n * Treasure Configurator\n */\n\n// Modules\nvar _ = __webpack_require__(/*! ./utils/lodash */ \"./lib/utils/lodash.js\");\nvar invariant = __webpack_require__(/*! ./utils/misc */ \"./lib/utils/misc.js\").invariant;\nvar config = __webpack_require__(/*! ./config */ \"./lib/config.js\");\nvar cookie = __webpack_require__(/*! ./vendor/js-cookies */ \"./lib/vendor/js-cookies.js\");\n\n// Helpers\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}\nvar defaultSSCCookieDomain = function defaultSSCCookieDomain() {\n var domainChunks = document.location.hostname.split('.');\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 cookie.setItem(name, domain, 3600, '/', domain);\n if (cookie.getItem(name) === domain) {\n return domain;\n }\n }\n return document.location.hostname;\n};\n\n// Default config for library values\nexports.DEFAULT_CONFIG = {\n database: config.DATABASE,\n development: 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/*\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 * */\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 if (!this.client.endpoint) {\n this.client.endpoint = 'https://' + this.client.host + this.client.pathname;\n }\n return this;\n};\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 */\nexports.set = function set(table, property, value) {\n if (_.isObject(table)) {\n property = table;\n table = '$global';\n }\n this.client.globals[table] = this.client.globals[table] || {};\n if (_.isObject(property)) {\n _.assign(this.client.globals[table], property);\n } else {\n this.client.globals[table][property] = value;\n }\n return this;\n};\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 */\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};\nexports.isGlobalIdEnabled = function () {\n return this.get(null, 'td_global_id') === 'td_global_id';\n};\n\n//# sourceURL=webpack:///./lib/configurator.js?"); +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 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.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?"); /***/ }), @@ -115,7 +115,7 @@ eval("/*\n * Treasure Configurator\n */\n\n// Modules\nvar _ = __webpack_require /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("/*\n * Treasure Index\n */\nvar Treasure = __webpack_require__(/*! ./treasure.js */ \"./lib/treasure.js\");\nvar window = __webpack_require__(/*! global/window */ \"./node_modules/global/window.js\");\nvar GLOBAL = __webpack_require__(/*! ./config */ \"./lib/config.js\").GLOBAL;\n\n// Load all cached clients\n__webpack_require__(/*! ./loadClients */ \"./lib/loadClients.js\")(Treasure, GLOBAL);\n\n// Expose the library on the window\nwindow[GLOBAL] = Treasure;\n\n//# sourceURL=webpack:///./lib/index.js?"); +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?"); /***/ }), @@ -126,7 +126,7 @@ eval("/*\n * Treasure Index\n */\nvar Treasure = __webpack_require__(/*! ./treas /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("/*\n * Treasure Client Loader\n */\n\n// Modules\nvar _ = __webpack_require__(/*! ./utils/lodash */ \"./lib/utils/lodash.js\");\nvar window = __webpack_require__(/*! global/window */ \"./node_modules/global/window.js\");\n\n// Helpers\nfunction applyToClient(client, method) {\n var _method = '_' + method;\n if (client[_method]) {\n var arr = client[_method] || [];\n while (arr.length) {\n client[method].apply(client, arr.shift());\n }\n delete client[_method];\n }\n}\n\n// Constants\nvar TREASURE_KEYS = ['init', 'set', 'blockEvents', 'unblockEvents', 'setSignedMode', 'setAnonymousMode', 'resetUUID', 'addRecord', 'fetchGlobalID', 'trackPageview', 'trackEvent', 'trackClicks', 'fetchUserSegments', 'fetchServerCookie', 'ready'];\n\n/*\n * Load clients\n */\nmodule.exports = function loadClients(Treasure, name) {\n if (_.isObject(window[name])) {\n var snippet = window[name];\n var clients = snippet.clients;\n\n // Copy over Treasure.prototype functions over to snippet's prototype\n // This allows already-instanciated clients to work\n _.forIn(Treasure.prototype, function (value, key) {\n snippet.prototype[key] = value;\n });\n\n // Iterate over each client instance\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?"); +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?"); /***/ }), @@ -137,7 +137,7 @@ eval("/*\n * Treasure Client Loader\n */\n\n// Modules\nvar _ = __webpack_requir /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { -eval("var window = __webpack_require__(/*! global/window */ \"./node_modules/global/window.js\");\nvar elementUtils = __webpack_require__(/*! ../utils/element */ \"./lib/utils/element.js\");\nvar assign = __webpack_require__(/*! ../utils/lodash */ \"./lib/utils/lodash.js\").assign;\nvar disposable = __webpack_require__(/*! ../utils/misc */ \"./lib/utils/misc.js\").disposable;\nfunction defaultExtendClickData(event, data) {\n return data;\n}\nfunction configure() {\n this._clickTrackingInstalled = false;\n}\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 * - `