Skip to content

Recommended way to use micro-frontends with Sentry JS SDK #7622

Closed
getsentry/sentry-docs
#6754
@AbhiPrasad

Description

@AbhiPrasad

After soliciting feedback about micro-frontends from a variety of users and getting issues about it, we need to take steps to define a solid strategy around using Sentry with micro-frontends.

The most common thing we heard is that users want to be able to send to different sentry projects from a single web application.

There are some things we heard mixed messaging about, that folks were both for and against.

  • Isolating breadcrumbs to an individual micro-frontend
  • Conditionally requiring different automatic instrumentations based on micro-frontend module
  • Exact behavior around performance monitoring with multiple micro-frontends

In addition, Browser JavaScript does not provide any async storage mechanism, so there is no way for us to properly isolate data to an set of async function calls.

Based on this, our recommended solution for micro-frontends is going to be as the following (until we can make larger SDK refactors for more advanced behaviours - requires a new major version):

1 web application means 1 call to Sentry.init, and we will provide an API so that users can make decisions on what events to send to what project. We made some early attempts at exploring this already.

// Just an example.
Sentry.init({
  // replays/sessions/transactions all to go MAIN_DSN
  dsn: 'MAIN_DSN';
  // only works with errors
  integrations: [new Multiplexer([
    {
      dsn: '__DSN_ONE__',
      matcher: (event) => event.tags.user === 'VERY IMPORTANT USER';
    },
    {
      dsn: '__DSN_TWO__',
      matcher: (event) => GLOBAL_PER_MODULE_TYPE === 'MODULE_TWO';
    },
  ])];
});

Then in the docs we add a one-pager about our recommended way to use micro-frontends.

This way is very opinionated on purpose - let's make sure we have a confident answer to give to users instead of just giving half-measures.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions