Skip to content

Commit

Permalink
chore: types improvement on Micro Frontend support document (#7672)
Browse files Browse the repository at this point in the history
* chore: typescript improvement

* chore: move type declaration
  • Loading branch information
sagarhani committed Aug 23, 2023
1 parent 160943f commit 9394f1f
Showing 1 changed file with 14 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,21 @@ fallback DSN defined in `Sentry.init`.
```typescript
import { captureException, init, makeFetchTransport } from "@sentry/browser";
import { makeMultiplexedTransport } from "@sentry/core";
import { Envelope, EnvelopeItemType } from "@sentry/types";

function dsnFromFeature({ getEvent }) {
interface MatchParam {
/** The envelope to be sent */
envelope: Envelope;
/**
* A function that returns an event from the envelope if one exists. You can optionally pass an array of envelope item
* types to filter by - only envelopes matching the given types will be returned.
*
* @param types Defaults to ['event'] (only error events will be returned)
*/
getEvent(types?: EnvelopeItemType[]): Event | undefined;
}

function dsnFromFeature({ getEvent }: MatchParam) {
const event = getEvent();
switch (event?.tags?.feature) {
case "cart":
Expand Down Expand Up @@ -129,31 +142,6 @@ You can then set tags/contexts on events in individual micro-frontends to decide
containing the DSN and optionally the release.
```typescript
type EnvelopeItemType =
| "client_report"
| "user_report"
| "session"
| "sessions"
| "transaction"
| "attachment"
| "event"
| "profile"
| "replay_event"
| "replay_recording"
| "check_in";

interface MatchParam {
/** The envelope to be sent */
envelope: Envelope;
/**
* A function that returns an event from the envelope if one exists. You can optionally pass an array of envelope item
* types to filter by - only envelopes matching the given types will be returned.
*
* @param types Defaults to ['event'] (only error events will be returned)
*/
getEvent(types?: EnvelopeItemType[]): Event | undefined;
}

interface RouteTo {
dsn: string;
release?: string;
Expand Down

1 comment on commit 9394f1f

@vercel
Copy link

@vercel vercel bot commented on 9394f1f Aug 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

docs.sentry.io
sentry-docs-git-master.sentry.dev
sentry-docs.sentry.dev

Please sign in to comment.