Skip to content

Commit

Permalink
feat(v8): Remove Severity enum (#10551)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Feb 7, 2024
1 parent f34503f commit be0cc01
Show file tree
Hide file tree
Showing 26 changed files with 37 additions and 142 deletions.
8 changes: 8 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Upgrading from 7.x to 8.x

## Removal of Severity Enum

In v7 we deprecated the `Severity` enum in favor of using the `SeverityLevel` type. In v8 we removed the `Severity`
enum. If you were using the `Severity` enum, you should replace it with the `SeverityLevel` type. See
[below](#severity-severitylevel-and-severitylevels) for code snippet examples

# Deprecations in 7.x

You can use the **Experimental** [@sentry/migr8](https://www.npmjs.com/package/@sentry/migr8) to automatically update
Expand Down
4 changes: 1 addition & 3 deletions packages/browser/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
EventHint,
Options,
ParameterizedString,
Severity,
SeverityLevel,
UserFeedback,
} from '@sentry/types';
Expand Down Expand Up @@ -76,8 +75,7 @@ export class BrowserClient extends BaseClient<BrowserClientOptions> {
*/
public eventFromMessage(
message: ParameterizedString,
// eslint-disable-next-line deprecation/deprecation
level: Severity | SeverityLevel = 'info',
level: SeverityLevel = 'info',
hint?: EventHint,
): PromiseLike<Event> {
return eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace);
Expand Down
4 changes: 1 addition & 3 deletions packages/browser/src/eventbuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type {
EventHint,
Exception,
ParameterizedString,
Severity,
SeverityLevel,
StackFrame,
StackParser,
Expand Down Expand Up @@ -178,8 +177,7 @@ export function eventFromException(
export function eventFromMessage(
stackParser: StackParser,
message: ParameterizedString,
// eslint-disable-next-line deprecation/deprecation
level: Severity | SeverityLevel = 'info',
level: SeverityLevel = 'info',
hint?: EventHint,
attachStacktrace?: boolean,
): PromiseLike<Event> {
Expand Down
2 changes: 0 additions & 2 deletions packages/browser/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export type {
Event,
EventHint,
Exception,
// eslint-disable-next-line deprecation/deprecation
Severity,
SeverityLevel,
StackFrame,
Stacktrace,
Expand Down
2 changes: 0 additions & 2 deletions packages/bun/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export type {
EventHint,
Exception,
Session,
// eslint-disable-next-line deprecation/deprecation
Severity,
SeverityLevel,
Span,
StackFrame,
Expand Down
7 changes: 2 additions & 5 deletions packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import type {
SdkMetadata,
Session,
SessionAggregates,
Severity,
SeverityLevel,
StartSpanOptions,
Transaction,
Expand Down Expand Up @@ -186,8 +185,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
*/
public captureMessage(
message: ParameterizedString,
// eslint-disable-next-line deprecation/deprecation
level?: Severity | SeverityLevel,
level?: SeverityLevel,
hint?: EventHint,
scope?: Scope,
): string | undefined {
Expand Down Expand Up @@ -876,8 +874,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
*/
public abstract eventFromMessage(
_message: ParameterizedString,
// eslint-disable-next-line deprecation/deprecation
_level?: Severity | SeverityLevel,
_level?: SeverityLevel,
_hint?: EventHint,
): PromiseLike<Event>;
}
Expand Down
7 changes: 1 addition & 6 deletions packages/core/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import type {
Scope as ScopeInterface,
Session,
SessionContext,
Severity,
SeverityLevel,
Span,
TransactionContext,
Expand Down Expand Up @@ -56,11 +55,7 @@ export function captureException(
* @param captureContext Define the level of the message or pass in additional data to attach to the message.
* @returns the id of the captured message.
*/
export function captureMessage(
message: string,
// eslint-disable-next-line deprecation/deprecation
captureContext?: CaptureContext | Severity | SeverityLevel,
): string {
export function captureMessage(message: string, captureContext?: CaptureContext | SeverityLevel): string {
// This is necessary to provide explicit scopes upgrade, without changing the original
// arity of the `captureMessage(message, level)` method.
const level = typeof captureContext === 'string' ? captureContext : undefined;
Expand Down
8 changes: 1 addition & 7 deletions packages/core/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type {
Primitive,
Session,
SessionContext,
Severity,
SeverityLevel,
Transaction,
TransactionContext,
Expand Down Expand Up @@ -320,12 +319,7 @@ export class Hub implements HubInterface {
*
* @deprecated Use `Sentry.captureMessage()` instead.
*/
public captureMessage(
message: string,
// eslint-disable-next-line deprecation/deprecation
level?: Severity | SeverityLevel,
hint?: EventHint,
): string {
public captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string {
const eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4());
const syntheticException = new Error(message);
// eslint-disable-next-line deprecation/deprecation
Expand Down
9 changes: 2 additions & 7 deletions packages/core/src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import type {
ScopeContext,
ScopeData,
Session,
Severity,
SeverityLevel,
Span,
Transaction,
Expand Down Expand Up @@ -86,8 +85,7 @@ export class Scope implements ScopeInterface {
protected _fingerprint?: string[];

/** Severity */
// eslint-disable-next-line deprecation/deprecation
protected _level?: Severity | SeverityLevel;
protected _level?: SeverityLevel;

/**
* Transaction Name
Expand Down Expand Up @@ -283,10 +281,7 @@ export class Scope implements ScopeInterface {
/**
* @inheritDoc
*/
public setLevel(
// eslint-disable-next-line deprecation/deprecation
level: Severity | SeverityLevel,
): this {
public setLevel(level: SeverityLevel): this {
this._level = level;
this._notifyScopeListeners();
return this;
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/server-runtime-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
MonitorConfig,
ParameterizedString,
SerializedCheckIn,
Severity,
SeverityLevel,
TraceContext,
} from '@sentry/types';
Expand Down Expand Up @@ -70,8 +69,7 @@ export class ServerRuntimeClient<
*/
public eventFromMessage(
message: ParameterizedString,
// eslint-disable-next-line deprecation/deprecation
level: Severity | SeverityLevel = 'info',
level: SeverityLevel = 'info',
hint?: EventHint,
): PromiseLike<Event> {
return resolvedSyncPromise(
Expand Down
7 changes: 1 addition & 6 deletions packages/core/test/mocks/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type {
Outcome,
ParameterizedString,
Session,
Severity,
SeverityLevel,
} from '@sentry/types';
import { resolvedSyncPromise } from '@sentry/utils';
Expand Down Expand Up @@ -76,11 +75,7 @@ export class TestClient extends BaseClient<TestClientOptions> {
return resolvedSyncPromise(event);
}

public eventFromMessage(
message: ParameterizedString,
// eslint-disable-next-line deprecation/deprecation
level: Severity | SeverityLevel = 'info',
): PromiseLike<Event> {
public eventFromMessage(message: ParameterizedString, level: SeverityLevel = 'info'): PromiseLike<Event> {
return resolvedSyncPromise({ message, level });
}

Expand Down
2 changes: 0 additions & 2 deletions packages/deno/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export type {
EventHint,
Exception,
Session,
// eslint-disable-next-line deprecation/deprecation
Severity,
SeverityLevel,
Span,
StackFrame,
Expand Down
7 changes: 1 addition & 6 deletions packages/node-experimental/src/sdk/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type {
Extra,
Extras,
Primitive,
Severity,
SeverityLevel,
User,
} from '@sentry/types';
Expand Down Expand Up @@ -120,11 +119,7 @@ export function captureException(exception: unknown, hint?: ExclusiveEventHintOr
}

/** Record a message and send it to Sentry. */
export function captureMessage(
message: string,
// eslint-disable-next-line deprecation/deprecation
captureContext?: CaptureContext | Severity | SeverityLevel,
): string {
export function captureMessage(message: string, captureContext?: CaptureContext | SeverityLevel): string {
// This is necessary to provide explicit scopes upgrade, without changing the original
// arity of the `captureMessage(message, level)` method.
const level = typeof captureContext === 'string' ? captureContext : undefined;
Expand Down
8 changes: 1 addition & 7 deletions packages/node-experimental/src/sdk/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type {
Hub,
Integration,
IntegrationClass,
Severity,
SeverityLevel,
TransactionContext,
} from '@sentry/types';
Expand Down Expand Up @@ -68,12 +67,7 @@ export function getCurrentHub(): Hub {
captureException: (exception: unknown, hint?: EventHint) => {
return getCurrentScope().captureException(exception, hint);
},
captureMessage: (
message: string,
// eslint-disable-next-line deprecation/deprecation
level?: Severity | SeverityLevel,
hint?: EventHint,
) => {
captureMessage: (message: string, level?: SeverityLevel, hint?: EventHint) => {
return getCurrentScope().captureMessage(message, level, hint);
},
captureEvent,
Expand Down
9 changes: 2 additions & 7 deletions packages/node-experimental/src/sdk/scope.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getGlobalScope as _getGlobalScope, setGlobalScope } from '@sentry/core';
import { OpenTelemetryScope } from '@sentry/opentelemetry';
import type { Breadcrumb, Client, Event, EventHint, Severity, SeverityLevel } from '@sentry/types';
import type { Breadcrumb, Client, Event, EventHint, SeverityLevel } from '@sentry/types';
import { uuid4 } from '@sentry/utils';

import { getGlobalCarrier } from './globals';
Expand Down Expand Up @@ -140,12 +140,7 @@ export class Scope extends OpenTelemetryScope implements ScopeInterface {
}

/** Capture a message for this scope. */
public captureMessage(
message: string,
// eslint-disable-next-line deprecation/deprecation
level?: Severity | SeverityLevel,
hint?: EventHint,
): string {
public captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string {
const eventId = hint && hint.event_id ? hint.event_id : uuid4();
const syntheticException = new Error(message);

Expand Down
2 changes: 0 additions & 2 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export type {
EventHint,
Exception,
Session,
// eslint-disable-next-line deprecation/deprecation
Severity,
SeverityLevel,
Span,
StackFrame,
Expand Down
5 changes: 2 additions & 3 deletions packages/types/src/breadcrumb.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { Severity, SeverityLevel } from './severity';
import type { SeverityLevel } from './severity';

/** JSDoc */
export interface Breadcrumb {
type?: string;
// eslint-disable-next-line deprecation/deprecation
level?: Severity | SeverityLevel;
level?: SeverityLevel;
event_id?: string;
category?: string;
message?: string;
Expand Down
17 changes: 3 additions & 14 deletions packages/types/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { ParameterizedString } from './parameterize';
import type { Scope } from './scope';
import type { SdkMetadata } from './sdkmetadata';
import type { Session, SessionAggregates } from './session';
import type { Severity, SeverityLevel } from './severity';
import type { SeverityLevel } from './severity';
import type { StartSpanOptions } from './startSpanOptions';
import type { Transaction } from './transaction';
import type { Transport, TransportMakeRequestResponse } from './transport';
Expand Down Expand Up @@ -48,13 +48,7 @@ export interface Client<O extends ClientOptions = ClientOptions> {
* @param scope An optional scope containing event metadata.
* @returns The event id
*/
captureMessage(
message: string,
// eslint-disable-next-line deprecation/deprecation
level?: Severity | SeverityLevel,
hint?: EventHint,
scope?: Scope,
): string | undefined;
captureMessage(message: string, level?: SeverityLevel, hint?: EventHint, scope?: Scope): string | undefined;

/**
* Captures a manually created event and sends it to Sentry.
Expand Down Expand Up @@ -175,12 +169,7 @@ export interface Client<O extends ClientOptions = ClientOptions> {
eventFromException(exception: any, hint?: EventHint): PromiseLike<Event>;

/** Creates an {@link Event} from primitive inputs to `captureMessage`. */
eventFromMessage(
message: ParameterizedString,
// eslint-disable-next-line deprecation/deprecation
level?: Severity | SeverityLevel,
hint?: EventHint,
): PromiseLike<Event>;
eventFromMessage(message: ParameterizedString, level?: SeverityLevel, hint?: EventHint): PromiseLike<Event>;

/** Submits the event to Sentry */
sendEvent(event: Event, hint?: EventHint): void;
Expand Down
5 changes: 2 additions & 3 deletions packages/types/src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { Primitive } from './misc';
import type { Request } from './request';
import type { CaptureContext } from './scope';
import type { SdkInfo } from './sdkinfo';
import type { Severity, SeverityLevel } from './severity';
import type { SeverityLevel } from './severity';
import type { Span, SpanJSON } from './span';
import type { Thread } from './thread';
import type { TransactionSource } from './transaction';
Expand All @@ -26,8 +26,7 @@ export interface Event {
};
timestamp?: number;
start_timestamp?: number;
// eslint-disable-next-line deprecation/deprecation
level?: Severity | SeverityLevel;
level?: SeverityLevel;
platform?: string;
logger?: string;
server_name?: string;
Expand Down
9 changes: 2 additions & 7 deletions packages/types/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { Integration, IntegrationClass } from './integration';
import type { Primitive } from './misc';
import type { Scope } from './scope';
import type { Session } from './session';
import type { Severity, SeverityLevel } from './severity';
import type { SeverityLevel } from './severity';
import type { CustomSamplingContext, Transaction, TransactionContext } from './transaction';
import type { User } from './user';

Expand Down Expand Up @@ -116,12 +116,7 @@ export interface Hub {
*
* @deprecated Use `Sentry.captureMessage()` instead.
*/
captureMessage(
message: string,
// eslint-disable-next-line deprecation/deprecation
level?: Severity | SeverityLevel,
hint?: EventHint,
): string;
captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string;

/**
* Captures a manually created event and sends it to Sentry.
Expand Down
3 changes: 1 addition & 2 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ export type {
SerializedSession,
} from './session';

// eslint-disable-next-line deprecation/deprecation
export type { Severity, SeverityLevel } from './severity';
export type { SeverityLevel } from './severity';
export type {
Span,
SpanContext,
Expand Down
Loading

0 comments on commit be0cc01

Please sign in to comment.