Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@
## 23.2.3
- Mitigated an issue where the new device ID was used when ending a session if device ID was changed without merging.

## 23.2.2
- Mitigated a mutex issue that can happen during update loop.

Expand Down
2 changes: 1 addition & 1 deletion include/countly/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <string>

#define COUNTLY_SDK_NAME "cpp-native-unknown"
#define COUNTLY_SDK_VERSION "23.2.2"
#define COUNTLY_SDK_VERSION "23.2.3"
#define COUNTLY_POST_THRESHOLD 2000
#define COUNTLY_KEEPALIVE_INTERVAL 3000
#define COUNTLY_MAX_EVENTS_DEFAULT 200
Expand Down
18 changes: 9 additions & 9 deletions src/countly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,19 +288,18 @@ void Countly::_sendIndependantLocationRequest() {
#pragma region Device Id
void Countly::setDeviceID(const std::string &value, bool same_user) {
mutex->lock();
configuration->deviceId = value;
log(LogLevel::INFO, "[Countly][changeDeviceIdWithMerge] setDeviceID = '" + value + "'");
log(LogLevel::INFO, "[Countly][setDeviceID] setDeviceID requested = '" + value + "'");

// Checking old and new devices ids are same
if (session_params.contains("device_id") && session_params["device_id"].get<std::string>() == value) {
log(LogLevel::DEBUG, "[Countly][setDeviceID] new device id and old device id are same.");
if (!session_params.contains("device_id")) {
session_params["device_id"] = value;
configuration->deviceId = value;
log(LogLevel::DEBUG, "[Countly][setDeviceID] no previous device id, assigning initial device id");
mutex->unlock();
return;
}

if (!session_params.contains("device_id")) {
session_params["device_id"] = value;
log(LogLevel::DEBUG, "[Countly][setDeviceID] no device was set, setting device id");
if (session_params["device_id"].get<std::string>() == value) {
log(LogLevel::DEBUG, "[Countly][setDeviceID] new device id equals existing device id, ignoring.");
mutex->unlock();
return;
}
Expand All @@ -325,6 +324,7 @@ void Countly::_changeDeviceIdWithMerge(const std::string &value) {

session_params["old_device_id"] = session_params["device_id"];
session_params["device_id"] = value;
configuration->deviceId = value;

const std::chrono::system_clock::time_point now = Countly::getTimestamp();
const auto timestamp = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch());
Expand All @@ -340,7 +340,6 @@ void Countly::_changeDeviceIdWithMerge(const std::string &value) {
mutex->unlock();
}

/* Change device ID without merge after SDK has been initialized.*/
void Countly::_changeDeviceIdWithoutMerge(const std::string &value) {
log(LogLevel::DEBUG, "[Countly][changeDeviceIdWithoutMerge] deviceId = '" + value + "'");

Expand All @@ -352,6 +351,7 @@ void Countly::_changeDeviceIdWithoutMerge(const std::string &value) {

mutex->lock();
session_params["device_id"] = value;
configuration->deviceId = value;
mutex->unlock();

// start a new session for new user
Expand Down
Loading