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

Filtering breadcrumbs in a beforeNotify #1411

Open
rabidpraxis opened this issue Oct 16, 2024 · 1 comment
Open

Filtering breadcrumbs in a beforeNotify #1411

rabidpraxis opened this issue Oct 16, 2024 · 1 comment

Comments

@rabidpraxis
Copy link
Contributor

We had a customer reach out about filtering breadcrumbs, so I looked into recommending a beforeNotify snippet to remove unwanted breadcrumbs.

I could not get it to work, as the filtered breadcrumbs would not persist in the final payload. Now, I understand that accessing a field with double underscores (__breadcrumbs) is generally a no-no. Is there a way to do this that I am unaware of?

I pushed up a test in a branch with how I thought it would work:

master...filter-breadcrumbs

@subzero10
Copy link
Member

Hey @rabidpraxis, the reason your approach didn't work is because beforeNotify callbacks act on the notice itself and breadcrumbs are only added to the request payload on a later stage. Your test in the branch didn't work because there is no n.__breadcrumbs variable; breadcrumbs are inside a client.__store variable.

The easiest workaround I can come up right now without introducing any changes would be to call Honeybadger.configure({ breadcrumbsEnabled: false }) to disable breadcrumb collection and then calling it again to enable it: Honeybadger.configure({ breadcrumbsEnabled: true }). Do you know if this would work for them?

In regards to your question about double underscores, it's one of the earlier ways to mark a field as private, but it's up to us whether we want to respect this (i.e. Javascript won't complain). In some occasions, it may be OK if we access these fields internally but we should not encourage their usage as part of the public SDK (i.e. we should not ask people to access it in a beforeNotify handler). I hope that makes sense.

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

No branches or pull requests

2 participants