diff --git a/analytics/generate_windows_stubs.py b/analytics/generate_windows_stubs.py new file mode 100755 index 0000000000..5c7a6d66a9 --- /dev/null +++ b/analytics/generate_windows_stubs.py @@ -0,0 +1,223 @@ +#!/usr/bin/env python3 +# 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. + +"""Generate stubs and function pointers for Windows SDK""" + +import argparse +import os +import re +import sys + +HEADER_GUARD_PREFIX = "FIREBASE_ANALYTICS_SRC_WINDOWS_" +INCLUDE_PATH = "src/windows/" +INCLUDE_PREFIX = "analytics/" + INCLUDE_PATH +COPYRIGHT_NOTICE = """// 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. + +""" + +def generate_function_pointers(header_file_path, output_h_path, output_c_path): + """ + Parses a C header file to generate a self-contained header with typedefs, + extern function pointer declarations, and a source file with stub functions, + initialized pointers, and a dynamic loading function for Windows. + + Args: + header_file_path (str): The path to the input C header file. + output_h_path (str): The path for the generated C header output file. + output_c_path (str): The path for the generated C source output file. + """ + print(f"Reading header file: {header_file_path}") + try: + with open(header_file_path, 'r', encoding='utf-8') as f: + header_content = f.read() + except FileNotFoundError: + print(f"Error: Header file not found at '{header_file_path}'") + return + + # --- Extract necessary definitions from the original header --- + + # Find all standard includes (e.g., ) + includes = re.findall(r"#include\s+<.*?>", header_content) + + # Find all typedefs, including their documentation comments + typedefs = re.findall(r"/\*\*(?:[\s\S]*?)\*/\s*typedef[\s\S]*?;\s*", header_content) + + # --- Extract function prototypes --- + function_pattern = re.compile( + r"ANALYTICS_API\s+([\w\s\*]+?)\s+(\w+)\s*\((.*?)\);", + re.DOTALL + ) + matches = function_pattern.finditer(header_content) + + extern_declarations = [] + stub_functions = [] + pointer_initializations = [] + function_details_for_loader = [] + + for match in matches: + return_type = match.group(1).strip() + function_name = match.group(2).strip() + params_str = match.group(3).strip() + + cleaned_params_for_decl = re.sub(r'\s+', ' ', params_str) if params_str else "" + stub_name = f"Stub_{function_name}" + + # Generate return statement for the stub + if "void" in return_type: + return_statement = " // No return value." + elif "*" in return_type: + return_statement = " return NULL;" + else: # bool, int64_t, etc. + return_statement = " return 0;" + + stub_function = ( + f"// Stub for {function_name}\n" + f"static {return_type} {stub_name}({params_str}) {{\n" + f"{return_statement}\n" + f"}}" + ) + stub_functions.append(stub_function) + + declaration = f"extern {return_type} (*ptr_{function_name})({cleaned_params_for_decl});" + extern_declarations.append(declaration) + + pointer_init = f"{return_type} (*ptr_{function_name})({cleaned_params_for_decl}) = &{stub_name};" + pointer_initializations.append(pointer_init) + + function_details_for_loader.append((function_name, return_type, cleaned_params_for_decl)) + + print(f"Found {len(pointer_initializations)} functions. Generating output files...") + + # --- Write the self-contained Header File (.h) --- + header_guard = f"{HEADER_GUARD_PREFIX}{os.path.basename(output_h_path).upper().replace('.', '_')}_" + with open(output_h_path, 'w', encoding='utf-8') as f: + f.write(f"{COPYRIGHT_NOTICE}") + f.write(f"// Generated from {os.path.basename(header_file_path)} by {os.path.basename(sys.argv[0])}\n\n") + f.write(f"#ifndef {header_guard}\n") + f.write(f"#define {header_guard}\n\n") + + f.write("// --- Copied from original header ---\n") + f.write("\n".join(includes) + "\n\n") + f.write("".join(typedefs)) + f.write("// --- End of copied section ---\n\n") + + f.write("#ifdef __cplusplus\n") + f.write('extern "C" {\n') + f.write("#endif\n\n") + f.write("// --- Function Pointer Declarations ---\n") + f.write("// clang-format off\n") + f.write("\n".join(extern_declarations)) + f.write("\n// clang-format on\n") + f.write("\n\n// --- Dynamic Loader Declaration for Windows ---\n") + f.write("#if defined(_WIN32)\n") + f.write('#include // For HMODULE\n') + f.write('// Load Google Analytics functions from the given DLL handle into function pointers.\n') + f.write(f'// Returns the number of functions successfully loaded (out of {len(function_details_for_loader)}).\n') + f.write("int FirebaseAnalytics_LoadAnalyticsFunctions(HMODULE dll_handle);\n\n") + f.write('// Reset all function pointers back to stubs.\n') + f.write("void FirebaseAnalytics_UnloadAnalyticsFunctions(void);\n\n") + f.write("#endif // defined(_WIN32)\n") + f.write("\n#ifdef __cplusplus\n") + f.write("}\n") + f.write("#endif\n\n") + f.write(f"#endif // {header_guard}\n") + + print(f"Successfully generated header file: {output_h_path}") + + # --- Write the Source File (.c) --- + with open(output_c_path, 'w', encoding='utf-8') as f: + f.write(f"{COPYRIGHT_NOTICE}") + f.write(f"// Generated from {os.path.basename(header_file_path)} by {os.path.basename(sys.argv[0])}\n\n") + f.write(f'#include "{INCLUDE_PREFIX}{os.path.basename(output_h_path)}"\n') + f.write('#include \n\n') + f.write("// clang-format off\n\n") + f.write("// --- Stub Function Definitions ---\n") + f.write("\n\n".join(stub_functions)) + f.write("\n\n\n// --- Function Pointer Initializations ---\n") + f.write("\n".join(pointer_initializations)) + f.write("\n\n// --- Dynamic Loader Function for Windows ---\n") + loader_lines = [ + '#if defined(_WIN32)', + 'int FirebaseAnalytics_LoadAnalyticsFunctions(HMODULE dll_handle) {', + ' int count = 0;\n', + ' if (!dll_handle) {', + ' return count;', + ' }\n' + ] + for name, ret_type, params in function_details_for_loader: + pointer_type_cast = f"({ret_type} (*)({params}))" + proc_check = [ + f' FARPROC proc_{name} = GetProcAddress(dll_handle, "{name}");', + f' if (proc_{name}) {{', + f' ptr_{name} = {pointer_type_cast}proc_{name};', + f' count++;', + f' }}' + ] + loader_lines.extend(proc_check) + loader_lines.append('\n return count;') + loader_lines.append('}\n') + loader_lines.append('void FirebaseAnalytics_UnloadAnalyticsFunctions(void) {') + for name, ret_type, params in function_details_for_loader: + loader_lines.append(f' ptr_{name} = &Stub_{name};'); + loader_lines.append('}\n') + loader_lines.append('#endif // defined(_WIN32)\n') + f.write('\n'.join(loader_lines)) + f.write("// clang-format on\n") + + print(f"Successfully generated C source file: {output_c_path}") + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description="Generate C stubs and function pointers from a header file." + ) + parser.add_argument( + "--windows_header", + default = os.path.join(os.path.dirname(sys.argv[0]), "windows/include/public/c/analytics.h"), + #required=True, + help="Path to the input C header file." + ) + parser.add_argument( + "--output_header", + default = os.path.join(os.path.dirname(sys.argv[0]), INCLUDE_PATH, "analytics_dynamic.h"), + #required=True, + help="Path for the generated output header file." + ) + parser.add_argument( + "--output_source", + default = os.path.join(os.path.dirname(sys.argv[0]), INCLUDE_PATH, "analytics_dynamic.c"), + #required=True, + help="Path for the generated output source file." + ) + + args = parser.parse_args() + + generate_function_pointers( + args.windows_header, + args.output_header, + args.output_source + ) diff --git a/analytics/src/windows/analytics_dynamic.c b/analytics/src/windows/analytics_dynamic.c new file mode 100644 index 0000000000..99ab325779 --- /dev/null +++ b/analytics/src/windows/analytics_dynamic.c @@ -0,0 +1,283 @@ +// 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. + +// Generated from analytics.h by generate_windows_stubs.py + +#include "analytics/src/windows/analytics_dynamic.h" + +#include + +// clang-format off + +// --- Stub Function Definitions --- +// Stub for GoogleAnalytics_Item_Create +static GoogleAnalytics_Item* Stub_GoogleAnalytics_Item_Create() { + return NULL; +} + +// Stub for GoogleAnalytics_Item_InsertInt +static void Stub_GoogleAnalytics_Item_InsertInt(GoogleAnalytics_Item* item, + const char* key, + int64_t value) { + // No return value. +} + +// Stub for GoogleAnalytics_Item_InsertDouble +static void Stub_GoogleAnalytics_Item_InsertDouble(GoogleAnalytics_Item* item, + const char* key, + double value) { + // No return value. +} + +// Stub for GoogleAnalytics_Item_InsertString +static void Stub_GoogleAnalytics_Item_InsertString(GoogleAnalytics_Item* item, + const char* key, + const char* value) { + // No return value. +} + +// Stub for GoogleAnalytics_Item_Destroy +static void Stub_GoogleAnalytics_Item_Destroy(GoogleAnalytics_Item* item) { + // No return value. +} + +// Stub for GoogleAnalytics_ItemVector_Create +static GoogleAnalytics_ItemVector* Stub_GoogleAnalytics_ItemVector_Create() { + return NULL; +} + +// Stub for GoogleAnalytics_ItemVector_InsertItem +static void Stub_GoogleAnalytics_ItemVector_InsertItem(GoogleAnalytics_ItemVector* item_vector, GoogleAnalytics_Item* item) { + // No return value. +} + +// Stub for GoogleAnalytics_ItemVector_Destroy +static void Stub_GoogleAnalytics_ItemVector_Destroy(GoogleAnalytics_ItemVector* item_vector) { + // No return value. +} + +// Stub for GoogleAnalytics_EventParameters_Create +static GoogleAnalytics_EventParameters* Stub_GoogleAnalytics_EventParameters_Create() { + return NULL; +} + +// Stub for GoogleAnalytics_EventParameters_InsertInt +static void Stub_GoogleAnalytics_EventParameters_InsertInt(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, + int64_t value) { + // No return value. +} + +// Stub for GoogleAnalytics_EventParameters_InsertDouble +static void Stub_GoogleAnalytics_EventParameters_InsertDouble(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, + double value) { + // No return value. +} + +// Stub for GoogleAnalytics_EventParameters_InsertString +static void Stub_GoogleAnalytics_EventParameters_InsertString(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, + const char* value) { + // No return value. +} + +// Stub for GoogleAnalytics_EventParameters_InsertItemVector +static void Stub_GoogleAnalytics_EventParameters_InsertItemVector(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, + GoogleAnalytics_ItemVector* value) { + // No return value. +} + +// Stub for GoogleAnalytics_EventParameters_Destroy +static void Stub_GoogleAnalytics_EventParameters_Destroy(GoogleAnalytics_EventParameters* event_parameter_map) { + // No return value. +} + +// Stub for GoogleAnalytics_LogEvent +static void Stub_GoogleAnalytics_LogEvent(const char* name, GoogleAnalytics_EventParameters* parameters) { + // No return value. +} + +// Stub for GoogleAnalytics_SetUserProperty +static void Stub_GoogleAnalytics_SetUserProperty(const char* name, + const char* value) { + // No return value. +} + +// Stub for GoogleAnalytics_SetUserId +static void Stub_GoogleAnalytics_SetUserId(const char* user_id) { + // No return value. +} + +// Stub for GoogleAnalytics_ResetAnalyticsData +static void Stub_GoogleAnalytics_ResetAnalyticsData() { + // No return value. +} + +// Stub for GoogleAnalytics_SetAnalyticsCollectionEnabled +static void Stub_GoogleAnalytics_SetAnalyticsCollectionEnabled(bool enabled) { + // No return value. +} + + +// --- Function Pointer Initializations --- +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; +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; +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; +void (*ptr_GoogleAnalytics_EventParameters_Destroy)(GoogleAnalytics_EventParameters* event_parameter_map) = &Stub_GoogleAnalytics_EventParameters_Destroy; +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; + +// --- Dynamic Loader Function for Windows --- +#if defined(_WIN32) +int FirebaseAnalytics_LoadAnalyticsFunctions(HMODULE dll_handle) { + int count = 0; + + if (!dll_handle) { + return count; + } + + FARPROC proc_GoogleAnalytics_Item_Create = GetProcAddress(dll_handle, "GoogleAnalytics_Item_Create"); + if (proc_GoogleAnalytics_Item_Create) { + ptr_GoogleAnalytics_Item_Create = (GoogleAnalytics_Item* (*)())proc_GoogleAnalytics_Item_Create; + count++; + } + 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; + 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; + 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; + count++; + } + FARPROC proc_GoogleAnalytics_Item_Destroy = GetProcAddress(dll_handle, "GoogleAnalytics_Item_Destroy"); + if (proc_GoogleAnalytics_Item_Destroy) { + ptr_GoogleAnalytics_Item_Destroy = (void (*)(GoogleAnalytics_Item* item))proc_GoogleAnalytics_Item_Destroy; + count++; + } + FARPROC proc_GoogleAnalytics_ItemVector_Create = GetProcAddress(dll_handle, "GoogleAnalytics_ItemVector_Create"); + if (proc_GoogleAnalytics_ItemVector_Create) { + ptr_GoogleAnalytics_ItemVector_Create = (GoogleAnalytics_ItemVector* (*)())proc_GoogleAnalytics_ItemVector_Create; + count++; + } + 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; + count++; + } + FARPROC proc_GoogleAnalytics_ItemVector_Destroy = GetProcAddress(dll_handle, "GoogleAnalytics_ItemVector_Destroy"); + if (proc_GoogleAnalytics_ItemVector_Destroy) { + ptr_GoogleAnalytics_ItemVector_Destroy = (void (*)(GoogleAnalytics_ItemVector* item_vector))proc_GoogleAnalytics_ItemVector_Destroy; + count++; + } + FARPROC proc_GoogleAnalytics_EventParameters_Create = GetProcAddress(dll_handle, "GoogleAnalytics_EventParameters_Create"); + if (proc_GoogleAnalytics_EventParameters_Create) { + ptr_GoogleAnalytics_EventParameters_Create = (GoogleAnalytics_EventParameters* (*)())proc_GoogleAnalytics_EventParameters_Create; + count++; + } + 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; + 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; + 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; + 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; + count++; + } + FARPROC proc_GoogleAnalytics_EventParameters_Destroy = GetProcAddress(dll_handle, "GoogleAnalytics_EventParameters_Destroy"); + if (proc_GoogleAnalytics_EventParameters_Destroy) { + ptr_GoogleAnalytics_EventParameters_Destroy = (void (*)(GoogleAnalytics_EventParameters* event_parameter_map))proc_GoogleAnalytics_EventParameters_Destroy; + count++; + } + FARPROC proc_GoogleAnalytics_LogEvent = GetProcAddress(dll_handle, "GoogleAnalytics_LogEvent"); + if (proc_GoogleAnalytics_LogEvent) { + ptr_GoogleAnalytics_LogEvent = (void (*)(const char* name, GoogleAnalytics_EventParameters* parameters))proc_GoogleAnalytics_LogEvent; + count++; + } + FARPROC proc_GoogleAnalytics_SetUserProperty = GetProcAddress(dll_handle, "GoogleAnalytics_SetUserProperty"); + if (proc_GoogleAnalytics_SetUserProperty) { + ptr_GoogleAnalytics_SetUserProperty = (void (*)(const char* name, const char* value))proc_GoogleAnalytics_SetUserProperty; + count++; + } + FARPROC proc_GoogleAnalytics_SetUserId = GetProcAddress(dll_handle, "GoogleAnalytics_SetUserId"); + if (proc_GoogleAnalytics_SetUserId) { + ptr_GoogleAnalytics_SetUserId = (void (*)(const char* user_id))proc_GoogleAnalytics_SetUserId; + count++; + } + FARPROC proc_GoogleAnalytics_ResetAnalyticsData = GetProcAddress(dll_handle, "GoogleAnalytics_ResetAnalyticsData"); + if (proc_GoogleAnalytics_ResetAnalyticsData) { + ptr_GoogleAnalytics_ResetAnalyticsData = (void (*)())proc_GoogleAnalytics_ResetAnalyticsData; + count++; + } + FARPROC proc_GoogleAnalytics_SetAnalyticsCollectionEnabled = GetProcAddress(dll_handle, "GoogleAnalytics_SetAnalyticsCollectionEnabled"); + if (proc_GoogleAnalytics_SetAnalyticsCollectionEnabled) { + ptr_GoogleAnalytics_SetAnalyticsCollectionEnabled = (void (*)(bool enabled))proc_GoogleAnalytics_SetAnalyticsCollectionEnabled; + count++; + } + + return count; +} + +void FirebaseAnalytics_UnloadAnalyticsFunctions(void) { + ptr_GoogleAnalytics_Item_Create = &Stub_GoogleAnalytics_Item_Create; + ptr_GoogleAnalytics_Item_InsertInt = &Stub_GoogleAnalytics_Item_InsertInt; + ptr_GoogleAnalytics_Item_InsertDouble = &Stub_GoogleAnalytics_Item_InsertDouble; + ptr_GoogleAnalytics_Item_InsertString = &Stub_GoogleAnalytics_Item_InsertString; + ptr_GoogleAnalytics_Item_Destroy = &Stub_GoogleAnalytics_Item_Destroy; + ptr_GoogleAnalytics_ItemVector_Create = &Stub_GoogleAnalytics_ItemVector_Create; + ptr_GoogleAnalytics_ItemVector_InsertItem = &Stub_GoogleAnalytics_ItemVector_InsertItem; + ptr_GoogleAnalytics_ItemVector_Destroy = &Stub_GoogleAnalytics_ItemVector_Destroy; + ptr_GoogleAnalytics_EventParameters_Create = &Stub_GoogleAnalytics_EventParameters_Create; + ptr_GoogleAnalytics_EventParameters_InsertInt = &Stub_GoogleAnalytics_EventParameters_InsertInt; + ptr_GoogleAnalytics_EventParameters_InsertDouble = &Stub_GoogleAnalytics_EventParameters_InsertDouble; + ptr_GoogleAnalytics_EventParameters_InsertString = &Stub_GoogleAnalytics_EventParameters_InsertString; + ptr_GoogleAnalytics_EventParameters_InsertItemVector = &Stub_GoogleAnalytics_EventParameters_InsertItemVector; + ptr_GoogleAnalytics_EventParameters_Destroy = &Stub_GoogleAnalytics_EventParameters_Destroy; + ptr_GoogleAnalytics_LogEvent = &Stub_GoogleAnalytics_LogEvent; + ptr_GoogleAnalytics_SetUserProperty = &Stub_GoogleAnalytics_SetUserProperty; + ptr_GoogleAnalytics_SetUserId = &Stub_GoogleAnalytics_SetUserId; + ptr_GoogleAnalytics_ResetAnalyticsData = &Stub_GoogleAnalytics_ResetAnalyticsData; + ptr_GoogleAnalytics_SetAnalyticsCollectionEnabled = &Stub_GoogleAnalytics_SetAnalyticsCollectionEnabled; +} + +#endif // defined(_WIN32) +// clang-format on diff --git a/analytics/src/windows/analytics_dynamic.h b/analytics/src/windows/analytics_dynamic.h new file mode 100644 index 0000000000..ffd927e899 --- /dev/null +++ b/analytics/src/windows/analytics_dynamic.h @@ -0,0 +1,109 @@ +// 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. + +// Generated from analytics.h by generate_windows_stubs.py + +#ifndef FIREBASE_ANALYTICS_SRC_WINDOWS_ANALYTICS_DYNAMIC_H_ +#define FIREBASE_ANALYTICS_SRC_WINDOWS_ANALYTICS_DYNAMIC_H_ + +// --- Copied from original header --- +#include + +/** + * @brief Opaque type for an item. + * + * This type is an opaque object that represents an item in an item vector. + * + * The caller is responsible for creating the item using the + * GoogleAnalytics_Item_Create() function, and destroying it using the + * GoogleAnalytics_Item_Destroy() function, unless it has been added to an + * item vector, in which case it will be destroyed at that time. + */ +typedef struct GoogleAnalytics_Item_Opaque GoogleAnalytics_Item; + +/** + * @brief Opaque type for an item vector. + * + * This type is an opaque object that represents a list of items. It is + * used to pass item vectors to the + * GoogleAnalytics_EventParameters_InsertItemVector() function. + * + * The caller is responsible for creating the item vector using the + * GoogleAnalytics_ItemVector_Create() function, and destroying it using the + * GoogleAnalytics_ItemVector_Destroy() function, unless it has been added + * to an event parameter map, in which case it will be destroyed at that time. + */ +typedef struct GoogleAnalytics_ItemVector_Opaque GoogleAnalytics_ItemVector; + +/** + * @brief Opaque type for an event parameter map. + * + * This type is an opaque object that represents a dictionary of event + * parameters. It is used to pass event parameters to the + * GoogleAnalytics_LogEvent() function. + * + * The caller is responsible for creating the event parameter map using the + * GoogleAnalytics_EventParameters_Create() function, and destroying it using + * the GoogleAnalytics_EventParameters_Destroy() function, unless it has been + * logged, in which case it will be destroyed automatically. + */ +typedef struct GoogleAnalytics_EventParameters_Opaque + GoogleAnalytics_EventParameters; + +// --- End of copied section --- + +#ifdef __cplusplus +extern "C" { +#endif + +// --- Function Pointer Declarations --- +// clang-format off +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 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 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 void (*ptr_GoogleAnalytics_EventParameters_Destroy)(GoogleAnalytics_EventParameters* event_parameter_map); +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); +// clang-format on + +// --- Dynamic Loader Declaration for Windows --- +#if defined(_WIN32) +#include // For HMODULE +// Load Google Analytics functions from the given DLL handle into function +// pointers. Returns the number of functions successfully loaded (out of 19). +int FirebaseAnalytics_LoadAnalyticsFunctions(HMODULE dll_handle); + +// Reset all function pointers back to stubs. +void FirebaseAnalytics_UnloadAnalyticsFunctions(void); + +#endif // defined(_WIN32) + +#ifdef __cplusplus +} +#endif + +#endif // FIREBASE_ANALYTICS_SRC_WINDOWS_ANALYTICS_DYNAMIC_H_ diff --git a/analytics/windows/analytics_win.dll b/analytics/windows/analytics_win.dll new file mode 100755 index 0000000000..f0c83825e3 Binary files /dev/null and b/analytics/windows/analytics_win.dll differ diff --git a/analytics/windows/include/public/analytics.h b/analytics/windows/include/public/analytics.h new file mode 100644 index 0000000000..d2dcc448ae --- /dev/null +++ b/analytics/windows/include/public/analytics.h @@ -0,0 +1,225 @@ +// Copyright 2025 Google LLC +#ifndef ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_ANALYTICS_H_ +#define ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_ANALYTICS_H_ + +#include +#include +#include +#include +#include +#include + +#include "c/analytics.h" + +namespace google::analytics { + +/** + * The top level Firebase Analytics singleton that provides methods for logging + * events and setting user properties. See the + * developer guides for general information on using Firebase Analytics in + * your apps. + * + * @note The Analytics SDK uses SQLite to persist events and other app-specific + * data. Calling certain thread-unsafe global SQLite methods like + * `sqlite3_shutdown()` can result in unexpected crashes at runtime. + */ +class Analytics { + public: + using PrimitiveValue = std::variant; + using Item = std::unordered_map; + using ItemVector = std::vector; + using EventParameterValue = + std::variant; + using EventParameters = std::unordered_map; + + /** + * @brief Returns the singleton instance of the Analytics class. + */ + static Analytics& GetInstance() { + static Analytics instance; + return instance; + } + + // This type is neither copyable nor movable. + Analytics(const Analytics&) = delete; + Analytics& operator=(const Analytics&) = delete; + Analytics(Analytics&&) = delete; + Analytics& operator=(Analytics&&) = delete; + + /** + * @brief Logs an app event. + * + * The event can have up to 25 parameters. Events with the same name must have + * the same parameters. Up to 500 event names are supported. Using predefined + * events and/or parameters is recommended for optimal reporting. + * + * The following event names are reserved and cannot be used: + * - ad_activeview + * - ad_click + * - ad_exposure + * - ad_query + * - ad_reward + * - adunit_exposure + * - app_clear_data + * - app_exception + * - app_remove + * - app_store_refund + * - app_store_subscription_cancel + * - app_store_subscription_convert + * - app_store_subscription_renew + * - app_update + * - app_upgrade + * - dynamic_link_app_open + * - dynamic_link_app_update + * - dynamic_link_first_open + * - error + * - firebase_campaign + * - first_open + * - first_visit + * - in_app_purchase + * - notification_dismiss + * - notification_foreground + * - notification_open + * - notification_receive + * - os_update + * - session_start + * - session_start_with_rollout + * - user_engagement + * + * @param[in] name The name of the event. Should contain 1 to 40 alphanumeric + * characters or underscores. The name must start with an alphabetic + * character. Some event names are reserved. See event_names.h for the list + * of reserved event names. The "firebase_", "google_", and "ga_" prefixes are + * reserved and should not be used. Note that event names are case-sensitive + * and that logging two events whose names differ only in case will result in + * two distinct events. To manually log screen view events, use the + * `screen_view` event name. Must be UTF-8 encoded. + * @param[in] parameters The map of event parameters. Passing `std::nullopt` + * indicates that the event has no parameters. Parameter names can be up to 40 + * characters long and must start with an alphabetic character and contain + * only alphanumeric characters and underscores. Only String, Int, and Double + * parameter types are supported. String parameter values can be up to 100 + * characters long for standard Google Analytics properties, and up to 500 + * characters long for Google Analytics 360 properties. The "firebase_", + * "google_", and "ga_" prefixes are reserved and should not be used for + * parameter names. String keys and values must be UTF-8 encoded. + */ + void LogEvent(const std::string& event_name, + const std::optional& parameters) { + if (!parameters.has_value()) { + GoogleAnalytics_LogEvent(std::string(event_name).c_str(), nullptr); + return; + } + GoogleAnalytics_EventParameters* map = + GoogleAnalytics_EventParameters_Create(); + for (const auto& [name, value] : parameters.value()) { + if (auto* int_value = std::get_if(&value)) { + GoogleAnalytics_EventParameters_InsertInt(map, name.c_str(), + *int_value); + } else if (auto* double_value = std::get_if(&value)) { + GoogleAnalytics_EventParameters_InsertDouble(map, name.c_str(), + *double_value); + } else if (auto* string_value = std::get_if(&value)) { + GoogleAnalytics_EventParameters_InsertString(map, name.c_str(), + string_value->c_str()); + } else if (auto* items = std::get_if(&value)) { + GoogleAnalytics_ItemVector* item_vector = + GoogleAnalytics_ItemVector_Create(); + for (const auto& item : *items) { + GoogleAnalytics_Item* nested_item = GoogleAnalytics_Item_Create(); + for (const auto& [nested_name, nested_value] : item) { + if (auto* nested_int_value = std::get_if(&nested_value)) { + GoogleAnalytics_Item_InsertInt(nested_item, nested_name.c_str(), + *nested_int_value); + } else if (auto* nested_double_value = + std::get_if(&nested_value)) { + GoogleAnalytics_Item_InsertDouble( + nested_item, nested_name.c_str(), *nested_double_value); + } else if (auto* nested_string_value = + std::get_if(&nested_value)) { + GoogleAnalytics_Item_InsertString(nested_item, + nested_name.c_str(), + nested_string_value->c_str()); + } + } + GoogleAnalytics_ItemVector_InsertItem(item_vector, nested_item); + } + GoogleAnalytics_EventParameters_InsertItemVector(map, name.c_str(), + item_vector); + } + } + GoogleAnalytics_LogEvent(std::string(event_name).c_str(), map); + } + + /** + * @brief Sets a user property to a given value. + * + * Up to 25 user property names are supported. Once set, user property values + * persist throughout the app lifecycle and across sessions. + * + * The following user property names are reserved and cannot be used: + * + * - first_open_time + * - last_deep_link_referrer + * - user_id + * + * @param[in] name The name of the user property to set. Should contain 1 to + * 24 alphanumeric characters or underscores, and must start with an + * alphabetic character. The "firebase_", "google_", and "ga_" prefixes are + * reserved and should not be used for user property names. Must be UTF-8 + * encoded. + * @param[in] value The value of the user property. Values can be up to 36 + * characters long. Setting the value to `std::nullopt` removes the user + * property. Must be UTF-8 encoded. + */ + void SetUserProperty(const std::string& name, + std::optional value) { + const char* value_ptr = value.has_value() ? value->c_str() : nullptr; + GoogleAnalytics_SetUserProperty(name.c_str(), value_ptr); + } + + /** + * @brief Sets the user ID property. + * + * This feature must be used in accordance with + * Google's Privacy + * Policy + * + * @param[in] user_id The user ID associated with the user of this app on this + * device. The user ID must be non-empty and no more than 256 characters + * long, and UTF-8 encoded. Setting user_id to std::nullopt removes the + * user ID. + */ + void SetUserId(std::optional user_id) { + if (!user_id.has_value()) { + GoogleAnalytics_SetUserId(nullptr); + } else { + GoogleAnalytics_SetUserId(user_id->c_str()); + } + } + + /** + * @brief Clears all analytics data for this instance from the device and + * resets the app instance ID. + */ + void ResetAnalyticsData() { GoogleAnalytics_ResetAnalyticsData(); } + + /** + * @brief Sets whether analytics collection is enabled for this app on this + * device. + * + * This setting is persisted across app sessions. By default it is enabled. + * + * @param[in] enabled A flag that enables or disables Analytics collection. + */ + void SetAnalyticsCollectionEnabled(bool enabled) { + GoogleAnalytics_SetAnalyticsCollectionEnabled(enabled); + } + + private: + Analytics() = default; +}; + +} // namespace google::analytics + +#endif // ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_ANALYTICS_H_ diff --git a/analytics/windows/include/public/c/analytics.h b/analytics/windows/include/public/c/analytics.h new file mode 100644 index 0000000000..cb3047f310 --- /dev/null +++ b/analytics/windows/include/public/c/analytics.h @@ -0,0 +1,332 @@ +// Copyright 2025 Google LLC +#ifndef ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_C_ANALYTICS_H_ +#define ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_C_ANALYTICS_H_ + +#include + +#if defined(ANALYTICS_DLL) && defined(_WIN32) +#define ANALYTICS_API __declspec(dllexport) +#else +#define ANALYTICS_API +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Opaque type for an item. + * + * This type is an opaque object that represents an item in an item vector. + * + * The caller is responsible for creating the item using the + * GoogleAnalytics_Item_Create() function, and destroying it using the + * GoogleAnalytics_Item_Destroy() function, unless it has been added to an + * item vector, in which case it will be destroyed at that time. + */ +typedef struct GoogleAnalytics_Item_Opaque GoogleAnalytics_Item; + +/** + * @brief Opaque type for an item vector. + * + * This type is an opaque object that represents a list of items. It is + * used to pass item vectors to the + * GoogleAnalytics_EventParameters_InsertItemVector() function. + * + * The caller is responsible for creating the item vector using the + * GoogleAnalytics_ItemVector_Create() function, and destroying it using the + * GoogleAnalytics_ItemVector_Destroy() function, unless it has been added + * to an event parameter map, in which case it will be destroyed at that time. + */ +typedef struct GoogleAnalytics_ItemVector_Opaque GoogleAnalytics_ItemVector; + +/** + * @brief Opaque type for an event parameter map. + * + * This type is an opaque object that represents a dictionary of event + * parameters. It is used to pass event parameters to the + * GoogleAnalytics_LogEvent() function. + * + * The caller is responsible for creating the event parameter map using the + * GoogleAnalytics_EventParameters_Create() function, and destroying it using + * the GoogleAnalytics_EventParameters_Destroy() function, unless it has been + * logged, in which case it will be destroyed automatically. + */ +typedef struct GoogleAnalytics_EventParameters_Opaque + GoogleAnalytics_EventParameters; + +/** + * @brief Creates an item. + * + * The caller is responsible for destroying the item using the + * GoogleAnalytics_Item_Destroy() function, unless it has been added to an + * item vector, in which case it will be destroyed when it is added. + */ +ANALYTICS_API GoogleAnalytics_Item* GoogleAnalytics_Item_Create(); + +/** + * @brief Inserts an int parameter into the item. + * + * @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. + */ +ANALYTICS_API void GoogleAnalytics_Item_InsertInt(GoogleAnalytics_Item* item, + const char* key, + int64_t value); + +/** + * @brief Inserts a double parameter into the 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. + */ +ANALYTICS_API void GoogleAnalytics_Item_InsertDouble(GoogleAnalytics_Item* item, + const char* key, + double value); + +/** + * @brief Inserts a string parameter into the 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. + */ +ANALYTICS_API void GoogleAnalytics_Item_InsertString(GoogleAnalytics_Item* item, + const char* key, + const char* value); + +/** + * @brief Destroys the item. + * + * The caller is responsible for destroying the item using this + * function, unless it has been added to an item vector, in which case it + * will be destroyed when it is added. + * + * @param[in] item The item to destroy. + */ +ANALYTICS_API void GoogleAnalytics_Item_Destroy(GoogleAnalytics_Item* item); + +/** + * @brief Creates an item vector. + * + * The caller is responsible for destroying the item vector using the + * GoogleAnalytics_ItemVector_Destroy() function, unless it has been added + * to an event parameter map, in which case it will be destroyed when it is + * added. + */ +ANALYTICS_API GoogleAnalytics_ItemVector* GoogleAnalytics_ItemVector_Create(); + +/** + * @brief Inserts a item into the item vector. + * + * @param[in] item_vector The item vector to insert the item into. + * @param[in] item The item to insert. Automatically destroyed when added. + */ +ANALYTICS_API void GoogleAnalytics_ItemVector_InsertItem( + GoogleAnalytics_ItemVector* item_vector, GoogleAnalytics_Item* item); + +/** + * @brief Destroys the item vector. + * + * The caller has the option to destroy the item vector using this function, + * unless it has been added to an event parameter map, in which case it will be + * destroyed when it is added. + * + * @param[in] item_vector The item vector to destroy. + */ +ANALYTICS_API void GoogleAnalytics_ItemVector_Destroy( + GoogleAnalytics_ItemVector* item_vector); + +/** + * @brief Creates an event parameter map. + * + * The caller is responsible for destroying the event parameter map using the + * GoogleAnalytics_EventParameters_Destroy() function, unless it has been + * logged, in which case it will be destroyed automatically when it is logged. + */ +ANALYTICS_API GoogleAnalytics_EventParameters* +GoogleAnalytics_EventParameters_Create(); + +/** + * @brief Inserts an int parameter into the event parameter map. + * + * @param[in] event_parameter_map The event parameter map 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. + */ +ANALYTICS_API void GoogleAnalytics_EventParameters_InsertInt( + GoogleAnalytics_EventParameters* event_parameter_map, const char* key, + int64_t value); + +/** + * @brief Inserts a double parameter into the event parameter map. + * + * @param[in] event_parameter_map The event parameter map 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. + */ +ANALYTICS_API void GoogleAnalytics_EventParameters_InsertDouble( + GoogleAnalytics_EventParameters* event_parameter_map, const char* key, + double value); + +/** + * @brief Inserts a string parameter into the event parameter map. + * + * @param[in] event_parameter_map The event parameter map 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. + */ +ANALYTICS_API void GoogleAnalytics_EventParameters_InsertString( + GoogleAnalytics_EventParameters* event_parameter_map, const char* key, + const char* value); + +/** + * @brief Inserts an item vector into the event parameter map. + * + * @param[in] event_parameter_map The event parameter map to insert the item + * vector into. + * @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. + */ +ANALYTICS_API void GoogleAnalytics_EventParameters_InsertItemVector( + GoogleAnalytics_EventParameters* event_parameter_map, const char* key, + GoogleAnalytics_ItemVector* value); + +/** + * @brief Destroys the event parameter map. + * + * The caller is responsible for destroying the event parameter map using this + * function. Unless it has been logged, in which case it will be destroyed + * automatically when it is logged. + * + * @param[in] event_parameter_map The event parameter map to destroy. + */ +ANALYTICS_API void GoogleAnalytics_EventParameters_Destroy( + GoogleAnalytics_EventParameters* event_parameter_map); + +/** + * @brief Logs an app event. + * + * The event can have up to 25 parameters. Events with the same name must have + * the same parameters. Up to 500 event names are supported. Using predefined + * events and/or parameters is recommended for optimal reporting. + * + * The following event names are reserved and cannot be used: + * - ad_activeview + * - ad_click + * - ad_exposure + * - ad_query + * - ad_reward + * - adunit_exposure + * - app_clear_data + * - app_exception + * - app_remove + * - app_store_refund + * - app_store_subscription_cancel + * - app_store_subscription_convert + * - app_store_subscription_renew + * - app_update + * - app_upgrade + * - dynamic_link_app_open + * - dynamic_link_app_update + * - dynamic_link_first_open + * - error + * - firebase_campaign + * - first_open + * - first_visit + * - in_app_purchase + * - notification_dismiss + * - notification_foreground + * - notification_open + * - notification_receive + * - os_update + * - session_start + * - session_start_with_rollout + * - user_engagement + * + * @param[in] name The name of the event. Should contain 1 to 40 alphanumeric + * characters or underscores. The name must start with an alphabetic + * character. Some event names are reserved. See event_names.h for the list + * of reserved event names. The "firebase_", "google_", and "ga_" prefixes are + * reserved and should not be used. Note that event names are case-sensitive + * and that logging two events whose names differ only in case will result in + * two distinct events. To manually log screen view events, use the + * `screen_view` event name. Must be UTF-8 encoded. + * @param[in] parameters The map of event parameters. Passing `nullptr` + * indicates that the event has no parameters. Parameter names can be up to 40 + * characters long and must start with an alphabetic character and contain + * only alphanumeric characters and underscores. Only String, Int, and Double + * parameter types are supported. String parameter values can be up to 100 + * characters long for standard Google Analytics properties, and up to 500 + * characters long for Google Analytics 360 properties. The "firebase_", + * "google_", and "ga_" prefixes are reserved and should not be used for + * parameter names. The parameter map must be created using the + * GoogleAnalytics_EventParameters_Create() function. Automatically destroyed + * when it is logged. + */ +ANALYTICS_API void GoogleAnalytics_LogEvent( + const char* name, GoogleAnalytics_EventParameters* parameters); + +/** + * @brief Sets a user property to a given value. + * + * Up to 25 user property names are supported. Once set, user property values + * persist throughout the app lifecycle and across sessions. + * + * The following user property names are reserved and cannot be used: + * + * - first_open_time + * - last_deep_link_referrer + * - user_id + * + * @param[in] name The name of the user property to set. Should contain 1 to 24 + * alphanumeric characters or underscores, and must start with an alphabetic + * character. The "firebase_", "google_", and "ga_" prefixes are reserved and + * should not be used for user property names. Must be UTF-8 encoded. + * @param[in] value The value of the user property. Values can be up to 36 + * characters long. Setting the value to `nullptr` remove the user property. + * Must be UTF-8 encoded. + */ +ANALYTICS_API void GoogleAnalytics_SetUserProperty(const char* name, + const char* value); + +/* + * @brief Sets the user ID property. + * + * This feature must be used in accordance with + * Google's Privacy + * Policy + * + * @param[in] user_id The user ID associated with the user of this app on this + * device. The user ID must be non-empty and no more than 256 characters long, + * and UTF-8 encoded. Setting user_id to nullptr removes the user ID. + */ +ANALYTICS_API void GoogleAnalytics_SetUserId(const char* user_id); + +/* + * @brief Clears all analytics data for this instance from the device and resets + * the app instance ID. + */ +ANALYTICS_API void GoogleAnalytics_ResetAnalyticsData(); + +/* + * @brief Sets whether analytics collection is enabled for this app on this + * device. + * + * This setting is persisted across app sessions. By default it is enabled. + * + * @param[in] enabled A flag that enables or disables Analytics collection. + */ +ANALYTICS_API void GoogleAnalytics_SetAnalyticsCollectionEnabled(bool enabled); + +#ifdef __cplusplus +} +#endif + +#endif // ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_C_ANALYTICS_H_ diff --git a/analytics/windows/include/public/event_names.h b/analytics/windows/include/public/event_names.h new file mode 100644 index 0000000000..ef8330751f --- /dev/null +++ b/analytics/windows/include/public/event_names.h @@ -0,0 +1,426 @@ +// Copyright 2025 Google LLC +#ifndef ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_EVENT_NAMES_H_ +#define ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_EVENT_NAMES_H_ + +// Predefined event names. +// +// An Event is an important occurrence in your app that you want to measure. You +// can report up to 500 different types of Events per app and you can associate +// up to 25 unique parameters with each Event type. Some common events are +// suggested below, but you may also choose to specify custom Event types that +// are associated with your specific app. Each event type is identified by a +// unique name. Event names can be up to 40 characters long, may only contain +// alphanumeric characters and underscores ("_"), and must start with an +// alphabetic character. The "firebase_", "google_", and "ga_" prefixes are +// reserved and should not be used. + +namespace firebase::analytics { + +// Ad Impression event. This event signifies when a user sees an ad impression. +// 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 kParameterAdPlatform (string) (optional)
  • +//
  • @c kParameterAdFormat (string) (optional)
  • +//
  • @c kParameterAdSource (string) (optional)
  • +//
  • @c kParameterAdUnitName (string) (optional)
  • +//
  • @c kParameterCurrency (string) (optional)
  • +//
  • @c kParameterValue (double) (optional)
  • +//
+inline constexpr char kEventPublicAdImpression[] = "ad_impression"; + +// 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 +// metrics can be computed accurately. Params: +// +//
    +//
  • @c kParameterCoupon (string) (optional)
  • +//
  • @c kParameterCurrency (string) (optional)
  • +//
  • @c kParameterItems (array) (optional)
  • +//
  • @c kParameterPaymentType (string) (optional)
  • +//
  • @c kParameterValue (double) (optional)
  • +//
+inline constexpr char kEventAddPaymentInfo[] = "add_payment_info"; + +// Add Shipping Info event. This event signifies that a user has submitted their +// shipping information. 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 kParameterCoupon (string) (optional)
  • +//
  • @c kParameterCurrency (string) (optional)
  • +//
  • @c kParameterItems (array) (optional)
  • +//
  • @c kParameterShippingTier (string) (optional)
  • +//
  • @c kParameterValue (double) (optional)
  • +//
+inline constexpr char kEventAddShippingInfo[] = "add_shipping_info"; + +// Add to Cart event. This event signifies that an item was added to a cart for +// purchase. Add this event to a funnel with @c kEventPurchase to gauge the +// effectiveness of your checkout process. 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) (optional)
  • +//
  • @c kParameterItems (array) (optional)
  • +//
  • @c kParameterValue (double) (optional)
  • +//
+inline constexpr char kEventAddToCart[] = "add_to_cart"; + +// Add to Wishlist event. This event signifies that an item was added to a +// wishlist. Use this event to identify popular gift items. 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) (optional)
  • +//
  • @c kParameterItems (array) (optional)
  • +//
  • @c kParameterValue (double) (optional)
  • +//
+inline constexpr char kEventAddToWishlist[] = "add_to_wishlist"; + +// App Open event. By logging this event when an App becomes active, developers +// can understand how often users leave and return during the course of a +// Session. Although Sessions are automatically reported, this event can provide +// further clarification around the continuous engagement of app-users. +inline constexpr char kEventAppOpen[] = "app_open"; + +// E-Commerce Begin Checkout event. This event signifies that a user has begun +// the process of checking out. Add this event to a funnel with your @c +// kEventPurchase event to gauge the effectiveness of your checkout process. +// 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 kParameterCoupon (string) (optional)
  • +//
  • @c kParameterCurrency (string) (optional)
  • +//
  • @c kParameterItems (array) (optional)
  • +//
  • @c kParameterValue (double) (optional)
  • +//
+inline constexpr char kEventBeginCheckout[] = "begin_checkout"; + +// Campaign Detail event. Log this event to supply the referral details of a +// re-engagement campaign. Note: you must supply at least one of the required +// parameters kParameterSource, kParameterMedium or kParameterCampaign. Params: +// +//
    +//
  • @c kParameterSource (string)
  • +//
  • @c kParameterMedium (string)
  • +//
  • @c kParameterCampaign (string)
  • +//
  • @c kParameterTerm (string) (optional)
  • +//
  • @c kParameterContent (string) (optional)
  • +//
  • @c kParameterAdNetworkClickId (string) (optional)
  • +//
  • @c kParameterCP1 (string) (optional)
  • +//
+inline constexpr char kEventCampaignDetails[] = "campaign_details"; + +// Earn Virtual Currency event. This event tracks the awarding of virtual +// currency in your app. Log this along with @c kEventSpendVirtualCurrency to +// better understand your virtual economy. Params: +// +//
    +//
  • @c kParameterVirtualCurrencyName (string)
  • +//
  • @c kParameterValue (signed 64-bit integer or double)
  • +//
+inline constexpr char kEventEarnVirtualCurrency[] = "earn_virtual_currency"; + +// Generate Lead event. Log this event when a lead has been generated in the app +// to understand the efficacy of your install and re-engagement campaigns. 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) (optional)
  • +//
  • @c kParameterValue (double) (optional)
  • +//
+inline constexpr char kEventGenerateLead[] = "generate_lead"; + +// Join Group event. Log this event when a user joins a group such as a guild, +// team or family. Use this event to analyze how popular certain groups or +// social features are in your app. Params: +// +//
    +//
  • @c kParameterGroupId (string)
  • +//
+inline constexpr char kEventJoinGroup[] = "join_group"; + +// Level Start event. Log this event when the user starts a level. Params: +// +//
    +//
  • @c kParameterLevelName (string)
  • +//
  • @c kParameterSuccess (string)
  • +//
+inline constexpr char kEventLevelEnd[] = "level_end"; + +// Level Up event. Log this event when the user finishes a level. Params: +// +//
    +//
  • @c kParameterLevelName (string)
  • +//
  • @c kParameterSuccess (string)
  • +//
+inline constexpr char kEventLevelStart[] = "level_start"; + +// Level Up event. This event signifies that a player has leveled up in your +// gaming app. It can help you gauge the level distribution of your userbase +// and help you identify certain levels that are difficult to pass. Params: +// +//
    +//
  • @c kParameterLevel (signed 64-bit integer)
  • +//
  • @c kParameterCharacter (string) (optional)
  • +//
+inline constexpr char kEventLevelUp[] = "level_up"; + +// Login event. Apps with a login feature can report this event to signify that +// a user has logged in. +inline constexpr char kEventLogin[] = "login"; + +// Post Score event. Log this event when the user posts a score in your gaming +// app. This event can help you understand how users are actually performing in +// your game and it can help you correlate high scores with certain audiences or +// behaviors. Params: +// +//
    +//
  • @c kParameterScore (signed 64-bit integer)
  • +//
  • @c kParameterLevel (signed 64-bit integer) (optional)
  • +//
  • @c kParameterCharacter (string) (optional)
  • +//
+//
  • @c kParameterAffiliation (string) (optional)
  • +//
  • @c kParameterCoupon (string) (optional)
  • +//
  • @c kParameterCurrency (string) (optional)
  • +//
  • @c kParameterItems (array) (optional)
  • +//
  • @c kParameterShipping (double) (optional)
  • +//
  • @c kParameterTax (double) (optional)
  • +//
  • @c kParameterTransactionId (string) (optional)
  • +//
  • @c kParameterValue (double) (optional)
  • +// +inline constexpr char kEventPurchase[] = "purchase"; + +// E-Commerce Refund event. This event signifies that a refund was issued. +// 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 kParameterAffiliation (string) (optional)
    • +//
    • @c kParameterCoupon (string) (optional)
    • +//
    • @c kParameterCurrency (string) (optional)
    • +//
    • @c kParameterItems (array) (optional)
    • +//
    • @c kParameterShipping (double) (optional)
    • +//
    • @c kParameterTax (double) (optional)
    • +//
    • @c kParameterTransactionId (string) (optional)
    • +//
    • @c kParameterValue (double) (optional)
    • +//
    +inline constexpr char kEventRefund[] = "refund"; + +// E-Commerce Remove from Cart event. This event signifies that an item(s) was +// removed from a cart. 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) (optional)
    • +//
    • @c kParameterItems (array) (optional)
    • +//
    • @c kParameterValue (double) (optional)
    • +//
    +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: +// +//
      +//
    • @c kParameterScreenClass (string) (required)
    • +//
    • @c kParameterScreenName (string) (optional)
    • +//
    +inline constexpr char kEventScreenView[] = "screen_view"; + +// Search event. Apps that support search features can use this event to +// contextualize search operations by supplying the appropriate, corresponding +// parameters. This event can help you identify the most popular content in your +// app. Params: +// +//
      +//
    • @c kParameterSearchTerm (string)
    • +//
    • @c kParameterStartDate (string) (optional)
    • +//
    • @c kParameterEndDate (string) (optional)
    • +//
    • @c kParameterNumberOfNights (signed 64-bit integer) +// (optional) for hotel bookings
    • +//
    • @c kParameterNumberOfRooms (signed 64-bit integer) +// (optional) for hotel bookings
    • +//
    • @c kParameterNumberOfPassengers (signed 64-bit integer) +// (optional) for travel bookings
    • +//
    • @c kParameterOrigin (string) (optional)
    • +//
    • @c kParameterDestination (string) (optional)
    • +//
    • @c kParameterTravelClass (string) (optional) for travel bookings
    • +//
    +inline constexpr char kEventSearch[] = "search"; + +// Select Content event. This general purpose event signifies that a user has +// selected some content of a certain type in an app. The content can be any +// object in your app. This event can help you identify popular content and +// categories of content in your app. Params: +// +//
      +//
    • @c kParameterContentType (string)
    • +//
    • @c kParameterItemId (string)
    • +//
    +inline constexpr char kEventSelectContent[] = "select_content"; + +// Select Item event. This event signifies that an item was selected by a user +// from a list. Use the appropriate parameters to contextualize the event. Use +// this event to discover the most popular items selected. Params: +// +//
      +//
    • @c kParameterItems (array) (optional)
    • +//
    • @c kParameterItemListId (string) (optional)
    • +//
    • @c kParameterItemListName (string) (optional)
    • +//
    +inline constexpr char kEventSelectItem[] = "select_item"; + +// Select Promotion event. This event signifies that a user has selected a +// promotion offer. Use the appropriate parameters to contextualize the event, +// such as the item(s) for which the promotion applies. Params: +// +//
      +//
    • @c kParameterCreativeName (string) (optional)
    • +//
    • @c kParameterCreativeSlot (string) (optional)
    • +//
    • @c kParameterItems (array) (optional)
    • +//
    • @c kParameterLocationId (string) (optional)
    • +//
    • @c kParameterPromotionId (string) (optional)
    • +//
    • @c kParameterPromotionName (string) (optional)
    • +//
    +inline constexpr char kEventSelectPromotion[] = "select_promotion"; + +// Share event. Apps with social features can log the Share event to identify +// the most viral content. Params: +// +//
      +//
    • @c kParameterContentType (string)
    • +//
    • @c kParameterItemId (string)
    • +//
    +inline constexpr char kEventShare[] = "share"; + +// Sign Up event. This event indicates that a user has signed up for an account +// in your app. The parameter signifies the method by which the user signed up. +// Use this event to understand the different behaviors between logged in and +// logged out users. Params: +// +//
      +//
    • @c kParameterSignUpMethod (string)
    • +//
    +inline constexpr char kEventSignUp[] = "sign_up"; + +// Spend Virtual Currency event. This event tracks the sale of virtual goods in +// your app and can help you identify which virtual goods are the most popular +// objects of purchase. Params: +// +//
      +//
    • @c kParameterItemName (string)
    • +//
    • @c kParameterVirtualCurrencyName (string)
    • +//
    • @c kParameterValue (signed 64-bit integer or double)
    • +//
    +inline constexpr char kEventSpendVirtualCurrency[] = "spend_virtual_currency"; + +// Tutorial Begin event. This event signifies the start of the on-boarding +// process in your app. Use this in a funnel with kEventTutorialComplete to +// understand how many users complete this process and move on to the full app +// experience. +inline constexpr char kEventTutorialBegin[] = "tutorial_begin"; + +// Tutorial End event. Use this event to signify the user's completion of your +// app's on-boarding process. Add this to a funnel with kEventTutorialBegin to +// gauge the completion rate of your on-boarding process. +inline constexpr char kEventTutorialComplete[] = "tutorial_complete"; + +// Unlock Achievement event. Log this event when the user has unlocked an +// achievement in your game. Since achievements generally represent the breadth +// of a gaming experience, this event can help you understand how many users +// are experiencing all that your game has to offer. Params: +// +//
      +//
    • @c kParameterAchievementId (string)
    • +//
    +inline constexpr char kEventUnlockAchievement[] = "unlock_achievement"; + +// E-commerce View Cart event. This event signifies that a user has viewed +// their cart. Use this to analyze your purchase funnel. 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) (optional)
    • +//
    • @c kParameterItems (array) (optional)
    • +//
    • @c kParameterValue (double) (optional)
    • +//
    +inline constexpr char kEventViewCart[] = "view_cart"; + +// View Item event. This event signifies that a user has viewed an item. Use +// the appropriate parameters to contextualize the event. Use this event to +// discover the most popular items viewed in your app. 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) (optional)
    • +//
    • @c kParameterItems (array) (optional)
    • +//
    • @c kParameterValue (double) (optional)
    • +//
    +inline constexpr char kEventViewItem[] = "view_item"; + +// View Item List event. Log this event when a user sees a list of items or +// offerings. Params: +// +//
      +//
    • @c kParameterItems (array) (optional)
    • +//
    • @c kParameterItemListId (string) (optional)
    • +//
    • @c kParameterItemListName (string) (optional)
    • +//
    +inline constexpr char kEventViewItemList[] = "view_item_list"; + +// View Promotion event. This event signifies that a promotion was shown to a +// user. Add this event to a funnel with the @c kEventAddToCart and +// @c kEventPurchase to gauge your conversion process. Params: +// +//
      +//
    • @c kParameterCreativeName (string) (optional)
    • +//
    • @c kParameterCreativeSlot (string) (optional)
    • +//
    • @c kParameterItems (array) (optional)
    • +//
    • @c kParameterLocationId (string) (optional)
    • +//
    • @c kParameterPromotionId (string) (optional)
    • +//
    • @c kParameterPromotionName (string) (optional)
    • +//
    +inline constexpr char kEventViewPromotion[] = "view_promotion"; + +// View Search Results event. Log this event when the user has been presented +// with the results of a search. Params: +// +//
      +//
    • @c kParameterSearchTerm (string)
    • +//
    +inline constexpr char kEventViewSearchResults[] = "view_search_results"; + +} // namespace firebase::analytics + +#endif // ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_EVENT_NAMES_H_ diff --git a/analytics/windows/include/public/parameter_names.h b/analytics/windows/include/public/parameter_names.h new file mode 100644 index 0000000000..7c5f45695e --- /dev/null +++ b/analytics/windows/include/public/parameter_names.h @@ -0,0 +1,253 @@ +// Copyright 2025 Google LLC +#ifndef ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_PARAMETER_NAMES_H_ +#define ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_PARAMETER_NAMES_H_ + +namespace firebase::analytics { + +// Game achievement ID (string). +inline constexpr char kParameterAchievementId[] = "achievement_id"; + +// The ad format (e.g. Banner, Interstitial, Rewarded, Native, Rewarded +// Interstitial, Instream). (string). +inline constexpr char kParameterAdFormat[] = "ad_format"; + +// Ad Network Click ID (string). Used for network-specific click IDs which vary +// in format. +inline constexpr char kParameterAdNetworkClickId[] = "aclid"; + +// The ad platform (e.g. MoPub, IronSource) (string). +inline constexpr char kParameterAdPlatform[] = "ad_platform"; + +// The ad source (e.g. AdColony) (string). +inline constexpr char kParameterAdSource[] = "ad_source"; + +// The ad unit name (e.g. Banner_03) (string). +inline constexpr char kParameterAdUnitName[] = "ad_unit_name"; + +// A product affiliation to designate a supplying company or brick and mortar +// store location (string). +inline constexpr char kParameterAffiliation[] = "affiliation"; + +// Campaign custom parameter (string). Used as a method of capturing custom data +// in a campaign. Use varies by network. +inline constexpr char kParameterCP1[] = "cp1"; + +// The individual campaign name, slogan, promo code, etc. Some networks have +// pre-defined macro to capture campaign information, otherwise can be populated +// by developer. Highly Recommended (string). +inline constexpr char kParameterCampaign[] = "campaign"; + +// Campaign ID (string). Used for keyword analysis to identify a specific +// product promotion or strategic campaign. This is a required key for GA4 data +// import. +inline constexpr char kParameterCampaignId[] = "campaign_id"; + +// Character used in game (string). +inline constexpr char kParameterCharacter[] = "character"; + +// Campaign content (string). +inline constexpr char kParameterContent[] = "content"; + +// Type of content selected (string). +inline constexpr char kParameterContentType[] = "content_type"; + +// Coupon code used for a purchase (string). +inline constexpr char kParameterCoupon[] = "coupon"; + +// Creative Format (string). Used to identify the high-level classification of +// the type of ad served by a specific campaign. +inline constexpr char kParameterCreativeFormat[] = "creative_format"; + +// The name of a creative used in a promotional spot (string). +inline constexpr char kParameterCreativeName[] = "creative_name"; + +// The name of a creative slot (string). +inline constexpr char kParameterCreativeSlot[] = "creative_slot"; + +// Currency of the purchase or items associated with the event, in 3-letter +// ISO_4217 format (string). +inline constexpr char kParameterCurrency[] = "currency"; + +// Flight or Travel destination (string). +inline constexpr char kParameterDestination[] = "destination"; + +// Monetary value of discount associated with a purchase (double). +inline constexpr char kParameterDiscount[] = "discount"; + +// The arrival date, check-out date or rental end date for the item. This should +// be in YYYY-MM-DD format (string). +inline constexpr char kParameterEndDate[] = "end_date"; + +// Indicates that the associated event should either extend the current session +// or start a new session if no session was active when the event was logged. +// Specify 1 to extend the current session or to start a new session; any other +// value will not extend or start a session. +inline constexpr char kParameterExtendSession[] = "extend_session"; + +// Flight or Travel origin (string). +inline constexpr char kParameterFlightNumber[] = "flight_number"; + +// Group/clan/guild ID (string). +inline constexpr char kParameterGroupId[] = "group_id"; + +// Index of an item in a list (integer). +inline constexpr char kParameterIndex[] = "index"; + +// Item brand (string). +inline constexpr char kParameterItemBrand[] = "item_brand"; + +// Item category (context-specific) (string). +inline constexpr char kParameterItemCategory[] = "item_category"; + +// Item category (context-specific) (string). +inline constexpr char kParameterItemCategory2[] = "item_category2"; + +// Item category (context-specific) (string). +inline constexpr char kParameterItemCategory3[] = "item_category3"; + +// Item category (context-specific) (string). +inline constexpr char kParameterItemCategory4[] = "item_category4"; + +// Item category (context-specific) (string). +inline constexpr char kParameterItemCategory5[] = "item_category5"; + +// Item ID (context-specific) (string). +inline constexpr char kParameterItemId[] = "item_id"; + +// The ID of the list in which the item was presented to the user (string). +inline constexpr char kParameterItemListId[] = "item_list_id"; + +// The name of the list in which the item was presented to the user (string). +inline constexpr char kParameterItemListName[] = "item_list_name"; + +// Item Name (context-specific) (string). +inline constexpr char kParameterItemName[] = "item_name"; + +// Item variant (string). +inline constexpr char kParameterItemVariant[] = "item_variant"; + +// The list of items involved in the transaction expressed as `[[String: Any]]`. +inline constexpr char kParameterItems[] = "items"; + +// Level in game (integer). +inline constexpr char kParameterLevel[] = "level"; + +// Location (string). The Google Place ID +// that corresponds to the associated event. Alternatively, you can supply +// your own custom Location ID. +inline constexpr char kParameterLocation[] = "location"; + +// The location associated with the event. Preferred to be the Google +// Place ID that +// corresponds to the associated item but could be overridden to a custom +// location ID string.(string). +inline constexpr char kParameterLocationId[] = "location_id"; + +// Marketing Tactic (string). Used to identify the targeting criteria applied to +// a specific campaign. +inline constexpr char kParameterMarketingTactic[] = "marketing_tactic"; + +// The method used to perform an operation (string). +inline constexpr char kParameterMethod[] = "method"; + +// Number of nights staying at hotel (integer). +inline constexpr char kParameterNumberOfNights[] = "number_of_nights"; + +// Number of passengers traveling (integer). +inline constexpr char kParameterNumberOfPassengers[] = "number_of_passengers"; + +// Number of rooms for travel events (integer). +inline constexpr char kParameterNumberOfRooms[] = "number_of_rooms"; + +// Flight or Travel origin (string). +inline constexpr char kParameterOrigin[] = "origin"; + +// The chosen method of payment (string). +inline constexpr char kParameterPaymentType[] = "payment_type"; + +// Purchase price (double). +inline constexpr char kParameterPrice[] = "price"; + +// The ID of a product promotion (string). +inline constexpr char kParameterPromotionId[] = "promotion_id"; + +// The name of a product promotion (string). +inline constexpr char kParameterPromotionName[] = "promotion_name"; + +// Purchase quantity (integer). +inline constexpr char kParameterQuantity[] = "quantity"; + +// Score in game (integer). +inline constexpr char kParameterScore[] = "score"; + +// Current screen class, such as the class name of the UI view controller, +// logged with screen_view event and added to every event (string). +inline constexpr char kParameterScreenClass[] = "screen_class"; + +// Current screen name, such as the name of the UI view, logged with screen_view +// event and added to every event (string). +inline constexpr char kParameterScreenName[] = "screen_name"; + +// The search string/keywords used (string). +inline constexpr char kParameterSearchTerm[] = "search_term"; + +// Shipping cost associated with a transaction (double). +inline constexpr char kParameterShipping[] = "shipping"; + +// The shipping tier (e.g. Ground, Air, Next-day) selected for delivery of the +// purchased item (string). +inline constexpr char kParameterShippingTier[] = "shipping_tier"; + +// The origin of your traffic, such as an Ad network (for example, google) or +// partner (urban airship). Identify the advertiser, site, publication, etc. +// that is sending traffic to your property. Highly recommended (string). +inline constexpr char kParameterSource[] = "source"; + +// Source Platform (string). Used to identify the platform responsible for +// directing traffic to a given Analytics property (e.g., a buying platform +// where budgets, targeting criteria, etc. are set, a platform for managing +// organic traffic data, etc.). +inline constexpr char kParameterSourcePlatform[] = "source_platform"; + +// The departure date, check-in date or rental start date for the item. This +// should be in YYYY-MM-DD format (string). +inline constexpr char kParameterStartDate[] = "start_date"; + +// The result of an operation. Specify 1 to indicate success and 0 to indicate +// failure (integer). +inline constexpr char kParameterSuccess[] = "success"; + +// Tax cost associated with a transaction (double). +inline constexpr char kParameterTax[] = "tax"; + +// If you're manually tagging keyword campaigns, you should use utm_term to +// specify the keyword (string). +inline constexpr char kParameterTerm[] = "term"; + +// The unique identifier of a transaction (string). +inline constexpr char kParameterTransactionId[] = "transaction_id"; + +// Travel class (string). +inline constexpr char kParameterTravelClass[] = "travel_class"; + +// A context-specific numeric value which is accumulated automatically for each +// event type. This is a general purpose parameter that is useful for +// accumulating a key metric that pertains to an event. Examples include +// revenue, distance, time and points. Value should be specified as integer or +// double. +// Notes: Values for pre-defined currency-related events (such as @c +// kEventAddToCart) should be supplied using Double and must be accompanied by a +// @c kParameterCurrency parameter. The valid range of accumulated values is +// [-9,223,372,036,854.77, 9,223,372,036,854.77]. Supplying a non-numeric value, +// omitting the corresponding @c kParameterCurrency parameter, or supplying an +// invalid currency code for conversion +// events will cause that conversion to be omitted from reporting. +inline constexpr char kParameterValue[] = "value"; + +// The type of virtual currency being used (string). +inline constexpr char kParameterVirtualCurrencyName[] = "virtual_currency_name"; + +} // namespace firebase::analytics + +#endif // ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_PARAMETER_NAMES_H_