Skip to content

Commit 7add130

Browse files
fix: behavior changes
1 parent 92f795e commit 7add130

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/countly.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ void Countly::_changeDeviceIdWithoutMerge(const std::string &value) {
346346

347347
// send all event to server and end current session of old user
348348
flushEvents();
349-
if(!configuration->manualSessionControl){
349+
if(configuration->manualSessionControl == false){
350350
endSession();
351351
}
352352

@@ -355,7 +355,7 @@ void Countly::_changeDeviceIdWithoutMerge(const std::string &value) {
355355
mutex->unlock();
356356

357357
// start a new session for new user
358-
if(!configuration->manualSessionControl){
358+
if(configuration->manualSessionControl == false){
359359
beginSession();
360360
}
361361

@@ -438,7 +438,7 @@ void Countly::start(const std::string &app_key, const std::string &host, int por
438438

439439
if (!running) {
440440

441-
if(!configuration->manualSessionControl){
441+
if(configuration->manualSessionControl == false){
442442
mutex->unlock();
443443
beginSession();
444444
mutex->lock();
@@ -469,7 +469,7 @@ void Countly::startOnCloud(const std::string &app_key) {
469469

470470
void Countly::stop() {
471471
_deleteThread();
472-
if (!configuration->manualSessionControl) {
472+
if (configuration->manualSessionControl == false) {
473473
endSession();
474474
}
475475
}
@@ -611,7 +611,7 @@ bool Countly::attemptSessionUpdateEQ() {
611611
return false;
612612
}
613613
#endif
614-
if(!configuration->manualSessionControl){
614+
if(configuration->manualSessionControl == false){
615615
return !updateSession();
616616
} else {
617617
packEvents();
@@ -676,7 +676,7 @@ std::vector<std::string> Countly::debugReturnStateOfEQ() {
676676
bool Countly::beginSession() {
677677
mutex->lock();
678678
log(LogLevel::INFO, "[Countly][beginSession]");
679-
if (began_session) {
679+
if (began_session == true) {
680680
mutex->unlock();
681681
log(LogLevel::DEBUG, "[Countly][beginSession] Session is already active.");
682682
return true;
@@ -732,9 +732,9 @@ bool Countly::updateSession() {
732732
try {
733733
// Check if there was a session, if not try to start one
734734
mutex->lock();
735-
if (!began_session) {
735+
if (began_session == false) {
736736
mutex->unlock();
737-
if(configuration->manualSessionControl){
737+
if(configuration->manualSessionControl == true){
738738
log(LogLevel::WARNING, "[Countly][updateSession] SDK is in manual session control mode and there is no active session. Please start a session first.");
739739
return false;
740740
}
@@ -859,7 +859,7 @@ void Countly::sendEventsToRQ(const nlohmann::json &events) {
859859

860860
bool Countly::endSession() {
861861
log(LogLevel::INFO, "[Countly][endSession]");
862-
if(!began_session) {
862+
if(began_session == false) {
863863
log(LogLevel::DEBUG, "[Countly][endSession] There is no active session to end.");
864864
return true;
865865
}
@@ -1200,9 +1200,9 @@ void Countly::updateLoop() {
12001200
size_t last_wait_milliseconds = wait_milliseconds;
12011201
mutex->unlock();
12021202
std::this_thread::sleep_for(std::chrono::milliseconds(last_wait_milliseconds));
1203-
if (enable_automatic_session && !configuration->manualSessionControl) {
1203+
if (enable_automatic_session == true && configuration->manualSessionControl == false) {
12041204
updateSession();
1205-
} else {
1205+
} else if (configuration->manualSessionControl == true) {
12061206
packEvents();
12071207
}
12081208
requestModule->processQueue(mutex);

tests/config.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ TEST_CASE("Validate setting configuration values") {
5151
CHECK(config.breadcrumbsThreshold == 100);
5252
CHECK(config.forcePost == false);
5353
CHECK(config.port == 443);
54+
CHECK(config.manualSessionControl == false);
5455
CHECK(config.sha256_function == nullptr);
5556
CHECK(config.http_client_function == nullptr);
5657
CHECK(config.metrics.empty());
@@ -76,6 +77,7 @@ TEST_CASE("Validate setting configuration values") {
7677
ct.setMaxRequestQueueSize(10);
7778
ct.SetPath(TEST_DATABASE_NAME);
7879
ct.setMaxRQProcessingBatchSize(10);
80+
ct.enableManualSessionControl();
7981
ct.start("YOUR_APP_KEY", "https://try.count.ly", -1, false);
8082

8183
// Get configuration values using Countly getters
@@ -94,6 +96,7 @@ TEST_CASE("Validate setting configuration values") {
9496
CHECK(config.breadcrumbsThreshold == 100);
9597
CHECK(config.forcePost == true);
9698
CHECK(config.port == 443);
99+
CHECK(config.manualSessionControl == true);
97100
CHECK(config.sha256_function("custom SHA256") == customSha_1_returnValue);
98101

99102
HTTPResponse response = config.http_client_function(true, "", "");

0 commit comments

Comments
 (0)