Skip to content

Commit

Permalink
feat(utils/core): Deprecate addRequestDataToEvent and `extractReque…
Browse files Browse the repository at this point in the history
…stData` (#14430)
  • Loading branch information
lforst authored Nov 22, 2024
1 parent 498d6d1 commit d49f1cb
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/migration/draft-v9-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- Deprecated `TransactionNamingScheme` type.
- Deprecated `validSeverityLevels`. Will not be replaced.
- Deprecated `urlEncode`. No replacements.
- Deprecated `addRequestDataToEvent`. Use `addNormalizedRequestDataToEvent` instead.
- Deprecated `extractRequestData`. Instead manually extract relevant data off request.
- Deprecated `arrayify`. No replacements.

## `@sentry/core`
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export {
addEventProcessor,
addIntegration,
addOpenTelemetryInstrumentation,
// eslint-disable-next-line deprecation/deprecation
addRequestDataToEvent,
amqplibIntegration,
anrIntegration,
Expand Down Expand Up @@ -39,6 +40,7 @@ export {
endSession,
expressErrorHandler,
expressIntegration,
// eslint-disable-next-line deprecation/deprecation
extractRequestData,
extraErrorDataIntegration,
fastifyIntegration,
Expand Down
2 changes: 2 additions & 0 deletions packages/aws-serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ export {
flush,
close,
getSentryRelease,
// eslint-disable-next-line deprecation/deprecation
addRequestDataToEvent,
DEFAULT_USER_INCLUDES,
// eslint-disable-next-line deprecation/deprecation
extractRequestData,
createGetModuleFromFilename,
anrIntegration,
Expand Down
2 changes: 2 additions & 0 deletions packages/bun/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ export {
flush,
close,
getSentryRelease,
// eslint-disable-next-line deprecation/deprecation
addRequestDataToEvent,
DEFAULT_USER_INCLUDES,
// eslint-disable-next-line deprecation/deprecation
extractRequestData,
createGetModuleFromFilename,
anrIntegration,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/integrations/requestdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const _requestDataIntegration = ((options: RequestDataIntegrationOptions = {}) =
return event;
}

// eslint-disable-next-line deprecation/deprecation
return addRequestDataToEvent(event, request, addRequestDataOptions);
},
};
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/utils-hoist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ export type { PromiseBuffer } from './promisebuffer';
export {
DEFAULT_USER_INCLUDES,
addNormalizedRequestDataToEvent,
// eslint-disable-next-line deprecation/deprecation
addRequestDataToEvent,
// eslint-disable-next-line deprecation/deprecation
extractPathForTransaction,
// eslint-disable-next-line deprecation/deprecation
extractRequestData,
winterCGHeadersToDict,
winterCGRequestToRequestData,
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/utils-hoist/requestdata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ function extractUserData(
* DEFAULT_REQUEST_INCLUDES if not provided.
* @param options.deps Injected, platform-specific dependencies
* @returns An object containing normalized request data
*
* @deprecated Instead manually normalize the request data into a format that fits `addNormalizedRequestDataToEvent`.
*/
export function extractRequestData(
req: PolymorphicRequest,
Expand Down Expand Up @@ -318,6 +320,8 @@ export function addNormalizedRequestDataToEvent(
* @param options.include Flags to control what data is included
* @param options.deps Injected platform-specific dependencies
* @returns The mutated `Event` object
*
* @deprecated Use `addNormalizedRequestDataToEvent` instead.
*/
export function addRequestDataToEvent(
event: Event,
Expand All @@ -335,6 +339,7 @@ export function addRequestDataToEvent(
includeRequest.push('ip');
}

// eslint-disable-next-line deprecation/deprecation
const extractedRequestData = extractRequestData(req, { include: includeRequest });

event.request = {
Expand Down
1 change: 1 addition & 0 deletions packages/core/test/utils-hoist/requestdata.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable deprecation/deprecation */
import type * as net from 'net';
import { addRequestDataToEvent, extractPathForTransaction, extractRequestData } from '@sentry/core';
import type { Event, PolymorphicRequest, TransactionSource, User } from '@sentry/types';
Expand Down
2 changes: 2 additions & 0 deletions packages/google-cloud-serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ export {
flush,
close,
getSentryRelease,
// eslint-disable-next-line deprecation/deprecation
addRequestDataToEvent,
DEFAULT_USER_INCLUDES,
// eslint-disable-next-line deprecation/deprecation
extractRequestData,
createGetModuleFromFilename,
anrIntegration,
Expand Down
1 change: 1 addition & 0 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export { cron } from './cron';

export type { NodeOptions } from './types';

// eslint-disable-next-line deprecation/deprecation
export { addRequestDataToEvent, DEFAULT_USER_INCLUDES, extractRequestData } from '@sentry/core';

export {
Expand Down
2 changes: 2 additions & 0 deletions packages/remix/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export {
addEventProcessor,
addIntegration,
addOpenTelemetryInstrumentation,
// eslint-disable-next-line deprecation/deprecation
addRequestDataToEvent,
amqplibIntegration,
anrIntegration,
Expand All @@ -43,6 +44,7 @@ export {
endSession,
expressErrorHandler,
expressIntegration,
// eslint-disable-next-line deprecation/deprecation
extractRequestData,
extraErrorDataIntegration,
fastifyIntegration,
Expand Down
2 changes: 2 additions & 0 deletions packages/solidstart/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {
addEventProcessor,
addIntegration,
addOpenTelemetryInstrumentation,
// eslint-disable-next-line deprecation/deprecation
addRequestDataToEvent,
amqplibIntegration,
anrIntegration,
Expand All @@ -34,6 +35,7 @@ export {
endSession,
expressErrorHandler,
expressIntegration,
// eslint-disable-next-line deprecation/deprecation
extractRequestData,
extraErrorDataIntegration,
fastifyIntegration,
Expand Down
2 changes: 2 additions & 0 deletions packages/sveltekit/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {
addEventProcessor,
addIntegration,
addOpenTelemetryInstrumentation,
// eslint-disable-next-line deprecation/deprecation
addRequestDataToEvent,
amqplibIntegration,
anrIntegration,
Expand All @@ -34,6 +35,7 @@ export {
endSession,
expressErrorHandler,
expressIntegration,
// eslint-disable-next-line deprecation/deprecation
extractRequestData,
extraErrorDataIntegration,
fastifyIntegration,
Expand Down
2 changes: 2 additions & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,11 @@ export const extractPathForTransaction = extractPathForTransaction_imported;
export const DEFAULT_USER_INCLUDES = DEFAULT_USER_INCLUDES_imported;

/** @deprecated Import from `@sentry/core` instead. */
// eslint-disable-next-line deprecation/deprecation
export const extractRequestData = extractRequestData_imported;

/** @deprecated Import from `@sentry/core` instead. */
// eslint-disable-next-line deprecation/deprecation
export const addRequestDataToEvent = addRequestDataToEvent_imported;

/** @deprecated Import from `@sentry/core` instead. */
Expand Down

0 comments on commit d49f1cb

Please sign in to comment.