Skip to content

Commit 9e862ab

Browse files
committed
ref: Move public interfaces to @sentry/types package (#1889)
* fix: Events created from exception shouldnt have top-level message attribute (#1831) * Use SyncPromise internally & Remove deprecated API & Trim Public API (#1858) * ref: Move PromiseBuffer and Error to utils package * ref: Remove all async api * ref: Remove invokeClientAsync function * feat: Finish Node SDK * feat: SyncPromise implementation * fix: Browser SDK * fix: beforeSend callback * fix: Core tests * fix: linting and tests * fix: browser npm package + add error for manual tests * meta: Remove deprecations * fix: Typedocs and public exposed functions * meta: Changelog * Apply suggestions from code review * ref: Move public interfaces to types package * fix: Tests * fix: Small type issues * ref: Remove scope listeners * fix: Add flush to interface * ref: Remove interfaces from core
1 parent 2dab59e commit 9e862ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1038
-1180
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ since we removed some methods from the public API and removed some classes from
1010

1111
- **breaking** [node] fix: Events created from exception shouldn't have top-level message attribute
1212
- [utils] ref: Update wrap method to hide internal sentry flags
13-
- [utils] fix: Make internal Sentry flags non-enumerable in fill util
13+
- [utils] fix: Make internal Sentry flags non-enumerable in fill utils
1414
- [utils] ref: Move `SentryError` + `PromiseBuffer` to utils
1515
- **breaking** [core] ref: Use `SyncPromise` internally, this reduces memory pressure by a lot.
1616
- **breaking** [browser] ref: Removed `BrowserBackend` from default export.

packages/browser/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default [
6666
interop: false,
6767
sourcemap: true,
6868
},
69-
external: ['@sentry/core', '@sentry/hub', '@sentry/minimal'],
69+
external: ['@sentry/core', '@sentry/hub', '@sentry/minimal', 'tslib'],
7070
plugins: [
7171
typescript({
7272
tsconfig: 'tsconfig.build.json',

packages/browser/src/backend.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { BaseBackend, Options } from '@sentry/core';
2-
import { SentryEvent, SentryEventHint, Severity, Transport } from '@sentry/types';
1+
import { BaseBackend } from '@sentry/core';
2+
import { Event, EventHint, Options, Severity, Transport } from '@sentry/types';
33
import { isDOMError, isDOMException, isError, isErrorEvent, isPlainObject } from '@sentry/utils/is';
44
import { supportsBeacon, supportsFetch } from '@sentry/utils/supports';
55
import { SyncPromise } from '@sentry/utils/syncpromise';
@@ -56,8 +56,8 @@ export class BrowserBackend extends BaseBackend<BrowserOptions> {
5656
/**
5757
* @inheritDoc
5858
*/
59-
public eventFromException(exception: any, hint?: SentryEventHint): SyncPromise<SentryEvent> {
60-
let event: SentryEvent;
59+
public eventFromException(exception: any, hint?: EventHint): SyncPromise<Event> {
60+
let event: Event;
6161

6262
if (isErrorEvent(exception as ErrorEvent) && (exception as ErrorEvent).error) {
6363
// If it is an ErrorEvent with `error` property, extract it to get actual Error
@@ -108,7 +108,7 @@ export class BrowserBackend extends BaseBackend<BrowserOptions> {
108108
/**
109109
* This is an internal helper function that creates an event.
110110
*/
111-
private buildEvent(event: SentryEvent, hint?: SentryEventHint): SentryEvent {
111+
private buildEvent(event: Event, hint?: EventHint): Event {
112112
return {
113113
...event,
114114
event_id: hint && hint.event_id,
@@ -125,12 +125,8 @@ export class BrowserBackend extends BaseBackend<BrowserOptions> {
125125
/**
126126
* @inheritDoc
127127
*/
128-
public eventFromMessage(
129-
message: string,
130-
level: Severity = Severity.Info,
131-
hint?: SentryEventHint,
132-
): SyncPromise<SentryEvent> {
133-
const event: SentryEvent = {
128+
public eventFromMessage(message: string, level: Severity = Severity.Info, hint?: EventHint): SyncPromise<Event> {
129+
const event: Event = {
134130
event_id: hint && hint.event_id,
135131
level,
136132
message,

packages/browser/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { API, BaseClient, Scope } from '@sentry/core';
2-
import { DsnLike, SentryEvent, SentryEventHint } from '@sentry/types';
2+
import { DsnLike, Event, EventHint } from '@sentry/types';
33
import { logger } from '@sentry/utils/logger';
44
import { getGlobalObject } from '@sentry/utils/misc';
55
import { SyncPromise } from '@sentry/utils/syncpromise';
@@ -50,7 +50,7 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
5050
/**
5151
* @inheritDoc
5252
*/
53-
protected prepareEvent(event: SentryEvent, scope?: Scope, hint?: SentryEventHint): SyncPromise<SentryEvent | null> {
53+
protected prepareEvent(event: Event, scope?: Scope, hint?: EventHint): SyncPromise<Event | null> {
5454
event.platform = event.platform || 'javascript';
5555
event.sdk = {
5656
...event.sdk,

packages/browser/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ export {
22
Breadcrumb,
33
Request,
44
SdkInfo,
5-
SentryEvent,
6-
SentryException,
7-
SentryResponse,
5+
Event,
6+
Exception,
7+
Response,
88
Severity,
99
StackFrame,
1010
Stacktrace,

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { API, getCurrentHub } from '@sentry/core';
2-
import { Breadcrumb, Integration, SentryBreadcrumbHint, Severity } from '@sentry/types';
2+
import { Breadcrumb, BreadcrumbHint, Integration, Severity } from '@sentry/types';
33
import { isFunction, isString } from '@sentry/utils/is';
44
import { logger } from '@sentry/utils/logger';
55
import { getEventDescription, getGlobalObject, parseUrl } from '@sentry/utils/misc';
@@ -454,9 +454,9 @@ export class Breadcrumbs implements Integration {
454454
/**
455455
* Helper that checks if integration is enabled on the client.
456456
* @param breadcrumb Breadcrumb
457-
* @param hint SentryBreadcrumbHint
457+
* @param hint BreadcrumbHint
458458
*/
459-
public static addBreadcrumb(breadcrumb: Breadcrumb, hint?: SentryBreadcrumbHint): void {
459+
public static addBreadcrumb(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): void {
460460
if (getCurrentHub().getIntegration(Breadcrumbs)) {
461461
getCurrentHub().addBreadcrumb(breadcrumb, hint);
462462
}

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getCurrentHub } from '@sentry/core';
2-
import { Integration, SentryEvent } from '@sentry/types';
2+
import { Event, Integration } from '@sentry/types';
33
import { logger } from '@sentry/utils/logger';
44
import { safeNormalize, serialize } from '@sentry/utils/object';
55
import { truncate } from '@sentry/utils/string';
@@ -83,11 +83,11 @@ export class GlobalHandlers implements Integration {
8383
}
8484

8585
/**
86-
* This function creates an SentryEvent from an TraceKitStackTrace.
86+
* This function creates an Event from an TraceKitStackTrace.
8787
*
88-
* @param stacktrace TraceKitStackTrace to be converted to an SentryEvent.
88+
* @param stacktrace TraceKitStackTrace to be converted to an Event.
8989
*/
90-
private eventFromGlobalHandler(stacktrace: TraceKitStackTrace): SentryEvent {
90+
private eventFromGlobalHandler(stacktrace: TraceKitStackTrace): Event {
9191
const event = eventFromStacktrace(stacktrace);
9292

9393
const data: { [key: string]: string } = {
@@ -102,7 +102,7 @@ export class GlobalHandlers implements Integration {
102102
data.name = stacktrace.name;
103103
}
104104

105-
const newEvent: SentryEvent = {
105+
const newEvent: Event = {
106106
...event,
107107
exception: {
108108
...event.exception,

packages/browser/src/integrations/helpers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { captureException, getCurrentHub, withScope } from '@sentry/core';
2-
import { Mechanism, SentryEvent, SentryWrappedFunction } from '@sentry/types';
2+
import { Event as SentryEvent, Mechanism, WrappedFunction } from '@sentry/types';
33
import { isFunction } from '@sentry/utils/is';
44
import { htmlTreeAsString } from '@sentry/utils/misc';
55
import { safeNormalize } from '@sentry/utils/object';
@@ -36,11 +36,11 @@ export function ignoreNextOnError(): void {
3636
* @hidden
3737
*/
3838
export function wrap(
39-
fn: SentryWrappedFunction,
39+
fn: WrappedFunction,
4040
options: {
4141
mechanism?: Mechanism;
4242
} = {},
43-
before?: SentryWrappedFunction,
43+
before?: WrappedFunction,
4444
): any {
4545
if (!isFunction(fn)) {
4646
return fn;
@@ -63,7 +63,7 @@ export function wrap(
6363
return fn;
6464
}
6565

66-
const sentryWrapped: SentryWrappedFunction = function(this: any): void {
66+
const sentryWrapped: WrappedFunction = function(this: any): void {
6767
if (before && isFunction(before)) {
6868
before.apply(this, arguments);
6969
}

packages/browser/src/integrations/linkederrors.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
2-
import { Integration, SentryEvent, SentryEventHint, SentryException } from '@sentry/types';
2+
import { Event, EventHint, Exception, Integration } from '@sentry/types';
33
import { exceptionFromStacktrace } from '../parsers';
44
import { computeStackTrace } from '../tracekit';
55

@@ -47,7 +47,7 @@ export class LinkedErrors implements Integration {
4747
* @inheritDoc
4848
*/
4949
public setupOnce(): void {
50-
addGlobalEventProcessor((event: SentryEvent, hint?: SentryEventHint) => {
50+
addGlobalEventProcessor((event: Event, hint?: EventHint) => {
5151
const self = getCurrentHub().getIntegration(LinkedErrors);
5252
if (self) {
5353
return self.handler(event, hint);
@@ -59,7 +59,7 @@ export class LinkedErrors implements Integration {
5959
/**
6060
* @inheritDoc
6161
*/
62-
public handler(event: SentryEvent, hint?: SentryEventHint): SentryEvent | null {
62+
public handler(event: Event, hint?: EventHint): Event | null {
6363
if (!event.exception || !event.exception.values || !hint || !(hint.originalException instanceof Error)) {
6464
return event;
6565
}
@@ -71,7 +71,7 @@ export class LinkedErrors implements Integration {
7171
/**
7272
* @inheritDoc
7373
*/
74-
public walkErrorTree(error: ExtendedError, key: string, stack: SentryException[] = []): SentryException[] {
74+
public walkErrorTree(error: ExtendedError, key: string, stack: Exception[] = []): Exception[] {
7575
if (!(error[key] instanceof Error) || stack.length + 1 >= this.limit) {
7676
return stack;
7777
}

packages/browser/src/integrations/pluggable/ember.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { captureException, captureMessage, getCurrentHub, Scope, withScope } from '@sentry/core';
2-
import { Integration, SentryEvent } from '@sentry/types';
2+
import { Event, Integration } from '@sentry/types';
33
import { logger } from '@sentry/utils/logger';
44
import { getGlobalObject } from '@sentry/utils/misc';
55

@@ -81,7 +81,7 @@ export class Ember implements Integration {
8181
* @param scope The scope currently used.
8282
*/
8383
private addIntegrationToSdkInfo(scope: Scope): void {
84-
scope.addEventProcessor((event: SentryEvent) => {
84+
scope.addEventProcessor((event: Event) => {
8585
if (event.sdk) {
8686
const integrations = event.sdk.integrations || [];
8787
event.sdk = {

0 commit comments

Comments
 (0)