Skip to content
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

Merged
merged 6 commits into from
Dec 9, 2019
Merged

V7: Callback refactor #665

merged 6 commits into from
Dec 9, 2019

Conversation

bengourley
Copy link
Contributor

@bengourley bengourley commented Dec 6, 2019

  • Add public onBreadcrumb and onSession breadcrumbs
  • Add private onSessionPayload breadcrumbs (will be required by a subsequent PR for attaching data to a session)
  • Add client methods for adding/removing all kinds of callback
  • Add config options for supplying public callbacks

@bugsnagbot
Copy link
Collaborator

bugsnagbot commented Dec 6, 2019

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 39.40 kB 11.94 kB
After 40.64 kB 12.28 kB
± ⚠️ +1,238 bytes ⚠️ +344 bytes

Generated by 🚫 dangerJS against 852e01d

@bengourley bengourley marked this pull request as ready for review December 9, 2019 10:52
expect(sSpy).toHaveBeenCalledTimes(1)
c.notify(new Error(), () => {}, () => {
expect(bSpy).toHaveBeenCalledTimes(1)
expect(bSpy).toHaveBeenCalledTimes(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate assertion

expect(sSpy).toHaveBeenCalledTimes(1)
c.notify(new Error(), () => {}, () => {
expect(bSpy).toHaveBeenCalledTimes(1)
expect(bSpy).toHaveBeenCalledTimes(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate assertion

Copy link
Contributor Author

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.

this._logger.error('Error occurred in onSession callback, continuing anyway…')
this._logger.error(e)
}
}
Copy link
Contributor

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
  }

Copy link
Contributor Author

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.

@bengourley bengourley merged commit 057eae2 into v7 Dec 9, 2019
@bengourley bengourley deleted the v7-callbacks branch December 9, 2019 17:14
@bengourley bengourley mentioned this pull request Apr 14, 2020
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants