-
Notifications
You must be signed in to change notification settings - Fork 251
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
V7: Callback refactor #665
Conversation
packages/core/test/client.test.js
Outdated
expect(sSpy).toHaveBeenCalledTimes(1) | ||
c.notify(new Error(), () => {}, () => { | ||
expect(bSpy).toHaveBeenCalledTimes(1) | ||
expect(bSpy).toHaveBeenCalledTimes(1) |
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.
duplicate assertion
packages/core/test/client.test.js
Outdated
expect(sSpy).toHaveBeenCalledTimes(1) | ||
c.notify(new Error(), () => {}, () => { | ||
expect(bSpy).toHaveBeenCalledTimes(1) | ||
expect(bSpy).toHaveBeenCalledTimes(1) |
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.
duplicate assertion
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.
Good spot – this was actually meant to make an assertion about eSpy
.
packages/core/client.js
Outdated
this._logger.error('Error occurred in onSession callback, continuing anyway…') | ||
this._logger.error(e) | ||
} | ||
} |
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.
This could be refactored although it doesn't help to reduce the bundle diff:
runSyncCallbacks (callbacks, callbackArg, callbackType) {
let ignore = false
const cbs = callbacks.slice(0)
while (!ignore) {
if (!cbs.length) break
try {
ignore = cbs.pop()(callbackArg) === false
} catch (e) {
this._logger.error(`Error occurred in ${callbackType} callback, continuing anyway…`)
this._logger.error(e)
}
}
return ignore
}
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.
I'll take this – we can reuse it for the internal session payload callbacks too.
onBreadcrumb
andonSession
breadcrumbsonSessionPayload
breadcrumbs (will be required by a subsequent PR for attaching data to a session)