Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Custom Categories #60

Merged
merged 13 commits into from
Dec 11, 2019
Merged

Custom Categories #60

merged 13 commits into from
Dec 11, 2019

Conversation

notfelineit
Copy link
Contributor

@notfelineit notfelineit commented Dec 9, 2019

Add Custom Categories

This PR adds a config property to ConsentManager called customCategories that looks like the following:

interface CustomCategories {
    [key: string]: Category
}

interface Category {
    purpose: string 
    integrations: string[] // Segment Integration Names
}

Users can verify their integration names via https://cdn.segment.com/v1/projects/<writeKey>/integrations. That returns an array of integration objects:

{"name":"Slack","creationName":"Slack","description":"Slack is a team collaboration tool.","website":"http://slack.com","category":"Customer Success"}

(name would be Slack here)

Example

<ConsentManager
        writeKey="tYQQPcY78Hc3T1hXUYk0n4xcbEHnN7r0"
        otherWriteKeys={['vMRS7xbsjH97Bb2PeKbEKvYDvgMm5T3l']}
        bannerContent={bannerContent}
        bannerSubContent={bannerSubContent}
        preferencesDialogTitle={preferencesDialogTitle}
        preferencesDialogContent={preferencesDialogContent}
        cancelDialogTitle={cancelDialogTitle}
        cancelDialogContent={cancelDialogContent}
        closeBehavior={props.closeBehavior}
        customCategories={{
            "Do Not Sell": { 
                integrations: ["Google Ads (Classic)"],
                purpose: "To give the right to opt out of the sale of personal data." 
           } 
       }}
/>

renders as:
Screen Shot 2019-12-11 at 9 01 01 AM

which in turn, reflects this cookie:

{
  "destinationPreferences": {
    "AdWords": false
  },
  "customPreferences": {
    "Do Not Sell": false
  }
}

Manual Flow Tests

Default Consent Categories

originalconsent

Custom Consent Categories

customconsent

@msanterre
Copy link

I was thinking this would replace our current categories and let users map destinations directly to categories.

@notfelineit
Copy link
Contributor Author

That sounds good to me! Should it be to entire categories of destinations <> consent category, or allow specific destination <> consent category?

@msanterre
Copy link

I think specific would be more useful!

@notfelineit
Copy link
Contributor Author

notfelineit commented Dec 11, 2019

I think what I'll do is:
1) Uphold existing default behavior, which is by category but
2) Make sure users can also pass in mapCustomPreferences to do custom destination/yes/no

Actually, going to make this map custom category <> destination name - since you made a good point about customCategories being a very specific feature Max :-)

@notfelineit notfelineit marked this pull request as ready for review December 11, 2019 19:32
Copy link

@msanterre msanterre left a comment

Choose a reason for hiding this comment

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

lgtm
]

@@ -23,6 +23,7 @@ interface ContainerProps {
resetPreferences: () => void
closeBehavior?: CloseBehavior
destinations: Destination[]
customCategories?: CustomCategories | undefined

Choose a reason for hiding this comment

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

Doesn't the ? take care of the undefined case here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I originally had it as just customCategories?: CustomCategories but it was failing validation - because sometimes we do pass in customCategories but the value is undefined.

if (customCategories) {
for (const preferenceName of Object.keys(customCategories)) {
const value = preferences[preferenceName]
if (typeof value === 'boolean') {

Choose a reason for hiding this comment

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

You could just do this here I think:

          customPreferences[preferenceName] = Boolean(value)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is saying "if explicitly set as true or false, set as true or false, if not set (i.e. value is null), set to true"

@notfelineit notfelineit merged commit 79ce264 into master Dec 11, 2019