feat: add vite-plugin sentry #1991
12
src/main.ts
12
src/main.ts
|
@ -4,7 +4,6 @@ import {createApp} from 'vue'
|
|||
import pinia from './pinia'
|
||||
import router from './router'
|
||||
import App from './App.vue'
|
||||
|
||||
import {setupSentry} from './sentry'
|
||||
import {error, success} from './message'
|
||||
import {VERSION} from './version.json'
|
||||
|
||||
|
@ -105,12 +104,13 @@ setLanguage(browserLanguage).then(() => {
|
|||
}
|
||||
|
||||
if (window.SENTRY_ENABLED) {
|
||||
try{
|
||||
setupSentry(app, router)
|
||||
} catch(e) {
|
||||
console.error('Could not enable Sentry tracking', e)
|
||||
try {
|
||||
import {setupSentry} from './sentry'
|
||||
setupSentry(app, router).then(sentry => sentry.default(app, router))
|
||||
} catch (e) {
|
||||
console.error('Could not enable Sentry tracking', e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app.use(pinia)
|
||||
app.use(router)
|
||||
|
|
Reference in New Issue
By loading sentry synchroniously I hope that it tracks errors that happen very early in the app.
This will impact total load time of the app, but as a dev tool I think it's fine.
So it will only be loaded synchroniously in dev builds?
Good question. By dev builds you mean while in development, the
build:dev
command or also the ones we have for try?I guess it might really make sense to really not load it depending on the build. I'm not a fan of bundling tracking scripts, but for good development it's really helpful.
Maybe this could be possible when we load the sentry file with the help of vites glob import with the
eager
option enabled.While in development or built with
build:dev
.I think it's fine to load this automatically for dev builds but should be disableable (and not loaded in that case) for prod builds.
Tricky if we want to:
TBH I think the only real way here are two separate builds where in one it gets conditionally included.
Maybe that would be an acceptable trade-off? (To not try to catch these kinds of errors).
Unsure. Lots of errors happen on the initial load.
Stuff can behave differently once SPA routing is enabled.
I see. Still, I'd like to avoid the added complexity of releasing two versions for everything.