Skip to content

Commit d806c1f

Browse files
committed
Update DLL.
1 parent e75fb8c commit d806c1f

File tree

7 files changed

+263
-15
lines changed

7 files changed

+263
-15
lines changed

analytics/src/analytics_desktop_dynamic.c

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,26 @@ static void* g_stub_memory = NULL;
2323
// clang-format off
2424

2525
// Number of Google Analytics functions expected to be loaded from the DLL.
26-
const int FirebaseAnalytics_DynamicFunctionCount = 19;
26+
const int FirebaseAnalytics_DynamicFunctionCount = 22;
2727

2828
#if defined(_WIN32)
29-
// Google Analytics Windows DLL SHA256 hash, to be verified on load.
30-
const unsigned char FirebaseAnalytics_WindowsDllHash[] = {
31-
0xc1, 0xb9, 0xff, 0x6e, 0x91, 0x19, 0xc3, 0x0b, 0xbe, 0xb7, 0x47, 0x23, 0x26, 0xdc, 0xde, 0x41, 0x8f, 0x45, 0x68, 0x2e, 0x6b, 0x82, 0x2e, 0x25, 0xee, 0xd9, 0x22, 0xfe, 0x6e, 0x3c, 0xc6, 0x98
29+
// Array of known Google Analytics Windows DLL SHA256 hashes (hex strings).
30+
const char* FirebaseAnalytics_KnownWindowsDllHashes[] = {
31+
"13ae5f9349b24186f1f3667b52832076e8d14ad9656c3546b1b7fca79ac8144b"
3232
};
3333
#endif // defined(_WIN32)
3434

3535
// --- Stub Function Definitions ---
36+
// Stub for GoogleAnalytics_Options_Create
37+
static GoogleAnalytics_Options* Stub_GoogleAnalytics_Options_Create() {
38+
return (GoogleAnalytics_Options*)(&g_stub_memory);
39+
}
40+
41+
// Stub for GoogleAnalytics_Options_Destroy
42+
static void Stub_GoogleAnalytics_Options_Destroy(GoogleAnalytics_Options* options) {
43+
// No return value.
44+
}
45+
3646
// Stub for GoogleAnalytics_Item_Create
3747
static GoogleAnalytics_Item* Stub_GoogleAnalytics_Item_Create() {
3848
return (GoogleAnalytics_Item*)(&g_stub_memory);
@@ -113,6 +123,11 @@ static void Stub_GoogleAnalytics_EventParameters_Destroy(GoogleAnalytics_EventPa
113123
// No return value.
114124
}
115125

126+
// Stub for GoogleAnalytics_Initialize
127+
static bool Stub_GoogleAnalytics_Initialize(const GoogleAnalytics_Options* options) {
128+
return 1;
129+
}
130+
116131
// Stub for GoogleAnalytics_LogEvent
117132
static void Stub_GoogleAnalytics_LogEvent(const char* name, GoogleAnalytics_EventParameters* parameters) {
118133
// No return value.
@@ -141,6 +156,8 @@ static void Stub_GoogleAnalytics_SetAnalyticsCollectionEnabled(bool enabled) {
141156

142157

143158
// --- Function Pointer Initializations ---
159+
GoogleAnalytics_Options* (*ptr_GoogleAnalytics_Options_Create)() = &Stub_GoogleAnalytics_Options_Create;
160+
void (*ptr_GoogleAnalytics_Options_Destroy)(GoogleAnalytics_Options* options) = &Stub_GoogleAnalytics_Options_Destroy;
144161
GoogleAnalytics_Item* (*ptr_GoogleAnalytics_Item_Create)() = &Stub_GoogleAnalytics_Item_Create;
145162
void (*ptr_GoogleAnalytics_Item_InsertInt)(GoogleAnalytics_Item* item, const char* key, int64_t value) = &Stub_GoogleAnalytics_Item_InsertInt;
146163
void (*ptr_GoogleAnalytics_Item_InsertDouble)(GoogleAnalytics_Item* item, const char* key, double value) = &Stub_GoogleAnalytics_Item_InsertDouble;
@@ -155,6 +172,7 @@ void (*ptr_GoogleAnalytics_EventParameters_InsertDouble)(GoogleAnalytics_EventPa
155172
void (*ptr_GoogleAnalytics_EventParameters_InsertString)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, const char* value) = &Stub_GoogleAnalytics_EventParameters_InsertString;
156173
void (*ptr_GoogleAnalytics_EventParameters_InsertItemVector)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, GoogleAnalytics_ItemVector* value) = &Stub_GoogleAnalytics_EventParameters_InsertItemVector;
157174
void (*ptr_GoogleAnalytics_EventParameters_Destroy)(GoogleAnalytics_EventParameters* event_parameter_map) = &Stub_GoogleAnalytics_EventParameters_Destroy;
175+
bool (*ptr_GoogleAnalytics_Initialize)(const GoogleAnalytics_Options* options) = &Stub_GoogleAnalytics_Initialize;
158176
void (*ptr_GoogleAnalytics_LogEvent)(const char* name, GoogleAnalytics_EventParameters* parameters) = &Stub_GoogleAnalytics_LogEvent;
159177
void (*ptr_GoogleAnalytics_SetUserProperty)(const char* name, const char* value) = &Stub_GoogleAnalytics_SetUserProperty;
160178
void (*ptr_GoogleAnalytics_SetUserId)(const char* user_id) = &Stub_GoogleAnalytics_SetUserId;
@@ -170,6 +188,16 @@ int FirebaseAnalytics_LoadDynamicFunctions(HMODULE dll_handle) {
170188
return count;
171189
}
172190

191+
FARPROC proc_GoogleAnalytics_Options_Create = GetProcAddress(dll_handle, "GoogleAnalytics_Options_Create");
192+
if (proc_GoogleAnalytics_Options_Create) {
193+
ptr_GoogleAnalytics_Options_Create = (GoogleAnalytics_Options* (*)())proc_GoogleAnalytics_Options_Create;
194+
count++;
195+
}
196+
FARPROC proc_GoogleAnalytics_Options_Destroy = GetProcAddress(dll_handle, "GoogleAnalytics_Options_Destroy");
197+
if (proc_GoogleAnalytics_Options_Destroy) {
198+
ptr_GoogleAnalytics_Options_Destroy = (void (*)(GoogleAnalytics_Options* options))proc_GoogleAnalytics_Options_Destroy;
199+
count++;
200+
}
173201
FARPROC proc_GoogleAnalytics_Item_Create = GetProcAddress(dll_handle, "GoogleAnalytics_Item_Create");
174202
if (proc_GoogleAnalytics_Item_Create) {
175203
ptr_GoogleAnalytics_Item_Create = (GoogleAnalytics_Item* (*)())proc_GoogleAnalytics_Item_Create;
@@ -240,6 +268,11 @@ int FirebaseAnalytics_LoadDynamicFunctions(HMODULE dll_handle) {
240268
ptr_GoogleAnalytics_EventParameters_Destroy = (void (*)(GoogleAnalytics_EventParameters* event_parameter_map))proc_GoogleAnalytics_EventParameters_Destroy;
241269
count++;
242270
}
271+
FARPROC proc_GoogleAnalytics_Initialize = GetProcAddress(dll_handle, "GoogleAnalytics_Initialize");
272+
if (proc_GoogleAnalytics_Initialize) {
273+
ptr_GoogleAnalytics_Initialize = (bool (*)(const GoogleAnalytics_Options* options))proc_GoogleAnalytics_Initialize;
274+
count++;
275+
}
243276
FARPROC proc_GoogleAnalytics_LogEvent = GetProcAddress(dll_handle, "GoogleAnalytics_LogEvent");
244277
if (proc_GoogleAnalytics_LogEvent) {
245278
ptr_GoogleAnalytics_LogEvent = (void (*)(const char* name, GoogleAnalytics_EventParameters* parameters))proc_GoogleAnalytics_LogEvent;
@@ -270,6 +303,8 @@ int FirebaseAnalytics_LoadDynamicFunctions(HMODULE dll_handle) {
270303
}
271304

272305
void FirebaseAnalytics_UnloadDynamicFunctions(void) {
306+
ptr_GoogleAnalytics_Options_Create = &Stub_GoogleAnalytics_Options_Create;
307+
ptr_GoogleAnalytics_Options_Destroy = &Stub_GoogleAnalytics_Options_Destroy;
273308
ptr_GoogleAnalytics_Item_Create = &Stub_GoogleAnalytics_Item_Create;
274309
ptr_GoogleAnalytics_Item_InsertInt = &Stub_GoogleAnalytics_Item_InsertInt;
275310
ptr_GoogleAnalytics_Item_InsertDouble = &Stub_GoogleAnalytics_Item_InsertDouble;
@@ -284,6 +319,7 @@ void FirebaseAnalytics_UnloadDynamicFunctions(void) {
284319
ptr_GoogleAnalytics_EventParameters_InsertString = &Stub_GoogleAnalytics_EventParameters_InsertString;
285320
ptr_GoogleAnalytics_EventParameters_InsertItemVector = &Stub_GoogleAnalytics_EventParameters_InsertItemVector;
286321
ptr_GoogleAnalytics_EventParameters_Destroy = &Stub_GoogleAnalytics_EventParameters_Destroy;
322+
ptr_GoogleAnalytics_Initialize = &Stub_GoogleAnalytics_Initialize;
287323
ptr_GoogleAnalytics_LogEvent = &Stub_GoogleAnalytics_LogEvent;
288324
ptr_GoogleAnalytics_SetUserProperty = &Stub_GoogleAnalytics_SetUserProperty;
289325
ptr_GoogleAnalytics_SetUserId = &Stub_GoogleAnalytics_SetUserId;

analytics/src/analytics_desktop_dynamic.h

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,79 @@
2020
#include <stdbool.h> // needed for bool type in pure C
2121

2222
// --- Copied from original header ---
23+
#include <stdbool.h>
2324
#include <stdint.h>
2425

26+
/**
27+
* @brief GoogleAnalytics_Options for initializing the Analytics SDK.
28+
* GoogleAnalytics_Options_Create() must be used to create an instance of this
29+
* struct with default values. If these options are created manually instead of
30+
* using GoogleAnalytics_Options_Create(), initialization will fail, and the
31+
* caller will be responsible for destroying the options.
32+
*/
33+
ANALYTICS_API typedef struct {
34+
/**
35+
* @brief The unique identifier for the Firebase app across all of Firebase
36+
* with a platform-specific format. This is a required field, can not be null
37+
* or empty, and must be UTF-8 encoded.
38+
*
39+
* The caller is responsible for allocating this memory, and deallocating it
40+
* once the options instance has been destroyed.
41+
*
42+
* Example: 1:1234567890:android:321abc456def7890
43+
*/
44+
const char* app_id;
45+
46+
/**
47+
* @brief Unique identifier for the application implementing the SDK. The
48+
* format typically follows a reversed domain name convention. This is a
49+
* required field, can not be null or empty, and must be UTF-8 encoded.
50+
*
51+
* The caller is responsible for allocating this memory, and deallocating it
52+
* once the options instance has been destroyed.
53+
*
54+
* Example: com.google.analytics.AnalyticsApp
55+
*/
56+
const char* package_name;
57+
58+
/**
59+
* @brief Whether Analytics is enabled at the very first launch.
60+
* This value is then persisted across app sessions, and from then on, takes
61+
* precedence over the value of this field.
62+
* GoogleAnalytics_SetAnalyticsCollectionEnabled() can be used to
63+
* enable/disable after that point.
64+
*/
65+
bool analytics_collection_enabled_at_first_launch;
66+
67+
/**
68+
* @brief Reserved for internal use by the SDK.
69+
*/
70+
GoogleAnalytics_Reserved* reserved;
71+
} GoogleAnalytics_Options;
72+
73+
/**
74+
* @brief Creates an instance of GoogleAnalytics_Options with default values.
75+
*
76+
* The caller is responsible for destroying the options using the
77+
* GoogleAnalytics_Options_Destroy() function, unless it has been passed to the
78+
* GoogleAnalytics_Initialize() function, in which case it will be destroyed
79+
* automatically.
80+
*
81+
* @return A pointer to a newly allocated GoogleAnalytics_Options instance.
82+
*/
83+
ANALYTICS_API GoogleAnalytics_Options* GoogleAnalytics_Options_Create();
84+
85+
/**
86+
* @brief Destroys the GoogleAnalytics_Options instance. Must not be called if
87+
* the options were created with GoogleAnalytics_Options_Create() and passed to
88+
* the GoogleAnalytics_Initialize() function, which would destroy them
89+
* automatically.
90+
*
91+
* @param[in] options The GoogleAnalytics_Options instance to destroy.
92+
*/
93+
ANALYTICS_API void GoogleAnalytics_Options_Destroy(
94+
GoogleAnalytics_Options* options);
95+
2596
/**
2697
* @brief Opaque type for an item.
2798
*
@@ -71,6 +142,8 @@ extern "C" {
71142

72143
// --- Function Pointer Declarations ---
73144
// clang-format off
145+
extern GoogleAnalytics_Options* (*ptr_GoogleAnalytics_Options_Create)();
146+
extern void (*ptr_GoogleAnalytics_Options_Destroy)(GoogleAnalytics_Options* options);
74147
extern GoogleAnalytics_Item* (*ptr_GoogleAnalytics_Item_Create)();
75148
extern void (*ptr_GoogleAnalytics_Item_InsertInt)(GoogleAnalytics_Item* item, const char* key, int64_t value);
76149
extern void (*ptr_GoogleAnalytics_Item_InsertDouble)(GoogleAnalytics_Item* item, const char* key, double value);
@@ -85,12 +158,15 @@ extern void (*ptr_GoogleAnalytics_EventParameters_InsertDouble)(GoogleAnalytics_
85158
extern void (*ptr_GoogleAnalytics_EventParameters_InsertString)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, const char* value);
86159
extern void (*ptr_GoogleAnalytics_EventParameters_InsertItemVector)(GoogleAnalytics_EventParameters* event_parameter_map, const char* key, GoogleAnalytics_ItemVector* value);
87160
extern void (*ptr_GoogleAnalytics_EventParameters_Destroy)(GoogleAnalytics_EventParameters* event_parameter_map);
161+
extern bool (*ptr_GoogleAnalytics_Initialize)(const GoogleAnalytics_Options* options);
88162
extern void (*ptr_GoogleAnalytics_LogEvent)(const char* name, GoogleAnalytics_EventParameters* parameters);
89163
extern void (*ptr_GoogleAnalytics_SetUserProperty)(const char* name, const char* value);
90164
extern void (*ptr_GoogleAnalytics_SetUserId)(const char* user_id);
91165
extern void (*ptr_GoogleAnalytics_ResetAnalyticsData)();
92166
extern void (*ptr_GoogleAnalytics_SetAnalyticsCollectionEnabled)(bool enabled);
93167

168+
#define GoogleAnalytics_Options_Create ptr_GoogleAnalytics_Options_Create
169+
#define GoogleAnalytics_Options_Destroy ptr_GoogleAnalytics_Options_Destroy
94170
#define GoogleAnalytics_Item_Create ptr_GoogleAnalytics_Item_Create
95171
#define GoogleAnalytics_Item_InsertInt ptr_GoogleAnalytics_Item_InsertInt
96172
#define GoogleAnalytics_Item_InsertDouble ptr_GoogleAnalytics_Item_InsertDouble
@@ -105,6 +181,7 @@ extern void (*ptr_GoogleAnalytics_SetAnalyticsCollectionEnabled)(bool enabled);
105181
#define GoogleAnalytics_EventParameters_InsertString ptr_GoogleAnalytics_EventParameters_InsertString
106182
#define GoogleAnalytics_EventParameters_InsertItemVector ptr_GoogleAnalytics_EventParameters_InsertItemVector
107183
#define GoogleAnalytics_EventParameters_Destroy ptr_GoogleAnalytics_EventParameters_Destroy
184+
#define GoogleAnalytics_Initialize ptr_GoogleAnalytics_Initialize
108185
#define GoogleAnalytics_LogEvent ptr_GoogleAnalytics_LogEvent
109186
#define GoogleAnalytics_SetUserProperty ptr_GoogleAnalytics_SetUserProperty
110187
#define GoogleAnalytics_SetUserId ptr_GoogleAnalytics_SetUserId

analytics/windows/analytics_win.dll

-34 KB
Binary file not shown.

analytics/windows/include/public/analytics.h

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// Copyright 2025 Google LLC
21
#ifndef ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_ANALYTICS_H_
32
#define ANALYTICS_MOBILE_CONSOLE_MEASUREMENT_PUBLIC_ANALYTICS_H_
43

@@ -32,6 +31,38 @@ class Analytics {
3231
std::variant<int64_t, double, std::string, ItemVector>;
3332
using EventParameters = std::unordered_map<std::string, EventParameterValue>;
3433

34+
/**
35+
* @brief Options for initializing the Analytics SDK.
36+
*/
37+
struct Options {
38+
/**
39+
* @brief The unique identifier for the Firebase app across all of Firebase
40+
* with a platform-specific format. This is a required field, can not be
41+
* empty, and must be UTF-8 encoded.
42+
*
43+
* Example: 1:1234567890:android:321abc456def7890
44+
*/
45+
std::string app_id;
46+
47+
/**
48+
* @brief Unique identifier for the application implementing the SDK. The
49+
* format typically follows a reversed domain name convention. This is a
50+
* required field, can not be empty, and must be UTF-8 encoded.
51+
*
52+
* Example: com.google.analytics.AnalyticsApp
53+
*/
54+
std::string package_name;
55+
56+
/**
57+
* @brief Whether Analytics is enabled at the very first launch.
58+
* This value is then persisted across app sessions, and from then on, takes
59+
* precedence over the value of this field.
60+
* SetAnalyticsCollectionEnabled() can be used to enable/disable after that
61+
* point.
62+
*/
63+
bool analytics_collection_enabled_at_first_launch = true;
64+
};
65+
3566
/**
3667
* @brief Returns the singleton instance of the Analytics class.
3768
*/
@@ -46,6 +77,26 @@ class Analytics {
4677
Analytics(Analytics&&) = delete;
4778
Analytics& operator=(Analytics&&) = delete;
4879

80+
/**
81+
* @brief Initializes the Analytics SDK with the given options. Until this is
82+
* called, all analytics methods below will be no-ops.
83+
*
84+
* @param[in] options The options to initialize the Analytics SDK with.
85+
*
86+
* @return true if the Analytics SDK was successfully initialized, false
87+
* otherwise. Also returns false if the Analytics SDK has already been
88+
* initialized.
89+
*/
90+
bool Initialize(const Options& options) {
91+
GoogleAnalytics_Options* google_analytics_options =
92+
GoogleAnalytics_Options_Create();
93+
google_analytics_options->app_id = options.app_id.c_str();
94+
google_analytics_options->package_name = options.package_name.c_str();
95+
google_analytics_options->analytics_collection_enabled_at_first_launch =
96+
options.analytics_collection_enabled_at_first_launch;
97+
return GoogleAnalytics_Initialize(google_analytics_options);
98+
}
99+
49100
/**
50101
* @brief Logs an app event.
51102
*

0 commit comments

Comments
 (0)