diff --git a/CHANGELOG.md b/CHANGELOG.md index 654f754..23a645c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/include/countly/constants.hpp b/include/countly/constants.hpp index 300e09e..5ea5367 100644 --- a/include/countly/constants.hpp +++ b/include/countly/constants.hpp @@ -13,7 +13,7 @@ #include #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 diff --git a/src/countly.cpp b/src/countly.cpp index e5b321a..42552d6 100644 --- a/src/countly.cpp +++ b/src/countly.cpp @@ -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() == 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() == value) { + log(LogLevel::DEBUG, "[Countly][setDeviceID] new device id equals existing device id, ignoring."); mutex->unlock(); return; } @@ -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(now.time_since_epoch()); @@ -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 + "'"); @@ -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