Skip to content
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

feat: Multiple consent types with one setConsent call #671

Open
3 of 13 tasks
gasci opened this issue Jul 4, 2024 · 0 comments
Open
3 of 13 tasks

feat: Multiple consent types with one setConsent call #671

gasci opened this issue Jul 4, 2024 · 0 comments

Comments

@gasci
Copy link

gasci commented Jul 4, 2024

Plugin(s)

  • Analytics
  • App
  • App Check
  • Authentication
  • Crashlytics
  • Cloud Firestore
  • Cloud Functions
  • Cloud Messaging
  • Cloud Storage
  • Performance
  • Remote Config

Current problem

Multiple consent calls cannot be sent within one function:

if (isPlatform(["web", "android", "ios"])) {
    const consent = await Preferences.get({ key: 'cookieConsent' });

    await FirebaseAnalytics.setConsent({
      type: ConsentType.AdPersonalization,
      status: consent.value === 'authorized' ? ConsentStatus.Granted : ConsentStatus.Denied
    });

    await FirebaseAnalytics.setConsent({
      type: ConsentType.PersonalizationStorage,
      status: consent.value === 'authorized' ? ConsentStatus.Granted : ConsentStatus.Denied
    });

    await FirebaseAnalytics.setConsent({
      type: ConsentType.AdUserData,
      status: consent.value === 'authorized' ? ConsentStatus.Granted : ConsentStatus.Denied
    });

    await FirebaseAnalytics.setConsent({
      type: ConsentType.AdStorage,
      status: consent.value === 'authorized' ? ConsentStatus.Granted : ConsentStatus.Denied
    });

    await FirebaseAnalytics.setConsent({
      type: ConsentType.AnalyticsStorage,
      status: consent.value === 'authorized' ? ConsentStatus.Granted : ConsentStatus.Denied
    });
  }

We get the following error:

VM4026:944 Uncaught (in promise) Error: consentType must be provided.
    at returnResult (<anonymous>:944:32)
    at win.androidBridge.onmessage (<anonymous>:919:21)

Preferred solution

Passing all the types in one parameter would result in only one call.

await FirebaseAnalytics.setConsent({
      type: [ConsentType.AnalyticsStorage, ConsentType.AdUserData],
      status: consent.value === 'authorized' ? ConsentStatus.Granted : ConsentStatus.Denied
    });

Alternative options

No response

Additional context

No response

Before submitting

@gasci gasci changed the title feat: feat: Multiple consent types with one setConsent call Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants