demarches-normaliennes/app/javascript/shared/track/crisp.js
Chaïb Martinez d968e7e6bd Add some admin usage info for contextual help with crisp
Fix #4052

Signed-off-by: Chaïb Martinez <chaibax@gmail.com>
2019-07-15 12:10:56 +02:00

43 lines
1.3 KiB
JavaScript

const { key, enabled, administrateur } = gon.crisp || {};
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';
firstScript.parentNode.insertBefore(script, firstScript);
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],
[
'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],
[
'URL_MANAGER',
'https://www.demarches-simplifiees.fr/manager/administrateurs/' +
administrateur.DS_ID
]
]
]
]);
window.$crisp.push([
'set',
'session:event',
[[['PAGE_VIEW', { URL: window.location.pathname }]]]
]);
}