feat: add vite-plugin sentry #1991

Merged
konrad merged 8 commits from dpschen/frontend:feature/feat-vite-plugin-sentry into main 2023-06-18 13:40:23 +00:00
1 changed files with 6 additions and 6 deletions
Showing only changes of commit 96c9407414 - Show all commits

View File

@ -4,7 +4,6 @@ import {createApp} from 'vue'
import pinia from './pinia'
import router from './router'
import App from './App.vue'

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.

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?

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.

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](https://vitejs.dev/guide/features.html#glob-import) with the `eager` option enabled.

Good question. By dev builds you mean while in development, the build:dev command or also the ones we have for try?

While in development or built with build:dev.

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.

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.

> Good question. By dev builds you mean while in development, the build:dev command or also the ones we have for try? While in development or built with `build:dev`. > 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. 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:

  • have it loaded synchroniously (in order to track errors on initial load)
  • disable it via a window variable

TBH I think the only real way here are two separate builds where in one it gets conditionally included.

Tricky if we want to: - have it loaded synchroniously (in order to track errors on initial load) - disable it via a window variable TBH I think the only real way here are two separate builds where in one it gets conditionally included.

in order to track errors on initial load

Maybe that would be an acceptable trade-off? (To not try to catch these kinds of errors).

> in order to track errors on initial load 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.

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.

I see. Still, I'd like to avoid the added complexity of releasing two versions for everything.
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)