diff --git a/analytics/src/analytics_desktop.cc b/analytics/src/analytics_desktop.cc index 1a1df7a480..880c3936a9 100644 --- a/analytics/src/analytics_desktop.cc +++ b/analytics/src/analytics_desktop.cc @@ -411,8 +411,7 @@ LogLevel ConvertAnalyticsLogLevelToFirebaseLogLevel( } } -void GoogleAnalyticsWrapperLogCallback(GoogleAnalytics_LogLevel log_level, - const char* message) { +void GoogleAnalyticsWrapperLogCallback(int32_t log_level, const char* message) { LogCallback callback_to_call; { @@ -421,8 +420,8 @@ void GoogleAnalyticsWrapperLogCallback(GoogleAnalytics_LogLevel log_level, } if (callback_to_call) { - LogLevel firebase_log_level = - ConvertAnalyticsLogLevelToFirebaseLogLevel(log_level); + LogLevel firebase_log_level = ConvertAnalyticsLogLevelToFirebaseLogLevel( + static_cast(log_level)); callback_to_call(firebase_log_level, message); } } diff --git a/analytics/src/analytics_desktop_dynamic.c b/analytics/src/analytics_desktop_dynamic.c index 2385d13011..bd84385601 100644 --- a/analytics/src/analytics_desktop_dynamic.c +++ b/analytics/src/analytics_desktop_dynamic.c @@ -33,11 +33,12 @@ const char* FirebaseAnalytics_KnownWindowsDllHashes[] = { "c1b9ff6e9119c30bbeb7472326dcde418f45682e6b822e25eed922fe6e3cc698", "13ae5f9349b24186f1f3667b52832076e8d14ad9656c3546b1b7fca79ac8144b", "3f1fb1bb21bce0061c4b89bb674d3b6c94eaea2c8de98802198a35ea94c97900", - "1e944cd4a2b8d115a32d01f4cc900f23805934b5587b55305df9cd189f9d78d5" + "1e944cd4a2b8d115a32d01f4cc900f23805934b5587b55305df9cd189f9d78d5", + "496a9f262836523a7e5db097b2b663f9875eab36e010343d9b967bfa9eef567d" }; // Count of known Google Analytics Windows DLL SHA256 hashes. -const int FirebaseAnalytics_KnownWindowsDllHashCount = 4; +const int FirebaseAnalytics_KnownWindowsDllHashCount = 5; #endif // defined(_WIN32) // --- Stub Function Definitions --- diff --git a/analytics/src/analytics_desktop_dynamic.h b/analytics/src/analytics_desktop_dynamic.h index ca41908880..b7aad18d98 100644 --- a/analytics/src/analytics_desktop_dynamic.h +++ b/analytics/src/analytics_desktop_dynamic.h @@ -113,7 +113,7 @@ typedef enum GoogleAnalytics_LogLevel { * * @param[in] message The log message string. */ -typedef void (*GoogleAnalytics_LogCallback)(GoogleAnalytics_LogLevel log_level, +typedef void (*GoogleAnalytics_LogCallback)(int32_t log_level, const char* message); /** diff --git a/analytics/windows/google_analytics.dll b/analytics/windows/google_analytics.dll index f24ff4a379..9c62a9cd87 100644 Binary files a/analytics/windows/google_analytics.dll and b/analytics/windows/google_analytics.dll differ diff --git a/analytics/windows/include/public/analytics.h b/analytics/windows/include/public/analytics.h index df55c7dcdb..72f88815ee 100644 --- a/analytics/windows/include/public/analytics.h +++ b/analytics/windows/include/public/analytics.h @@ -132,6 +132,15 @@ class Analytics { * The path must pre-exist and the app has read and write access to it. */ std::optional app_data_directory; + /** + * @brief The duration of inactivity in seconds after which a session + * terminates. + * + * If a user interacts with the app after this timeout period, a new session + * is initiated. If this field is not set or a negative value is + * provided, the SDK's default timeout duration is used. + */ + std::optional session_timeout_duration_seconds; }; /** @@ -169,6 +178,8 @@ class Analytics { options.app_data_directory.value_or("").empty() ? nullptr : options.app_data_directory.value().c_str(); + google_analytics_options->session_timeout_duration_seconds = + options.session_timeout_duration_seconds.value_or(-1); return GoogleAnalytics_Initialize(google_analytics_options); } @@ -373,35 +384,49 @@ class Analytics { return; } - GoogleAnalytics_SetLogCallback( - [](GoogleAnalytics_LogLevel log_level, const char* message) { - LogLevel cpp_log_level; - switch (log_level) { - case GoogleAnalytics_LogLevel_kDebug: - cpp_log_level = LogLevel::kDebug; - break; - case GoogleAnalytics_LogLevel_kInfo: - cpp_log_level = LogLevel::kInfo; - break; - case GoogleAnalytics_LogLevel_kWarning: - cpp_log_level = LogLevel::kWarning; - break; - case GoogleAnalytics_LogLevel_kError: - cpp_log_level = LogLevel::kError; - break; - default: - cpp_log_level = LogLevel::kInfo; - } - LogCallback local_callback; - Analytics& self = Analytics::GetInstance(); - { - std::lock_guard lock(self.mutex_); - local_callback = self.current_callback_; - } - if (local_callback) { - local_callback(cpp_log_level, std::string(message)); - } - }); + GoogleAnalytics_SetLogCallback([](int32_t log_level, const char* message) { + LogLevel cpp_log_level; + switch (log_level) { + case GoogleAnalytics_LogLevel_kDebug: + cpp_log_level = LogLevel::kDebug; + break; + case GoogleAnalytics_LogLevel_kInfo: + cpp_log_level = LogLevel::kInfo; + break; + case GoogleAnalytics_LogLevel_kWarning: + cpp_log_level = LogLevel::kWarning; + break; + case GoogleAnalytics_LogLevel_kError: + cpp_log_level = LogLevel::kError; + break; + default: + cpp_log_level = LogLevel::kInfo; + } + LogCallback local_callback; + Analytics& self = Analytics::GetInstance(); + { + std::lock_guard lock(self.mutex_); + local_callback = self.current_callback_; + } + if (local_callback) { + local_callback(cpp_log_level, std::string(message)); + } + }); + } + + /** + * @brief Sets the duration of inactivity in seconds after which a session + * terminates. + * + * If a user interacts with the app after this timeout period, a new session + * is initiated. If set to a negative value, the value is ignored. The default + * value is 1800 seconds (30 minutes). + * + * @param[in] session_timeout_duration_seconds The session timeout duration in + * seconds. + */ + void SetSessionTimeoutInterval(int64_t session_timeout_duration_seconds) { + GoogleAnalytics_SetSessionTimeoutInterval(session_timeout_duration_seconds); } /** diff --git a/analytics/windows/include/public/c/analytics.h b/analytics/windows/include/public/c/analytics.h index 2bdc1d6d90..e0ddc79148 100644 --- a/analytics/windows/include/public/c/analytics.h +++ b/analytics/windows/include/public/c/analytics.h @@ -82,6 +82,16 @@ typedef struct ANALYTICS_API GoogleAnalytics_Options { */ const char* app_data_directory; + /** + * @brief The duration of inactivity in seconds after which a session + * terminates. + * + * If a user interacts with the app after this timeout period, + * a new session is initiated. If set to a negative value, the SDK's + * default timeout duration is used. + */ + int64_t session_timeout_duration_seconds; + /** * @brief Reserved for internal use by the SDK. */ @@ -137,9 +147,15 @@ typedef enum GoogleAnalytics_LogLevel { /** * @brief Function pointer type for a log callback. * - * @param[in] message The log message string. + * @param[in] message The log message string. Pass a value from the + * #GoogleAnalytics_LogLevel enum. + * + * @note The parameters are defined as `int32_t` to ensure ABI stability across + * different compilers, but callers should use the enum constants directly. + * + * @see GoogleAnalytics_LogLevel */ -typedef void (*GoogleAnalytics_LogCallback)(GoogleAnalytics_LogLevel log_level, +typedef void (*GoogleAnalytics_LogCallback)(int32_t log_level, const char* message); /** @@ -525,6 +541,20 @@ ANALYTICS_API void GoogleAnalytics_SetAnalyticsCollectionEnabled(bool enabled); ANALYTICS_API void GoogleAnalytics_SetLogCallback( GoogleAnalytics_LogCallback callback); +/** + * @brief Sets the duration of inactivity in seconds after which a session + * terminates. + * + * If a user interacts with the app after this timeout period, a new session is + * initiated. If set to a negative value, the value is ignored. The default + * value is 1800 seconds (30 minutes). + * + * @param[in] session_timeout_duration_seconds The session timeout duration in + * seconds. + */ +ANALYTICS_API void GoogleAnalytics_SetSessionTimeoutInterval( + int64_t session_timeout_duration_seconds); + /** * @brief Notifies the current state of the app's lifecycle. * @@ -537,10 +567,15 @@ ANALYTICS_API void GoogleAnalytics_SetLogCallback( * data is uploaded or an error occurs. The caller must ensure the OS does not * terminate background threads before the call returns. * - * @param[in] state The current state of the app's lifecycle. + * @param[in] state The current state of the app's lifecycle. Pass a value from + * the #GoogleAnalytics_AppLifecycleState enum. + * + * @note The parameters are defined as `int32_t` to ensure ABI stability across + * different compilers, but callers should use the enum constants directly. + * + * @see GoogleAnalytics_AppLifecycleState */ -ANALYTICS_API void GoogleAnalytics_NotifyAppLifecycleChange( - GoogleAnalytics_AppLifecycleState state); +ANALYTICS_API void GoogleAnalytics_NotifyAppLifecycleChange(int32_t state); #ifdef __cplusplus } diff --git a/analytics/windows/known_dll_hashes.txt b/analytics/windows/known_dll_hashes.txt index 0da98fae2d..18fa3faa33 100644 --- a/analytics/windows/known_dll_hashes.txt +++ b/analytics/windows/known_dll_hashes.txt @@ -1,4 +1,5 @@ c1b9ff6e9119c30bbeb7472326dcde418f45682e6b822e25eed922fe6e3cc698 13ae5f9349b24186f1f3667b52832076e8d14ad9656c3546b1b7fca79ac8144b 3f1fb1bb21bce0061c4b89bb674d3b6c94eaea2c8de98802198a35ea94c97900 -1e944cd4a2b8d115a32d01f4cc900f23805934b5587b55305df9cd189f9d78d5 \ No newline at end of file +1e944cd4a2b8d115a32d01f4cc900f23805934b5587b55305df9cd189f9d78d5 +496a9f262836523a7e5db097b2b663f9875eab36e010343d9b967bfa9eef567d