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

Add consent opt out #1063

Merged
merged 56 commits into from
Apr 17, 2024
Merged

Add consent opt out #1063

merged 56 commits into from
Apr 17, 2024

Conversation

silesky
Copy link
Contributor

@silesky silesky commented Apr 4, 2024

Add support for opt-out consent.

OneTrust Consent Model Behavior
Opt-in Opt-in
Opt-out Opt-out
Implicit Consent Opt-in
Default (any other model) Opt-out

Note: to override the default behavior for OneTrust, the following setting(s) have been added:

withOneTrust(analytics, { consentModel: () => 'opt-out' | 'opt-in' })
  • I've included a changeset (psst. run yarn changeset. Read about changesets here).

Copy link

changeset-bot bot commented Apr 4, 2024

🦋 Changeset detected

Latest commit: f294612

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@segment/analytics-consent-tools Major
@segment/analytics-consent-wrapper-onetrust Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@silesky silesky force-pushed the add-consent-opt-out branch 2 times, most recently from 8aa69b9 to 989d37e Compare April 10, 2024 21:26
@silesky silesky force-pushed the add-consent-opt-out branch from 9edef47 to f505ae7 Compare April 12, 2024 22:03
@silesky silesky marked this pull request as ready for review April 15, 2024 21:24
@silesky silesky requested a review from chrisradek April 15, 2024 21:24
Copy link
Contributor

@chrisradek chrisradek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally think this looks good! Comments are relatively minor.

export enum OtConsentModel {
optIn = 'opt-in',
optOut = 'opt-out',
implicit = 'implied consent',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is implicit needed now? Doesn't look like it's exposed in OneTrustSettings and is currently an alias for optIn

Copy link
Contributor Author

@silesky silesky Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was that since we only have unique behavior for opt-in and opt-out, I felt like it would be good to leave it out of the public API, but document that it exists in the enum, since this enum is meant to be an Internal DTO that maps to the actual OT API. I don't feel super strongly either way! There are a few other OneTrust consent models that I left out, since everything but implicit defaults to opt-out. coerceConsentModel is where that logic lives.

Comment on lines 20 to 21
* - opt-in (default) - load segment and all destinations without waiting for explicit consent.
* - opt-out (strict/GDPR) - wait for explicit consent before loading segment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't these flipped? opt-in is the one where we wait for you to opt-in before loading, and opt-out is where we load until you explicitly opt out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, yep, the README is correct but these comments are flipped. Good catch.

shouldLoadSegment?: (
ctx: LoadContext
) => Categories | void | Promise<Categories | void>
shouldLoadSegment?: (ctx: LoadContext) => void | Promise<void>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a breaking change - are we doing a major version bump (totally cool with it if we are!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, was going to do a major bump!

'on' in analytics &&
'addSourceMiddleware' in analytics
) {
if ('load' in analytics && 'addSourceMiddleware' in analytics) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check for addDestinationMiddleware now too?

Copy link
Contributor Author

@silesky silesky Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err, yeah -- you got me, this typeguard is incomplete (was being a bit lazy here). 😄

@silesky silesky force-pushed the add-consent-opt-out branch from 7d5117f to 5aeeb11 Compare April 16, 2024 19:33
Copy link
Contributor

@chrisradek chrisradek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved! Only one outstanding comment (missing closing HTML tag in a file)

@silesky silesky requested a review from didiergarcia April 16, 2024 21:57
@silesky silesky force-pushed the add-consent-opt-out branch from e163a7f to 18e78cc Compare April 17, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants