diff --git a/.gitignore b/.gitignore index 9b0a74e964..c9f17024f1 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ __pycache__/ ### IDE generated files .vscode/ +**/.vs/ # Unencrypted secret files google-services.json diff --git a/analytics/generate_windows_stubs.py b/analytics/generate_windows_stubs.py index 0b7f7f0db3..4c9dd9cef8 100755 --- a/analytics/generate_windows_stubs.py +++ b/analytics/generate_windows_stubs.py @@ -262,7 +262,7 @@ def generate_function_pointers(dll_file_path, header_file_path, output_h_path, o ) parser.add_argument( "--windows_dll", - default = os.path.join(os.path.dirname(sys.argv[0]), "windows/analytics_win.dll"), + default = os.path.join(os.path.dirname(sys.argv[0]), "windows/google_analytics.dll"), help="Path to the DLL file to calculate a hash." ) parser.add_argument( diff --git a/analytics/integration_test/CMakeLists.txt b/analytics/integration_test/CMakeLists.txt index 3a91d28c84..fddfc0ec58 100644 --- a/analytics/integration_test/CMakeLists.txt +++ b/analytics/integration_test/CMakeLists.txt @@ -211,7 +211,7 @@ else() ) elseif(MSVC) set(ADDITIONAL_LIBS advapi32 ws2_32 crypt32) - set(ANALYTICS_WINDOWS_DLL "${FIREBASE_CPP_SDK_DIR}/analytics/windows/analytics_win.dll") + set(ANALYTICS_WINDOWS_DLL "${FIREBASE_CPP_SDK_DIR}/analytics/windows/google_analytics.dll") # For Windows, check if the Analytics DLL exists, and copy it in if so. if (EXISTS "${ANALYTICS_WINDOWS_DLL}") diff --git a/analytics/integration_test/src/integration_test.cc b/analytics/integration_test/src/integration_test.cc index bedccee516..16aa9a1be6 100644 --- a/analytics/integration_test/src/integration_test.cc +++ b/analytics/integration_test/src/integration_test.cc @@ -259,6 +259,14 @@ TEST_F(FirebaseAnalyticsTest, TestLogEvents) { "spoon_welders"); } +TEST_F(FirebaseAnalyticsTest, TestNotifyAppLifecycleChange) { + // Can't confirm that these do anything but just run them all to ensure the + // app doesn't crash. + firebase::analytics::NotifyAppLifecycleChange(firebase::analytics::kUnknown); + firebase::analytics::NotifyAppLifecycleChange( + firebase::analytics::kTermination); +} + TEST_F(FirebaseAnalyticsTest, TestLogEventWithMultipleParameters) { const firebase::analytics::Parameter kLevelUpParameters[] = { firebase::analytics::Parameter(firebase::analytics::kParameterLevel, 5), diff --git a/analytics/src/analytics_desktop.cc b/analytics/src/analytics_desktop.cc index 24f7effb79..e7c3fc58d1 100644 --- a/analytics/src/analytics_desktop.cc +++ b/analytics/src/analytics_desktop.cc @@ -36,7 +36,7 @@ namespace firebase { namespace analytics { #if defined(_WIN32) -#define ANALYTICS_DLL_FILENAME L"analytics_win.dll" +#define ANALYTICS_DLL_FILENAME L"google_analytics.dll" static HMODULE g_analytics_module = 0; #endif // defined(_WIN32) @@ -134,6 +134,10 @@ bool IsInitialized() { return g_initialized; } void Terminate() { #if defined(_WIN32) if (g_analytics_module) { + // Make sure to notify the SDK that the analytics is being terminated to + // upload any pending data. + NotifyAppLifecycleChange(AppLifecycleState::kTermination); + FirebaseAnalytics_UnloadDynamicFunctions(); FreeLibrary(g_analytics_module); g_analytics_module = 0; @@ -381,6 +385,13 @@ void ResetAnalyticsData() { g_fake_instance_id++; } +// Notify the Analytics SDK about the current state of the app's lifecycle. +void NotifyAppLifecycleChange(AppLifecycleState state) { + FIREBASE_ASSERT_RETURN_VOID(internal::IsInitialized()); + GoogleAnalytics_NotifyAppLifecycleChange( + static_cast(state)); +} + // Overloaded versions of LogEvent for convenience. void LogEvent(const char* name) { diff --git a/analytics/src/analytics_desktop_dynamic.c b/analytics/src/analytics_desktop_dynamic.c index dec496ba40..fcbef558a1 100644 --- a/analytics/src/analytics_desktop_dynamic.c +++ b/analytics/src/analytics_desktop_dynamic.c @@ -25,17 +25,18 @@ static char g_stub_memory[256] = {0}; // clang-format off // Number of Google Analytics functions expected to be loaded from the DLL. -const int FirebaseAnalytics_DynamicFunctionCount = 22; +const int FirebaseAnalytics_DynamicFunctionCount = 24; #if defined(_WIN32) // Array of known Google Analytics Windows DLL SHA256 hashes (hex strings). const char* FirebaseAnalytics_KnownWindowsDllHashes[] = { "c1b9ff6e9119c30bbeb7472326dcde418f45682e6b822e25eed922fe6e3cc698", - "13ae5f9349b24186f1f3667b52832076e8d14ad9656c3546b1b7fca79ac8144b" + "13ae5f9349b24186f1f3667b52832076e8d14ad9656c3546b1b7fca79ac8144b", + "3f1fb1bb21bce0061c4b89bb674d3b6c94eaea2c8de98802198a35ea94c97900" }; // Count of known Google Analytics Windows DLL SHA256 hashes. -const int FirebaseAnalytics_KnownWindowsDllHashCount = 2; +const int FirebaseAnalytics_KnownWindowsDllHashCount = 3; #endif // defined(_WIN32) // --- Stub Function Definitions --- @@ -55,24 +56,24 @@ static GoogleAnalytics_Item* Stub_GoogleAnalytics_Item_Create() { } // Stub for GoogleAnalytics_Item_InsertInt -static void Stub_GoogleAnalytics_Item_InsertInt(GoogleAnalytics_Item* item, +static bool Stub_GoogleAnalytics_Item_InsertInt(GoogleAnalytics_Item* item, const char* key, int64_t value) { - // No return value. + return 1; } // Stub for GoogleAnalytics_Item_InsertDouble -static void Stub_GoogleAnalytics_Item_InsertDouble(GoogleAnalytics_Item* item, +static bool Stub_GoogleAnalytics_Item_InsertDouble(GoogleAnalytics_Item* item, const char* key, double value) { - // No return value. + return 1; } // Stub for GoogleAnalytics_Item_InsertString -static void Stub_GoogleAnalytics_Item_InsertString(GoogleAnalytics_Item* item, +static bool Stub_GoogleAnalytics_Item_InsertString(GoogleAnalytics_Item* item, const char* key, const char* value) { - // No return value. + return 1; } // Stub for GoogleAnalytics_Item_Destroy @@ -86,8 +87,8 @@ static GoogleAnalytics_ItemVector* Stub_GoogleAnalytics_ItemVector_Create() { } // Stub for GoogleAnalytics_ItemVector_InsertItem -static void Stub_GoogleAnalytics_ItemVector_InsertItem(GoogleAnalytics_ItemVector* item_vector, GoogleAnalytics_Item* item) { - // No return value. +static bool Stub_GoogleAnalytics_ItemVector_InsertItem(GoogleAnalytics_ItemVector* item_vector, GoogleAnalytics_Item* item) { + return 1; } // Stub for GoogleAnalytics_ItemVector_Destroy @@ -101,27 +102,27 @@ static GoogleAnalytics_EventParameters* Stub_GoogleAnalytics_EventParameters_Cre } // Stub for GoogleAnalytics_EventParameters_InsertInt -static void Stub_GoogleAnalytics_EventParameters_InsertInt(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, +static bool Stub_GoogleAnalytics_EventParameters_InsertInt(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, int64_t value) { - // No return value. + return 1; } // Stub for GoogleAnalytics_EventParameters_InsertDouble -static void Stub_GoogleAnalytics_EventParameters_InsertDouble(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, +static bool Stub_GoogleAnalytics_EventParameters_InsertDouble(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, double value) { - // No return value. + return 1; } // Stub for GoogleAnalytics_EventParameters_InsertString -static void Stub_GoogleAnalytics_EventParameters_InsertString(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, +static bool Stub_GoogleAnalytics_EventParameters_InsertString(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, const char* value) { - // No return value. + return 1; } // Stub for GoogleAnalytics_EventParameters_InsertItemVector -static void Stub_GoogleAnalytics_EventParameters_InsertItemVector(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, +static bool Stub_GoogleAnalytics_EventParameters_InsertItemVector(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, GoogleAnalytics_ItemVector* value) { - // No return value. + return 1; } // Stub for GoogleAnalytics_EventParameters_Destroy @@ -130,7 +131,7 @@ static void Stub_GoogleAnalytics_EventParameters_Destroy(GoogleAnalytics_EventPa } // Stub for GoogleAnalytics_Initialize -static bool Stub_GoogleAnalytics_Initialize(const GoogleAnalytics_Options* options) { +static bool Stub_GoogleAnalytics_Initialize(GoogleAnalytics_Options* options) { return 1; } @@ -160,30 +161,42 @@ static void Stub_GoogleAnalytics_SetAnalyticsCollectionEnabled(bool enabled) { // No return value. } +// Stub for GoogleAnalytics_SetLogCallback +static void Stub_GoogleAnalytics_SetLogCallback(GoogleAnalytics_LogCallback callback) { + // No return value. +} + +// Stub for GoogleAnalytics_NotifyAppLifecycleChange +static void Stub_GoogleAnalytics_NotifyAppLifecycleChange(GoogleAnalytics_AppLifecycleState state) { + // No return value. +} + // --- Function Pointer Initializations --- GoogleAnalytics_Options* (*ptr_GoogleAnalytics_Options_Create)() = &Stub_GoogleAnalytics_Options_Create; void (*ptr_GoogleAnalytics_Options_Destroy)(GoogleAnalytics_Options* options) = &Stub_GoogleAnalytics_Options_Destroy; GoogleAnalytics_Item* (*ptr_GoogleAnalytics_Item_Create)() = &Stub_GoogleAnalytics_Item_Create; -void (*ptr_GoogleAnalytics_Item_InsertInt)(GoogleAnalytics_Item* item, const char* key, int64_t value) = &Stub_GoogleAnalytics_Item_InsertInt; -void (*ptr_GoogleAnalytics_Item_InsertDouble)(GoogleAnalytics_Item* item, const char* key, double value) = &Stub_GoogleAnalytics_Item_InsertDouble; -void (*ptr_GoogleAnalytics_Item_InsertString)(GoogleAnalytics_Item* item, const char* key, const char* value) = &Stub_GoogleAnalytics_Item_InsertString; +bool (*ptr_GoogleAnalytics_Item_InsertInt)(GoogleAnalytics_Item* item, const char* key, int64_t value) = &Stub_GoogleAnalytics_Item_InsertInt; +bool (*ptr_GoogleAnalytics_Item_InsertDouble)(GoogleAnalytics_Item* item, const char* key, double value) = &Stub_GoogleAnalytics_Item_InsertDouble; +bool (*ptr_GoogleAnalytics_Item_InsertString)(GoogleAnalytics_Item* item, const char* key, const char* value) = &Stub_GoogleAnalytics_Item_InsertString; void (*ptr_GoogleAnalytics_Item_Destroy)(GoogleAnalytics_Item* item) = &Stub_GoogleAnalytics_Item_Destroy; GoogleAnalytics_ItemVector* (*ptr_GoogleAnalytics_ItemVector_Create)() = &Stub_GoogleAnalytics_ItemVector_Create; -void (*ptr_GoogleAnalytics_ItemVector_InsertItem)(GoogleAnalytics_ItemVector* item_vector, GoogleAnalytics_Item* item) = &Stub_GoogleAnalytics_ItemVector_InsertItem; +bool (*ptr_GoogleAnalytics_ItemVector_InsertItem)(GoogleAnalytics_ItemVector* item_vector, GoogleAnalytics_Item* item) = &Stub_GoogleAnalytics_ItemVector_InsertItem; void (*ptr_GoogleAnalytics_ItemVector_Destroy)(GoogleAnalytics_ItemVector* item_vector) = &Stub_GoogleAnalytics_ItemVector_Destroy; GoogleAnalytics_EventParameters* (*ptr_GoogleAnalytics_EventParameters_Create)() = &Stub_GoogleAnalytics_EventParameters_Create; -void (*ptr_GoogleAnalytics_EventParameters_InsertInt)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, int64_t value) = &Stub_GoogleAnalytics_EventParameters_InsertInt; -void (*ptr_GoogleAnalytics_EventParameters_InsertDouble)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, double value) = &Stub_GoogleAnalytics_EventParameters_InsertDouble; -void (*ptr_GoogleAnalytics_EventParameters_InsertString)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, const char* value) = &Stub_GoogleAnalytics_EventParameters_InsertString; -void (*ptr_GoogleAnalytics_EventParameters_InsertItemVector)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, GoogleAnalytics_ItemVector* value) = &Stub_GoogleAnalytics_EventParameters_InsertItemVector; +bool (*ptr_GoogleAnalytics_EventParameters_InsertInt)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, int64_t value) = &Stub_GoogleAnalytics_EventParameters_InsertInt; +bool (*ptr_GoogleAnalytics_EventParameters_InsertDouble)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, double value) = &Stub_GoogleAnalytics_EventParameters_InsertDouble; +bool (*ptr_GoogleAnalytics_EventParameters_InsertString)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, const char* value) = &Stub_GoogleAnalytics_EventParameters_InsertString; +bool (*ptr_GoogleAnalytics_EventParameters_InsertItemVector)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, GoogleAnalytics_ItemVector* value) = &Stub_GoogleAnalytics_EventParameters_InsertItemVector; void (*ptr_GoogleAnalytics_EventParameters_Destroy)(GoogleAnalytics_EventParameters* event_parameter_map) = &Stub_GoogleAnalytics_EventParameters_Destroy; -bool (*ptr_GoogleAnalytics_Initialize)(const GoogleAnalytics_Options* options) = &Stub_GoogleAnalytics_Initialize; +bool (*ptr_GoogleAnalytics_Initialize)(GoogleAnalytics_Options* options) = &Stub_GoogleAnalytics_Initialize; void (*ptr_GoogleAnalytics_LogEvent)(const char* name, GoogleAnalytics_EventParameters* parameters) = &Stub_GoogleAnalytics_LogEvent; void (*ptr_GoogleAnalytics_SetUserProperty)(const char* name, const char* value) = &Stub_GoogleAnalytics_SetUserProperty; void (*ptr_GoogleAnalytics_SetUserId)(const char* user_id) = &Stub_GoogleAnalytics_SetUserId; void (*ptr_GoogleAnalytics_ResetAnalyticsData)() = &Stub_GoogleAnalytics_ResetAnalyticsData; void (*ptr_GoogleAnalytics_SetAnalyticsCollectionEnabled)(bool enabled) = &Stub_GoogleAnalytics_SetAnalyticsCollectionEnabled; +void (*ptr_GoogleAnalytics_SetLogCallback)(GoogleAnalytics_LogCallback callback) = &Stub_GoogleAnalytics_SetLogCallback; +void (*ptr_GoogleAnalytics_NotifyAppLifecycleChange)(GoogleAnalytics_AppLifecycleState state) = &Stub_GoogleAnalytics_NotifyAppLifecycleChange; // --- Dynamic Loader Function for Windows --- #if defined(_WIN32) @@ -211,17 +224,17 @@ int FirebaseAnalytics_LoadDynamicFunctions(HMODULE dll_handle) { } FARPROC proc_GoogleAnalytics_Item_InsertInt = GetProcAddress(dll_handle, "GoogleAnalytics_Item_InsertInt"); if (proc_GoogleAnalytics_Item_InsertInt) { - ptr_GoogleAnalytics_Item_InsertInt = (void (*)(GoogleAnalytics_Item* item, const char* key, int64_t value))proc_GoogleAnalytics_Item_InsertInt; + ptr_GoogleAnalytics_Item_InsertInt = (bool (*)(GoogleAnalytics_Item* item, const char* key, int64_t value))proc_GoogleAnalytics_Item_InsertInt; count++; } FARPROC proc_GoogleAnalytics_Item_InsertDouble = GetProcAddress(dll_handle, "GoogleAnalytics_Item_InsertDouble"); if (proc_GoogleAnalytics_Item_InsertDouble) { - ptr_GoogleAnalytics_Item_InsertDouble = (void (*)(GoogleAnalytics_Item* item, const char* key, double value))proc_GoogleAnalytics_Item_InsertDouble; + ptr_GoogleAnalytics_Item_InsertDouble = (bool (*)(GoogleAnalytics_Item* item, const char* key, double value))proc_GoogleAnalytics_Item_InsertDouble; count++; } FARPROC proc_GoogleAnalytics_Item_InsertString = GetProcAddress(dll_handle, "GoogleAnalytics_Item_InsertString"); if (proc_GoogleAnalytics_Item_InsertString) { - ptr_GoogleAnalytics_Item_InsertString = (void (*)(GoogleAnalytics_Item* item, const char* key, const char* value))proc_GoogleAnalytics_Item_InsertString; + ptr_GoogleAnalytics_Item_InsertString = (bool (*)(GoogleAnalytics_Item* item, const char* key, const char* value))proc_GoogleAnalytics_Item_InsertString; count++; } FARPROC proc_GoogleAnalytics_Item_Destroy = GetProcAddress(dll_handle, "GoogleAnalytics_Item_Destroy"); @@ -236,7 +249,7 @@ int FirebaseAnalytics_LoadDynamicFunctions(HMODULE dll_handle) { } FARPROC proc_GoogleAnalytics_ItemVector_InsertItem = GetProcAddress(dll_handle, "GoogleAnalytics_ItemVector_InsertItem"); if (proc_GoogleAnalytics_ItemVector_InsertItem) { - ptr_GoogleAnalytics_ItemVector_InsertItem = (void (*)(GoogleAnalytics_ItemVector* item_vector, GoogleAnalytics_Item* item))proc_GoogleAnalytics_ItemVector_InsertItem; + ptr_GoogleAnalytics_ItemVector_InsertItem = (bool (*)(GoogleAnalytics_ItemVector* item_vector, GoogleAnalytics_Item* item))proc_GoogleAnalytics_ItemVector_InsertItem; count++; } FARPROC proc_GoogleAnalytics_ItemVector_Destroy = GetProcAddress(dll_handle, "GoogleAnalytics_ItemVector_Destroy"); @@ -251,22 +264,22 @@ int FirebaseAnalytics_LoadDynamicFunctions(HMODULE dll_handle) { } FARPROC proc_GoogleAnalytics_EventParameters_InsertInt = GetProcAddress(dll_handle, "GoogleAnalytics_EventParameters_InsertInt"); if (proc_GoogleAnalytics_EventParameters_InsertInt) { - ptr_GoogleAnalytics_EventParameters_InsertInt = (void (*)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, int64_t value))proc_GoogleAnalytics_EventParameters_InsertInt; + ptr_GoogleAnalytics_EventParameters_InsertInt = (bool (*)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, int64_t value))proc_GoogleAnalytics_EventParameters_InsertInt; count++; } FARPROC proc_GoogleAnalytics_EventParameters_InsertDouble = GetProcAddress(dll_handle, "GoogleAnalytics_EventParameters_InsertDouble"); if (proc_GoogleAnalytics_EventParameters_InsertDouble) { - ptr_GoogleAnalytics_EventParameters_InsertDouble = (void (*)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, double value))proc_GoogleAnalytics_EventParameters_InsertDouble; + ptr_GoogleAnalytics_EventParameters_InsertDouble = (bool (*)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, double value))proc_GoogleAnalytics_EventParameters_InsertDouble; count++; } FARPROC proc_GoogleAnalytics_EventParameters_InsertString = GetProcAddress(dll_handle, "GoogleAnalytics_EventParameters_InsertString"); if (proc_GoogleAnalytics_EventParameters_InsertString) { - ptr_GoogleAnalytics_EventParameters_InsertString = (void (*)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, const char* value))proc_GoogleAnalytics_EventParameters_InsertString; + ptr_GoogleAnalytics_EventParameters_InsertString = (bool (*)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, const char* value))proc_GoogleAnalytics_EventParameters_InsertString; count++; } FARPROC proc_GoogleAnalytics_EventParameters_InsertItemVector = GetProcAddress(dll_handle, "GoogleAnalytics_EventParameters_InsertItemVector"); if (proc_GoogleAnalytics_EventParameters_InsertItemVector) { - ptr_GoogleAnalytics_EventParameters_InsertItemVector = (void (*)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, GoogleAnalytics_ItemVector* value))proc_GoogleAnalytics_EventParameters_InsertItemVector; + ptr_GoogleAnalytics_EventParameters_InsertItemVector = (bool (*)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, GoogleAnalytics_ItemVector* value))proc_GoogleAnalytics_EventParameters_InsertItemVector; count++; } FARPROC proc_GoogleAnalytics_EventParameters_Destroy = GetProcAddress(dll_handle, "GoogleAnalytics_EventParameters_Destroy"); @@ -276,7 +289,7 @@ int FirebaseAnalytics_LoadDynamicFunctions(HMODULE dll_handle) { } FARPROC proc_GoogleAnalytics_Initialize = GetProcAddress(dll_handle, "GoogleAnalytics_Initialize"); if (proc_GoogleAnalytics_Initialize) { - ptr_GoogleAnalytics_Initialize = (bool (*)(const GoogleAnalytics_Options* options))proc_GoogleAnalytics_Initialize; + ptr_GoogleAnalytics_Initialize = (bool (*)(GoogleAnalytics_Options* options))proc_GoogleAnalytics_Initialize; count++; } FARPROC proc_GoogleAnalytics_LogEvent = GetProcAddress(dll_handle, "GoogleAnalytics_LogEvent"); @@ -304,6 +317,16 @@ int FirebaseAnalytics_LoadDynamicFunctions(HMODULE dll_handle) { ptr_GoogleAnalytics_SetAnalyticsCollectionEnabled = (void (*)(bool enabled))proc_GoogleAnalytics_SetAnalyticsCollectionEnabled; count++; } + FARPROC proc_GoogleAnalytics_SetLogCallback = GetProcAddress(dll_handle, "GoogleAnalytics_SetLogCallback"); + if (proc_GoogleAnalytics_SetLogCallback) { + ptr_GoogleAnalytics_SetLogCallback = (void (*)(GoogleAnalytics_LogCallback callback))proc_GoogleAnalytics_SetLogCallback; + count++; + } + FARPROC proc_GoogleAnalytics_NotifyAppLifecycleChange = GetProcAddress(dll_handle, "GoogleAnalytics_NotifyAppLifecycleChange"); + if (proc_GoogleAnalytics_NotifyAppLifecycleChange) { + ptr_GoogleAnalytics_NotifyAppLifecycleChange = (void (*)(GoogleAnalytics_AppLifecycleState state))proc_GoogleAnalytics_NotifyAppLifecycleChange; + count++; + } return count; } @@ -331,6 +354,8 @@ void FirebaseAnalytics_UnloadDynamicFunctions(void) { ptr_GoogleAnalytics_SetUserId = &Stub_GoogleAnalytics_SetUserId; ptr_GoogleAnalytics_ResetAnalyticsData = &Stub_GoogleAnalytics_ResetAnalyticsData; ptr_GoogleAnalytics_SetAnalyticsCollectionEnabled = &Stub_GoogleAnalytics_SetAnalyticsCollectionEnabled; + ptr_GoogleAnalytics_SetLogCallback = &Stub_GoogleAnalytics_SetLogCallback; + ptr_GoogleAnalytics_NotifyAppLifecycleChange = &Stub_GoogleAnalytics_NotifyAppLifecycleChange; } #endif // defined(_WIN32) diff --git a/analytics/src/analytics_desktop_dynamic.h b/analytics/src/analytics_desktop_dynamic.h index 55567bd1ba..3f52b4dee8 100644 --- a/analytics/src/analytics_desktop_dynamic.h +++ b/analytics/src/analytics_desktop_dynamic.h @@ -34,7 +34,7 @@ typedef struct GoogleAnalytics_Reserved_Opaque GoogleAnalytics_Reserved; * using GoogleAnalytics_Options_Create(), initialization will fail, and the * caller will be responsible for destroying the options. */ -ANALYTICS_API typedef struct { +typedef struct ANALYTICS_API GoogleAnalytics_Options { /** * @brief The unique identifier for the Firebase app across all of Firebase * with a platform-specific format. This is a required field, can not be null @@ -68,12 +68,54 @@ ANALYTICS_API typedef struct { */ bool analytics_collection_enabled_at_first_launch; + /** + * @brief An optional path to a folder where the SDK can store its data. + * If not provided, the SDK will store its data in the same folder as the + * executable. + * + * The path must pre-exist and the app has read and write access to it. + */ + const char* app_data_directory; + /** * @brief Reserved for internal use by the SDK. */ GoogleAnalytics_Reserved* reserved; } GoogleAnalytics_Options; +/** + * @brief The state of an app in its lifecycle. + */ +typedef enum GoogleAnalytics_AppLifecycleState { + /** + * @brief This is an invalid state that is used to capture unininitialized + * values. + */ + GoogleAnalytics_AppLifecycleState_kUnknown = 0, + /** + * @brief The app is about to be terminated. + */ + GoogleAnalytics_AppLifecycleState_kTermination = 1, +} GoogleAnalytics_AppLifecycleState; + +/** + * @brief The log level of a log message. + */ +typedef enum GoogleAnalytics_LogLevel { + kDebug, + kInfo, + kWarning, + kError, +} GoogleAnalytics_LogLevel; + +/** + * @brief Function pointer type for a log callback. + * + * @param[in] message The log message string. + */ +typedef void (*GoogleAnalytics_LogCallback)(GoogleAnalytics_LogLevel log_level, + const char* message); + /** * @brief Creates an instance of GoogleAnalytics_Options with default values. * @@ -149,25 +191,27 @@ extern "C" { extern GoogleAnalytics_Options* (*ptr_GoogleAnalytics_Options_Create)(); extern void (*ptr_GoogleAnalytics_Options_Destroy)(GoogleAnalytics_Options* options); extern GoogleAnalytics_Item* (*ptr_GoogleAnalytics_Item_Create)(); -extern void (*ptr_GoogleAnalytics_Item_InsertInt)(GoogleAnalytics_Item* item, const char* key, int64_t value); -extern void (*ptr_GoogleAnalytics_Item_InsertDouble)(GoogleAnalytics_Item* item, const char* key, double value); -extern void (*ptr_GoogleAnalytics_Item_InsertString)(GoogleAnalytics_Item* item, const char* key, const char* value); +extern bool (*ptr_GoogleAnalytics_Item_InsertInt)(GoogleAnalytics_Item* item, const char* key, int64_t value); +extern bool (*ptr_GoogleAnalytics_Item_InsertDouble)(GoogleAnalytics_Item* item, const char* key, double value); +extern bool (*ptr_GoogleAnalytics_Item_InsertString)(GoogleAnalytics_Item* item, const char* key, const char* value); extern void (*ptr_GoogleAnalytics_Item_Destroy)(GoogleAnalytics_Item* item); extern GoogleAnalytics_ItemVector* (*ptr_GoogleAnalytics_ItemVector_Create)(); -extern void (*ptr_GoogleAnalytics_ItemVector_InsertItem)(GoogleAnalytics_ItemVector* item_vector, GoogleAnalytics_Item* item); +extern bool (*ptr_GoogleAnalytics_ItemVector_InsertItem)(GoogleAnalytics_ItemVector* item_vector, GoogleAnalytics_Item* item); extern void (*ptr_GoogleAnalytics_ItemVector_Destroy)(GoogleAnalytics_ItemVector* item_vector); extern GoogleAnalytics_EventParameters* (*ptr_GoogleAnalytics_EventParameters_Create)(); -extern void (*ptr_GoogleAnalytics_EventParameters_InsertInt)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, int64_t value); -extern void (*ptr_GoogleAnalytics_EventParameters_InsertDouble)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, double value); -extern void (*ptr_GoogleAnalytics_EventParameters_InsertString)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, const char* value); -extern void (*ptr_GoogleAnalytics_EventParameters_InsertItemVector)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, GoogleAnalytics_ItemVector* value); +extern bool (*ptr_GoogleAnalytics_EventParameters_InsertInt)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, int64_t value); +extern bool (*ptr_GoogleAnalytics_EventParameters_InsertDouble)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, double value); +extern bool (*ptr_GoogleAnalytics_EventParameters_InsertString)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, const char* value); +extern bool (*ptr_GoogleAnalytics_EventParameters_InsertItemVector)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, GoogleAnalytics_ItemVector* value); extern void (*ptr_GoogleAnalytics_EventParameters_Destroy)(GoogleAnalytics_EventParameters* event_parameter_map); -extern bool (*ptr_GoogleAnalytics_Initialize)(const GoogleAnalytics_Options* options); +extern bool (*ptr_GoogleAnalytics_Initialize)(GoogleAnalytics_Options* options); extern void (*ptr_GoogleAnalytics_LogEvent)(const char* name, GoogleAnalytics_EventParameters* parameters); extern void (*ptr_GoogleAnalytics_SetUserProperty)(const char* name, const char* value); extern void (*ptr_GoogleAnalytics_SetUserId)(const char* user_id); extern void (*ptr_GoogleAnalytics_ResetAnalyticsData)(); extern void (*ptr_GoogleAnalytics_SetAnalyticsCollectionEnabled)(bool enabled); +extern void (*ptr_GoogleAnalytics_SetLogCallback)(GoogleAnalytics_LogCallback callback); +extern void (*ptr_GoogleAnalytics_NotifyAppLifecycleChange)(GoogleAnalytics_AppLifecycleState state); #define GoogleAnalytics_Options_Create ptr_GoogleAnalytics_Options_Create #define GoogleAnalytics_Options_Destroy ptr_GoogleAnalytics_Options_Destroy @@ -191,6 +235,8 @@ extern void (*ptr_GoogleAnalytics_SetAnalyticsCollectionEnabled)(bool enabled); #define GoogleAnalytics_SetUserId ptr_GoogleAnalytics_SetUserId #define GoogleAnalytics_ResetAnalyticsData ptr_GoogleAnalytics_ResetAnalyticsData #define GoogleAnalytics_SetAnalyticsCollectionEnabled ptr_GoogleAnalytics_SetAnalyticsCollectionEnabled +#define GoogleAnalytics_SetLogCallback ptr_GoogleAnalytics_SetLogCallback +#define GoogleAnalytics_NotifyAppLifecycleChange ptr_GoogleAnalytics_NotifyAppLifecycleChange // clang-format on // Number of Google Analytics functions expected to be loaded from the DLL. diff --git a/analytics/src/include/firebase/analytics.h b/analytics/src/include/firebase/analytics.h index 746df99894..e2e5a82856 100644 --- a/analytics/src/include/firebase/analytics.h +++ b/analytics/src/include/firebase/analytics.h @@ -558,6 +558,27 @@ void SetSessionTimeoutDuration(int64_t milliseconds); /// instance id. void ResetAnalyticsData(); +/// @brief The state of an app in its lifecycle. +/// +/// kUnknown is an invalid state that is used to capture uninitialized values. +/// kTermination is used to indicate that the app is about to be terminated. +enum AppLifecycleState { kUnknown = 0, kTermination }; + +/// @brief Notifies the current state of the app's lifecycle. +/// +/// This method is used to notify the Analytics SDK about the current state of +/// the app's lifecycle. The Analytics SDK will use this information to log +/// events, update user properties, upload data, etc. +/// +/// kTermination is used to indicate that the app is about to be terminated. +/// The caller will be blocked until all pending 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. + +void NotifyAppLifecycleChange(AppLifecycleState state); + /// Get the instance ID from the analytics service. /// /// @note This is *not* the same ID as the ID returned by diff --git a/analytics/windows/analytics_win.dll b/analytics/windows/analytics_win.dll deleted file mode 100755 index bc2725ffb7..0000000000 Binary files a/analytics/windows/analytics_win.dll and /dev/null differ diff --git a/analytics/windows/google_analytics.dll b/analytics/windows/google_analytics.dll new file mode 100644 index 0000000000..0dee614a43 Binary files /dev/null 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 1781e6e83d..35bc4fff95 100644 --- a/analytics/windows/include/public/analytics.h +++ b/analytics/windows/include/public/analytics.h @@ -1,9 +1,23 @@ // Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #ifndef ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_ANALYTICS_H_ #define ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_ANALYTICS_H_ #include +#include +#include #include #include #include @@ -33,6 +47,41 @@ class Analytics { std::variant; using EventParameters = std::unordered_map; + /** + * @brief The state of an app in its lifecycle. + */ + enum AppLifecycleState { + /** + * @brief This is an invalid state that is used to capture unininitialized + * values. + */ + kUnknown, + /** + * @brief The app is about to be terminated. + */ + kTermination, + }; + + /** + * @brief The log level of the message logged by the SDK. + */ + enum LogLevel { + kDebug, + kInfo, + kWarning, + kError, + }; + + /** + * @brief The callback type for logging messages from the SDK. + * + * The callback is invoked whenever the SDK logs a message. + * + * @param[in] log_level The log level of the message. + * @param[in] message The message logged by the SDK. + */ + using LogCallback = std::function; + /** * @brief Options for initializing the Analytics SDK. */ @@ -63,6 +112,15 @@ class Analytics { * point. */ bool analytics_collection_enabled_at_first_launch = true; + + /** + * @brief An optional path to a folder where the SDK can store its data. + * If not provided, the SDK will store its data in the same folder as the + * executable. + * + * The path must pre-exist and the app has read and write access to it. + */ + std::optional app_data_directory; }; /** @@ -96,6 +154,10 @@ class Analytics { google_analytics_options->package_name = options.package_name.c_str(); google_analytics_options->analytics_collection_enabled_at_first_launch = options.analytics_collection_enabled_at_first_launch; + google_analytics_options->app_data_directory = + options.app_data_directory.value_or("").empty() + ? nullptr + : options.app_data_directory.value().c_str(); return GoogleAnalytics_Initialize(google_analytics_options); } @@ -269,8 +331,87 @@ class Analytics { GoogleAnalytics_SetAnalyticsCollectionEnabled(enabled); } + /** + * @brief Allows the passing of a callback to be used when the SDK logs any + * messages regarding its behavior. The callback must be thread-safe. + * + * @param[in] callback The callback to use. Must be thread-safe. + */ + void SetLogCallback(LogCallback callback) { + { + std::lock_guard lock(mutex_); + current_callback_ = callback; + } + + if (!callback) { + GoogleAnalytics_SetLogCallback(nullptr); + 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)); + } + }); + } + + /** + * @brief Notifies the current state of the app's lifecycle. + * + * This method is used to notify the Analytics SDK about the current state of + * the app's lifecycle. The Analytics SDK will use this information to log + * events, update user properties, upload data, etc. + * + * kTermination is used to indicate that the app is about to be terminated. + * The caller will be blocked until all pending 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. + */ + void NotifyAppLifecycleChange(AppLifecycleState state) { + GoogleAnalytics_AppLifecycleState c_state; + switch (state) { + case AppLifecycleState::kTermination: + c_state = GoogleAnalytics_AppLifecycleState_kTermination; + break; + case AppLifecycleState::kUnknown: + default: + c_state = GoogleAnalytics_AppLifecycleState_kUnknown; + break; + } + GoogleAnalytics_NotifyAppLifecycleChange(c_state); + } + private: Analytics() = default; + + std::mutex mutex_; + LogCallback current_callback_; }; } // namespace google::analytics diff --git a/analytics/windows/include/public/c/analytics.h b/analytics/windows/include/public/c/analytics.h index dc6ddd3ceb..6b87226f20 100644 --- a/analytics/windows/include/public/c/analytics.h +++ b/analytics/windows/include/public/c/analytics.h @@ -1,4 +1,16 @@ // Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #ifndef ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_C_ANALYTICS_H_ #define ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_C_ANALYTICS_H_ @@ -25,7 +37,7 @@ typedef struct GoogleAnalytics_Reserved_Opaque GoogleAnalytics_Reserved; * using GoogleAnalytics_Options_Create(), initialization will fail, and the * caller will be responsible for destroying the options. */ -ANALYTICS_API typedef struct { +typedef struct ANALYTICS_API GoogleAnalytics_Options { /** * @brief The unique identifier for the Firebase app across all of Firebase * with a platform-specific format. This is a required field, can not be null @@ -59,12 +71,54 @@ ANALYTICS_API typedef struct { */ bool analytics_collection_enabled_at_first_launch; + /** + * @brief An optional path to a folder where the SDK can store its data. + * If not provided, the SDK will store its data in the same folder as the + * executable. + * + * The path must pre-exist and the app has read and write access to it. + */ + const char* app_data_directory; + /** * @brief Reserved for internal use by the SDK. */ GoogleAnalytics_Reserved* reserved; } GoogleAnalytics_Options; +/** + * @brief The state of an app in its lifecycle. + */ +typedef enum GoogleAnalytics_AppLifecycleState { + /** + * @brief This is an invalid state that is used to capture unininitialized + * values. + */ + GoogleAnalytics_AppLifecycleState_kUnknown = 0, + /** + * @brief The app is about to be terminated. + */ + GoogleAnalytics_AppLifecycleState_kTermination = 1, +} GoogleAnalytics_AppLifecycleState; + +/** + * @brief The log level of a log message. + */ +typedef enum GoogleAnalytics_LogLevel { + kDebug, + kInfo, + kWarning, + kError, +} GoogleAnalytics_LogLevel; + +/** + * @brief Function pointer type for a log callback. + * + * @param[in] message The log message string. + */ +typedef void (*GoogleAnalytics_LogCallback)(GoogleAnalytics_LogLevel log_level, + const char* message); + /** * @brief Creates an instance of GoogleAnalytics_Options with default values. * @@ -144,8 +198,9 @@ ANALYTICS_API GoogleAnalytics_Item* GoogleAnalytics_Item_Create(); * @param[in] item The item to insert the int parameter into. * @param[in] key The key of the int parameter. Must be UTF-8 encoded. * @param[in] value The value of the int parameter. + * @return true if the int parameter was successfully inserted, false otherwise. */ -ANALYTICS_API void GoogleAnalytics_Item_InsertInt(GoogleAnalytics_Item* item, +ANALYTICS_API bool GoogleAnalytics_Item_InsertInt(GoogleAnalytics_Item* item, const char* key, int64_t value); @@ -155,8 +210,10 @@ ANALYTICS_API void GoogleAnalytics_Item_InsertInt(GoogleAnalytics_Item* item, * @param[in] item The item to insert the double parameter into. * @param[in] key The key of the double parameter. Must be UTF-8 encoded. * @param[in] value The value of the double parameter. + * @return true if the double parameter was successfully inserted, false + * otherwise. */ -ANALYTICS_API void GoogleAnalytics_Item_InsertDouble(GoogleAnalytics_Item* item, +ANALYTICS_API bool GoogleAnalytics_Item_InsertDouble(GoogleAnalytics_Item* item, const char* key, double value); @@ -166,8 +223,10 @@ ANALYTICS_API void GoogleAnalytics_Item_InsertDouble(GoogleAnalytics_Item* item, * @param[in] item The item to insert the string parameter into. * @param[in] key The key of the string parameter. Must be UTF-8 encoded. * @param[in] value The value of the string parameter. Must be UTF-8 encoded. + * @return true if the string parameter was successfully inserted, false + * otherwise. */ -ANALYTICS_API void GoogleAnalytics_Item_InsertString(GoogleAnalytics_Item* item, +ANALYTICS_API bool GoogleAnalytics_Item_InsertString(GoogleAnalytics_Item* item, const char* key, const char* value); @@ -197,8 +256,9 @@ ANALYTICS_API GoogleAnalytics_ItemVector* GoogleAnalytics_ItemVector_Create(); * * @param[in] item_vector The item vector to insert the item into. * @param[in] item The item to insert. Automatically destroyed when added. + * @return true if the item was successfully inserted, false otherwise. */ -ANALYTICS_API void GoogleAnalytics_ItemVector_InsertItem( +ANALYTICS_API bool GoogleAnalytics_ItemVector_InsertItem( GoogleAnalytics_ItemVector* item_vector, GoogleAnalytics_Item* item); /** @@ -230,8 +290,9 @@ GoogleAnalytics_EventParameters_Create(); * parameter into. * @param[in] key The key of the int parameter. Must be UTF-8 encoded. * @param[in] value The value of the int parameter. + * @return true if the int parameter was successfully inserted, false otherwise. */ -ANALYTICS_API void GoogleAnalytics_EventParameters_InsertInt( +ANALYTICS_API bool GoogleAnalytics_EventParameters_InsertInt( GoogleAnalytics_EventParameters* event_parameter_map, const char* key, int64_t value); @@ -242,8 +303,10 @@ ANALYTICS_API void GoogleAnalytics_EventParameters_InsertInt( * parameter into. * @param[in] key The key of the double parameter. Must be UTF-8 encoded. * @param[in] value The value of the double parameter. + * @return true if the double parameter was successfully inserted, false + * otherwise. */ -ANALYTICS_API void GoogleAnalytics_EventParameters_InsertDouble( +ANALYTICS_API bool GoogleAnalytics_EventParameters_InsertDouble( GoogleAnalytics_EventParameters* event_parameter_map, const char* key, double value); @@ -254,8 +317,10 @@ ANALYTICS_API void GoogleAnalytics_EventParameters_InsertDouble( * parameter into. * @param[in] key The key of the string parameter. Must be UTF-8 encoded. * @param[in] value The value of the string parameter. Must be UTF-8 encoded. + * @return true if the string parameter was successfully inserted, false + * otherwise. */ -ANALYTICS_API void GoogleAnalytics_EventParameters_InsertString( +ANALYTICS_API bool GoogleAnalytics_EventParameters_InsertString( GoogleAnalytics_EventParameters* event_parameter_map, const char* key, const char* value); @@ -267,8 +332,9 @@ ANALYTICS_API void GoogleAnalytics_EventParameters_InsertString( * @param[in] key The key of the item vector. Must be UTF-8 encoded. * @param[in] value The value of the item vector. Automatically destroyed as it * is added. + * @return true if the item vector was successfully inserted, false otherwise. */ -ANALYTICS_API void GoogleAnalytics_EventParameters_InsertItemVector( +ANALYTICS_API bool GoogleAnalytics_EventParameters_InsertItemVector( GoogleAnalytics_EventParameters* event_parameter_map, const char* key, GoogleAnalytics_ItemVector* value); @@ -295,8 +361,7 @@ ANALYTICS_API void GoogleAnalytics_EventParameters_Destroy( * otherwise. Also returns false if the Analytics SDK has already been * initialized. */ -ANALYTICS_API bool GoogleAnalytics_Initialize( - const GoogleAnalytics_Options* options); +ANALYTICS_API bool GoogleAnalytics_Initialize(GoogleAnalytics_Options* options); /** * @brief Logs an app event. @@ -413,6 +478,33 @@ ANALYTICS_API void GoogleAnalytics_ResetAnalyticsData(); */ ANALYTICS_API void GoogleAnalytics_SetAnalyticsCollectionEnabled(bool enabled); +/** + * @brief Allows the passing of a callback to be used when the SDK logs any + * messages regarding its behavior. The callback must be thread-safe. + * + * @param[in] callback The callback to use. Passing `nullptr` removes the + * currently set callback. + */ +ANALYTICS_API void GoogleAnalytics_SetLogCallback( + GoogleAnalytics_LogCallback callback); + +/** + * @brief Notifies the current state of the app's lifecycle. + * + * This method is used to notify the Analytics SDK about the current state of + * the app's lifecycle. The Analytics SDK will use this information to log + * events, update user properties, upload data, etc. + * + * GoogleAnalytics_AppLifecycleState_kTermination is used to indicate that the + * app is about to be terminated. The caller will be blocked until all pending + * 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. + */ +ANALYTICS_API void GoogleAnalytics_NotifyAppLifecycleChange( + GoogleAnalytics_AppLifecycleState state); + #ifdef __cplusplus } #endif diff --git a/analytics/windows/include/public/event_names.h b/analytics/windows/include/public/event_names.h index 3a3566070e..10a71dfab5 100644 --- a/analytics/windows/include/public/event_names.h +++ b/analytics/windows/include/public/event_names.h @@ -1,4 +1,16 @@ // Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #ifndef ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_EVENT_NAMES_H_ #define ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_EVENT_NAMES_H_ @@ -32,6 +44,20 @@ namespace google::analytics { // inline constexpr char kEventPublicAdImpression[] = "ad_impression"; +// In-App Purchase event. This event signifies that extra content or a +// subscription was purchased by a user inside an app. Note: This is different +// from the ecommerce purchase event. Note: If you supply the @c kParameterValue +// parameter, you must also supply the @c kParameterCurrency parameter so that +// revenue metrics can be computed accurately. Params: +// +//
    +//
  • @c kParameterCurrency (string)
  • +//
  • @c kParameterQuantity (double) (optional)
  • +//
  • @c kParameterPrice (double) (optional)
  • +//
  • @c kParameterValue (double)
  • +//
+inline constexpr char kEventPublicInAppPurchase[] = "in_app_purchase"; + // Add Payment Info event. This event signifies that a user has submitted their // payment information. Note: If you supply the @c kParameterValue parameter, // you must also supply the @c kParameterCurrency parameter so that revenue @@ -243,15 +269,12 @@ inline constexpr char kEventRefund[] = "refund"; // inline constexpr char kEventRemoveFromCart[] = "remove_from_cart"; -// Screen View event. This event signifies that a screen in your app has -// appeared. Use this event to contextualize Events that occur on a specific -// screen. Note: The @c kParameterScreenName parameter is optional, and the @c -// kParameterScreenClass parameter is required. If the @c kParameterScreenClass -// is not provided, or if there are extra parameters, the call to log this event -// will be ignored. Params: +// Screen View event. This event signifies a screen view. Use this when a screen +// transition occurs. This event can be logged irrespective of whether automatic +// screen tracking is enabled. Params: // //
    -//
  • @c kParameterScreenClass (string) (required)
  • +//
  • @c kParameterScreenClass (string) (optional)
  • //
  • @c kParameterScreenName (string) (optional)
  • //
inline constexpr char kEventScreenView[] = "screen_view"; diff --git a/analytics/windows/include/public/parameter_names.h b/analytics/windows/include/public/parameter_names.h index c0181beea9..52029ab9f9 100644 --- a/analytics/windows/include/public/parameter_names.h +++ b/analytics/windows/include/public/parameter_names.h @@ -1,4 +1,16 @@ // Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #ifndef ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_PARAMETER_NAMES_H_ #define ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_PARAMETER_NAMES_H_ diff --git a/analytics/windows/known_dll_hashes.txt b/analytics/windows/known_dll_hashes.txt index ecfa9d04ad..86f1b5b6b5 100644 --- a/analytics/windows/known_dll_hashes.txt +++ b/analytics/windows/known_dll_hashes.txt @@ -1,2 +1,3 @@ c1b9ff6e9119c30bbeb7472326dcde418f45682e6b822e25eed922fe6e3cc698 13ae5f9349b24186f1f3667b52832076e8d14ad9656c3546b1b7fca79ac8144b +3f1fb1bb21bce0061c4b89bb674d3b6c94eaea2c8de98802198a35ea94c97900