(iOS/Android): avoid collection state getting out of sync, remove restriction to override plist defaults #423
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.
PR Type
What kind of change does this PR introduce?
PR Checklist
For bug fixes / features, please check if your PR fulfills the following requirements:
What is the purpose of this PR?
Currently it is possible for the 3 collections (analytics collection, performance collection, crashlytics collection) to get into an inconsistent state.
This is possible because when setting the flags an error is thrown if the plugins own state already matches the value the user would like to set (e.g. "Analytics data collection is already set to enabled"). However it is possible the Firebase SDK was already used before the plist config flags were introduced which could lead to the following scenario:
I understand the plugins local state was added to provide information about the state, which is not exposed by the SDK itself, so it the plugins own state cannot be removed completely.
This PR removes the logic which prevents the users setting from being set directly in the SDK. This solves the above mentioned scenario (and other variations of it) and also keeps the ability to provide info about the current state.
Update:
In my followup commits I also did the same changes for Android and I also removed the check which does not allow to override the plist default values if they are set to
true
. This way developers can also offer an "opt-out" scenario, where data-collection is enabled by default and can be disabled by the user on-demand.I also checked the firebase documentation and it also says that always the SDK preference takes precedence over the plist config:
Which is why I don't really see the reasoning behind these checks in the plugin.
Does this PR introduce a breaking change?
What testing has been done on the changes in the PR?
Enabling/disabling the three collections. Test different combinations of old SDK and then updating to the new SDK, changing plist flags them again enabling/disabling the flags.
What testing has been done on existing functionality?
Tested in our in-house projects which all use the firebase plugin - no regressions so far.