diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c4f6419..885a3033 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 3.1.3 (2023-06-15) +* `postWithTimeout` should be requested with body +* only enable `td_global_id` when in signed mode + + ## 3.1.2 (2022-10-05) * Default values for backward compatibility diff --git a/README.md b/README.md index 48280d7c..b647501f 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Install td-js-sdk on your page by copying the appropriate JavaScript snippet bel ```html ``` diff --git a/dist/td.js b/dist/td.js index 2b6b2459..e3b54012 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: '3.1.2',\n HOST: 'in.treasuredata.com',\n DATABASE: '',\n PATHNAME: '/js/v3/event/'\n};\n\n//# sourceURL=webpack:///./lib/config.js?"); +eval("module.exports = {\n GLOBAL: 'Treasure',\n VERSION: '3.1.3',\n HOST: 'in.treasuredata.com',\n DATABASE: '',\n PATHNAME: '/js/v3/event/'\n};\n\n//# sourceURL=webpack:///./lib/config.js?"); /***/ }), @@ -104,7 +104,7 @@ eval("module.exports = {\n GLOBAL: 'Treasure',\n VERSION: '3.1.2',\n HOST: 'i /*! 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