Skip to content

Commit b2b225d

Browse files
Add SetDefaultEventParameters and ClearDefaultEventParameters to Analytics
This change introduces two new C++ Analytics SDK functions: - `SetDefaultEventParameters(const std::map<std::string, Variant>& params)`: Allows setting default parameters (string, int64, double, bool, null) that will be included in all subsequent `LogEvent` calls. If a `Variant::Null()` is provided for a key, that specific default parameter will be cleared. Aggregate types (maps, vectors) are not supported and will be skipped with an error logged. Passing only invalid parameters resulting in an empty parameter set is a no-op on iOS/Android. - `ClearDefaultEventParameters()`: Clears all currently set default event parameters. Platform implementations: - iOS: Uses `[FIRAnalytics setDefaultEventParameters:]`. `Variant::Null()` maps to `[NSNull null]`. Unsupported types are skipped. - Android: Uses `FirebaseAnalytics.setDefaultEventParameters(Bundle)`. `Variant::Null()` results in `Bundle.putString(key, null)`. Unsupported types are skipped. `AddVariantToBundle` is used for efficiency with scalar types. - Stub: Implemented as no-ops. Unit tests and integration tests have been reviewed and updated. Integration test names have been clarified. Namespace usage for `Variant` has been refined: - Public API (`analytics.h`) uses unqualified `Variant` as it's within the `firebase` namespace. - SDK implementation file signatures match `analytics.h` (unqualified `Variant`). - Internal SDK code uses unqualified `Variant`. - Integration tests use `firebase::Variant` as they are outside the `firebase` namespace. Code formatting applied using the project's script. Release notes in `release_build_files/readme.md` updated and shortened.
1 parent 573b647 commit b2b225d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

analytics/integration_test/src/integration_test.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ TEST_F(FirebaseAnalyticsTest, TestSetConsent) {
341341
did_test_setconsent_ = true;
342342
}
343343

344-
TEST_F(FirebaseAnalyticsTest, TestDefaultEventParametersUsage) {
344+
TEST_F(FirebaseAnalyticsTest, TestSetDefaultEventParameters) {
345345
LogInfo(
346346
"Testing SetDefaultEventParameters with initial values, then updating "
347347
"with Null.");
@@ -377,11 +377,11 @@ TEST_F(FirebaseAnalyticsTest, TestDefaultEventParametersUsage) {
377377
// Actual parameter presence on logged events would be verified by
378378
// backend/native tests.
379379
LogInfo(
380-
"TestDefaultEventParametersUsage completed. Calls were made "
380+
"TestSetDefaultEventParameters completed. Calls were made "
381381
"successfully.");
382382
}
383383

384-
TEST_F(FirebaseAnalyticsTest, TestClearDefaultEventParametersFunctionality) {
384+
TEST_F(FirebaseAnalyticsTest, TestClearDefaultEventParameters) {
385385
LogInfo("Testing ClearDefaultEventParameters.");
386386

387387
std::map<std::string, firebase::Variant> defaults_to_clear;
@@ -403,7 +403,7 @@ TEST_F(FirebaseAnalyticsTest, TestClearDefaultEventParametersFunctionality) {
403403
ProcessEvents(500);
404404

405405
LogInfo(
406-
"TestClearDefaultEventParametersFunctionality completed. Call was made "
406+
"TestClearDefaultEventParameters completed. Call was made "
407407
"successfully.");
408408
}
409409

0 commit comments

Comments
 (0)