Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set_id method for the node #109

Merged
merged 7 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## XX.XX.XX
- Added a new method `set_id(newDeviceId)` for managing device ID changes according to the device ID Type

## 24.10.0
- Default max segmentation value count changed from 30 to 100
- Mitigated an issue where SDK could create an unintended dump file
Expand Down
20 changes: 20 additions & 0 deletions lib/countly.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,26 @@ Countly.Bulk = Bulk;
return Countly.device_id;
};

/**
* Changes the current device ID according to the device ID type (the preffered method)
* @param {string} newId - new user/device ID to use. Must be a non-empty string value. Invalid values (like null, empty string or undefined) will be rejected
* */
Countly.set_id = function(newId) {
cc.log(cc.logLevelEnums.INFO, `set_id, Changing the device ID to: [${newId}]`);
arifBurakDemiray marked this conversation as resolved.
Show resolved Hide resolved
if (newId === null || newId === "") {
cc.log(cc.logLevelEnums.WARNING, "set_id, The provided device is not a valid ID");
return;
}
if (Countly.deviceIdType === cc.deviceIdTypeEnums.DEVELOPER_SUPPLIED) {
// change ID without merge as current ID is Dev supplied, so not first login
Countly.change_id(newId, false);
}
else {
// change ID with merge as current ID is not Dev supplied*/
Countly.change_id(newId, true);
}
};

/**
* Change current user/device id
* @param {string} newId - new user/device ID to use
Expand Down
Loading