question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow configuring which console calls capture breadcrumb

See original GitHub issue

Do you want to request a feature or report a bug? Request a feature

What is the current behavior? Using existing configuration one can only turn autoBreadcrumbs.console on or off. There’s no precise control over which console functions are capturing breadcrumb and which don’t.

What is the expected behavior? There should be a way to express which console methods are expected to capture a breadcrumb.

My use case: I use console.debug in my app but I don’t want those to be sent to Sentry. I see I have a few options:

  • I can eliminate certain console calls as a build step so that they just aren’t there on stages and production
  • I can use breadcrumbCallback to find and eliminate crumbs of category: 'console' and level: 'debug'. Although it’s a great way, it took me some time to figure out that what I want is doable via breadcrumbCallback

I think the following should be considered:

In config

autoBreadcrumbs: {
  console: true | false | object
}

If object then the following object can be passed:

{
  debug: true (default) | false,
  info: true (default) | false,
  log: true (default) | false,
  warn: true (default) | false,
  error: true (default) | false,
  ... (any other key, if true, will be treated as console method name)
}

Pros:

  • it will be immediately discoverable which console methods will and which won’t
  • defaults can be omitted (as it is now for defaults of autoBreadcrumbs)

Cons:

  • there should be additional check for presence of a console method before it’s wrapped to prevent misconfiguration. In fact there’s one already in the condition for autoBreadcrumbs.console, where presence of console.log is checked.

Summing things up:

  • passing false as value for keys corresponding with 5 default console methods will disable capturing breadcrumb for them
  • passing true as value for keys not being within 5 default, but present on console object and being functions will result in capturing breadcrumbs for that method

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (12 by maintainers)

github_iconTop GitHub Comments

5reactions
akashnimarecommented, Sep 21, 2018

@kamilogorek no, just want to disable the console logs. Would that be enough -

init({
  dsn: '__YOUR_DSN__',
  integrations: [new Sentry.Integrations.Breadcrumbs({
      console: false
  })] 
})

Thanks for the help 😃

2reactions
jrenczcommented, Jan 8, 2019

@didnotwant you can use beforeBreadcrumb or eventProcessor to filter out those you don’t want for some reason.

In Breadcrumbs integration code you can see that it passes the level value in the SentryBreadcrumbHint object to Breadcrumbs.addBreadcrumb:

https://github.com/getsentry/sentry-javascript/blob/65965ff30b4c978c4f200ef8bb5c88d220059324/packages/browser/src/integrations/breadcrumbs.ts#L118-L160

You can use the hind to prevent the breadcrumb from being sent

Read more comments on GitHub >

github_iconTop Results From Across the Web

Breadcrumbs for JavaScript | Sentry Documentation
Sentry uses breadcrumbs to create a trail of events that happened prior to an issue. These events are very similar to traditional logs,...
Read more >
Capturing Events with Breadcrumbs - Javascript Honeybadger ...
Honeybadger captures many types of breadcrumbs automatically, such as click events, console logs, and Ajax requests. You can enhance your ability to rapidly ......
Read more >
Configuration options - Ember - Bugsnag docs
navigation breadcrumbs are left on page loads, DOMContentLoaded events, pushState / replaceState calls, and popstate / hashchange events. Network requests.
Read more >
Default Integrations for JavaScript - DocBase AI Documentation
This integration wraps native APIs to capture breadcrumbs. ... { // Log calls to `console.log`, `console.debug`, etc console: boolean; // Log all click...
Read more >
Customize your Firebase Crashlytics crash reports - Google
Catch up on everything announced at Firebase Summit, and learn how Firebase ... of an existing key by calling the key and setting...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found