Skip to content

Commit 16fbe18

Browse files
authored
Merge pull request #144 from Countly/staging
Staging 23.2.3
2 parents 9b47134 + cf85277 commit 16fbe18

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 23.2.3
2+
- Mitigated an issue where the new device ID was used when ending a session if device ID was changed without merging.
3+
14
## 23.2.2
25
- Mitigated a mutex issue that can happen during update loop.
36

include/countly/constants.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <string>
1414

1515
#define COUNTLY_SDK_NAME "cpp-native-unknown"
16-
#define COUNTLY_SDK_VERSION "23.2.2"
16+
#define COUNTLY_SDK_VERSION "23.2.3"
1717
#define COUNTLY_POST_THRESHOLD 2000
1818
#define COUNTLY_KEEPALIVE_INTERVAL 3000
1919
#define COUNTLY_MAX_EVENTS_DEFAULT 200

src/countly.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,19 +288,18 @@ void Countly::_sendIndependantLocationRequest() {
288288
#pragma region Device Id
289289
void Countly::setDeviceID(const std::string &value, bool same_user) {
290290
mutex->lock();
291-
configuration->deviceId = value;
292-
log(LogLevel::INFO, "[Countly][changeDeviceIdWithMerge] setDeviceID = '" + value + "'");
291+
log(LogLevel::INFO, "[Countly][setDeviceID] setDeviceID requested = '" + value + "'");
293292

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

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

326325
session_params["old_device_id"] = session_params["device_id"];
327326
session_params["device_id"] = value;
327+
configuration->deviceId = value;
328328

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

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

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

353352
mutex->lock();
354353
session_params["device_id"] = value;
354+
configuration->deviceId = value;
355355
mutex->unlock();
356356

357357
// start a new session for new user

0 commit comments

Comments
 (0)