|
15 | 15 | #include "analytics/src/windows/analytics_windows.h" |
16 | 16 | #include "app/src/include/firebase/app.h" |
17 | 17 | #include "analytics/src/include/firebase/analytics.h" // Path confirmed to remain as is |
| 18 | +#include "analytics/src/common/analytics_common.h" |
18 | 19 | #include "common/src/include/firebase/variant.h" |
19 | 20 | #include "app/src/include/firebase/future.h" |
20 | 21 | #include "app/src/include/firebase/log.h" |
|
24 | 25 | #include <string> |
25 | 26 | #include <map> |
26 | 27 |
|
27 | | -// Error code for Analytics features not supported on this platform. (Will be removed) |
28 | | -// const int kAnalyticsErrorNotSupportedOnPlatform = 1; // Or a more specific range |
29 | | - |
30 | 28 | namespace firebase { |
31 | 29 | namespace analytics { |
32 | 30 |
|
33 | | -namespace internal { // Or directly in firebase::analytics if that's the pattern |
34 | | -// Functions that return a Future. |
35 | | -enum AnalyticsFn { |
36 | | - kAnalyticsFn_GetAnalyticsInstanceId = 0, |
37 | | - kAnalyticsFn_GetSessionId, |
38 | | - kAnalyticsFnCount // Must be the last enum value. |
39 | | -}; |
40 | | -} // namespace internal |
| 31 | +// (Local AnalyticsFn enum removed, assuming it's now provided by analytics_common.h) |
| 32 | +// namespace internal { |
| 33 | +// // Functions that return a Future. |
| 34 | +// enum AnalyticsFn { |
| 35 | +// kAnalyticsFn_GetAnalyticsInstanceId = 0, |
| 36 | +// kAnalyticsFn_GetSessionId, |
| 37 | +// kAnalyticsFnCount // Must be the last enum value. |
| 38 | +// }; |
| 39 | +// } // namespace internal |
41 | 40 |
|
42 | 41 | // Future data for analytics. |
43 | 42 | // This is initialized in `Initialize()` and cleaned up in `Terminate()`. |
@@ -103,12 +102,8 @@ static void ConvertParametersToGAParams( |
103 | 102 | GoogleAnalytics_EventParameters_InsertString( |
104 | 103 | c_event_params, param.name, param.value.string_value()); |
105 | 104 | } else if (param.value.is_vector()) { |
106 | | - // Vector types for top-level event parameters are not directly supported for conversion |
107 | | - // to GoogleAnalytics_EventParameters on Desktop. |
108 | | - // The previous implementation attempted to interpret a vector of maps as an "Item Array", |
109 | | - // but the standard way to log an array of Items is via a single parameter (e.g., "items") |
110 | | - // whose value is a vector of firebase::analytics::Item objects (which are maps). |
111 | | - // For direct parameters, vector is an unsupported type. |
| 105 | + // Vector types for top-level event parameters are not supported on Desktop. |
| 106 | + // Only specific complex types (like a map processed into an ItemVector) are handled. |
112 | 107 | LogError("Analytics: Parameter '%s' has type Vector, which is unsupported for event parameters on Desktop. Skipping.", param.name); |
113 | 108 | continue; // Skip this parameter |
114 | 109 | } else if (param.value.is_map()) { |
@@ -143,32 +138,28 @@ static void ConvertParametersToGAParams( |
143 | 138 | continue; // Skip this key-value pair, try next one in map |
144 | 139 | } |
145 | 140 |
|
146 | | - // Store the original map's key as the "name" of this item property |
147 | | - GoogleAnalytics_Item_InsertString(c_item, "name", key_from_map.c_str()); |
| 141 | + // Removed: GoogleAnalytics_Item_InsertString(c_item, "name", key_from_map.c_str()); |
148 | 142 |
|
149 | | - bool value_property_set = false; |
| 143 | + bool item_had_valid_property = false; |
150 | 144 | if (value_from_map.is_int64()) { |
151 | | - GoogleAnalytics_Item_InsertInt(c_item, "int_value", value_from_map.int64_value()); |
152 | | - value_property_set = true; |
| 145 | + GoogleAnalytics_Item_InsertInt(c_item, key_from_map.c_str(), value_from_map.int64_value()); |
| 146 | + item_had_valid_property = true; |
153 | 147 | } else if (value_from_map.is_double()) { |
154 | | - GoogleAnalytics_Item_InsertDouble(c_item, "double_value", value_from_map.double_value()); |
155 | | - value_property_set = true; |
| 148 | + GoogleAnalytics_Item_InsertDouble(c_item, key_from_map.c_str(), value_from_map.double_value()); |
| 149 | + item_had_valid_property = true; |
156 | 150 | } else if (value_from_map.is_string()) { |
157 | | - GoogleAnalytics_Item_InsertString(c_item, "string_value", value_from_map.string_value()); |
158 | | - value_property_set = true; |
| 151 | + GoogleAnalytics_Item_InsertString(c_item, key_from_map.c_str(), value_from_map.string_value()); |
| 152 | + item_had_valid_property = true; |
159 | 153 | } else { |
160 | 154 | LogWarning("Analytics: Value for key '%s' in map parameter '%s' has an unsupported Variant type. This key-value pair will be skipped.", key_from_map.c_str(), param.name); |
161 | | - // As "name" was set, but no value, this item is incomplete. |
162 | 155 | } |
163 | 156 |
|
164 | | - if (value_property_set) { |
| 157 | + if (item_had_valid_property) { |
165 | 158 | GoogleAnalytics_ItemVector_InsertItem(c_item_vector, c_item); |
166 | 159 | // c_item is now owned by c_item_vector |
167 | 160 | item_vector_populated = true; |
168 | 161 | } else { |
169 | | - // If value wasn't set (e.g. unsupported type), or c_item creation failed. |
170 | | - // (c_item creation failure is handled by 'continue' above, so this 'else' |
171 | | - // is mainly for when value_property_set is false due to unsupported type) |
| 162 | + // If no valid property was set for this c_item (e.g., value type was unsupported) |
172 | 163 | GoogleAnalytics_Item_Destroy(c_item); |
173 | 164 | } |
174 | 165 | } |
|
0 commit comments