Skip to content

Commit

Permalink
Merge pull request #38 from Moesif/add-campgian-to-anonymous-user
Browse files Browse the repository at this point in the history
Add campgian to anonymous user
  • Loading branch information
dgilling authored Feb 26, 2021
2 parents 9719b9d + 64d0cb1 commit d012df9
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 24 deletions.
13 changes: 12 additions & 1 deletion build/moesif.amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ define(function () { 'use strict';

var Config = {
DEBUG: false,
LIB_VERSION: '1.8.1'
LIB_VERSION: '1.8.2'
};

// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
Expand Down Expand Up @@ -3291,6 +3291,17 @@ define(function () { 'use strict';
this._companyId = getFromPersistence(STORAGE_CONSTANTS.STORED_COMPANY_ID, ops);
this._anonymousId = getAnonymousId(this._persist, ops);
this._campaign = getCampaignData(this._persist, ops);

// try to save campaign data on anonymous id
// if there is no userId saved, means it is still anonymous.
// later on, when identifyUser is called with real user id,
// the campaigne data will be resent with that again.
if (this._campaign && !this._userId) {
var anonUserObject = {};
anonUserObject['anonymous_id'] = this._anonymousId;
anonUserObject['campaign'] = this._campaign;
this.updateUser(anonUserObject, this._options.applicationId, this._options.host, this._options.callback);
}
} catch(err) {
console.error('error loading saved data from local storage but continue');
}
Expand Down
13 changes: 12 additions & 1 deletion build/moesif.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var Config = {
DEBUG: false,
LIB_VERSION: '1.8.1'
LIB_VERSION: '1.8.2'
};

// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
Expand Down Expand Up @@ -3291,6 +3291,17 @@ function moesifCreator () {
this._companyId = getFromPersistence(STORAGE_CONSTANTS.STORED_COMPANY_ID, ops);
this._anonymousId = getAnonymousId(this._persist, ops);
this._campaign = getCampaignData(this._persist, ops);

// try to save campaign data on anonymous id
// if there is no userId saved, means it is still anonymous.
// later on, when identifyUser is called with real user id,
// the campaigne data will be resent with that again.
if (this._campaign && !this._userId) {
var anonUserObject = {};
anonUserObject['anonymous_id'] = this._anonymousId;
anonUserObject['campaign'] = this._campaign;
this.updateUser(anonUserObject, this._options.applicationId, this._options.host, this._options.callback);
}
} catch(err) {
console.error('error loading saved data from local storage but continue');
}
Expand Down
13 changes: 12 additions & 1 deletion build/moesif.globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

var Config = {
DEBUG: false,
LIB_VERSION: '1.8.1'
LIB_VERSION: '1.8.2'
};

// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
Expand Down Expand Up @@ -3292,6 +3292,17 @@
this._companyId = getFromPersistence(STORAGE_CONSTANTS.STORED_COMPANY_ID, ops);
this._anonymousId = getAnonymousId(this._persist, ops);
this._campaign = getCampaignData(this._persist, ops);

// try to save campaign data on anonymous id
// if there is no userId saved, means it is still anonymous.
// later on, when identifyUser is called with real user id,
// the campaigne data will be resent with that again.
if (this._campaign && !this._userId) {
var anonUserObject = {};
anonUserObject['anonymous_id'] = this._anonymousId;
anonUserObject['campaign'] = this._campaign;
this.updateUser(anonUserObject, this._options.applicationId, this._options.host, this._options.callback);
}
} catch(err) {
console.error('error loading saved data from local storage but continue');
}
Expand Down
13 changes: 12 additions & 1 deletion build/moesif.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

var Config = {
DEBUG: false,
LIB_VERSION: '1.8.1'
LIB_VERSION: '1.8.2'
};

// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
Expand Down Expand Up @@ -3295,6 +3295,17 @@
this._companyId = getFromPersistence(STORAGE_CONSTANTS.STORED_COMPANY_ID, ops);
this._anonymousId = getAnonymousId(this._persist, ops);
this._campaign = getCampaignData(this._persist, ops);

// try to save campaign data on anonymous id
// if there is no userId saved, means it is still anonymous.
// later on, when identifyUser is called with real user id,
// the campaigne data will be resent with that again.
if (this._campaign && !this._userId) {
var anonUserObject = {};
anonUserObject['anonymous_id'] = this._anonymousId;
anonUserObject['campaign'] = this._campaign;
this.updateUser(anonUserObject, this._options.applicationId, this._options.host, this._options.callback);
}
} catch(err) {
console.error('error loading saved data from local storage but continue');
}
Expand Down
13 changes: 12 additions & 1 deletion examples/commonjs-browserify/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

var Config = {
DEBUG: false,
LIB_VERSION: '1.8.1'
LIB_VERSION: '1.8.2'
};

// since es6 imports are static and we run unit tests from the console, window won't be defined when importing this file
Expand Down Expand Up @@ -3292,6 +3292,17 @@ function moesifCreator () {
this._companyId = getFromPersistence(STORAGE_CONSTANTS.STORED_COMPANY_ID, ops);
this._anonymousId = getAnonymousId(this._persist, ops);
this._campaign = getCampaignData(this._persist, ops);

// try to save campaign data on anonymous id
// if there is no userId saved, means it is still anonymous.
// later on, when identifyUser is called with real user id,
// the campaigne data will be resent with that again.
if (this._campaign && !this._userId) {
var anonUserObject = {};
anonUserObject['anonymous_id'] = this._anonymousId;
anonUserObject['campaign'] = this._campaign;
this.updateUser(anonUserObject, this._options.applicationId, this._options.host, this._options.callback);
}
} catch(err) {
console.error('error loading saved data from local storage but continue');
}
Expand Down
13 changes: 12 additions & 1 deletion examples/es2015-babelify/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ Object.defineProperty(exports, '__esModule', {
});
var Config = {
DEBUG: false,
LIB_VERSION: '1.8.1'
LIB_VERSION: '1.8.2'
};

exports['default'] = Config;
Expand Down Expand Up @@ -840,6 +840,17 @@ exports['default'] = function () {
this._companyId = (0, _persistence.getFromPersistence)(_persistence.STORAGE_CONSTANTS.STORED_COMPANY_ID, ops);
this._anonymousId = (0, _anonymousId.getAnonymousId)(this._persist, ops);
this._campaign = (0, _campaign2['default'])(this._persist, ops);

// try to save campaign data on anonymous id
// if there is no userId saved, means it is still anonymous.
// later on, when identifyUser is called with real user id,
// the campaigne data will be resent with that again.
if (this._campaign && !this._userId) {
var anonUserObject = {};
anonUserObject['anonymous_id'] = this._anonymousId;
anonUserObject['campaign'] = this._campaign;
this.updateUser(anonUserObject, this._options.applicationId, this._options.host, this._options.callback);
}
} catch (err) {
_utils.console.error('error loading saved data from local storage but continue');
}
Expand Down
2 changes: 1 addition & 1 deletion examples/umd-webpack/dist/main.js

Large diffs are not rendered by default.

Loading

0 comments on commit d012df9

Please sign in to comment.