use rollbar

This commit is contained in:
Pete Matsyburka
2024-05-23 17:53:42 +03:00
parent b2c8667c53
commit e466562391
8 changed files with 121 additions and 101 deletions
+34
View File
@@ -0,0 +1,34 @@
import Rollbar from 'rollbar/dist/rollbar.umd'
const token = document.querySelector('meta[name="rollbar-token"]')?.getAttribute('content')
if (token) {
window.Rollbar ||= new Rollbar({
accessToken: token,
captureUncaught: true,
captureUnhandledRejections: true,
captureIp: false,
autoInstrument: false,
ignoredMessages: [
/Failed to fetch/i,
/NetworkError/i,
/Load failed/i,
/Clipboard write is not allowed/i
],
transform (payload) {
payload.body.telemetry = []
const string = JSON.stringify(payload)
return JSON.parse(string.replace(/(\/[des]\/)\w{6}/g, (_, m) => m))
},
payload: {
client: {
javascript: {
source_map_enabled: true
}
},
environment: 'production'
}
})
}
-19
View File
@@ -1,19 +0,0 @@
import * as Sentry from '@sentry/browser'
const sentryDsn = document.querySelector('meta[name="sentry-dsn"]')?.getAttribute('content')
if (sentryDsn) {
Sentry.init({
dsn: sentryDsn,
beforeSend (event) {
if (event.request.url.match(/\/[ds]\//)) {
event.request.url = event.request.url.slice(0, -6)
}
return event
},
beforeBreadcrumb () {
return null
}
})
}