Skip to content

Commit 982696f

Browse files
authored
ref(hub): Reduce hub bundle size (#5306)
Move field initializers inside constructor to reduce bundle size.
1 parent 076f754 commit 982696f

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

packages/hub/src/scope.ts

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,37 @@ const MAX_BREADCRUMBS = 100;
4444
*/
4545
export class Scope implements ScopeInterface {
4646
/** Flag if notifying is happening. */
47-
protected _notifyingListeners: boolean = false;
47+
protected _notifyingListeners: boolean;
4848

4949
/** Callback for client to receive scope changes. */
50-
protected _scopeListeners: Array<(scope: Scope) => void> = [];
50+
protected _scopeListeners: Array<(scope: Scope) => void>;
5151

5252
/** Callback list that will be called after {@link applyToEvent}. */
53-
protected _eventProcessors: EventProcessor[] = [];
53+
protected _eventProcessors: EventProcessor[];
5454

5555
/** Array of breadcrumbs. */
56-
protected _breadcrumbs: Breadcrumb[] = [];
56+
protected _breadcrumbs: Breadcrumb[];
5757

5858
/** User */
59-
protected _user: User = {};
59+
protected _user: User;
6060

6161
/** Tags */
62-
protected _tags: { [key: string]: Primitive } = {};
62+
protected _tags: { [key: string]: Primitive };
6363

6464
/** Extra */
65-
protected _extra: Extras = {};
65+
protected _extra: Extras;
6666

6767
/** Contexts */
68-
protected _contexts: Contexts = {};
68+
protected _contexts: Contexts;
69+
70+
/** Attachments */
71+
protected _attachments: Attachment[];
72+
73+
/**
74+
* A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get
75+
* sent to Sentry
76+
*/
77+
protected _sdkProcessingMetadata: { [key: string]: unknown };
6978

7079
/** Fingerprint */
7180
protected _fingerprint?: string[];
@@ -86,14 +95,18 @@ export class Scope implements ScopeInterface {
8695
/** Request Mode Session Status */
8796
protected _requestSession?: RequestSession;
8897

89-
/** Attachments */
90-
protected _attachments: Attachment[] = [];
91-
92-
/**
93-
* A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get
94-
* sent to Sentry
95-
*/
96-
protected _sdkProcessingMetadata?: { [key: string]: unknown } = {};
98+
public constructor() {
99+
this._notifyingListeners = false;
100+
this._scopeListeners = [];
101+
this._eventProcessors = [];
102+
this._breadcrumbs = [];
103+
this._attachments = [];
104+
this._user = {};
105+
this._tags = {};
106+
this._extra = {};
107+
this._contexts = {};
108+
this._sdkProcessingMetadata = {};
109+
}
97110

98111
/**
99112
* Inherit values from the parent scope.

0 commit comments

Comments
 (0)