Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/browser/src/backend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseBackend } from '@sentry/core';
import { Event, EventHint, Options, SeverityLevel, Transport } from '@sentry/types';
import { Event, EventHint, Options, Severity, Transport } from '@sentry/types';
import { supportsFetch } from '@sentry/utils';

import { eventFromException, eventFromMessage } from './eventbuilder';
Expand Down Expand Up @@ -45,7 +45,7 @@ export class BrowserBackend extends BaseBackend<BrowserOptions> {
/**
* @inheritDoc
*/
public eventFromMessage(message: string, level: SeverityLevel = 'info', hint?: EventHint): PromiseLike<Event> {
public eventFromMessage(message: string, level: Severity = Severity.Info, hint?: EventHint): PromiseLike<Event> {
return eventFromMessage(this._options, message, level, hint);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/browser/src/eventbuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Event, EventHint, Options, SeverityLevel } from '@sentry/types';
import { Event, EventHint, Options, Severity } from '@sentry/types';
import {
addExceptionMechanism,
addExceptionTypeValue,
Expand All @@ -24,7 +24,7 @@ export function eventFromException(options: Options, exception: unknown, hint?:
attachStacktrace: options.attachStacktrace,
});
addExceptionMechanism(event); // defaults to { type: 'generic', handled: true }
event.level = 'error';
event.level = Severity.Error;
if (hint && hint.event_id) {
event.event_id = hint.event_id;
}
Expand All @@ -38,7 +38,7 @@ export function eventFromException(options: Options, exception: unknown, hint?:
export function eventFromMessage(
options: Options,
message: string,
level: SeverityLevel = 'info',
level: Severity = Severity.Info,
hint?: EventHint,
): PromiseLike<Event> {
const syntheticException = (hint && hint.syntheticException) || undefined;
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {
EventStatus,
Exception,
Response,
Severity,
SeverityLevel,
StackFrame,
Stacktrace,
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/integrations/breadcrumbs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable max-lines */
import { getCurrentHub } from '@sentry/core';
import { Event, Integration } from '@sentry/types';
import { Event, Integration, Severity } from '@sentry/types';
import {
addInstrumentationHandler,
getEventDescription,
Expand Down Expand Up @@ -230,7 +230,7 @@ function _fetchBreadcrumb(handlerData: { [key: string]: any }): void {
{
category: 'fetch',
data: handlerData.fetchData,
level: 'error',
level: Severity.Error,
type: 'http',
},
{
Expand Down
4 changes: 2 additions & 2 deletions packages/browser/src/integrations/globalhandlers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { getCurrentHub } from '@sentry/core';
import { Event, EventHint, Hub, Integration, Primitive } from '@sentry/types';
import { Event, EventHint, Hub, Integration, Primitive, Severity } from '@sentry/types';
import {
addExceptionMechanism,
addInstrumentationHandler,
Expand Down Expand Up @@ -148,7 +148,7 @@ function _installGlobalOnUnhandledRejectionHandler(): void {
isRejection: true,
});

event.level = 'error';
event.level = Severity.Error;

addMechanismAndCapture(hub, error, event, 'onunhandledrejection');
return;
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/basebackend.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Event, EventHint, Options, Session, SeverityLevel, Transport } from '@sentry/types';
import { Event, EventHint, Options, Session, Severity, Transport } from '@sentry/types';
import { isDebugBuild, logger, SentryError } from '@sentry/utils';

import { NoopTransport } from './transports/noop';
Expand Down Expand Up @@ -29,7 +29,7 @@ export interface Backend {
eventFromException(exception: any, hint?: EventHint): PromiseLike<Event>;

/** Creates an {@link Event} from primitive inputs to `captureMessage`. */
eventFromMessage(message: string, level?: SeverityLevel, hint?: EventHint): PromiseLike<Event>;
eventFromMessage(message: string, level?: Severity, hint?: EventHint): PromiseLike<Event>;

/** Submits the event to Sentry */
sendEvent(event: Event): void;
Expand Down Expand Up @@ -83,7 +83,7 @@ export abstract class BaseBackend<O extends Options> implements Backend {
/**
* @inheritDoc
*/
public eventFromMessage(_message: string, _level?: SeverityLevel, _hint?: EventHint): PromiseLike<Event> {
public eventFromMessage(_message: string, _level?: Severity, _hint?: EventHint): PromiseLike<Event> {
throw new SentryError('Backend has to implement `eventFromMessage` method');
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Integration,
IntegrationClass,
Options,
SeverityLevel,
Severity,
Transport,
} from '@sentry/types';
import {
Expand Down Expand Up @@ -129,7 +129,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement
/**
* @inheritDoc
*/
public captureMessage(message: string, level?: SeverityLevel, hint?: EventHint, scope?: Scope): string | undefined {
public captureMessage(message: string, level?: Severity, hint?: EventHint, scope?: Scope): string | undefined {
let eventId: string | undefined = hint && hint.event_id;

const promisedEvent = isPrimitive(message)
Expand Down
4 changes: 2 additions & 2 deletions packages/core/test/mocks/backend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Session } from '@sentry/hub';
import { Event, Options, SeverityLevel, Transport } from '@sentry/types';
import { Event, Options, Severity, Transport } from '@sentry/types';
import { resolvedSyncPromise } from '@sentry/utils';

import { BaseBackend } from '../../src/basebackend';
Expand Down Expand Up @@ -38,7 +38,7 @@ export class TestBackend extends BaseBackend<TestOptions> {
});
}

public eventFromMessage(message: string, level: SeverityLevel = 'info'): PromiseLike<Event> {
public eventFromMessage(message: string, level: Severity = Severity.Info): PromiseLike<Event> {
return resolvedSyncPromise({ message, level });
}

Expand Down
4 changes: 2 additions & 2 deletions packages/hub/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
IntegrationClass,
Primitive,
SessionContext,
SeverityLevel,
Severity,
Span,
SpanContext,
Transaction,
Expand Down Expand Up @@ -215,7 +215,7 @@ export class Hub implements HubInterface {
/**
* @inheritDoc
*/
public captureMessage(message: string, level?: SeverityLevel, hint?: EventHint): string {
public captureMessage(message: string, level?: Severity, hint?: EventHint): string {
const eventId = (this._lastEventId = uuid4());
let finalHint = hint;

Expand Down
6 changes: 3 additions & 3 deletions packages/hub/src/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
RequestSession,
Scope as ScopeInterface,
ScopeContext,
SeverityLevel,
Severity,
Span,
Transaction,
User,
Expand Down Expand Up @@ -61,7 +61,7 @@ export class Scope implements ScopeInterface {
protected _fingerprint?: string[];

/** Severity */
protected _level?: SeverityLevel;
protected _level?: Severity;

/** Transaction Name */
protected _transactionName?: string;
Expand Down Expand Up @@ -208,7 +208,7 @@ export class Scope implements ScopeInterface {
/**
* @inheritDoc
*/
public setLevel(level: SeverityLevel): this {
public setLevel(level: Severity): this {
this._level = level;
this._notifyScopeListeners();
return this;
Expand Down
22 changes: 11 additions & 11 deletions packages/hub/test/scope.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Event, EventHint } from '@sentry/types';
import { Event, EventHint, Severity } from '@sentry/types';
import { getGlobalObject } from '@sentry/utils';

import { addGlobalEventProcessor, Scope } from '../src';
Expand Down Expand Up @@ -85,8 +85,8 @@ describe('Scope', () => {

test('setLevel', () => {
const scope = new Scope();
scope.setLevel('critical');
expect((scope as any)._level).toEqual('critical');
scope.setLevel(Severity.Critical);
expect((scope as any)._level).toEqual(Severity.Critical);
});

test('setTransactionName', () => {
Expand Down Expand Up @@ -137,8 +137,8 @@ describe('Scope', () => {

test('chaining', () => {
const scope = new Scope();
scope.setLevel('critical').setUser({ id: '1' });
expect((scope as any)._level).toEqual('critical');
scope.setLevel(Severity.Critical).setUser({ id: '1' });
expect((scope as any)._level).toEqual(Severity.Critical);
expect((scope as any)._user).toEqual({ id: '1' });
});
});
Expand Down Expand Up @@ -202,7 +202,7 @@ describe('Scope', () => {
scope.setTag('a', 'b');
scope.setUser({ id: '1' });
scope.setFingerprint(['abcd']);
scope.setLevel('warning');
scope.setLevel(Severity.Warning);
scope.setTransactionName('/abc');
scope.addBreadcrumb({ message: 'test' });
scope.setContext('os', { id: '1' });
Expand Down Expand Up @@ -294,11 +294,11 @@ describe('Scope', () => {
test('scope level should have priority over event level', () => {
expect.assertions(1);
const scope = new Scope();
scope.setLevel('warning');
scope.setLevel(Severity.Warning);
const event: Event = {};
event.level = 'critical';
event.level = Severity.Critical;
return scope.applyToEvent(event).then(processedEvent => {
expect(processedEvent!.level).toEqual('warning');
expect(processedEvent!.level).toEqual(Severity.Warning);
});
});

Expand Down Expand Up @@ -410,7 +410,7 @@ describe('Scope', () => {
scope.setContext('foo', { id: '1' });
scope.setContext('bar', { id: '2' });
scope.setUser({ id: '1337' });
scope.setLevel('info');
scope.setLevel(Severity.Info);
scope.setFingerprint(['foo']);
scope.setRequestSession({ status: 'ok' });
});
Expand Down Expand Up @@ -458,7 +458,7 @@ describe('Scope', () => {
localScope.setContext('bar', { id: '3' });
localScope.setContext('baz', { id: '4' });
localScope.setUser({ id: '42' });
localScope.setLevel('warning');
localScope.setLevel(Severity.Warning);
localScope.setFingerprint(['bar']);
(localScope as any)._requestSession = { status: 'ok' };

Expand Down
6 changes: 3 additions & 3 deletions packages/minimal/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Extra,
Extras,
Primitive,
SeverityLevel,
Severity,
Transaction,
TransactionContext,
User,
Expand Down Expand Up @@ -53,10 +53,10 @@ export function captureException(exception: any, captureContext?: CaptureContext
* Captures a message event and sends it to Sentry.
*
* @param message The message to send to Sentry.
* @param SeverityLevel Define the level of the message.
* @param Severity Define the level of the message.
* @returns The generated eventId.
*/
export function captureMessage(message: string, captureContext?: CaptureContext | SeverityLevel): string {
export function captureMessage(message: string, captureContext?: CaptureContext | Severity): string {
let syntheticException: Error;
try {
throw new Error(message);
Expand Down
13 changes: 7 additions & 6 deletions packages/minimal/test/lib/minimal.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getCurrentHub, getHubFromCarrier, Scope } from '@sentry/hub';
import { Severity } from '@sentry/types';

import {
_callOnClient,
Expand Down Expand Up @@ -164,8 +165,8 @@ describe('Minimal', () => {
const client: any = new TestClient({});
const scope = getCurrentHub().pushScope();
getCurrentHub().bindClient(client);
scope.setLevel('warning');
expect(global.__SENTRY__.hub._stack[1].scope._level).toEqual('warning');
scope.setLevel(Severity.Warning);
expect(global.__SENTRY__.hub._stack[1].scope._level).toEqual(Severity.Warning);
});
});

Expand Down Expand Up @@ -244,16 +245,16 @@ describe('Minimal', () => {

test('withScope', () => {
withScope(scope => {
scope.setLevel('warning');
scope.setLevel(Severity.Warning);
scope.setFingerprint(['1']);
withScope(scope2 => {
scope2.setLevel('info');
scope2.setLevel(Severity.Info);
scope2.setFingerprint(['2']);
withScope(scope3 => {
scope3.clear();
expect(global.__SENTRY__.hub._stack[1].scope._level).toEqual('warning');
expect(global.__SENTRY__.hub._stack[1].scope._level).toEqual(Severity.Warning);
expect(global.__SENTRY__.hub._stack[1].scope._fingerprint).toEqual(['1']);
expect(global.__SENTRY__.hub._stack[2].scope._level).toEqual('info');
expect(global.__SENTRY__.hub._stack[2].scope._level).toEqual(Severity.Info);
expect(global.__SENTRY__.hub._stack[2].scope._fingerprint).toEqual(['2']);
expect(global.__SENTRY__.hub._stack[3].scope._level).toBeUndefined();
});
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/backend.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BaseBackend } from '@sentry/core';
import { Event, EventHint, SeverityLevel, Transport, TransportOptions } from '@sentry/types';
import { Event, EventHint, Severity, Transport, TransportOptions } from '@sentry/types';
import { makeDsn } from '@sentry/utils';

import { eventFromException, eventFromMessage } from './eventbuilder';
Expand All @@ -22,7 +22,7 @@ export class NodeBackend extends BaseBackend<NodeOptions> {
/**
* @inheritDoc
*/
public eventFromMessage(message: string, level: SeverityLevel = 'info', hint?: EventHint): PromiseLike<Event> {
public eventFromMessage(message: string, level: Severity = Severity.Info, hint?: EventHint): PromiseLike<Event> {
return eventFromMessage(this._options, message, level, hint);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/eventbuilder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getCurrentHub } from '@sentry/hub';
import { Event, EventHint, Mechanism, Options, SeverityLevel } from '@sentry/types';
import { Event, EventHint, Mechanism, Options, Severity } from '@sentry/types';
import {
addExceptionMechanism,
addExceptionTypeValue,
Expand Down Expand Up @@ -69,7 +69,7 @@ export function eventFromException(options: Options, exception: unknown, hint?:
export function eventFromMessage(
options: Options,
message: string,
level: SeverityLevel = 'info',
level: Severity = Severity.Info,
hint?: EventHint,
): PromiseLike<Event> {
const event: Event = {
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 @@ -8,6 +8,7 @@ export {
EventStatus,
Exception,
Response,
Severity,
SeverityLevel,
StackFrame,
Stacktrace,
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/integrations/onuncaughtexception.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getCurrentHub, Scope } from '@sentry/core';
import { Integration } from '@sentry/types';
import { Integration, Severity } from '@sentry/types';
import { logger } from '@sentry/utils';

import { NodeClient } from '../client';
Expand Down Expand Up @@ -77,7 +77,7 @@ export class OnUncaughtException implements Integration {

if (hub.getIntegration(OnUncaughtException)) {
hub.withScope((scope: Scope) => {
scope.setLevel('fatal');
scope.setLevel(Severity.Fatal);
hub.captureException(error, {
originalException: error,
data: { mechanism: { handled: false, type: 'onuncaughtexception' } },
Expand Down
2 changes: 1 addition & 1 deletion packages/serverless/src/awslambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export function wrapHandler<TEvent, TResult>(
timeoutWarningTimer = setTimeout(() => {
withScope(scope => {
scope.setTag('timeout', humanReadableTimeout);
captureMessage(`Possible function timeout: ${context.functionName}`, 'warning');
captureMessage(`Possible function timeout: ${context.functionName}`, Sentry.Severity.Warning);
});
}, timeoutWarningDelay);
}
Expand Down
1 change: 1 addition & 0 deletions packages/tracing/src/index.bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export {
EventStatus,
Exception,
Response,
Severity,
SeverityLevel,
StackFrame,
Stacktrace,
Expand Down
Loading