Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #47 from akiliinteractive/master
Browse files Browse the repository at this point in the history
change setNewDeviceId parameter order to match web SDK
  • Loading branch information
nxvinay authored Aug 9, 2018
2 parents e0ef726 + 0196810 commit 2b05ff0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Countly.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,11 @@ class Countly {
)

/**
* @description setNewDeviceId:onServer method implementation
* @param {*} ROOT_URL dashboard base address
*/
setNewDeviceId = (onServer = false, deviceId) => (
* Change current user/device id
* @param {string} newId - new user/device ID to use
* @param {boolean} onServer - if true, move data from old ID to new ID on server
**/
setNewDeviceId = (deviceId, onServer = false) => (
new Promise(async (resolve, reject) => {
if (onServer) {
if (this.DEVICE_ID === deviceId) {
Expand All @@ -529,8 +530,9 @@ class Countly {
} catch(error) {
return reject(new Error(`Unable to change DeviceId ${error}`));
}
} else if(onServer === false) {
} else { // merge locally, stop session and start new session
try {
await this.stop();
const result = await Ajax.setItem('DEVICE_ID', deviceId, (result) => {this.log(result)});
this.DEVICE_ID = deviceId;
this.storedEvents = {};
Expand All @@ -540,7 +542,6 @@ class Countly {
return reject(new Error(`Unable to change DeviceId ${error}`));
}
}
return reject(new Error('Unable to change DeviceId onServer is not set'));
})
)

Expand Down

0 comments on commit 2b05ff0

Please sign in to comment.