bugsnag / bugsnag-source-maps

CLI and JS library for uploading source maps to BugSnag
MIT License
16 stars 9 forks source link

Differ source maps per release stage and appType #72

Closed ujinho closed 3 years ago

ujinho commented 3 years ago

Hello!

We've integrated Bugsnag into our projects and now we're willing to upload typescript's source maps for them. And there is an issue with that. We have a bunch of Node.js micro-services written in Typescript and register Bugsnag notifier in every single MS like so:

bugsnag.register(<KEY>, {
  releaseStage: process.env.ENVIRONMENT,
  appVersion: packageJson.version,
  appType: packageJson.name,
  ...
}

These options (releaseStage, appType) help us to reliably determine which particular micro-service has thrown an error and identify the source of issue uniquely.

But unfortunately, there're no such options for source maps. As we have multiple micro-services in various release stages and in different versions, we're willing to have a unique set of source maps for every single build from that combinations, say for awesome-microservice of version 6.4 deployed to staging.

The idea was in using uploadMultiple (when every particular micro-service starts) in a following manner:

export const uploadSourceMapsToBugsnag = async (directory, projectRoot) {
....
  const apiKey = <KEY>;
  const appVersion = packageJson.version;

  try {
    await node.uploadMultiple({
      apiKey,
      appVersion,
      directory,
      projectRoot,
      overwrite: true,
    });
  } catch (err) {
    ...
  }
}

But that leads to conflicts between files from different builds. Files with same names just override. We can add more specifics into an appVersion option, say include release stage and micro-service's name into it in some custom manner, say make it look like so: staging_awesome-service-6.4. But how Bugsnag notifier would do the mapping in that case, how it identify the target source-maps's bundle and link it with a build which was originated an error?

In other words, will you please clarify how to upload source maps for multiple micro-services with several release stages and various version inside one project and link them to specific builds?

Reading manuals didn't help unfortunately.

Thank you.

mattdyoung commented 3 years ago

We've already responded via your related support ticket, but for wider visibility here's the response:

Bugsnag will apply source maps based on:

You could set the appVersion of your application, as you mentioned, to something like staging_awesome-service-6.4​ https://docs.bugsnag.com/platforms/javascript/configuration-options/#appversion

You can then upload your source maps, with a matching app version name. As these will then have a different app version, they will not be overwritten on upload and will be applied to your different services as appropriate.