Add custom HTTPHeaders in URLRequest
Problem Statement
Please add functionality to provide custom headers in all URLRequest.
The SDK should already add headers for failed HTTP requests here https://github.com/getsentry/sentry-cocoa/blob/2af280d3fd36a58915d26a619323499f72757fbc/Sources/Sentry/SentryNetworkTracker.m#L375-L379
Where exactly would you like to add custom headers? Would you like to see them as well for spans and breadcrumbs?
@philipphofmann how can we add headers to that request? Need to add this in all urlrequests.
Example need to do here https://github.com/getsentry/sentry-cocoa/blob/2af280d3fd36a58915d26a619323499f72757fbc/Sources/Sentry/SentryNSURLRequest.m#L80-L84
Hello @n1tesh-airtel currently its not possible to modify sentry requests.
@n1tesh-airtel, can you please elaborate on why you need to add headers to these requests?
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
I'd also benefit from the ability to add custom headers.
Usecase: we host our own Sentry instance and it's hidden behind a proxy. This proxy expects some client-related headers to be passed with every request. I think this is a rather common use case for the self-hosted Sentry instances.
Our JavaScript SDK allows you to set custom headers with the transport options
Sentry.init({
transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport),
transportOptions: {
headers: {
key: 'value'
}
}
})
The Cocoa SDK transport is not public yet. On Java, you can achieve this by implementing a custom transport. We can implement this feature, but I can't give you an ETA.
I have the same issue as @siejkowski and would benefit from sentry-cocoa's ability to attach custom headers. I have been stuck on sentry-cocoa v4.4.1 for years because the ability to customize the headers using beforeSendRequest was removed in 5.x. Apologies if I am misunderstanding the documentation, but it seems like there is no way to communicate with a self-hosted Sentry server that requires custom headers using sentry-cocoa. Is this correct?
but it seems like there is no way to communicate with a self-hosted Sentry server that requires custom headers using sentry-cocoa. Is this correct?
@lillymaxwell, yes, sadly, that's correct.