Skip to content

Commit

Permalink
Create const for sourcepoint choice type id (#1846)
Browse files Browse the repository at this point in the history
* Create enum for sourcepoint choice type id

* Change enum to const
  • Loading branch information
akinsola-guardian authored Dec 19, 2024
1 parent 7c7b866 commit b409cc0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ export const ENDPOINT = isGuardianDomain()
? 'https://sourcepoint.theguardian.com'
: 'https://cdn.privacy-mgmt.com';
export type EndPoint = typeof ENDPOINT;

// https://docs.sourcepoint.com/hc/en-us/articles/4405397484307-Event-callbacks-CMP#h_01FTY32EGZ7H3SS192MEE6SNCP
export const SourcePointChoiceTypes = {
AcceptAll: 11,
RejectAll: 13,
Dismiss: 15,
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ENDPOINT,
PROPERTY_ID,
PROPERTY_ID_AUSTRALIA,
SourcePointChoiceTypes,
} from './lib/sourcepointConfig';
import { invokeCallbacks } from './onConsentChange';
import { stub } from './stub';
Expand Down Expand Up @@ -134,11 +135,11 @@ export const init = (framework: ConsentFramework, pubData = {}): void => {

log('cmp', `onMessageChoiceSelect choice_id: ${choice_id}`);
log('cmp', `onMessageChoiceSelect choice_type_id: ${choiceTypeID}`);
// https://documentation.sourcepoint.com/web-implementation/web-implementation/multi-campaign-web-implementation/event-callbacks#choice-type-id-descriptions
if (
// https://documentation.sourcepoint.com/web-implementation/web-implementation/multi-campaign-web-implementation/event-callbacks#choice-type-id-descriptions
choiceTypeID === 11 ||
choiceTypeID === 13 ||
choiceTypeID === 15
Object.values(SourcePointChoiceTypes).some(
(spChoiceType) => spChoiceType === choiceTypeID,
)
) {
setTimeout(invokeCallbacks, 0);
}
Expand Down

0 comments on commit b409cc0

Please sign in to comment.