From d1ad1faa4cc1557e867987e7c99a7d3f0f143ff5 Mon Sep 17 00:00:00 2001 From: Sagar Hani Date: Fri, 18 Aug 2023 17:01:41 +0200 Subject: [PATCH 1/2] chore: typescript improvement --- .../configuration/micro-frontend-support.mdx | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/platforms/javascript/common/configuration/micro-frontend-support.mdx b/src/platforms/javascript/common/configuration/micro-frontend-support.mdx index 9d454ed34341d..40a70e0dbad73 100644 --- a/src/platforms/javascript/common/configuration/micro-frontend-support.mdx +++ b/src/platforms/javascript/common/configuration/micro-frontend-support.mdx @@ -93,7 +93,7 @@ The example below uses a `feature` tag to determine which Sentry project to send the event to. If the event does not have a `feature` tag, we send it to the fallback DSN defined in `Sentry.init`. -```typescript +```javascript import { captureException, init, makeFetchTransport } from "@sentry/browser"; import { makeMultiplexedTransport } from "@sentry/core"; @@ -129,18 +129,7 @@ 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"; +import { Envelope, EnvelopeItemType } from "@sentry/types"; interface MatchParam { /** The envelope to be sent */ From 570b5b91d427f441e6b895b6da96f7651c145a07 Mon Sep 17 00:00:00 2001 From: Sagar Hani Date: Tue, 22 Aug 2023 21:42:17 +0200 Subject: [PATCH 2/2] chore: move type declaration --- .../configuration/micro-frontend-support.mdx | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/platforms/javascript/common/configuration/micro-frontend-support.mdx b/src/platforms/javascript/common/configuration/micro-frontend-support.mdx index 40a70e0dbad73..2bb758fdc8ccd 100644 --- a/src/platforms/javascript/common/configuration/micro-frontend-support.mdx +++ b/src/platforms/javascript/common/configuration/micro-frontend-support.mdx @@ -93,11 +93,24 @@ The example below uses a `feature` tag to determine which Sentry project to send the event to. If the event does not have a `feature` tag, we send it to the fallback DSN defined in `Sentry.init`. -```javascript +```typescript import { captureException, init, makeFetchTransport } from "@sentry/browser"; import { makeMultiplexedTransport } from "@sentry/core"; +import { Envelope, EnvelopeItemType } from "@sentry/types"; + +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 }) { +function dsnFromFeature({ getEvent }: MatchParam) { const event = getEvent(); switch (event?.tags?.feature) { case "cart": @@ -129,20 +142,6 @@ You can then set tags/contexts on events in individual micro-frontends to decide containing the DSN and optionally the release. ```typescript -import { Envelope, EnvelopeItemType } from "@sentry/types"; - -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;