From 3c247345a6e2efbf1b252c823c2b3cabee9057a8 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 15 Nov 2024 10:27:43 +0100 Subject: [PATCH] ref(types): Deprecate `Request` type in favor of `RequestEventData` --- docs/migration/draft-v9-migration-guide.md | 4 ++++ packages/browser/src/exports.ts | 2 ++ packages/bun/src/index.ts | 2 ++ packages/cloudflare/src/index.ts | 2 ++ packages/deno/src/index.ts | 2 ++ packages/node/src/index.ts | 2 ++ .../integrations/http/SentryHttpInstrumentation.ts | 6 +++--- packages/types/src/event.ts | 6 +++--- packages/types/src/index.ts | 8 +++++++- packages/types/src/request.ts | 9 +++++++-- packages/utils/src/requestdata.ts | 11 +++++++---- packages/vercel-edge/src/index.ts | 2 ++ 12 files changed, 43 insertions(+), 13 deletions(-) diff --git a/docs/migration/draft-v9-migration-guide.md b/docs/migration/draft-v9-migration-guide.md index 5630d82ede90..bbbb2c2d367f 100644 --- a/docs/migration/draft-v9-migration-guide.md +++ b/docs/migration/draft-v9-migration-guide.md @@ -11,3 +11,7 @@ ## `@sentry/core` - Deprecated `transactionNamingScheme` option in `requestDataIntegration`. + +## `@sentry/types`` + +- Deprecated `Request` in favor of `RequestEventData`. diff --git a/packages/browser/src/exports.ts b/packages/browser/src/exports.ts index fe5179f77661..ebea58f1fa7c 100644 --- a/packages/browser/src/exports.ts +++ b/packages/browser/src/exports.ts @@ -1,7 +1,9 @@ export type { Breadcrumb, BreadcrumbHint, + // eslint-disable-next-line deprecation/deprecation Request, + RequestEventData, SdkInfo, Event, EventHint, diff --git a/packages/bun/src/index.ts b/packages/bun/src/index.ts index 5688d1007769..d8c97d6e8246 100644 --- a/packages/bun/src/index.ts +++ b/packages/bun/src/index.ts @@ -2,7 +2,9 @@ export type { Breadcrumb, BreadcrumbHint, PolymorphicRequest, + // eslint-disable-next-line deprecation/deprecation Request, + RequestEventData, SdkInfo, Event, EventHint, diff --git a/packages/cloudflare/src/index.ts b/packages/cloudflare/src/index.ts index fa0d76a54521..4115874aa5e5 100644 --- a/packages/cloudflare/src/index.ts +++ b/packages/cloudflare/src/index.ts @@ -2,7 +2,9 @@ export type { Breadcrumb, BreadcrumbHint, PolymorphicRequest, + // eslint-disable-next-line deprecation/deprecation Request, + RequestEventData, SdkInfo, Event, EventHint, diff --git a/packages/deno/src/index.ts b/packages/deno/src/index.ts index c7328c810f92..3531074793f3 100644 --- a/packages/deno/src/index.ts +++ b/packages/deno/src/index.ts @@ -2,7 +2,9 @@ export type { Breadcrumb, BreadcrumbHint, PolymorphicRequest, + // eslint-disable-next-line deprecation/deprecation Request, + RequestEventData, SdkInfo, Event, EventHint, diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index 6ab536034894..88b105682e6d 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -144,7 +144,9 @@ export type { Breadcrumb, BreadcrumbHint, PolymorphicRequest, + // eslint-disable-next-line deprecation/deprecation Request, + RequestEventData, SdkInfo, Event, EventHint, diff --git a/packages/node/src/integrations/http/SentryHttpInstrumentation.ts b/packages/node/src/integrations/http/SentryHttpInstrumentation.ts index 6b6fe8aaad40..b17810adb601 100644 --- a/packages/node/src/integrations/http/SentryHttpInstrumentation.ts +++ b/packages/node/src/integrations/http/SentryHttpInstrumentation.ts @@ -6,7 +6,7 @@ import type { InstrumentationConfig } from '@opentelemetry/instrumentation'; import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation'; import { getRequestInfo } from '@opentelemetry/instrumentation-http'; import { addBreadcrumb, getClient, getIsolationScope, withIsolationScope } from '@sentry/core'; -import type { PolymorphicRequest, Request, SanitizedRequestData } from '@sentry/types'; +import type { PolymorphicRequest, RequestEventData, SanitizedRequestData } from '@sentry/types'; import { getBreadcrumbLogLevelFromHttpStatusCode, getSanitizedUrlString, @@ -142,7 +142,7 @@ export class SentryHttpInstrumentation extends InstrumentationBase; capturedSpanScope?: Scope; capturedSpanIsolationScope?: Scope; diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index b100c1e9c26a..5dd1839aeba7 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -87,7 +87,13 @@ export type { SendFeedbackParams, UserFeedback, } from './feedback'; -export type { QueryParams, Request, SanitizedRequestData } from './request'; +export type { + QueryParams, + RequestEventData, + // eslint-disable-next-line deprecation/deprecation + Request, + SanitizedRequestData, +} from './request'; export type { Runtime } from './runtime'; export type { CaptureContext, Scope, ScopeContext, ScopeData } from './scope'; export type { SdkInfo } from './sdkinfo'; diff --git a/packages/types/src/request.ts b/packages/types/src/request.ts index f0c2bdb268ca..6ba060219dfd 100644 --- a/packages/types/src/request.ts +++ b/packages/types/src/request.ts @@ -1,8 +1,7 @@ /** * Request data included in an event as sent to Sentry. - * TODO(v9): Rename this to avoid confusion, because Request is also a native type. */ -export interface Request { +export interface RequestEventData { url?: string; method?: string; data?: any; @@ -12,6 +11,12 @@ export interface Request { headers?: { [key: string]: string }; } +/** + * Request data included in an event as sent to Sentry. + * @deprecated: This type will be removed in v9. Use `RequestEventData` instead. + */ +export type Request = RequestEventData; + export type QueryParams = string | { [key: string]: string } | Array<[string, string]>; /** diff --git a/packages/utils/src/requestdata.ts b/packages/utils/src/requestdata.ts index 26b12b07c69e..13ec367addda 100644 --- a/packages/utils/src/requestdata.ts +++ b/packages/utils/src/requestdata.ts @@ -3,7 +3,7 @@ import type { Event, ExtractedNodeRequestData, PolymorphicRequest, - Request, + RequestEventData, TransactionSource, WebFetchHeaders, WebFetchRequest, @@ -260,7 +260,7 @@ export function extractRequestData( */ export function addNormalizedRequestDataToEvent( event: Event, - req: Request, + req: RequestEventData, // This is non-standard data that is not part of the regular HTTP request additionalData: { ipAddress?: string; user?: Record }, options: AddRequestDataToEventOptions, @@ -428,10 +428,13 @@ export function winterCGRequestToRequestData(req: WebFetchRequest): PolymorphicR }; } -function extractNormalizedRequestData(normalizedRequest: Request, { include }: { include: string[] }): Request { +function extractNormalizedRequestData( + normalizedRequest: RequestEventData, + { include }: { include: string[] }, +): RequestEventData { const includeKeys = include ? (Array.isArray(include) ? include : DEFAULT_REQUEST_INCLUDES) : []; - const requestData: Request = {}; + const requestData: RequestEventData = {}; const headers = { ...normalizedRequest.headers }; if (includeKeys.includes('headers')) { diff --git a/packages/vercel-edge/src/index.ts b/packages/vercel-edge/src/index.ts index e222d2de1ad1..4eea3f90d2d8 100644 --- a/packages/vercel-edge/src/index.ts +++ b/packages/vercel-edge/src/index.ts @@ -2,7 +2,9 @@ export type { Breadcrumb, BreadcrumbHint, PolymorphicRequest, + // eslint-disable-next-line deprecation/deprecation Request, + RequestEventData, SdkInfo, Event, EventHint,