Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/amplitude-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ var AmplitudeClient = function AmplitudeClient(instanceName) {
plan: { ...DEFAULT_OPTIONS.plan },
trackingOptions: { ...DEFAULT_OPTIONS.trackingOptions },
};
this.cookieStorage = new cookieStorage().getStorage();
this._q = []; // queue for proxied functions before script load
this._sending = false;
this._updateScheduled = false;
Expand Down Expand Up @@ -127,6 +126,7 @@ AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, o

this._cookieName = Constants.COOKIE_PREFIX + '_' + this._storageSuffixV5;

this.cookieStorage = new cookieStorage().getStorage(this.options.disableCookies);
this.cookieStorage.options({
expirationDays: this.options.cookieExpiration,
domain: this.options.domain,
Expand Down
4 changes: 2 additions & 2 deletions src/cookiestorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ var cookieStorage = function () {
this.storage = null;
};

cookieStorage.prototype.getStorage = function () {
cookieStorage.prototype.getStorage = function (disableCookies) {
if (this.storage !== null) {
return this.storage;
}

if (baseCookie.areCookiesEnabled()) {
if (!disableCookies && baseCookie.areCookiesEnabled()) {
this.storage = Cookie;
} else {
// if cookies disabled, fallback to localstorage
Expand Down
4 changes: 2 additions & 2 deletions test/amplitude-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,11 +888,11 @@ describe('AmplitudeClient', function () {
var onErrorSpy = sinon.spy();

var amplitude = new AmplitudeClient();
sinon.stub(amplitude.cookieStorage, 'options').throws();
sinon.stub(amplitude, '_refreshDynamicConfig').throws();
amplitude.init(apiKey, null, { onError: onErrorSpy });
assert.isTrue(onErrorSpy.calledOnce);

amplitude.cookieStorage.options.restore();
amplitude['_refreshDynamicConfig'].restore();
});

it('should set observer plan options', function () {
Expand Down