flutterfire
flutterfire copied to clipboard
feat(analytics): add consent mode v2
Description
Adding consent mode v2 to firebase analytics.
Reference: https://developers.google.com/tag-platform/security/guides/app-consent
Related Issues
Fixes https://github.com/firebase/flutterfire/issues/12148
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]
).
This will ensure a smooth and quick review process. Updating the pubspec.yaml
and changelogs is not required.
- [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
- [x] My PR includes unit or integration tests for all changed/updated/fixed behaviors (See [Contributor Guide]).
- [x] All existing and new tests are passing.
- [x] I updated/added relevant documentation (doc comments with
///
). - [x] The analyzer (
melos run analyze
) does not report any problems on my PR. - [x] I read and followed the [Flutter Style Guide].
- [x] I signed the [CLA].
- [x] I am willing to follow-up on review comments in a timely manner.
Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?
- [ ] Yes, this is a breaking change.
- [x] No, this is not a breaking change.
Thanks for the PR, @matinzd. As mentioned in the issue: https://github.com/firebase/flutterfire/issues/12148, we're discussing internally the shape of the API before rolling out 👍
I cannot run the example app since there is something wrong with the pod install.
Although pod install succeeds, FirebaseAnalytics
and GoogleAppMeasurement
pod folder is empty.
Pod install log:
Analyzing dependencies
firebase_analytics: Using Firebase SDK version '10.20.0' defined in 'firebase_core'
firebase_core: Using Firebase SDK version '10.20.0' defined in 'firebase_core'
Downloading dependencies
Installing FirebaseAnalytics 10.20.0
Installing GoogleAppMeasurement 10.20.0
Generating Pods project
Integrating client project
Pod installation complete! There are 3 dependencies from the Podfile and 12 total pods installed.
Build log:
Semantic Issue (Xcode): Use of undeclared identifier 'FIRAnalytics'
Semantic Issue (Xcode): Use of undeclared identifier 'FIRConsentTypeAnalyticsStorage'
...
Updated cocoapods and the example app is now working. For some reasons, the pods where not being copied to the corresponding folder. Example app with works both on iOS and Android.
Any updates? @russellwheatley
@matinzd - not as such. Will let you know when it has been decided 👍
@matinzd - not as such. Will let you know when it has been decided 👍
Is there an estimated time for the decision to approve the PR?
@matinzd thank you already for your effort implementing this! Are you also aiming to provide the functionallity to FlutterFire WEB with this PR? https://firebase.google.com/docs/reference/js/analytics#setconsent_1697027
@Sese-Schneider
IMO, it's better to merge iOS and Android first and then have the web implemented in a separate PR. For now, it seems like it's not a priority at all as this PR is officially one month old and all of our campaigns paused due to this being a blocker for us.
I am gonna adjust the PR tonight. Thanks for the feedback!
@matinzd - we are looking to get this released next week, let me know if you have the time to complete, if not, I can take over. Thanks 😄
Hey! Will update it tonight.
Fixed some formatting issues. Can you rerun the workflows @russellwheatley ?
Rebased again. I reverted the change for firestore formatting.
I guess it's ready now.
@matinzd
FYI, I copied your code from PR.
I've enabled 4 consents in the Firebase analytics code but in the "Verbose" log I can see only 3 consents granted. I did not see "adPersonalization" consent property.
Do you know why?
How to enable a verbose log you can check this link?
Can you please check from your end, if it works fine? do you have any suggestion where I made mistake?
Which consent is missing in verbose log? @nitinrgadhiya
adPersonalization
@matinzd
I couldn't find any issues with adPersonalizationSignalsConsentGranted
key. It seems everything is in order. Keys are being properly passed into the platform method channel and on the native side, we have the same key as well. I am feeling that it's not showing up in the verbose log or it's just a user property which you can see in the log.
I couldn't find any issues with
adPersonalizationSignalsConsentGranted
key. It seems everything is in order. Keys are being properly passed into the platform method channel and on the native side, we have the same key as well. I am feeling that it's not showing up in the verbose log or it's just a user property which you can see in the log.
yes, I agree with what you say ("about key passed properly."). And if your feeling is right, then It's okay. Thanks for quick response. @matinzd
@russellwheatley ?
Hey @matinzd - I just realised the integration tests are failing and need updating here: https://github.com/firebase/flutterfire/blob/master/tests/integration_test/firebase_analytics/firebase_analytics_e2e_test.dart#L211-L228
Update to this should work:
test(
'setConsent',
() async {
await expectLater(
FirebaseAnalytics.instance.setConsent(
analyticsStorageConsentGranted: true,
adStorageConsentGranted: true,
adPersonalizationSignalsConsentGranted: true,
adUserDataConsentGranted: true,
functionalityStorageConsentGranted: true,
personalizationStorageConsentGranted: true,
securityStorageConsentGranted: true,
),
completes,
);
},
);
Fixed. If anything else popped up, feel free to push to the branch 👍
Thanks a lot @matinzd for helping with this, really appreciated :D