[mirotalksfu] - improve stats, update dep.
هذا الالتزام موجود في:
@@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
|
||||
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
||||
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||
* @version 1.3.56
|
||||
* @version 1.3.57
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
||||
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||
* @version 1.3.56
|
||||
* @version 1.3.57
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,26 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
// const url = 'https://localhost:3010/stats';
|
||||
const url = 'https://sfu.mirotalk.com/stats';
|
||||
console.log('STATS', window.location);
|
||||
|
||||
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);
|
||||
});
|
||||
const statsDataKey = 'statsData';
|
||||
const statsData = window.sessionStorage.getItem(statsDataKey);
|
||||
|
||||
const apiUrl = window.location.origin + '/stats';
|
||||
|
||||
if (statsData) {
|
||||
setStats(JSON.parse(statsData));
|
||||
} else {
|
||||
fetch(apiUrl)
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then((data) => {
|
||||
setStats(data);
|
||||
window.sessionStorage.setItem(statsDataKey, JSON.stringify(data));
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Stats fetch error:', error);
|
||||
});
|
||||
}
|
||||
|
||||
function setStats(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);
|
||||
}
|
||||
}
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم