Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v2

- uses: actions/setup-node@v2
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'

- name: Restore lerna
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
node_modules
Expand Down
8 changes: 4 additions & 4 deletions packages/utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ interface BrowserInfo {

## Integration Utils

The integration utils helps to work with our integration tools like one trust.
The integration utils helps to work with our integration tools like one trust or user centrics.

### `loadOneTrustBaloiseSwitzerland`
### `loadConsentManagerBaloiseSwitzerland`

Loads the one trust script directly from our main cms system with the necessary parameters.
Loads the consent management script directly from our main cms system with the necessary parameters.

**Signature**
`loadOneTrustBaloiseSwitzerland(): void`
`loadConsentManagerBaloiseSwitzerland(): void`

## Common Model Utils

Expand Down
20 changes: 10 additions & 10 deletions packages/utils/src/integration/app-integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,28 +86,28 @@ describe('getBaseUrl', () => {
)
})
test('should determine the integration url for region DE and type onetrust and lang DE', () => {
expect(getIntegrationUrl(GERMAN, 'DE', something.IntegrationType.ONETRUST)).toBe(
'https://www.baloise.ch/app-integration/v2/de/onetrust/all.json',
expect(getIntegrationUrl(GERMAN, 'DE', something.IntegrationType.CONSENT_MANAGER)).toBe(
'https://www.baloise.ch/app-integration/v3/de/consent.json',
)
})
test('should determine the integration url for region DE and type onetrust and lang FR', () => {
expect(getIntegrationUrl(FRENCH, 'DE', something.IntegrationType.ONETRUST)).toBe(
'https://www.baloise.ch/app-integration/v2/de/onetrust/all.json',
expect(getIntegrationUrl(FRENCH, 'DE', something.IntegrationType.CONSENT_MANAGER)).toBe(
'https://www.baloise.ch/app-integration/v3/de/consent.json',
)
})
test('should determine the integration url for region CH and type onetrust and lang DE', () => {
expect(getIntegrationUrl(GERMAN, 'CH', something.IntegrationType.ONETRUST)).toBe(
'https://www.baloise.ch/app-integration/v2/ch/onetrust/all.json',
expect(getIntegrationUrl(GERMAN, 'CH', something.IntegrationType.CONSENT_MANAGER)).toBe(
'https://www.baloise.ch/app-integration/v3/ch/consent.json',
)
})
test('should determine the integration url for region CH and type onetrust and lang DE', () => {
expect(getIntegrationUrl(FRENCH, 'CH', something.IntegrationType.ONETRUST)).toBe(
'https://www.baloise.ch/app-integration/v2/ch/onetrust/all.json',
expect(getIntegrationUrl(FRENCH, 'CH', something.IntegrationType.CONSENT_MANAGER)).toBe(
'https://www.baloise.ch/app-integration/v3/ch/consent.json',
)
})
test('should determine the integration url for region CH and type onetrust and lang DE', () => {
expect(getIntegrationUrl(ITALIAN, 'CH', something.IntegrationType.ONETRUST)).toBe(
'https://www.baloise.ch/app-integration/v2/ch/onetrust/all.json',
expect(getIntegrationUrl(ITALIAN, 'CH', something.IntegrationType.CONSENT_MANAGER)).toBe(
'https://www.baloise.ch/app-integration/v3/ch/consent.json',
)
})
})
8 changes: 4 additions & 4 deletions packages/utils/src/integration/app-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export const getIntegrationUrl = (
lang: Language,
region: Region = 'CH',
type: IntegrationType = IntegrationType.FOOTER,
version: 'v1' | 'v2' = 'v2',
version: 'v1' | 'v2' | 'v3' = 'v2',
) => {
let langPath: string = lang.key
if (type === IntegrationType.ONETRUST) {
langPath = 'all'
if (type === IntegrationType.CONSENT_MANAGER) {
return `${getIntegrationBaseUrl()}${INTEGRATION_BASE_PATH}/v3/${region.toLowerCase()}/consent.json`
} else {
if (region === 'DE') {
langPath = 'de'
Expand All @@ -34,5 +34,5 @@ export const getHost = () => window?.location?.host || undefined
export enum IntegrationType {
FOOTER = 'footer',
SOCIAL_MEDIA = 'socialmediachannels',
ONETRUST = 'onetrust',
CONSENT_MANAGER = 'onetrust',
}
20 changes: 10 additions & 10 deletions packages/utils/src/integration/integration.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { GERMAN, Language, LanguagesOfSwitzerland } from '../language/index'
import { getIntegrationUrl, IntegrationType, Region } from './app-integration'

export const loadOneTrustBaloiseSwitzerland = (lang?: Language): Promise<void> => {
return loadOnetrustDataSwitzerland().then((cmsData: OnetrustData[]) => {
export const loadConsentManagerBaloiseSwitzerland = (lang?: Language): Promise<void> => {
return loadConsentManager().then((cmsData: ConsentManagerData[]) => {
const win = window
if (win && win.localStorage && win.localStorage.getItem('onetrust_debug_mode') === 'true') {
return
}

const effectiveLang = LanguagesOfSwitzerland.valueOfOrDefault(lang ? lang.key : undefined)
const oneTrustData = cmsData.find(entry => entry.lang === effectiveLang.key)
if (oneTrustData) {
const oneTrustScript = oneTrustData.script
includeScriptsFromString(oneTrustScript)
const consentManagerData = cmsData.find(entry => entry.lang === effectiveLang.key)
if (consentManagerData) {
const consentManagerScript = consentManagerData.script
includeScriptsFromString(consentManagerScript)
}
return
})
Expand All @@ -34,14 +34,14 @@ const includeScriptsFromString = (scriptAsString: string): void => {
}
}

interface OnetrustData {
interface ConsentManagerData {
lang: string
script: string
}

const loadOnetrustDataSwitzerland = (lang: Language = GERMAN, region: Region = 'CH'): Promise<OnetrustData[]> => {
const url = getIntegrationUrl(lang, region, IntegrationType.ONETRUST)
const loadConsentManager = (lang: Language = GERMAN, region: Region = 'CH'): Promise<ConsentManagerData[]> => {
const url = getIntegrationUrl(lang, region, IntegrationType.CONSENT_MANAGER)
return fetch(url)
.then(res => res.json())
.then(res => res as OnetrustData[])
.then(res => res as ConsentManagerData[])
}