[mirotalk] - improve and made stats configurable, update dep.

This commit is contained in:
Miroslav Pejic
2024-01-28 20:16:39 +01:00
parent 3140fef792
commit 265be30d6a
5 changed files with 69 additions and 14 deletions
+8
View File
@@ -108,3 +108,11 @@ CHATGTP_APIKEY=YourOpenAiApiKey
CHATGPT_MODEL=gpt-3.5-turbo-instruct
CHATGPT_MAX_TOKENS=1000
CHATGPT_TEMPERATURE=0
# Stats
# Umami: https://github.com/umami-software/umami
# We use our Self-hosted Umami to track aggregated usage statistics in order to improve our service.
STATS_ENABLED=true # true or false
STATS_SCR=https://stats.mirotalk.com/script.js
STATS_ID=c7615aa7-ceec-464a-baba-54cb605d7261
+16 -1
View File
@@ -38,7 +38,7 @@ dependencies: {
* @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.2.76
* @version 1.2.77
*
*/
@@ -208,6 +208,13 @@ if (configChatGPT.enabled) {
}
}
// stats configuration
const statsData = {
enabled: process.env.STATS_ENABLED ? getEnvBoolean(process.env.STATS_ENABLED) : true,
src: process.env.STATS_SCR || 'https://stats.mirotalk.com/script.js',
id: process.env.STATS_ID || 'c7615aa7-ceec-464a-baba-54cb605d7261',
};
// directory
const dir = {
public: path.join(__dirname, '../../', 'public'),
@@ -285,6 +292,12 @@ app.get(['/'], (req, res) => {
}
});
// Get stats endpoint
app.get(['/stats'], (req, res) => {
//log.debug('Send stats', statsData);
res.send(statsData);
});
// mirotalk about
app.get(['/about'], (req, res) => {
res.sendFile(views.about);
@@ -539,6 +552,7 @@ async function ngrokStart() {
// server settings
log.debug('settings', {
iceServers: iceServers,
stats: statsData,
host: hostCfg,
presenters: roomPresenters,
ngrok: {
@@ -594,6 +608,7 @@ server.listen(port, null, () => {
// server settings
log.debug('settings', {
iceServers: iceServers,
stats: statsData,
host: hostCfg,
presenters: roomPresenters,
server: host,
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "mirotalk",
"version": "1.2.76",
"version": "1.2.77",
"description": "A free WebRTC browser-based video call",
"main": "server.js",
"scripts": {
@@ -37,18 +37,18 @@
"license": "AGPL-3.0",
"homepage": "https://github.com/miroslavpejic85/mirotalk",
"dependencies": {
"@sentry/integrations": "^7.94.1",
"@sentry/node": "^7.94.1",
"axios": "^1.6.5",
"@sentry/integrations": "^7.98.0",
"@sentry/node": "^7.98.0",
"axios": "^1.6.7",
"body-parser": "^1.20.2",
"colors": "^1.4.0",
"compression": "^1.7.4",
"cors": "^2.8.5",
"crypto-js": "^4.2.0",
"dotenv": "^16.3.2",
"dotenv": "^16.4.1",
"express": "^4.18.2",
"ngrok": "^4.3.3",
"openai": "^4.25.0",
"openai": "^4.26.0",
"qs": "^6.11.2",
"socket.io": "^4.7.4",
"swagger-ui-express": "^5.0.0",
+1 -1
View File
@@ -15,7 +15,7 @@
* @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.2.76
* @version 1.2.77
*
*/
+38 -6
View File
@@ -1,9 +1,41 @@
'use strict';
// https://github.com/mikecao/umami
// Umami analytics: https://github.com/mikecao/umami
const script = document.createElement('script');
script.setAttribute('async', '');
script.setAttribute('src', 'https://stats.mirotalk.com/script.js');
script.setAttribute('data-website-id', 'c7615aa7-ceec-464a-baba-54cb605d7261');
document.head.appendChild(script);
console.log('STATS', window.location);
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);
}
}