[mirotalksfu] - #115 Added the ability to enable or disable stats from the config.js file

هذا الالتزام موجود في:
Miroslav Pejic
2023-08-01 08:52:58 +02:00
الأصل e983a371d2
التزام e2c97a01bc
4 ملفات معدلة مع 47 إضافات و7 حذوفات

عرض الملف

@@ -1,9 +1,26 @@
'use strict';
// https://github.com/mikecao/umami
// const url = 'https://localhost:3010/stats';
const url = 'https://sfu.mirotalk.com/stats';
const script = document.createElement('script');
script.setAttribute('async', '');
script.setAttribute('src', 'https://stats.mirotalk.com/script.js');
script.setAttribute('data-website-id', '41d26670-f275-45bb-af82-3ce91fe57756');
document.head.appendChild(script);
fetch(url)
.then((response) => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then((data) => {
// console.log('STATS', data);
const { enabled, src, id } = data;
if (enabled) {
const script = document.createElement('script');
script.setAttribute('async', '');
script.setAttribute('src', src);
script.setAttribute('data-website-id', id);
document.head.appendChild(script);
}
})
.catch((error) => {
console.error('Stats fetch error:', error);
});