Conversation

jonsimantov

This change introduces two new C++ Analytics SDK functions:

  • SetDefaultEventParameters(const std::map<std::string, Variant>& params): Allows setting default parameters that will be included in all subsequent LogEvent calls. If a Variant::Null() is provided as a value for a key, that specific default parameter will be cleared/removed.
  • ClearDefaultEventParameters(): Clears all currently set default event parameters.

Platform implementations:

  • iOS: Uses [FIRAnalytics setDefaultEventParameters:]. Variant::Null() maps to [NSNull null] for clearing individual parameters. Calling with nil clears all.
  • Android: Uses FirebaseAnalytics.setDefaultEventParameters(Bundle). Variant::Null() results in Bundle.putString(key, null). Calling with a null Bundle clears all.
  • Stub: Implemented as no-ops.

Unit tests and integration tests have been updated to cover these new functionalities, including the null-value handling for clearing specific parameters and the overall clearing of all parameters.

Description

Provide details of the change, and generalize the change in the PR title above.


Testing

Describe how you've tested these changes. Link any manually triggered Integration tests or CPP binary SDK Packaging Action workflows, if applicable.


Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

Notes

  • Bug fixes and feature changes require an update to the Release Notes section of release_build_files/readme.md.
  • Read the contribution guidelines CONTRIBUTING.md.
  • Changes to the public API require an internal API review. If you'd like to help us make Firebase APIs better, please propose your change in a feature request so that we can discuss it together.

…ytics

This change introduces two new C++ Analytics SDK functions:
- `SetDefaultEventParameters(const std::map<std::string, Variant>& params)`: Allows setting default parameters that will be included in all subsequent `LogEvent` calls. If a `Variant::Null()` is provided as a value for a key, that specific default parameter will be cleared/removed.
- `ClearDefaultEventParameters()`: Clears all currently set default event parameters.

Platform implementations:
- iOS: Uses `[FIRAnalytics setDefaultEventParameters:]`. `Variant::Null()` maps to `[NSNull null]` for clearing individual parameters. Calling with `nil` clears all.
- Android: Uses `FirebaseAnalytics.setDefaultEventParameters(Bundle)`. `Variant::Null()` results in `Bundle.putString(key, null)`. Calling with a `null` Bundle clears all.
- Stub: Implemented as no-ops.

Unit tests and integration tests have been updated to cover these new functionalities, including the null-value handling for clearing specific parameters and the overall clearing of all parameters.
@jonsimantovjonsimantov added the tests-requested: quickTrigger a quick set of integration tests.label May 29, 2025
@github-actions-actions bot added tests: in-progressThis PR's integration tests are in progress.and removed tests-requested: quickTrigger a quick set of integration tests.labels May 29, 2025
@github-actionsGitHub Actions

✅  Integration test succeeded!

Requested by @jonsimantov on commit f84caa0
Last updated: Wed Jun 4 11:44 PDT 2025
View integration test log & download artifacts

@github-actions-actions bot added the tests: failedThis PR's integration tests failed.label May 29, 2025
@firebase-workflow-triggerfirebase-workflow-trigger bot removed the tests: in-progressThis PR's integration tests are in progress.label May 29, 2025
…ytics

This change introduces two new C++ Analytics SDK functions:
- `SetDefaultEventParameters(const std::map<std::string, firebase::Variant>& params)`: Allows setting default parameters that will be included in all subsequent `LogEvent` calls. If a `firebase::Variant::Null()` is provided as a value for a key, that specific default parameter will be cleared/removed.
- `ClearDefaultEventParameters()`: Clears all currently set default event parameters.

Platform implementations:
- iOS: Uses `[FIRAnalytics setDefaultEventParameters:]`. `firebase::Variant::Null()` maps to `[NSNull null]` for clearing individual parameters. Calling with `nil` clears all.
- Android: Uses `FirebaseAnalytics.setDefaultEventParameters(Bundle)`. `firebase::Variant::Null()` results in `Bundle.putString(key, null)`. Calling with a `null` Bundle clears all.
- Stub: Implemented as no-ops.

Unit tests and integration tests have been updated to cover these new functionalities, including the null-value handling for clearing specific parameters and the overall clearing of all parameters.
@jonsimantovjonsimantov added the tests-requested: quickTrigger a quick set of integration tests.label May 30, 2025
@github-actions-actions bot added tests: in-progressThis PR's integration tests are in progress.tests: failedThis PR's integration tests failed.and removedTrigger a quick set of integration tests.tests: failedThis PR's integration tests failed.labels May 30, 2025
@firebase-workflow-triggerfirebase-workflow-trigger bot removed the tests: in-progressThis PR's integration tests are in progress.label May 30, 2025
…ytics

This change introduces two new C++ Analytics SDK functions:
- `SetDefaultEventParameters(const std::map<std::string, firebase::Variant>& params)`: Allows setting default parameters that will be included in all subsequent `LogEvent` calls. If a `firebase::Variant::Null()` is provided as a value for a key, that specific default parameter will be cleared/removed.
- `ClearDefaultEventParameters()`: Clears all currently set default event parameters.

Platform implementations:
- iOS: Uses `[FIRAnalytics setDefaultEventParameters:]`. `firebase::Variant::Null()` maps to `[NSNull null]` for clearing individual parameters. Calling with `nil` clears all.
- Android: Uses `FirebaseAnalytics.setDefaultEventParameters(Bundle)`. `firebase::Variant::Null()` results in `Bundle.putString(key, null)`. Calling with a `null` Bundle clears all.
- Stub: Implemented as no-ops.

Unit tests and integration tests have been updated to cover these new functionalities, including the null-value handling for clearing specific parameters and the overall clearing of all parameters. Integer literals in integration tests use standard int types.
@jonsimantovjonsimantov added the tests-requested: quickTrigger a quick set of integration tests.label May 30, 2025
@github-actions-actions bot added tests: in-progressThis PR's integration tests are in progress.tests: succeededThis PR's integration tests succeeded.and removed tests-requested: quickTrigger a quick set of integration tests.This PR's integration tests failed.labels May 30, 2025
@firebase-workflow-triggerfirebase-workflow-trigger bot removed the tests: in-progressThis PR's integration tests are in progress.label May 30, 2025
…ytics

This change introduces two new C++ Analytics SDK functions:
- `SetDefaultEventParameters(const std::map<std::string, firebase::Variant>& params)`:
  Allows setting default parameters (string, int64, double, bool, null)
  that will be included in all subsequent `LogEvent` calls.
  If a `firebase::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.
- `ClearDefaultEventParameters()`: Clears all currently set default event
  parameters.

Platform implementations:
- iOS: Uses `[FIRAnalytics setDefaultEventParameters:]`. `firebase::Variant::Null()`
  maps to `[NSNull null]`. Unsupported types are skipped.
- Android: Uses `FirebaseAnalytics.setDefaultEventParameters(Bundle)`.
  `firebase::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 to cover these
functionalities and type constraints.
@jonsimantovjonsimantov added the tests-requested: quickTrigger a quick set of integration tests.label May 30, 2025
@github-actions-actions bot added tests: in-progressThis PR's integration tests are in progress.tests: succeededThis PR's integration tests succeeded.and removed tests-requested: quickTrigger a quick set of integration tests.tests: succeededThis PR's integration tests succeeded.labels May 30, 2025
@firebase-workflow-triggerfirebase-workflow-trigger bot removed the tests: in-progressThis PR's integration tests are in progress.label May 30, 2025
…meters` and `ClearDefaultEventParameters` to Analytics:

This change introduces two new C++ Analytics SDK functions:
- `SetDefaultEventParameters(const std::map<std::string, firebase::Variant>& params)`:
  This allows you to set default parameters (string, int64, double, bool, null)
  that will be included in all subsequent `LogEvent` calls.
  If a `firebase::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.
- `ClearDefaultEventParameters()`: This clears all currently set default event
  parameters.

Here's how it's handled on different platforms:
- iOS: I'm using `[FIRAnalytics setDefaultEventParameters:]`. `firebase::Variant::Null()`
  maps to `[NSNull null]`. Unsupported types are skipped.
- Android: I'm using `FirebaseAnalytics.setDefaultEventParameters(Bundle)`.
  `firebase::Variant::Null()` results in `Bundle.putString(key, null)`.
  Unsupported types are skipped. I'm using `AddVariantToBundle` for efficiency
  with scalar types.
- Stub: These are implemented as no-ops.

I've reviewed and updated the unit tests and integration tests to cover these
functionalities and type constraints.

I also applied code formatting using the project's script and updated and shortened the release notes in `release_build_files/readme.md`.
…meters` and `ClearDefaultEventParameters` to Analytics:

This change introduces two new C++ Analytics SDK functions:
- `SetDefaultEventParameters(const std::map<std::string, firebase::Variant>& params)`:
  This allows you to set default parameters (string, int64, double, bool, null)
  that will be included in all subsequent `LogEvent` calls.
  If a `firebase::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.
- `ClearDefaultEventParameters()`: This clears all currently set default event
  parameters.

Here's how it's handled on different platforms:
- iOS: I'm using `[FIRAnalytics setDefaultEventParameters:]`. `firebase::Variant::Null()`
  maps to `[NSNull null]`. Unsupported types are skipped.
- Android: I'm using `FirebaseAnalytics.setDefaultEventParameters(Bundle)`.
  `firebase::Variant::Null()` results in `Bundle.putString(key, null)`.
  Unsupported types are skipped. I'm using `AddVariantToBundle` for efficiency
  with scalar types.
- Stub: These are implemented as no-ops.

I've reviewed and updated the unit tests and integration tests to cover these
functionalities and type constraints.

I also applied code formatting using the project's script and updated and shortened the release notes in `release_build_files/readme.md`.
…faultEventParameters` to Analytics.

This change introduces two new C++ Analytics SDK functions:
- `SetDefaultEventParameters(const std::map<std::string, firebase::Variant>& params)`:
  This allows you to set default parameters (string, int64, double, bool, null)
  that will be included in all subsequent `LogEvent` calls.
  If a `firebase::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.
- `ClearDefaultEventParameters()`: This clears all currently set default event
  parameters.

Platform implementations:
- iOS: Uses `[FIRAnalytics setDefaultEventParameters:]`. `firebase::Variant::Null()`
  maps to `[NSNull null]`. Unsupported types are skipped.
- Android: Uses `FirebaseAnalytics.setDefaultEventParameters(Bundle)`.
  `firebase::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.

I've reviewed and updated the unit tests and integration tests to cover these
functionalities and type constraints.

Namespace usage for `Variant` has been refined:
- Public API (`analytics.h`) and integration tests use `firebase::Variant`.
- Internal SDK implementation code uses unqualified `Variant` where appropriate,
  relying on the enclosing `firebase` namespace.

I've also applied code formatting using the project's script and updated and shortened the release notes in `release_build_files/readme.md`.
@jonsimantovjonsimantov added the tests-requested: quickTrigger a quick set of integration tests.label Jun 4, 2025
@github-actions-actions bot added tests: in-progressThis PR's integration tests are in progress.tests: succeededThis PR's integration tests succeeded.and removed tests-requested: quickTrigger a quick set of integration tests.tests: succeededThis PR's integration tests succeeded.labels Jun 4, 2025
@firebase-workflow-triggerfirebase-workflow-trigger bot removed the tests: in-progressThis PR's integration tests are in progress.label Jun 4, 2025
pair.first.c_str(), Variant::TypeName(value.type()));
}
}
[FIRAnalytics setDefaultEventParameters:ns_default_parameters];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-check FIRAnalytics setDefaultEventParameters -- if we pass in an empty dictionary, will it clear the parameters? This could happen if every single value we specified was an invalid type.

@@ -142,7 +142,7 @@ struct Parameter {
/// @param parameter_name Name of the parameter (see Parameter::name).
/// @param parameter_value Value for the parameter. Variants can
/// hold numbers and strings.
Parameter(const char* parameter_name, Variant parameter_value)
Parameter(const char* parameter_name, firebase::Variant parameter_value)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

firebase:: not needed here

@@ -245,7 +245,7 @@ struct Parameter {
///
/// See firebase::Variant for usage information.
/// @note String values can be up to 100 characters long.
Variant value;
firebase::Variant value;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

firebase:: not needed here

///
/// @param[in] default_parameters A map of parameter names to Variant values.
void SetDefaultEventParameters(
const std::map<std::string, firebase::Variant>& default_parameters);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

firebase:: not needed here

…rs` to Analytics for you.

This change introduces two new C++ Analytics SDK functions:
- `SetDefaultEventParameters(const std::map<std::string, Variant>& params)`:
  This allows you to set 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.
- `ClearDefaultEventParameters()`: This clears all currently set default event
  parameters.

Here's how it's implemented on different platforms:
- iOS: Uses `[FIRAnalytics setDefaultEventParameters:]`. `Variant::Null()`
  maps to `[NSNull null]`. Unsupported types are skipped. Passing an empty
  dictionary (if all input params are invalid) is a no-op.
- 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.

I've also reviewed and updated the unit tests and integration tests to cover these
functionalities and type constraints.

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.

I've applied code formatting using the project's script and updated and shortened the release notes in `release_build_files/readme.md`.
return;
}

for (const auto& pair : default_parameters) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that Android also treats an empty map as a no-op, similar to iOS?

@@ -341,4 +341,70 @@ TEST_F(FirebaseAnalyticsTest, TestSetConsent) {
did_test_setconsent_ = true;
}

TEST_F(FirebaseAnalyticsTest, TestDefaultEventParametersUsage) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this test TestSetDefaultEventParameters and the following test TestClearDefaultEventParameters.

…ytics

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.
Sign up for free to join this conversation on . Already have an account? Sign in to comment
tests: succeededThis PR's integration tests succeeded.
None yet

Successfully merging this pull request may close these issues.

@jonsimantov