Skip to content

Commit 7659398

Browse files
committed
ref(browser): Use new addInstrumentationHandler
1 parent 28b8ef0 commit 7659398

File tree

3 files changed

+20
-38
lines changed

3 files changed

+20
-38
lines changed

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,34 +84,19 @@ export class Breadcrumbs implements Integration {
8484
*/
8585
public setupOnce(): void {
8686
if (this._options.console) {
87-
addInstrumentationHandler({
88-
callback: _consoleBreadcrumb,
89-
type: 'console',
90-
});
87+
addInstrumentationHandler('console', _consoleBreadcrumb);
9188
}
9289
if (this._options.dom) {
93-
addInstrumentationHandler({
94-
callback: _domBreadcrumb(this._options.dom),
95-
type: 'dom',
96-
});
90+
addInstrumentationHandler('dom', _domBreadcrumb(this._options.dom));
9791
}
9892
if (this._options.xhr) {
99-
addInstrumentationHandler({
100-
callback: _xhrBreadcrumb,
101-
type: 'xhr',
102-
});
93+
addInstrumentationHandler('xhr', _xhrBreadcrumb);
10394
}
10495
if (this._options.fetch) {
105-
addInstrumentationHandler({
106-
callback: _fetchBreadcrumb,
107-
type: 'fetch',
108-
});
96+
addInstrumentationHandler('fetch', _fetchBreadcrumb);
10997
}
11098
if (this._options.history) {
111-
addInstrumentationHandler({
112-
callback: _historyBreadcrumb,
113-
type: 'history',
114-
});
99+
addInstrumentationHandler('history', _historyBreadcrumb);
115100
}
116101
}
117102
}

packages/browser/src/integrations/globalhandlers.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ export class GlobalHandlers implements Integration {
7474

7575
/** JSDoc */
7676
function _installGlobalOnErrorHandler(): void {
77-
addInstrumentationHandler({
77+
addInstrumentationHandler(
78+
'error',
7879
// eslint-disable-next-line @typescript-eslint/no-explicit-any
79-
callback: (data: { msg: any; url: any; line: any; column: any; error: any }) => {
80+
(data: { msg: any; url: any; line: any; column: any; error: any }) => {
8081
const [hub, attachStacktrace] = getHubAndAttachStacktrace();
8182
if (!hub.getIntegration(GlobalHandlers)) {
8283
return;
@@ -101,15 +102,15 @@ function _installGlobalOnErrorHandler(): void {
101102

102103
addMechanismAndCapture(hub, error, event, 'onerror');
103104
},
104-
type: 'error',
105-
});
105+
);
106106
}
107107

108108
/** JSDoc */
109109
function _installGlobalOnUnhandledRejectionHandler(): void {
110-
addInstrumentationHandler({
110+
addInstrumentationHandler(
111+
'unhandledrejection',
111112
// eslint-disable-next-line @typescript-eslint/no-explicit-any
112-
callback: (e: any) => {
113+
(e: any) => {
113114
const [hub, attachStacktrace] = getHubAndAttachStacktrace();
114115
if (!hub.getIntegration(GlobalHandlers)) {
115116
return;
@@ -151,8 +152,7 @@ function _installGlobalOnUnhandledRejectionHandler(): void {
151152
addMechanismAndCapture(hub, error, event, 'onunhandledrejection');
152153
return;
153154
},
154-
type: 'unhandledrejection',
155-
});
155+
);
156156
}
157157

158158
/**

packages/browser/src/sdk.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,12 @@ function startSessionTracking(): void {
226226
hub.captureSession();
227227

228228
// We want to create a session for every navigation as well
229-
addInstrumentationHandler({
230-
callback: ({ from, to }) => {
231-
// Don't create an additional session for the initial route or if the location did not change
232-
if (from === undefined || from === to) {
233-
return;
234-
}
235-
hub.startSession({ ignoreDuration: true });
236-
hub.captureSession();
237-
},
238-
type: 'history',
229+
addInstrumentationHandler('history', ({ from, to }) => {
230+
// Don't create an additional session for the initial route or if the location did not change
231+
if (from === undefined || from === to) {
232+
return;
233+
}
234+
hub.startSession({ ignoreDuration: true });
235+
hub.captureSession();
239236
});
240237
}

0 commit comments

Comments
 (0)