capawesome-team / capacitor-firebase

⚡️ Firebase plugins for Capacitor. Supports Android, iOS and the Web.
https://capawesome.io/plugins/firebase/
Apache License 2.0
374 stars 97 forks source link

bug: Consent for AdPersonalization enables personalization_storage instead of ad_personalization #703

Closed MitjaNucic closed 2 weeks ago

MitjaNucic commented 3 weeks ago

Plugin(s)

Version

6.1.0

Platform(s)

Current behavior

It looks like calling

 await FirebaseAnalytics.setConsent({
    type: ConsentType.AdPersonalization,
    status: ConsentStatus.Granted
  })

Is enabling personalization_storage instead of ad_personalization the correct behavior? Code from lib:

async setConsent(options) {
            const status = options.status === exports.ConsentStatus.Granted ? 'granted' : 'denied';
            const consentSettings = {};
            switch (options.type) {
             ...
                case exports.ConsentType.AdPersonalization:
                    consentSettings.personalization_storage = status;
                    break;
                ...
                case exports.ConsentType.PersonalizationStorage:
                    consentSettings.personalization_storage = status;
                    break;
            }
            analytics.setConsent(consentSettings);
        }

Code to reproduce:

watch(marketingConsent, async (newValue) => {
  await FirebaseAnalytics.setConsent({
    type: ConsentType.AdPersonalization,
    status: marketingConsent ? ConsentStatus.Granted : ConsentStatus.Denied,
  })
  await FirebaseAnalytics.setConsent({
    type: ConsentType.AdStorage,
    status: marketingConsent ? ConsentStatus.Granted : ConsentStatus.Denied,
  })
  await FirebaseAnalytics.setConsent({
    type: ConsentType.AdUserData,
    status: marketingConsent ? ConsentStatus.Granted : ConsentStatus.Denied,
  })
})

image

Expected behavior

Consent status for AdPersonalization should enable ad_personalization and not personalization_storage

Reproduction

https://github.com/capawesome-team/.capacitor-app

Steps to reproduce

Explained above.

Other information

No response

Capacitor doctor

Installed Dependencies:

@capacitor/core: 6.1.2 @capacitor/ios: 6.1.2 @capacitor/android: 6.1.2 @capacitor/cli: 6.1.2

[success] Android looking great! 👌 [error] Xcode is not installed

Before submitting

robingenz commented 3 weeks ago

Yes, this should be a bug. Would you be willing to create a PR?

bor-creatim commented 2 weeks ago

Something like this should probably suffice:

diff --git a/packages/analytics/src/web.ts b/packages/analytics/src/web.ts
index 7ee8262..f1a5c75 100644
--- a/packages/analytics/src/web.ts
+++ b/packages/analytics/src/web.ts
@@ -37,7 +37,7 @@ export class FirebaseAnalyticsWeb
     const consentSettings: ConsentSettings = {};
     switch (options.type) {
       case ConsentType.AdPersonalization:
-        consentSettings.personalization_storage = status;
+        consentSettings.ad_personalization = status;
         break;
       case ConsentType.AdStorage:
         consentSettings.ad_storage = status;