-
Notifications
You must be signed in to change notification settings - Fork 124
Add SetDefaultEventParameters and ClearDefaultEventParameters to Analytics C++ SDK. #1719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jonsimantov
wants to merge
12
commits into
main
Choose a base branch
from
feat-default-event-params
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+398
−2
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…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.
✅ Integration test succeeded!Requested by @jonsimantov on commit f84caa0 |
…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.
…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.
…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.
…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`.
jonsimantov
commented
Jun 7, 2025
jonsimantov
commented
Jun 7, 2025
jonsimantov
commented
Jun 7, 2025
jonsimantov
commented
Jun 7, 2025
…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`.
jonsimantov
commented
Jun 7, 2025
jonsimantov
commented
Jun 7, 2025
…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.
#1747) * Fix: Prevent SetDefaultEventParameters from clearing params with all-invalid input Addresses code review feedback regarding the behavior of SetDefaultEventParameters when all provided parameters are of invalid types. Previously, if all parameters in the C++ map were invalid, an empty NSDictionary/Bundle would be passed to the native iOS/Android setDefaultEventParameters method. According to documentation, passing nil/null (for iOS/Android respectively) clears all default parameters. While passing an empty dictionary/bundle is a valid operation, it could lead to unintentionally clearing parameters if that was the state before, or it might be a no-op if parameters were already set. This change modifies the iOS and Android implementations to explicitly check if the processed native parameter collection (NSDictionary for iOS, Bundle for Android) is empty after filtering for valid types. If it is empty, the call to the native SDK's setDefaultEventParameters method is skipped. This ensures that providing a C++ map containing exclusively invalid parameters (or an empty map) to SetDefaultEventParameters will be a true no-op from the C++ SDK's perspective, preventing any accidental modification or clearing of existing default parameters on the native side. * Fix: Prevent SetDefaultEventParameters from clearing params with all-invalid input Addresses code review feedback regarding the behavior of SetDefaultEventParameters when all provided parameters are of invalid types. Previously, if all parameters in the C++ map were invalid, an empty NSDictionary/Bundle would be passed to the native iOS/Android setDefaultEventParameters method. According to documentation, passing nil/null (for iOS/Android respectively) clears all default parameters. While passing an empty dictionary/bundle is a valid operation, it could lead to unintentionally clearing parameters if that was the state before, or it might be a no-op if parameters were already set. This change modifies the iOS and Android implementations to explicitly check if the processed native parameter collection (NSDictionary for iOS, Bundle for Android) is effectively empty after filtering for valid types. If it is, the call to the native SDK's setDefaultEventParameters method is skipped. For iOS, this is done by checking `[ns_default_parameters count] == 0`. For Android, this is done by tracking if any parameter was successfully added to the Bundle using a boolean flag, as a direct `bundle.isEmpty()` check before the native call could miss JNI exceptions during bundle population. This ensures that providing a C++ map containing exclusively invalid parameters (or an empty map) to SetDefaultEventParameters will be a true no-op from the C++ SDK's perspective, preventing any accidental modification or clearing of existing default parameters on the native side. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 subsequentLogEvent
calls. If aVariant::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:
[FIRAnalytics setDefaultEventParameters:]
.Variant::Null()
maps to[NSNull null]
for clearing individual parameters. Calling withnil
clears all.FirebaseAnalytics.setDefaultEventParameters(Bundle)
.Variant::Null()
results inBundle.putString(key, null)
. Calling with anull
Bundle clears all.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
Testing
Type of Change
Place an
x
the applicable box:Notes
Release Notes
section ofrelease_build_files/readme.md
.