-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Consent Managment] Send consent changed event (#936)
- Loading branch information
Showing
26 changed files
with
586 additions
and
147 deletions.
There are no files selected for viewing
This file contains 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,6 @@ | ||
--- | ||
'@segment/analytics-consent-tools': minor | ||
'@segment/analytics-consent-wrapper-onetrust': minor | ||
--- | ||
|
||
Add consent changed event |
This file contains 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 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 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 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 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
36 changes: 36 additions & 0 deletions
36
packages/consent/consent-tools/src/domain/consent-changed.ts
This file contains 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,36 @@ | ||
import { AnyAnalytics, Categories } from '../types' | ||
|
||
/** | ||
* Dispatch an event that looks like: | ||
* ```ts | ||
* { | ||
* "type": "track", | ||
* "event": "Segment Consent Preference", | ||
* "context": { | ||
* "consent": { | ||
* "categoryPreferences" : { | ||
* "C0001": true, | ||
* "C0002": false, | ||
* } | ||
* } | ||
* ... | ||
* ``` | ||
*/ | ||
export const sendConsentChangedEvent = ( | ||
analytics: AnyAnalytics, | ||
categories: Categories | ||
): void => { | ||
analytics.track( | ||
CONSENT_CHANGED_EVENT, | ||
undefined, | ||
createConsentChangedCtxDto(categories) | ||
) | ||
} | ||
|
||
const CONSENT_CHANGED_EVENT = 'Segment Consent Preference' | ||
|
||
const createConsentChangedCtxDto = (categories: Categories) => ({ | ||
consent: { | ||
categoryPreferences: categories, | ||
}, | ||
}) |
This file contains 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.