-
Notifications
You must be signed in to change notification settings - Fork 946
Add function setConsent() to set end user consent state for web apps in Firebase Analytics #6376
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1682a41
Add initial draft of setConsent logic
dwyfrequency 58aff2e
Update gtag wrappers to accommodate consent command
dwyfrequency d014600
Update API reports
dwyfrequency f41256c
Add changeset
dwyfrequency fbf2348
Merge remote-tracking branch 'origin/setConsent' into setConsent
dwyfrequency e5a7b73
Update types, documentation and functionality
dwyfrequency 069d0c8
Update API reports
dwyfrequency 767421e
Update comments and rename type
dwyfrequency afdfced
Merge branch 'master' into setConsent
dwyfrequency 572a151
Add tests and update public type docs.
dwyfrequency 05ca0d1
Add back 'set' test
dwyfrequency 2fa1ba8
Update API reports
dwyfrequency 0d0bd61
Add hyphen after param name in jsdoc
dwyfrequency File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@firebase/analytics': minor | ||
--- | ||
|
||
Add function `setConsent()` to set the applicable end user "consent" state. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ import { | |
Analytics, | ||
AnalyticsCallOptions, | ||
AnalyticsSettings, | ||
ConsentSettings, | ||
CustomParams, | ||
EventNameString, | ||
EventParams | ||
|
@@ -48,6 +49,7 @@ import { | |
setUserId as internalSetUserId, | ||
setUserProperties as internalSetUserProperties, | ||
setAnalyticsCollectionEnabled as internalSetAnalyticsCollectionEnabled, | ||
_setConsentDefaultForInit, | ||
_setDefaultEventParametersForInit | ||
} from './functions'; | ||
import { ERROR_FACTORY, AnalyticsError } from './errors'; | ||
|
@@ -734,3 +736,21 @@ export function logEvent( | |
* @public | ||
*/ | ||
export type CustomEventName<T> = T extends EventNameString ? never : T; | ||
|
||
/** | ||
* Sets the applicable end user consent state for this web app across all gtag references once | ||
* Firebase Analytics is initialized. | ||
* | ||
* Use the {@link ConsentSettings} to specify individual consent type values. By default consent | ||
* types are set to "granted". | ||
* @public | ||
* @param consentSettings Maps the applicable end user consent state for gtag.js. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, I just ran |
||
*/ | ||
export function setConsent(consentSettings: ConsentSettings): void { | ||
// Check if reference to existing gtag function on window object exists | ||
if (wrappedGtagFunction) { | ||
wrappedGtagFunction(GtagCommand.CONSENT, 'update', consentSettings); | ||
} else { | ||
_setConsentDefaultForInit(consentSettings); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.