@@ -142,6 +142,20 @@ void Countly::enableManualSessionControl() {
142142 mutex->unlock ();
143143}
144144
145+ /* *
146+ * Disable automatic events on user properties changes.
147+ */
148+ void Countly::disableAutoEventsOnUserProperties () {
149+ if (is_sdk_initialized) {
150+ log (LogLevel::WARNING, " [Countly][disableAutoEventsOnUserProperties] You can not disable automatic events on user properties after SDK initialization." );
151+ return ;
152+ }
153+
154+ mutex->lock ();
155+ configuration->autoEventsOnUserProperties = false ;
156+ mutex->unlock ();
157+ }
158+
145159void 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) {
146160 if (is_sdk_initialized) {
147161 log (LogLevel::WARNING, " [Countly][setMetrics] You can not set metrics after SDK initialization." );
@@ -182,6 +196,12 @@ void Countly::setUserDetails(const std::map<std::string, std::string> &value) {
182196 return ;
183197 }
184198
199+ if (configuration->autoEventsOnUserProperties == true ) {
200+ mutex->unlock ();
201+ flushEvents ();
202+ mutex->lock ();
203+ }
204+
185205 std::map<std::string, std::string> data = {{" app_key" , session_params[" app_key" ].get <std::string>()}, {" device_id" , session_params[" device_id" ].get <std::string>()}, {" user_details" , session_params[" user_details" ].dump ()}};
186206
187207 requestModule->addRequestToQueue (data);
@@ -198,6 +218,12 @@ void Countly::setCustomUserDetails(const std::map<std::string, std::string> &val
198218 return ;
199219 }
200220
221+ if (configuration->autoEventsOnUserProperties == true ) {
222+ mutex->unlock ();
223+ flushEvents ();
224+ mutex->lock ();
225+ }
226+
201227 std::map<std::string, std::string> data = {{" app_key" , session_params[" app_key" ].get <std::string>()}, {" device_id" , session_params[" device_id" ].get <std::string>()}, {" user_details" , session_params[" user_details" ].dump ()}};
202228 requestModule->addRequestToQueue (data);
203229
@@ -345,7 +371,7 @@ void Countly::_changeDeviceIdWithoutMerge(const std::string &value) {
345371
346372 // send all event to server and end current session of old user
347373 flushEvents ();
348- if (configuration->manualSessionControl == false ){
374+ if (configuration->manualSessionControl == false ) {
349375 endSession ();
350376 }
351377
@@ -355,10 +381,9 @@ void Countly::_changeDeviceIdWithoutMerge(const std::string &value) {
355381 mutex->unlock ();
356382
357383 // start a new session for new user
358- if (configuration->manualSessionControl == false ){
384+ if (configuration->manualSessionControl == false ) {
359385 beginSession ();
360386 }
361-
362387}
363388#pragma endregion Device Id
364389
@@ -439,7 +464,7 @@ void Countly::start(const std::string &app_key, const std::string &host, int por
439464
440465 if (!running) {
441466
442- if (configuration->manualSessionControl == false ){
467+ if (configuration->manualSessionControl == false ) {
443468 mutex->unlock ();
444469 beginSession ();
445470 mutex->lock ();
@@ -612,7 +637,7 @@ bool Countly::attemptSessionUpdateEQ() {
612637 return false ;
613638 }
614639#endif
615- if (configuration->manualSessionControl == false ){
640+ if (configuration->manualSessionControl == false ) {
616641 return !updateSession ();
617642 } else {
618643 packEvents ();
@@ -735,7 +760,7 @@ bool Countly::updateSession() {
735760 mutex->lock ();
736761 if (began_session == false ) {
737762 mutex->unlock ();
738- if (configuration->manualSessionControl == true ){
763+ if (configuration->manualSessionControl == true ) {
739764 log (LogLevel::WARNING, " [Countly][updateSession] SDK is in manual session control mode and there is no active session. Please start a session first." );
740765 return false ;
741766 }
@@ -829,7 +854,7 @@ void Countly::packEvents() {
829854 } else {
830855 log (LogLevel::DEBUG, " [Countly][packEvents] EQ empty." );
831856 }
832- // report events if there are any to request queue
857+ // report events if there are any to request queue
833858 if (!no_events) {
834859 sendEventsToRQ (events);
835860 }
@@ -852,7 +877,6 @@ void Countly::packEvents() {
852877 mutex->unlock ();
853878}
854879
855-
856880void Countly::sendEventsToRQ (const nlohmann::json &events) {
857881 log (LogLevel::DEBUG, " [Countly][sendEventsToRQ] Sending events to RQ." );
858882 std::map<std::string, std::string> data = {{" app_key" , session_params[" app_key" ].get <std::string>()}, {" device_id" , session_params[" device_id" ].get <std::string>()}, {" events" , events.dump ()}};
@@ -861,7 +885,7 @@ void Countly::sendEventsToRQ(const nlohmann::json &events) {
861885
862886bool Countly::endSession () {
863887 log (LogLevel::INFO, " [Countly][endSession]" );
864- if (began_session == false ) {
888+ if (began_session == false ) {
865889 log (LogLevel::DEBUG, " [Countly][endSession] There is no active session to end." );
866890 return true ;
867891 }
0 commit comments