From 193594668fc138a1cef9e52828939710293be7e0 Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray Date: Thu, 4 Dec 2025 15:47:13 +0300 Subject: [PATCH 1/5] feat: auto events on user props --- include/countly.hpp | 2 ++ include/countly/countly_configuration.hpp | 2 ++ src/countly.cpp | 42 ++++++++++++++++++----- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/include/countly.hpp b/include/countly.hpp index fa985e3..6065b9d 100644 --- a/include/countly.hpp +++ b/include/countly.hpp @@ -58,6 +58,8 @@ class Countly : public cly::CountlyDelegates { void enableManualSessionControl(); + void disableAutoEventsOnUserProperties(); + void setHTTPClient(HTTPClientFunction fun); void setMetrics(const std::string &os, const std::string &os_version, const std::string &device, const std::string &resolution, const std::string &carrier, const std::string &app_version); diff --git a/include/countly/countly_configuration.hpp b/include/countly/countly_configuration.hpp index c98d500..6540338 100644 --- a/include/countly/countly_configuration.hpp +++ b/include/countly/countly_configuration.hpp @@ -70,6 +70,8 @@ struct CountlyConfiguration { bool manualSessionControl = false; + bool autoEventsOnUserProperties = true; + HTTPClientFunction http_client_function = nullptr; nlohmann::json metrics; diff --git a/src/countly.cpp b/src/countly.cpp index 42552d6..bf01fef 100644 --- a/src/countly.cpp +++ b/src/countly.cpp @@ -142,6 +142,20 @@ void Countly::enableManualSessionControl() { mutex->unlock(); } +/** + * Disable automatic events on user properties changes. + */ +void Countly::disableAutoEventsOnUserProperties() { + if (is_sdk_initialized) { + log(LogLevel::WARNING, "[Countly][disableAutoEventsOnUserProperties] You can not disable automatic events on user properties after SDK initialization."); + return; + } + + mutex->lock(); + configuration->autoEventsOnUserProperties = false; + mutex->unlock(); +} + void Countly::setMetrics(const std::string &os, const std::string &os_version, const std::string &device, const std::string &resolution, const std::string &carrier, const std::string &app_version) { if (is_sdk_initialized) { log(LogLevel::WARNING, "[Countly][setMetrics] You can not set metrics after SDK initialization."); @@ -182,6 +196,12 @@ void Countly::setUserDetails(const std::map &value) { return; } + if (configuration->autoEventsOnUserProperties == true) { + mutex->unlock(); + flushEvents(); + mutex->lock(); + } + std::map data = {{"app_key", session_params["app_key"].get()}, {"device_id", session_params["device_id"].get()}, {"user_details", session_params["user_details"].dump()}}; requestModule->addRequestToQueue(data); @@ -198,6 +218,12 @@ void Countly::setCustomUserDetails(const std::map &val return; } + if (configuration->autoEventsOnUserProperties == true) { + mutex->unlock(); + flushEvents(); + mutex->lock(); + } + std::map data = {{"app_key", session_params["app_key"].get()}, {"device_id", session_params["device_id"].get()}, {"user_details", session_params["user_details"].dump()}}; requestModule->addRequestToQueue(data); @@ -345,7 +371,7 @@ void Countly::_changeDeviceIdWithoutMerge(const std::string &value) { // send all event to server and end current session of old user flushEvents(); - if(configuration->manualSessionControl == false){ + if (configuration->manualSessionControl == false) { endSession(); } @@ -355,10 +381,9 @@ void Countly::_changeDeviceIdWithoutMerge(const std::string &value) { mutex->unlock(); // start a new session for new user - if(configuration->manualSessionControl == false){ + if (configuration->manualSessionControl == false) { beginSession(); } - } #pragma endregion Device Id @@ -439,7 +464,7 @@ void Countly::start(const std::string &app_key, const std::string &host, int por if (!running) { - if(configuration->manualSessionControl == false){ + if (configuration->manualSessionControl == false) { mutex->unlock(); beginSession(); mutex->lock(); @@ -612,7 +637,7 @@ bool Countly::attemptSessionUpdateEQ() { return false; } #endif - if(configuration->manualSessionControl == false){ + if (configuration->manualSessionControl == false) { return !updateSession(); } else { packEvents(); @@ -735,7 +760,7 @@ bool Countly::updateSession() { mutex->lock(); if (began_session == false) { mutex->unlock(); - if(configuration->manualSessionControl == true){ + if (configuration->manualSessionControl == true) { log(LogLevel::WARNING, "[Countly][updateSession] SDK is in manual session control mode and there is no active session. Please start a session first."); return false; } @@ -829,7 +854,7 @@ void Countly::packEvents() { } else { log(LogLevel::DEBUG, "[Countly][packEvents] EQ empty."); } - // report events if there are any to request queue + // report events if there are any to request queue if (!no_events) { sendEventsToRQ(events); } @@ -852,7 +877,6 @@ void Countly::packEvents() { mutex->unlock(); } - void Countly::sendEventsToRQ(const nlohmann::json &events) { log(LogLevel::DEBUG, "[Countly][sendEventsToRQ] Sending events to RQ."); std::map data = {{"app_key", session_params["app_key"].get()}, {"device_id", session_params["device_id"].get()}, {"events", events.dump()}}; @@ -861,7 +885,7 @@ void Countly::sendEventsToRQ(const nlohmann::json &events) { bool Countly::endSession() { log(LogLevel::INFO, "[Countly][endSession]"); - if(began_session == false) { + if (began_session == false) { log(LogLevel::DEBUG, "[Countly][endSession] There is no active session to end."); return true; } From 80b27e96309a6b7193d07d889b846ee78f907472 Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray Date: Thu, 4 Dec 2025 15:49:34 +0300 Subject: [PATCH 2/5] feat: chnagelog for it --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23a645c..5e9b0c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## XX.XX.XX +- Events are automatically packed on user properties now. This bevavior could be reversed with "Countly::disableAutoEventsOnUserProperties". + ## 23.2.3 - Mitigated an issue where the new device ID was used when ending a session if device ID was changed without merging. From c474f1fa0816f4fd5c908aa7e95264656978156d Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray <57103426+arifBurakDemiray@users.noreply.github.com> Date: Tue, 9 Dec 2025 11:35:39 +0300 Subject: [PATCH 3/5] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e9b0c0..c71c008 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## XX.XX.XX -- Events are automatically packed on user properties now. This bevavior could be reversed with "Countly::disableAutoEventsOnUserProperties". +- Events are automatically packed on user properties now. ## 23.2.3 - Mitigated an issue where the new device ID was used when ending a session if device ID was changed without merging. From 52c40c853ef84eda21349a69e2323549b3b27ee2 Mon Sep 17 00:00:00 2001 From: turtledreams <62231246+turtledreams@users.noreply.github.com> Date: Tue, 9 Dec 2025 17:42:57 +0900 Subject: [PATCH 4/5] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c71c008..bf68688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## XX.XX.XX -- Events are automatically packed on user properties now. +- Mitigated an issue where cached events were not queued when a user property was recorded. ## 23.2.3 - Mitigated an issue where the new device ID was used when ending a session if device ID was changed without merging. From 4e637d57823bd1b8b4b2ea1154438f92ba134b04 Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray Date: Wed, 10 Dec 2025 17:53:09 +0300 Subject: [PATCH 5/5] feat: 23.2.4 --- CHANGELOG.md | 2 +- include/countly/constants.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf68688..6c1bf66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## XX.XX.XX +## 23.2.4 - Mitigated an issue where cached events were not queued when a user property was recorded. ## 23.2.3 diff --git a/include/countly/constants.hpp b/include/countly/constants.hpp index 5ea5367..52b436c 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.3" +#define COUNTLY_SDK_VERSION "23.2.4" #define COUNTLY_POST_THRESHOLD 2000 #define COUNTLY_KEEPALIVE_INTERVAL 3000 #define COUNTLY_MAX_EVENTS_DEFAULT 200