Skip to content

Commit ea549fe

Browse files
committed
s/CrossPlatformRequest/PolymorphicRequest
1 parent 3e0333a commit ea549fe

File tree

8 files changed

+23
-20
lines changed

8 files changed

+23
-20
lines changed

packages/node/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export type {
22
Breadcrumb,
33
BreadcrumbHint,
4-
CrossPlatformRequest,
4+
PolymorphicRequest,
55
Request,
66
SdkInfo,
77
Event,

packages/node/src/requestDataDeprecated.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/* eslint-disable deprecation/deprecation */
88
/* eslint-disable @typescript-eslint/no-explicit-any */
9-
import { CrossPlatformRequest, Event, ExtractedNodeRequestData } from '@sentry/types';
9+
import { Event, ExtractedNodeRequestData, PolymorphicRequest } from '@sentry/types';
1010
import {
1111
addRequestDataToEvent,
1212
AddRequestDataToEventOptions,
@@ -16,9 +16,9 @@ import * as cookie from 'cookie';
1616
import * as url from 'url';
1717

1818
/**
19-
* @deprecated `Handlers.ExpressRequest` is deprecated and will be removed in v8. Use `CrossPlatformRequest` instead.
19+
* @deprecated `Handlers.ExpressRequest` is deprecated and will be removed in v8. Use `PolymorphicRequest` instead.
2020
*/
21-
export type ExpressRequest = CrossPlatformRequest;
21+
export type ExpressRequest = PolymorphicRequest;
2222

2323
/**
2424
* Normalizes data from the request object, accounting for framework differences.

packages/node/src/sdk.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable max-lines */
22
import { getCurrentHub, getIntegrationsToSetup, initAndBind, Integrations as CoreIntegrations } from '@sentry/core';
33
import { getMainCarrier, setHubOnCarrier } from '@sentry/hub';
4-
import { CrossPlatformRequest, Event, ExtractedNodeRequestData, SessionStatus, StackParser } from '@sentry/types';
4+
import { Event, ExtractedNodeRequestData, PolymorphicRequest, SessionStatus, StackParser } from '@sentry/types';
55
import {
66
addRequestDataToEvent as _addRequestDataToEvent,
77
AddRequestDataToEventOptions,
@@ -293,7 +293,7 @@ function startSessionTracking(): void {
293293
*/
294294
export function addRequestDataToEvent(
295295
event: Event,
296-
req: CrossPlatformRequest,
296+
req: PolymorphicRequest,
297297
options?: Omit<AddRequestDataToEventOptions, 'deps'>,
298298
): Event {
299299
return _addRequestDataToEvent(event, req, {
@@ -317,7 +317,7 @@ export function addRequestDataToEvent(
317317
* @returns An object containing normalized request data
318318
*/
319319
export function extractRequestData(
320-
req: CrossPlatformRequest,
320+
req: PolymorphicRequest,
321321
options?: {
322322
include?: string[];
323323
},

packages/tracing/src/integrations/node/express.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable max-lines */
2-
import { CrossPlatformRequest, Integration, Transaction } from '@sentry/types';
2+
import { Integration, PolymorphicRequest, Transaction } from '@sentry/types';
33
import { extractPathForTransaction, getNumberOfUrlSegments, isRegExp, logger } from '@sentry/utils';
44

55
type Method =
@@ -33,8 +33,8 @@ type Router = {
3333
[method in Method]: (...args: any) => any; // eslint-disable-line @typescript-eslint/no-explicit-any
3434
};
3535

36-
/* Extend the CrossPlatformRequest type with a patched parameter to build a reconstructed route */
37-
type PatchedRequest = CrossPlatformRequest & { _reconstructedRoute?: string };
36+
/* Extend the PolymorphicRequest type with a patched parameter to build a reconstructed route */
37+
type PatchedRequest = PolymorphicRequest & { _reconstructedRoute?: string };
3838

3939
/* Types used for patching the express router prototype */
4040
type ExpressRouter = Router & {

packages/types/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export type { Mechanism } from './mechanism';
3939
export type { ExtractedNodeRequestData, HttpHeaderValue, Primitive, WorkerLocation } from './misc';
4040
export type { ClientOptions, Options } from './options';
4141
export type { Package } from './package';
42-
export type { PolymorphicEvent, CrossPlatformRequest } from './polymorphics';
42+
export type { PolymorphicEvent, PolymorphicRequest } from './polymorphics';
4343
export type { QueryParams, Request } from './request';
4444
export type { Runtime } from './runtime';
4545
export type { CaptureContext, Scope, ScopeContext } from './scope';

packages/types/src/polymorphics.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface PolymorphicEvent {
1313
}
1414

1515
/** A `Request` type compatible with Node, Express, browser, etc., because everything is optional */
16-
export type CrossPlatformRequest = BaseRequest &
16+
export type PolymorphicRequest = BaseRequest &
1717
BrowserRequest &
1818
NodeRequest &
1919
ExpressRequest &

packages/types/src/transaction.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Baggage } from './baggage';
22
import { MeasurementUnit } from './measurement';
33
import { ExtractedNodeRequestData, Primitive, WorkerLocation } from './misc';
4-
import { CrossPlatformRequest } from './polymorphics';
4+
import { PolymorphicRequest } from './polymorphics';
55
import { Span, SpanContext } from './span';
66
/**
77
* Interface holding Transaction-specific properties
@@ -143,6 +143,9 @@ export interface TransactionMetadata {
143143
/** The baggage object of a transaction's baggage header, used for dynamic sampling */
144144
baggage?: Baggage;
145145

146+
/** For transactions tracing server-side request handling, the request being tracked. */
147+
request?: PolymorphicRequest;
148+
146149
/** For transactions tracing server-side request handling, the path of the request being tracked. */
147150
requestPath?: string;
148151

packages/utils/src/requestdata.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/* eslint-disable max-lines */
1313
/* eslint-disable @typescript-eslint/no-explicit-any */
1414

15-
import { CrossPlatformRequest, Event, ExtractedNodeRequestData, Transaction, TransactionSource } from '@sentry/types';
15+
import { Event, ExtractedNodeRequestData, PolymorphicRequest, Transaction, TransactionSource } from '@sentry/types';
1616

1717
import { isPlainObject, isString } from './is';
1818
import { normalize } from './normalize';
@@ -44,7 +44,7 @@ type InjectedNodeDeps = {
4444
*/
4545
export function addRequestDataToTransaction(
4646
transaction: Transaction | undefined,
47-
req: CrossPlatformRequest,
47+
req: PolymorphicRequest,
4848
deps?: InjectedNodeDeps,
4949
): void {
5050
if (!transaction) return;
@@ -74,7 +74,7 @@ export function addRequestDataToTransaction(
7474
* @returns A tuple of the fully constructed transaction name [0] and its source [1] (can be either 'route' or 'url')
7575
*/
7676
export function extractPathForTransaction(
77-
req: CrossPlatformRequest,
77+
req: PolymorphicRequest,
7878
options: { path?: boolean; method?: boolean; customRoute?: string } = {},
7979
): [string, TransactionSource] {
8080
const method = req.method && req.method.toUpperCase();
@@ -110,7 +110,7 @@ export function extractPathForTransaction(
110110
type TransactionNamingScheme = 'path' | 'methodPath' | 'handler';
111111

112112
/** JSDoc */
113-
function extractTransaction(req: CrossPlatformRequest, type: boolean | TransactionNamingScheme): string {
113+
function extractTransaction(req: PolymorphicRequest, type: boolean | TransactionNamingScheme): string {
114114
switch (type) {
115115
case 'path': {
116116
return extractPathForTransaction(req, { path: true })[0];
@@ -154,7 +154,7 @@ function extractUserData(
154154
* @returns An object containing normalized request data
155155
*/
156156
export function extractRequestData(
157-
req: CrossPlatformRequest,
157+
req: PolymorphicRequest,
158158
options?: {
159159
include?: string[];
160160
deps?: InjectedNodeDeps;
@@ -282,7 +282,7 @@ export interface AddRequestDataToEventOptions {
282282
*/
283283
export function addRequestDataToEvent(
284284
event: Event,
285-
req: CrossPlatformRequest,
285+
req: PolymorphicRequest,
286286
options?: AddRequestDataToEventOptions,
287287
): Event {
288288
const include = {
@@ -335,7 +335,7 @@ export function addRequestDataToEvent(
335335
}
336336

337337
function extractQueryParams(
338-
req: CrossPlatformRequest,
338+
req: PolymorphicRequest,
339339
deps?: InjectedNodeDeps,
340340
): string | Record<string, unknown> | undefined {
341341
// url (including path and query string):

0 commit comments

Comments
 (0)