add setry

This commit is contained in:
Ross
2026-07-20 10:29:04 +01:00
parent 5aae169a25
commit c5663c4a56
2 changed files with 50 additions and 16 deletions
+5
View File
@@ -424,6 +424,10 @@
<div id="packet-history" class="fullscreen-overlay"></div>
<div id="database-error" class="fullscreen-overlay"></div>
<script
src="https://js-de.sentry-cdn.com/017b4494d7038e3e789fe38378b53fb2.min.js"
crossorigin="anonymous"
></script>
<script src="lib/loglevel.min.js"></script>
<script src="lib/uuidv4.min.js" type="module"></script>
@@ -447,6 +451,7 @@
<script src="js/main.js" defer="defer" type="module"></script>
<script src="lib/notify.min.js" type="text/javascript"></script>
<script></script>
</body>
</html>
+45 -16
View File
@@ -1,7 +1,6 @@
/**
* Sentry Error Monitoring initializer for RTS.
*
* Configurable via window.SENTRY_DSN or window.RTS_SENTRY_DSN or <meta name="sentry-dsn" content="...">
* Optimized for Free Tier with beforeSend noise filtering.
*/
export function initSentry() {
@@ -13,28 +12,58 @@ export function initSentry() {
return;
}
const beforeSend = (event, hint) => {
const error = hint?.originalException;
const message = event?.message || (error && error.message) || "";
// Ignore common harmless browser/network noise to preserve Sentry free quota
const noisePatterns = [
/ResizeObserver loop/i,
/Failed to fetch/i,
/NetworkError/i,
/Load failed/i,
/Script error/i,
/top.GLOBALS/i,
/chrome-extension:\/\//i,
/moz-extension:\/\//i,
];
if (noisePatterns.some((pattern) => pattern.test(message))) {
return null;
}
return event;
};
const config = {
dsn: dsn,
environment: window.SENTRY_ENVIRONMENT || "production",
tracesSampleRate: parseFloat(window.SENTRY_TRACES_SAMPLE_RATE || "0.02"),
beforeSend: beforeSend,
ignoreErrors: [
"ResizeObserver loop limit exceeded",
"ResizeObserver loop completed with undelivered notifications.",
"NetworkError when attempting to fetch resource.",
"Failed to fetch",
"Load failed",
],
};
if (window.Sentry) {
window.Sentry.init({
dsn: dsn,
environment: window.SENTRY_ENVIRONMENT || 'production',
tracesSampleRate: parseFloat(window.SENTRY_TRACES_SAMPLE_RATE || '0.05'),
...config,
integrations: [
window.Sentry.browserTracingIntegration ? window.Sentry.browserTracingIntegration() : null
].filter(Boolean)
window.Sentry.browserTracingIntegration ? window.Sentry.browserTracingIntegration() : null,
].filter(Boolean),
});
console.log("[RTS] Sentry error monitoring initialized");
} else {
// Dynamically load Sentry bundle if DSN is set but Sentry library tag isn't explicitly loaded
const script = document.createElement('script');
script.src = 'https://browser.sentry-cdn.com/8.48.0/bundle.min.js';
script.crossOrigin = 'anonymous';
const script = document.createElement("script");
script.src = "https://browser.sentry-cdn.com/8.48.0/bundle.min.js";
script.crossOrigin = "anonymous";
script.onload = () => {
if (window.Sentry) {
window.Sentry.init({
dsn: dsn,
environment: window.SENTRY_ENVIRONMENT || 'production',
tracesSampleRate: parseFloat(window.SENTRY_TRACES_SAMPLE_RATE || '0.05')
});
window.Sentry.init(config);
console.log("[RTS] Sentry error monitoring initialized via dynamic load");
}
};