-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref(browser): Update addInstrumentationHandler type #4264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
size-limit report
|
} | ||
if (this._options.history) { | ||
addInstrumentationHandler({ | ||
callback: (...args) => { | ||
this._historyBreadcrumb(...args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a lot of these wins are by rm -rf the spread operator ^^
@@ -82,59 +68,55 @@ export class Breadcrumbs implements Integration { | |||
* - Fetch API | |||
* - History API | |||
*/ | |||
public setupOnce(): void { | |||
public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void { | |||
const hub = getCurrentHub(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change to using a local hub vs. the global getCurrentHub
is more correct, and will help when we switch to passing in the hub/client explicitly.
I tried doing dynamic dispatch (haha yes insert // eslint-disable-next-line guard-for-in
for (const key in this._options) {
const val = this._options[key as keyof BreadcrumbsOptions];
if (key === DOM) {
_addDomBreadcrumbs(addBreadcrumb, val);
} else if (key !== 'sentry') {
DISPATCH[key as keyof Omit<BreadcrumbsOptions, 'dom' | 'sentry'>](addBreadcrumb);
}
}
const DISPATCH: {
[P in keyof Omit<BreadcrumbsOptions, 'dom' | 'sentry'>]: (addBreadcrumb: AddBreadcrumb) => void;
} = {
console: _addConsoleBreadcrumbs,
fetch: _addFetchBreadcrumbs,
history: _addHistoryBreadcrumbs,
xhr: _addXhrBreadcrumbs,
}; Edit: This is because if statements are very efficient: this.at.xhr && function(t) {
st(function(n) {
if (n.endTimestamp && !n.xhr.__sentry_own_request__) {
var r = n.xhr.__sentry_xhr__ || {},
i = r.method,
e = r.url,
o = r.status_code,
u = r.body;
t({
category: Zn,
data: {
method: i,
url: e,
status_code: o
},
type: "http"
}, {
xhr: n.xhr,
input: u
})
}
}, Zn)
}(o) |
ebf7a7d
to
3c91f6f
Compare
Gonna try to merge in #4265 first |
Closing - will revisit after #4279 gets merged in |
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint
) & (yarn test
).