[mirotalksfu] - #115 Added the ability to enable or disable stats from the config.js file
هذا الالتزام موجود في:
@@ -317,7 +317,7 @@ Support the project by [becoming a backer or sponsor](https://github.com/sponsor
|
|||||||
| --------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
| --------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
||||||
| [](https://broadcastx.de/) | [](https://hetzner.cloud/?ref=XdRifCzCK3bn) |
|
| [](https://broadcastx.de/) | [](https://hetzner.cloud/?ref=XdRifCzCK3bn) |
|
||||||
| [](https://luvlounge.ca) | [](https://www.questionpro.com) |
|
| [](https://luvlounge.ca) | [](https://www.questionpro.com) |
|
||||||
| [](https://www.browserstack.com) | [](https://crystalsound.ai) |
|
| [](https://www.browserstack.com) | [](https://crystalsound.ai) |
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|||||||
@@ -124,6 +124,13 @@ if (sentryEnabled) {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stats
|
||||||
|
const defaultStats = {
|
||||||
|
enabled: true,
|
||||||
|
src: 'https://stats.mirotalk.com/script.js',
|
||||||
|
id: '41d26670-f275-45bb-af82-3ce91fe57756',
|
||||||
|
};
|
||||||
|
|
||||||
// OpenAI/ChatGPT
|
// OpenAI/ChatGPT
|
||||||
let chatGPT;
|
let chatGPT;
|
||||||
if (config.chatGPT.enabled) {
|
if (config.chatGPT.enabled) {
|
||||||
@@ -319,6 +326,13 @@ function startServer() {
|
|||||||
res.sendFile(views.about);
|
res.sendFile(views.about);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Get stats endpoint
|
||||||
|
app.get(['/stats'], (req, res) => {
|
||||||
|
const stats = config.stats ? config.stats : defaultStats;
|
||||||
|
// log.debug('Send stats', stats);
|
||||||
|
res.send(stats);
|
||||||
|
});
|
||||||
|
|
||||||
// ####################################################
|
// ####################################################
|
||||||
// API
|
// API
|
||||||
// ####################################################
|
// ####################################################
|
||||||
|
|||||||
@@ -117,6 +117,15 @@ module.exports = {
|
|||||||
enabled: false,
|
enabled: false,
|
||||||
url: '',
|
url: '',
|
||||||
},
|
},
|
||||||
|
stats: {
|
||||||
|
/*
|
||||||
|
Umami: https://github.com/umami-software/umami
|
||||||
|
We use Umami to track aggregated usage statistics in order to improve our service.
|
||||||
|
*/
|
||||||
|
enabled: true,
|
||||||
|
src: 'https://stats.mirotalk.com/script.js',
|
||||||
|
id: '41d26670-f275-45bb-af82-3ce91fe57756',
|
||||||
|
},
|
||||||
mediasoup: {
|
mediasoup: {
|
||||||
// Worker settings
|
// Worker settings
|
||||||
numWorkers: Object.keys(os.cpus()).length,
|
numWorkers: Object.keys(os.cpus()).length,
|
||||||
|
|||||||
@@ -1,9 +1,26 @@
|
|||||||
'use strict';
|
'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');
|
fetch(url)
|
||||||
script.setAttribute('async', '');
|
.then((response) => {
|
||||||
script.setAttribute('src', 'https://stats.mirotalk.com/script.js');
|
if (!response.ok) {
|
||||||
script.setAttribute('data-website-id', '41d26670-f275-45bb-af82-3ce91fe57756');
|
throw new Error('Network response was not ok');
|
||||||
document.head.appendChild(script);
|
}
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم