Skip to content

Ability to add response body to httpClientIntegration #12544

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

Open
jerbob92 opened this issue Jun 19, 2024 · 7 comments
Open

Ability to add response body to httpClientIntegration #12544

jerbob92 opened this issue Jun 19, 2024 · 7 comments

Comments

@jerbob92
Copy link

Problem Statement

It would be very useful to have the response body for errors, because it mostly gives more explanation what caused an error.

Solution Brainstorm

Add two extra options to httpClientIntegration:

  • addRequestBody
  • addResponseBody
@mydea
Copy link
Member

mydea commented Jun 19, 2024

Hey, thanks for writing in.

Sadly, capturing payloads like this is relatively complex, there are a bunch of edge cases etc. to handle when trying to solve this generically 😬

So instead, what would you think about adding a new option to the httpClientIntegration that allows to configure a callback where you can do stuff yourself, e.g.:

httpClientIntegration({
  beforeCaptureEvent(event, data) {
    if(data.xhr.response) {
      // put response on event...
    } else if (data.fetch.response) {
      // put response on event...
   }
  }
})

@lforst
Copy link
Member

lforst commented Jun 19, 2024

I think this would be very valuable to add as an opt-in option.

@jerbob92
Copy link
Author

@mydea

So instead, what would you think about adding a new option to the httpClientIntegration that allows to configure a callback where you can do stuff yourself, e.g.:

I think that would be fine as well, I have currently implemented it by making a custom HTTP_INTERCEPTORS class (Angular) that basically does this.

@mydea
Copy link
Member

mydea commented Jun 21, 2024

I'll put this in our backlog as something todo - we are pretty busy right now, so PRs are always welcome as well! :)

@samuliasmala
Copy link

samuliasmala commented Apr 16, 2025

So instead, what would you think about adding a new option to the httpClientIntegration that allows to configure a callback where you can do stuff yourself, e.g.:

I like this idea, since it would allow to pass only certain error detail fields to Sentry to avoid accidentally sending private information which should not be sent.

One question: could we use the Sentry's beforeSend callback instead of adding a new callback? Currently beforeBreadcrumb provides access to the response by hint.response, could we add it to beforeSend as well?

EDIT: We would need async function to access the body of the response so maybe the new beforeCaptureEvent callback would be the solution.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 16, 2025
@lforst
Copy link
Member

lforst commented Apr 16, 2025

We will likely not add a callback for anything because that is too much API surface but a flag that will attach response bodies to events.

@samuliasmala
Copy link

That would be great. If I create a PR for this would it have a high change to get merged? If yes I'd like to get some guidance where in the events you would like to see the flag and response body added.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 16, 2025
@stephanie-anderson stephanie-anderson removed the Package: node Issues related to the Sentry Node SDK label Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Product Owner
Development

No branches or pull requests

7 participants