Skip to content

Commit a415aeb

Browse files
[mirotalkc2c] - improve Sentry logs
1 parent a769220 commit a415aeb

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

.env.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,6 @@ MATTERMOST_TOKEN=YourMettarmostToken
108108
# 3. Goto Settings/Projects/YourProjectName/Client Keys (DSN)
109109

110110
SENTRY_ENABLED=false # true or false
111+
SENTRY_LOG_LEVELS=error # Log levels to capture in Sentry (e.g., error,warn)
111112
SENTRY_DSN=YourClientKeyDSN
112113
SENTRY_TRACES_SAMPLE_RATE=0.5

backend/sentry.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,28 @@ const Logger = require('./logs');
55
const log = new Logger('Sentry');
66

77
const SENTRY_ENABLED = process.env.SENTRY_ENABLED === 'true';
8+
const SENTRY_LOG_LEVELS = (process.env.SENTRY_LOG_LEVELS || 'error').split(',').map(level => level.trim());
89
const SENTRY_DSN = process.env.SENTRY_DSN;
9-
const SENTRY_TRACES_SAMPLE_RATE = parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE || '0.0');
10+
const SENTRY_TRACES_SAMPLE_RATE = parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE || '0.5');
1011

1112
function patchConsoleForSentry() {
12-
const originalWarn = console.warn;
13-
const originalError = console.error;
14-
15-
console.warn = function (...args) {
16-
SentryNode.captureMessage(args.join(' '), 'warning');
17-
originalWarn.apply(console, args);
18-
};
19-
20-
console.error = function (...args) {
21-
args[0] instanceof Error
22-
? SentryNode.captureException(args[0])
23-
: SentryNode.captureException(new Error(args.join(' ')));
24-
originalError.apply(console, args);
25-
};
13+
const originalConsole = {};
14+
SENTRY_LOG_LEVELS.forEach((level) => {
15+
originalConsole[level] = console[level];
16+
console[level] = function (...args) {
17+
switch (level) {
18+
case 'warn':
19+
SentryNode.captureMessage(args.join(' '), 'warning');
20+
break;
21+
case 'error':
22+
args[0] instanceof Error
23+
? SentryNode.captureException(args[0])
24+
: SentryNode.captureException(new Error(args.join(' ')));
25+
break;
26+
}
27+
originalConsole[level].apply(console, args);
28+
};
29+
});
2630
}
2731

2832
function start() {

backend/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @license For private project or commercial purposes contact us at: [email protected] or purchase it directly via Code Canyon:
1010
* @license https://codecanyon.net/item/mirotalk-c2c-webrtc-real-time-cam-2-cam-video-conferences-and-screen-sharing/43383005
1111
* @author Miroslav Pejic - [email protected]
12-
* @version 1.2.13
12+
* @version 1.2.14
1313
*/
1414

1515
require('dotenv').config();

frontend/js/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @license For private project or commercial purposes contact us at: [email protected] or purchase it directly via Code Canyon:
1010
* @license https://codecanyon.net/item/mirotalk-c2c-webrtc-real-time-cam-2-cam-video-conferences-and-screen-sharing/43383005
1111
* @author Miroslav Pejic - [email protected]
12-
* @version 1.2.13
12+
* @version 1.2.14
1313
*/
1414

1515
const roomId = new URLSearchParams(window.location.search).get('room');

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mirotalkc2c",
3-
"version": "1.2.13",
3+
"version": "1.2.14",
44
"description": "A free WebRTC Cam-2-Cam browser-based video calls",
55
"main": "server.js",
66
"scripts": {

0 commit comments

Comments
 (0)