flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

feat(analytics): add consent mode v2

Open matinzd opened this issue 1 year ago • 3 comments

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.

matinzd avatar Feb 07 '24 13:02 matinzd

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 👍

russellwheatley avatar Feb 07 '24 13:02 russellwheatley

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.

Screenshot 2024-02-07 at 15 29 40

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'
...

matinzd avatar Feb 07 '24 14:02 matinzd

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.

matinzd avatar Feb 12 '24 20:02 matinzd

Any updates? @russellwheatley

matinzd avatar Feb 19 '24 10:02 matinzd

@matinzd - not as such. Will let you know when it has been decided 👍

russellwheatley avatar Feb 19 '24 10:02 russellwheatley

@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?

shanelic avatar Feb 23 '24 08:02 shanelic

@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 avatar Mar 04 '24 10:03 Sese-Schneider

@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.

matinzd avatar Mar 04 '24 10:03 matinzd

I am gonna adjust the PR tonight. Thanks for the feedback!

matinzd avatar Mar 12 '24 18:03 matinzd

@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 😄

russellwheatley avatar Mar 15 '24 10:03 russellwheatley

Hey! Will update it tonight.

matinzd avatar Mar 15 '24 12:03 matinzd

Fixed some formatting issues. Can you rerun the workflows @russellwheatley ?

matinzd avatar Mar 19 '24 10:03 matinzd

Rebased again. I reverted the change for firestore formatting.

matinzd avatar Mar 19 '24 13:03 matinzd

I guess it's ready now.

matinzd avatar Mar 19 '24 15:03 matinzd

@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?

image

Can you please check from your end, if it works fine? do you have any suggestion where I made mistake?

nitinrgadhiya avatar Mar 20 '24 07:03 nitinrgadhiya

Which consent is missing in verbose log? @nitinrgadhiya

matinzd avatar Mar 20 '24 07:03 matinzd

adPersonalization

@matinzd

nitinrgadhiya avatar Mar 20 '24 07:03 nitinrgadhiya

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.

matinzd avatar Mar 20 '24 07:03 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.

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

nitinrgadhiya avatar Mar 20 '24 08:03 nitinrgadhiya

@russellwheatley ?

matinzd avatar Mar 20 '24 11:03 matinzd

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,
        );
      },
    );

russellwheatley avatar Mar 20 '24 13:03 russellwheatley

Fixed. If anything else popped up, feel free to push to the branch 👍

matinzd avatar Mar 20 '24 13:03 matinzd

Thanks a lot @matinzd for helping with this, really appreciated :D

Lyokone avatar Mar 20 '24 15:03 Lyokone