Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload sourcemaps for multiple environments #532

Open
taobojlen opened this issue May 18, 2024 · 10 comments
Open

Upload sourcemaps for multiple environments #532

taobojlen opened this issue May 18, 2024 · 10 comments

Comments

@taobojlen
Copy link

We're using @sentry/vite-plugin to create releases & upload sourcemaps to Sentry. We have a lot of environments, so this is what our flow looks like:

  • Build our Docker image, which runs vite build without the Sentry plugin
  • Deploy this new image to each of our environments
  • After each environment has been deployed, run vite build again in a post-deploy step, this time with the Sentry plugin configured so it creates the Sentry release w. sourcemaps for that environment.

This is quite inefficient, since we have to build our frontend N+1 times for N environments. Ideally, there would be a way to upload sourcemaps for many environments at once when we build.

Alternatively, if we're using the plugin incorrectly, I'd love to hear it! But I imagine that this is not an uncommon setup.

@lforst
Copy link
Member

lforst commented May 21, 2024

It is strongly recommended to run the plugin exactly when the prod build is running to avoid source maps to be drifting apart between builds.

I still don't understand your setup. Do you deploy the same app multiple times? And do you point each deployment to a separate project in Sentry? If so, we don't support sharing artifacts between projects yet, meaning you have to upload them multiple times.

@taobojlen
Copy link
Author

@lforst yes, we deploy our app many times -- we have an environment for each of our customers. they all live in the same sentry project, but as different environments.

so the deployed code will be the same across environments. we want a way to tell sentry "hey, environments A and B were just updated to run version X of our app, so that's the sourcemap to use".

maybe this isn't actually necessary? if we upload the sourcemap once, and create releases via the sentry CLI or github integration, will that work?

@lforst
Copy link
Member

lforst commented May 28, 2024

Currently, you need to upload sourcemaps to each project separately.

@bastien-pruvost
Copy link

I have the same problem, I have a Vite application with two environments (staging and production). And the code base is not the same (I have new features on staging that I don't have in production yet). I use sentry vite plugin in the deployment CIs to upload the sourcemaps.
But how can I upload different sourcemaps in the same Sentry project but in two different Sentry environments (staging and production) ?

@lforst
Copy link
Member

lforst commented Jun 6, 2024

@bastien-pruvost I don't think your problem is the same. You are not uploading to two different projects. If you use the default configuration of the vite plugin, everything should just work for you.

@taobojlen
Copy link
Author

taobojlen commented Jun 6, 2024

@lforst I don't upload to different Sentry projects either! I just have one project, with multiple environments.

My understanding is that the hierarchy in Sentry goes like this: Project -> Environment -> Release -> Sourcemap.

So my overall question is: when we deploy the same build to n environments, do we need to upload n sourcemaps? Or is it possible to upload a single sourcemap, and create the releases separately (e.g. via Sentry's API)? Is Sentry smart enough to re-use the sourcemap across environments in that case?

@lforst
Copy link
Member

lforst commented Jun 6, 2024

The hierarchy goes:

  • Project -> Sourcemap (if you use debug IDs which is the default)
  • Project -> Release -> Sourcemap (if you use the legacy upload process)

So if you have multiple environments that all send to the same project in Sentry, everything should just work fine by uploading once, everytime you build your application.

@dsteinel
Copy link

I am facing the same problem with a similar setup. My issue is that I have 2 self-hosted Sentry instances (one for development and one for production) but I only run the build once, so the upload only happens to one instance. because of our deployment strategy I can not do another build. So I need to find a way to upload the source maps in the build step twice to 2 different Sentry urls.
My guess is that I need to use a custom script to upload the source maps or am I missing something?

@lforst
Copy link
Member

lforst commented Jun 28, 2024

@dsteinel I think you could add the plugin twice. I have never tried that out though. Two self-hosted instances is definitely not a pattern we optimize for.

@dsteinel
Copy link

Ah yes that actually works! Thanks a lot @lforst

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Community
Development

No branches or pull requests

5 participants