@@ -415,8 +415,6 @@ bool Countly::beginSession() {
415415}
416416
417417bool Countly::updateSession () {
418- log (Countly::LogLevel::INFO, " [Countly][updateSession]" );
419-
420418 mutex.lock ();
421419 if (!began_session) {
422420 mutex.unlock ();
@@ -484,7 +482,23 @@ bool Countly::updateSession() {
484482 auto duration = std::chrono::duration_cast<std::chrono::seconds>(getSessionDuration ());
485483 mutex.lock ();
486484
485+ if (duration.count () * 1000 >= COUNTLY_KEEPALIVE_INTERVAL) {
486+ log (Countly::LogLevel::DEBUG, " [Countly][updateSession] sending session update." );
487+ std::map<std::string, std::string> data = {
488+ {" app_key" , session_params[" app_key" ].get <std::string>()},
489+ {" device_id" , session_params[" device_id" ].get <std::string>()},
490+ {" session_duration" , std::to_string (duration.count ())}
491+ };
492+ if (!sendHTTP (" /i" , Countly::serializeForm (data)).success ) {
493+ mutex.unlock ();
494+ return false ;
495+ }
496+
497+ last_sent_session_request += duration;
498+ }
499+
487500 if (!no_events) {
501+ log (Countly::LogLevel::DEBUG, " [Countly][updateSession] sending event." );
488502 std::map<std::string, std::string> data = {
489503 {" app_key" , session_params[" app_key" ].get <std::string>()},
490504 {" device_id" , session_params[" device_id" ].get <std::string>()},
@@ -497,18 +511,6 @@ bool Countly::updateSession() {
497511 }
498512 }
499513
500- std::map<std::string, std::string> data = {
501- {" app_key" , session_params[" app_key" ].get <std::string>()},
502- {" device_id" , session_params[" device_id" ].get <std::string>()},
503- {" session_duration" , std::to_string (duration.count ())}
504- };
505- if (!sendHTTP (" /i" , Countly::serializeForm (data)).success ) {
506- mutex.unlock ();
507- return false ;
508- }
509-
510- last_sent_session_request += duration;
511-
512514#ifndef COUNTLY_USE_SQLITE
513515 event_queue.clear ();
514516#else
0 commit comments