From 8638570a00e468bbf923bf48c2e70f8085a0354c Mon Sep 17 00:00:00 2001 From: Dean Shi Date: Mon, 9 May 2022 14:37:54 -0700 Subject: [PATCH 1/2] fix: Assign domain after cookie storage options are added --- src/amplitude-client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/amplitude-client.js b/src/amplitude-client.js index 3611fa3a..c2a45cdc 100644 --- a/src/amplitude-client.js +++ b/src/amplitude-client.js @@ -126,6 +126,7 @@ AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, o secure: this.options.secureCookie, sameSite: this.options.sameSiteCookie, }); + this.options.domain = this.cookieStorage.options().domain; this._metadataStorage = new MetadataStorage({ storageKey: this._cookieName, @@ -141,7 +142,6 @@ AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, o const hasNewCookie = !!this._metadataStorage.load(); this._useOldCookie = !hasNewCookie && hasOldCookie && !this.options.cookieForceUpgrade; const hasCookie = hasNewCookie || hasOldCookie; - this.options.domain = this.cookieStorage.options().domain; if (this.options.deferInitialization && !hasCookie) { this._deferInitialization(apiKey, opt_userId, opt_config, opt_callback); From c27699a23ca5c31db54fb6a46b40fc0d576216dc Mon Sep 17 00:00:00 2001 From: Dean Shi Date: Mon, 9 May 2022 16:58:03 -0700 Subject: [PATCH 2/2] fix: address comment --- src/amplitude-client.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/amplitude-client.js b/src/amplitude-client.js index c2a45cdc..1d134f65 100644 --- a/src/amplitude-client.js +++ b/src/amplitude-client.js @@ -126,7 +126,6 @@ AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, o secure: this.options.secureCookie, sameSite: this.options.sameSiteCookie, }); - this.options.domain = this.cookieStorage.options().domain; this._metadataStorage = new MetadataStorage({ storageKey: this._cookieName, @@ -148,6 +147,8 @@ AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, o return; } + this.options.domain = this.cookieStorage.options().domain; + if (type(this.options.logLevel) === 'string') { utils.setLogLevel(this.options.logLevel); }