Skip to content

Commit b4f043d

Browse files
authored
ref(js): Add section about version alignment to Micro Frontends documentation #12023
1 parent 8917795 commit b4f043d

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

docs/platforms/javascript/common/best-practices/micro-frontends.mdx

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ keywords:
2121
"module metadata",
2222
]
2323
---
24+
2425
<Alert>
25-
To ensure the Sentry JavaScript SDK works with your micro frontends, make sure all micro frontends that import from a `@sentry/*` package are using the same version of the Sentry SDK.
26+
To ensure the Sentry JavaScript SDK works with your micro frontends, make sure
27+
all micro frontends that import from a `@sentry/*` package are [using the same
28+
version of the Sentry SDK](#sdk-version-alignment).
2629
</Alert>
2730

28-
If your app uses micro frontends, its very useful to be able to track which one an error is coming from. To do this with Sentry, you can create either an automatic or a manual setup where you send events to separate Sentry projects representing each of your micro frontends. This makes it easier to see whats going wrong and where, helping you track issues and fix them faster, especially in complex frontend architectures.
31+
If your app uses micro frontends, it's very useful to be able to track which one an error is coming from. To do this with Sentry, you can create either an automatic or a manual setup where you send events to separate Sentry projects representing each of your micro frontends. This makes it easier to see what's going wrong and where, helping you track issues and fix them faster, especially in complex frontend architectures.
2932

3033
Below you'll find setup instructions for both an automatic and a manual way to route errors to different Sentry projects.
3134

@@ -177,9 +180,14 @@ init({
177180
You can then set tags/contexts on events in individual micro-frontends to decide which Sentry project to send the event to as follows:
178181
179182
<Note>
180-
It's important to always use a local scope when setting the tag (either as shown below or using{" "} <PlatformLink to="/enriching-events/scopes/#local-scopes">
181-
withScope documentation </PlatformLink>). Using a global scope, for example, through `Sentry.setTag()` will result in all subsequent events being routed to the
182-
same DSN regardless of where they originated.
183+
It's important to always use a local scope when setting the tag (either as
184+
shown below or using{" "}
185+
<PlatformLink to="/enriching-events/scopes/#local-scopes">
186+
withScope documentation{" "}
187+
</PlatformLink>
188+
). Using a global scope, for example, through `Sentry.setTag()` will result in
189+
all subsequent events being routed to the same DSN regardless of where they
190+
originated.
183191
</Note>
184192
185193
```typescript
@@ -188,3 +196,17 @@ captureException(new Error("oh no!"), (scope) => {
188196
return scope;
189197
});
190198
```
199+
200+
## SDK Version Alignment
201+
202+
Starting with version [8.7.0](https://github.com/getsentry/sentry-javascript/releases/tag/8.7.0), if you have multiple Sentry JavaScript SDKs on the same page, they [only interact with each other](https://github.com/getsentry/sentry-javascript/pull/12206) if they're using the same version. This prevents unwanted cross-SDK interactions, where calls or accesses to recently added or no longer existing SDK APIs would lead to errors. A classic example for this are browser extensions or 3rd party scripts using Sentry when the host app also uses Sentry.
203+
204+
However, for use cases like micro frontends, where you might _want_ SDK interaction across multiple micro frontends or child applications, you'll need to ensure that all SDKs are using the same version.
205+
For example, if you initialize the SDK in a host or skeleton application, but make Sentry SDK calls (like `Sentry.captureException` or `Sentry.setTag`) in micro frontend child applications, you need to ensure that the SDK packages in the host and child applications are aligned to the same version.
206+
207+
<Note>
208+
209+
If you can't get all your micro frontends aligned on the same SDK version, you can [follow this workaround](https://github.com/getsentry/sentry-javascript/discussions/10576#discussioncomment-11446422).
210+
However, interoperability isn't guaranteed and you could run into some unexpected behavior.
211+
212+
</Note>

0 commit comments

Comments
 (0)