Skip to content

@sentry/browser - Support fetchOptions #2050

@dcherman

Description

@dcherman

In the original raven-js client for Sentry, it was possible to customize the options sent to fetch; it doesn't look like the transport in @sentry/browser supports that today.

const defaultOptions: RequestInit = {
body: JSON.stringify(event),
method: 'POST',
// Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default
// https://caniuse.com/#feat=referrer-policy
// It doesn't. And it throw exception instead of ignoring this parameter...
// REF: https://github.com/getsentry/raven-js/issues/1233
referrerPolicy: (supportsReferrerPolicy() ? 'origin' : '') as ReferrerPolicy,
};
return this._buffer.add(
global.fetch(this.url, defaultOptions).then(response => ({
status: Status.fromHttpCode(response.status),
})),

My use case is that our instance of Sentry lives behind an endpoint that uses cookie auth, however it's on a separate subdomain from the applications generating the errors. As a result, we need to use credentials: 'include' on fetch in order to pass cookies along.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions