2022-07-07 11:39:03 +02:00
|
|
|
import { getConfig } from '@utils';
|
|
|
|
const {
|
|
|
|
crisp: { key, enabled, administrateur }
|
|
|
|
} = getConfig();
|
|
|
|
|
|
|
|
declare const window: Window &
|
|
|
|
typeof globalThis & {
|
|
|
|
CRISP_WEBSITE_ID?: string | null;
|
|
|
|
$crisp: (
|
|
|
|
| [cmd: string, key: string, value: unknown]
|
|
|
|
| [key: string, value: unknown]
|
|
|
|
)[];
|
|
|
|
};
|
2019-05-15 14:15:48 +02:00
|
|
|
|
|
|
|
if (enabled) {
|
|
|
|
window.$crisp = [];
|
|
|
|
window.CRISP_WEBSITE_ID = key;
|
|
|
|
|
|
|
|
const script = document.createElement('script');
|
|
|
|
const firstScript = document.getElementsByTagName('script')[0];
|
|
|
|
script.type = 'text/javascript';
|
|
|
|
script.id = 'crisp-js';
|
|
|
|
script.async = true;
|
|
|
|
script.src = 'https://client.crisp.chat/l.js';
|
2022-07-07 11:39:03 +02:00
|
|
|
firstScript.parentNode?.insertBefore(script, firstScript);
|
2019-05-15 14:15:48 +02:00
|
|
|
|
|
|
|
window.$crisp.push(['set', 'user:email', [administrateur.email]]);
|
|
|
|
window.$crisp.push(['set', 'session:segments', [['administrateur']]]);
|
|
|
|
window.$crisp.push([
|
|
|
|
'set',
|
|
|
|
'session:data',
|
|
|
|
[
|
|
|
|
[
|
|
|
|
['DS_ID', administrateur.email],
|
|
|
|
['DS_SIGN_IN_COUNT', administrateur.DS_SIGN_IN_COUNT],
|
2019-07-11 16:05:41 +02:00
|
|
|
[
|
|
|
|
'DS_NB_DEMARCHES_BROUILLONS',
|
|
|
|
administrateur.DS_NB_DEMARCHES_BROUILLONS
|
|
|
|
],
|
|
|
|
['DS_NB_DEMARCHES_ACTIVES', administrateur.DS_NB_DEMARCHES_ACTIVES],
|
|
|
|
['DS_NB_DEMARCHES_ARCHIVES', administrateur.DS_NB_DEMARCHES_ARCHIVES],
|
2019-05-15 14:15:48 +02:00
|
|
|
[
|
|
|
|
'URL_MANAGER',
|
|
|
|
'https://www.demarches-simplifiees.fr/manager/administrateurs/' +
|
|
|
|
administrateur.DS_ID
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
]);
|
2019-07-08 17:50:02 +02:00
|
|
|
window.$crisp.push([
|
|
|
|
'set',
|
|
|
|
'session:event',
|
|
|
|
[[['PAGE_VIEW', { URL: window.location.pathname }]]]
|
|
|
|
]);
|
2020-06-26 15:02:02 +02:00
|
|
|
|
|
|
|
// Prevent Crisp to log warnings about Sentry overriding document.addEventListener
|
|
|
|
window.$crisp.push(['safe', true]);
|
2019-05-15 14:15:48 +02:00
|
|
|
}
|