Skip to content

Allow configuring which console calls capture breadcrumb #1307

@jrencz

Description

@jrencz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions