-
Notifications
You must be signed in to change notification settings - Fork 57
feat: map Rokt Privacy flags in cookieSyncManager #1140
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 all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c6751c0
feat: map Rokt Privacy flags in cookieSyncManager
jaissica12 c4f021a
add constructor in cookieSyncManager, links docs in privacyManager, c…
jaissica12 7e8885b
add . to PrivacyManager description
jaissica12 ceeb09b
added error logging for invalid privacy flags
jaissica12 9e4d51c
rename privacyManager to cokkieConsentManager, remove logger from coo…
jaissica12 b6cfb71
remove conditional if block from CookieConsentManager
jaissica12 256166f
remove unused isBoolean export from utils
jaissica12 e262374
clean up CookieConsentManager constructor and update tests
jaissica12 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
Some comments aren't visible on the classic Files Changed page.
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,64 @@ | ||
| /** | ||
| * Cookie consent flags control SDK behavior based on user consent preferences for Rokt integration. | ||
| * @see https://docs.rokt.com/developers/integration-guides/web/cookie-consent-flags/ | ||
| */ | ||
| export interface ICookieConsentFlags { | ||
| /** | ||
| * When true, indicates the user has opted out of functional cookies/tracking. | ||
| * Default: false (functional tracking is allowed) | ||
| */ | ||
| noFunctional: boolean; | ||
|
|
||
| /** | ||
| * When true, indicates the user has opted out of targeting cookies/tracking. | ||
| * This flag is used to block cookie syncs and other targeting-related features. | ||
| * Default: false (targeting is allowed) | ||
| */ | ||
| noTargeting: boolean; | ||
| } | ||
|
|
||
| export interface ICookieConsentManager { | ||
| /** | ||
| * Targeting is allowed when noTargeting is false (default) | ||
| */ | ||
| getNoTargeting: () => boolean; | ||
|
|
||
| /** | ||
| * Functional tracking is allowed when noFunctional is false (default) | ||
| */ | ||
| getNoFunctional: () => boolean; | ||
| } | ||
|
|
||
| /** | ||
| * CookieConsentManager handles storage and access of consent flags (noFunctional, noTargeting) | ||
| * that are passed via launcherOptions during SDK initialization. | ||
| * | ||
| * These flags allow Rokt integration to respect user privacy choices. | ||
| * | ||
| * Default behavior: Both flags default to false, meaning all features are allowed | ||
| * unless explicitly opted out by the user. | ||
| */ | ||
| export default class CookieConsentManager implements ICookieConsentManager { | ||
| constructor(private flags: ICookieConsentFlags) { | ||
| this.flags = { | ||
| noFunctional: flags.noFunctional === true, | ||
| noTargeting: flags.noTargeting === true, | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Returns true if third-party targeting is disabled. | ||
| * Targeting is allowed when noTargeting is false (default). | ||
| */ | ||
| getNoTargeting(): boolean { | ||
| return this.flags.noTargeting; | ||
| } | ||
|
|
||
| /** | ||
| * Returns true if functional tracking is disabled. | ||
| * Functional tracking is allowed when noFunctional is false (default). | ||
| */ | ||
| getNoFunctional(): boolean { | ||
| return this.flags.noFunctional; | ||
| } | ||
| } | ||
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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import CookieConsentManager from '../../src/cookieConsentManager'; | ||
|
|
||
| describe('CookieConsentManager', () => { | ||
| describe('#constructor', () => { | ||
| it('should default flags to false when not provided', () => { | ||
| const cookieConsentManager = new CookieConsentManager({ noFunctional: undefined, noTargeting: undefined }); | ||
|
|
||
| expect(cookieConsentManager.getNoFunctional()).toBe(false); | ||
| expect(cookieConsentManager.getNoTargeting()).toBe(false); | ||
| }); | ||
|
|
||
| it('should set flags when passed', () => { | ||
| const cookieConsentManager = new CookieConsentManager({ noFunctional: true, noTargeting: true }); | ||
|
|
||
| expect(cookieConsentManager.getNoFunctional()).toBe(true); | ||
| expect(cookieConsentManager.getNoTargeting()).toBe(true); | ||
| }); | ||
|
|
||
| it('should ignore non-boolean values', () => { | ||
| const cookieConsentManager = new CookieConsentManager({ | ||
| noFunctional: 'true' as unknown as boolean, | ||
| noTargeting: 1 as unknown as boolean, | ||
| }); | ||
|
|
||
| expect(cookieConsentManager.getNoFunctional()).toBe(false); | ||
| expect(cookieConsentManager.getNoTargeting()).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe('#getNoFunctional', () => { | ||
| it('should return the noFunctional flag value', () => { | ||
| const cookieConsentManager = new CookieConsentManager({ noFunctional: true, noTargeting: undefined }); | ||
|
|
||
| expect(cookieConsentManager.getNoFunctional()).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('#getNoTargeting', () => { | ||
| it('should return the noTargeting flag value', () => { | ||
| const cookieConsentManager = new CookieConsentManager({ noTargeting: true, noFunctional: undefined }); | ||
|
|
||
| expect(cookieConsentManager.getNoTargeting()).toBe(true); | ||
| }); | ||
| }); | ||
| }); |
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.
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.