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

automatic console breadcrumbs for node (bugsnag-js v8) #2107

Merged
merged 13 commits into from
Apr 22, 2024

Conversation

djskinner
Copy link
Contributor

@djskinner djskinner commented Apr 3, 2024

Goal

  • Support for breadcrumbs on bugsnag-js v8 is already merged into the integration branch
  • Adding automatic breadcrumbs on console calls makes sense to improve error debugging capabilities

Design

  • Re-use the existing plugin to benefit from DRY.
  • Call the leaveBreadcrumb method on the client clone stored in the async context, if it exists
  • The downside to this approach is a slight increase in the browser bundle size

Changeset

  • plugin-console-breadcrumbs included in the node notifier
  • behaviour of plugin-console-breadcrumbs in unchanged in the browser

Testing

  • unit tests
  • e2e tests
  • manual test against a test project using an alpha release
Screenshot 2024-04-03 at 17 41 07

@djskinner djskinner changed the base branch from next to integration/v8 April 3, 2024 15:41
Copy link

github-actions bot commented Apr 3, 2024

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 44.74 kB 13.64 kB
After 44.73 kB 13.64 kB
± -12 bytes -2 bytes

code coverage diff

<temporarily disabled>

Generated by 🚫 dangerJS against f79fb47

Comment on lines 16 to 17
// if we are in an async context, use the client from that context
const c = client._clientContext && client._clientContext.getStore() ? client._clientContext.getStore() : client
Copy link
Member

Choose a reason for hiding this comment

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

Would this be something we have to do in every plugin used in the node notifier now? If so it seems like we should make this automatic so that the plugins themselves don't need to change, otherwise we're inviting bugs where things are using the wrong client

@@ -53,6 +53,22 @@ const Bugsnag = {

const bugsnag = new Client(opts, schema, internalPlugins, { name, version, url })

Object.keys(Client.prototype).forEach((m) => {
if (/^_/.test(m)) return
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that this is right — wouldn't we want to proxy the call even if it's a "private" method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this needs to apply to all method calls so that it's consistently applied to the same client e.g. if a public method then calls a private method they need directing to the same place

@@ -186,7 +186,6 @@ class Client {
// stuff like __proto__ etc. (only store the result if the plugin had a
// name)
if (plugin.name) this._plugins[`~${plugin.name}~`] = result
return this
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't but I thought it worth removing since we're doing a major version change and it's not used

packages/node/test/notifier.test.ts Outdated Show resolved Hide resolved
Co-authored-by: Joe Haines <hello@joehaines.co.uk>
@djskinner djskinner merged commit 850f92e into integration/v8 Apr 22, 2024
66 checks passed
@djskinner djskinner deleted the node-console-breadcrumbs branch April 22, 2024 10:56
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.

None yet

3 participants