|
15 | 15 | */ |
16 | 16 |
|
17 | 17 | using System.Threading.Tasks; |
| 18 | +using System.Collections.Generic; |
18 | 19 |
|
19 | 20 | namespace Firebase.Analytics { |
20 | 21 |
|
@@ -206,18 +207,79 @@ public static void LogEvent(string name) { |
206 | 207 | /// |
207 | 208 | /// @param[in] parameters A parameter array of `Parameter` instances. |
208 | 209 | public static void LogEvent(string name, params Parameter[] parameters) { |
209 | | - // Convert the Parameter array into a StringList and VariantList to pass to C++ |
| 210 | + LogEvent(name, (IEnumerable<Parameter>)parameters); |
| 211 | + } |
| 212 | + |
| 213 | + /// @brief Log an event with associated parameters. |
| 214 | + /// |
| 215 | + /// An Event is an important occurrence in your app that you want to measure. |
| 216 | + /// You can report up to 500 different types of events per app and you can |
| 217 | + /// associate up to 25 unique parameters with each Event type. |
| 218 | + /// |
| 219 | + /// Some common events are in the reference guide via the |
| 220 | + /// FirebaseAnalytics.Event* constants, but you may also choose to specify |
| 221 | + /// custom event types that are associated with your specific app. |
| 222 | + /// |
| 223 | + /// @param[in] name Name of the event to log. Should contain 1 to 40 |
| 224 | + /// alphanumeric characters or underscores. The name must start with an |
| 225 | + /// alphabetic character. Some event names are reserved. |
| 226 | + /// See the FirebaseAnalytics.Event properties for the list of reserved event |
| 227 | + /// names. |
| 228 | + /// The "firebase_" prefix is reserved and should not be used. Note that event |
| 229 | + /// names are case-sensitive and that logging two events whose names differ |
| 230 | + /// only in case will result in two distinct events. |
| 231 | + /// |
| 232 | + /// @param[in] parameters An enumerable list of `Parameter` instances. |
| 233 | + public static void LogEvent(string name, IEnumerable<Parameter> parameters) { |
210 | 234 | StringList parameterNames = new StringList(); |
211 | 235 | VariantList parameterValues = new VariantList(); |
212 | | - |
213 | | - foreach (Parameter p in parameters) { |
214 | | - parameterNames.Add(p.Name); |
215 | | - parameterValues.Add(Firebase.Variant.FromObject(p.Value)); |
| 236 | + if (parameters != null) { |
| 237 | + foreach (Parameter p in parameters) { |
| 238 | + parameterNames.Add(p.Name); |
| 239 | + parameterValues.Add(Firebase.Variant.FromObject(p.Value)); |
| 240 | + } |
216 | 241 | } |
217 | | - |
218 | 242 | FirebaseAnalyticsInternal.LogEvent(name, parameterNames, parameterValues); |
219 | 243 | } |
220 | 244 |
|
| 245 | + /// @brief Adds parameters that will be set on every event logged from the SDK. |
| 246 | + /// |
| 247 | + /// Adds parameters that will be set on every event logged from the SDK, |
| 248 | + /// including automatic ones. The values passed in the parameters bundle will |
| 249 | + /// be added to the map of default event parameters. These parameters persist |
| 250 | + /// across app runs. They are of lower precedence than event parameters, so if |
| 251 | + /// an event parameter and a parameter set using this API have the same name, |
| 252 | + /// the value of the event parameter will be used. The same limitations on |
| 253 | + /// event parameters apply to default event parameters. |
| 254 | + /// |
| 255 | + /// @param[in] parameters A parameter array of `Parameter` instances. |
| 256 | + public static void SetDefaultEventParameters(params Parameter[] parameters){ |
| 257 | + SetDefaultEventParameters((IEnumerable<Parameter>)parameters); |
| 258 | + } |
| 259 | + |
| 260 | + /// @brief Adds parameters that will be set on every event logged from the SDK. |
| 261 | + /// |
| 262 | + /// Adds parameters that will be set on every event logged from the SDK, |
| 263 | + /// including automatic ones. The values passed in the parameters bundle will |
| 264 | + /// be added to the map of default event parameters. These parameters persist |
| 265 | + /// across app runs. They are of lower precedence than event parameters, so if |
| 266 | + /// an event parameter and a parameter set using this API have the same name, |
| 267 | + /// the value of the event parameter will be used. The same limitations on |
| 268 | + /// event parameters apply to default event parameters. |
| 269 | + /// |
| 270 | + /// @param[in] parameters An enumerable list of `Parameter` instances. |
| 271 | + public static void SetDefaultEventParameters(IEnumerable<Parameter> parameters){ |
| 272 | + StringList parameterNames = new StringList(); |
| 273 | + VariantList parameterValues = new VariantList(); |
| 274 | + if (parameters != null) { |
| 275 | + foreach (Parameter p in parameters) { |
| 276 | + parameterNames.Add(p.Name); |
| 277 | + parameterValues.Add(Firebase.Variant.FromObject(p.Value)); |
| 278 | + } |
| 279 | + } |
| 280 | + FirebaseAnalyticsInternal.SetDefaultEventParameters(parameterNames, parameterValues); |
| 281 | + } |
| 282 | + |
221 | 283 | /// Clears all analytics data for this app from the device and resets the app |
222 | 284 | /// instance id. |
223 | 285 | public static void ResetAnalyticsData() { |
|
0 commit comments