UNPKG

@m10s/cmp

Version:

Package containing scripts used by Schibsteds' sites to integrate with Sourcepoint CMP

38 lines (34 loc) 1.56 kB
import { setupPsiConfig } from './psi'; import { setupSccApi } from './scc'; import { setupTcfApi } from './tcf'; import { version } from './version'; import { loadMessagingScript, loadExternalToolsScript, loadTcfApi } from './utils/index'; import { checkIfShouldDisableOnWebview } from './utils/mobile'; import { getConsentHistory } from './sticky-consent/index'; import { getCookie } from './utils.js'; export function psi(window, document, navigator, config) { loadExternalToolsScript(document, config); setupPsiConfig(window, document, navigator, {...config, jsSdkVersion: version}, 'psi'); loadMessagingScript(config, document); } export function scc(window, document, navigator, config) { loadExternalToolsScript(document, config); setupPsiConfig(window, document, navigator, config, 'scc'); setupSccApi(window, config); loadMessagingScript(config, document); } export function tcf(window, document, navigator, config) { // workaround for webviews. do not init sourcepoint if native consent is not passed if (checkIfShouldDisableOnWebview(window, navigator, config)) { console.warn('CMP: Native consent is not passed. Sourcepoint will not be initialized.'); return; }; loadTcfApi(document); loadExternalToolsScript(document, config); setupPsiConfig(window, document, navigator, config, 'tcf'); setupTcfApi(window, config); loadMessagingScript(config, document); if (config.authId && !getCookie('CMP:stickyConsent')) { getConsentHistory(window, config); } }