Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/migration/v11-end-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ Affected SDKs: `@sentry/cloudflare`.
### `@sentry/core` / All SDKs

- The internal, deprecated `addAutoIpAddressToUser` export was removed.
- The deprecated positional `spanOrigin` argument of `instrumentFetchRequest` was removed. Pass an options object (e.g. `{ spanOrigin }`) as the last argument instead.
- The `createSpanEnvelope` function and the `SpanEnvelope` / `SpanItem` types were removed. They existed only to send standalone (v1) spans as their own segment envelope, which the SDK no longer does. Standalone spans are gone; spans are sent either on their transaction or, with span streaming, as streamed spans (`StreamedSpanEnvelope`).
- The `disableInstrumentationWarnings` option and the `MissingInstrumentationContext` type were removed. Now that instrumentation is channel-based, the SDK can no longer detect the "you imported a framework before `Sentry.init()`" case, so the warning it gated and the context it attached no longer exist.
- The deprecated `sendDefaultPii` option was removed. Use [`dataCollection`](#senddefaultpii-is-replaced-by-datacollection) instead.
Expand Down
47 changes: 5 additions & 42 deletions packages/core/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,6 @@ interface InstrumentFetchRequestOptions {
onRequestSpanEnd?: (span: Span, responseInformation: ResponseHookInfo) => void;
}

/**
* Create and track fetch request spans for usage in combination with `addFetchInstrumentationHandler`.
*
* @deprecated pass an options object instead of the spanOrigin parameter
*
* @returns Span if a span was created, otherwise void.
*/
export function instrumentFetchRequest(
handlerData: HandlerDataFetch,
shouldCreateSpan: (url: string) => boolean,
shouldAttachHeaders: (url: string) => boolean,
spans: Record<string, Span>,
spanOrigin: SpanOrigin,
): Span | undefined;
/**
* Create and track fetch request spans for usage in combination with `addFetchInstrumentationHandler`.
*
Expand All @@ -65,21 +51,7 @@ export function instrumentFetchRequest(
shouldCreateSpan: (url: string) => boolean,
shouldAttachHeaders: (url: string) => boolean,
spans: Record<string, Span>,
// eslint-disable-next-line @typescript-eslint/unified-signatures -- needed because the other overload is deprecated
instrumentFetchRequestOptions: InstrumentFetchRequestOptions,
): Span | undefined;

/**
* Create and track fetch request spans for usage in combination with `addFetchInstrumentationHandler`.
*
* @returns Span if a span was created, otherwise void.
*/
export function instrumentFetchRequest(
handlerData: HandlerDataFetch,
shouldCreateSpan: (url: string) => boolean,
shouldAttachHeaders: (url: string) => boolean,
spans: Record<string, Span>,
spanOriginOrOptions?: SpanOrigin | InstrumentFetchRequestOptions,
instrumentFetchRequestOptions?: InstrumentFetchRequestOptions,
): Span | undefined {
if (!handlerData.fetchData) {
return undefined;
Expand All @@ -99,7 +71,7 @@ export function instrumentFetchRequest(
// Only end the span and call hooks if we're actually recording
if (shouldCreateSpanResult) {
endSpan(span, handlerData);
_callOnRequestSpanEnd(span, handlerData, spanOriginOrOptions);
_callOnRequestSpanEnd(span, handlerData, instrumentFetchRequestOptions);
}

// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
Expand All @@ -109,11 +81,7 @@ export function instrumentFetchRequest(
return undefined;
}

// Backwards-compatible with the old signature. Needed to introduce the combined optional parameter
// to avoid API breakage for anyone calling this function with the optional spanOrigin parameter
// TODO (v11): remove this backwards-compatible code and only accept the options parameter
const { spanOrigin = 'auto.http.browser', propagateTraceparent = false } =
typeof spanOriginOrOptions === 'object' ? spanOriginOrOptions : { spanOrigin: spanOriginOrOptions };
const { spanOrigin = 'auto.http.browser', propagateTraceparent = false } = instrumentFetchRequestOptions ?? {};

const client = getClient();
const hasParent = !!getActiveSpan();
Expand Down Expand Up @@ -176,14 +144,9 @@ export function instrumentFetchRequest(
export function _callOnRequestSpanEnd(
span: Span,
handlerData: HandlerDataFetch,
spanOriginOrOptions?: SpanOrigin | InstrumentFetchRequestOptions,
instrumentFetchRequestOptions?: InstrumentFetchRequestOptions,
): void {
const onRequestSpanEnd =
typeof spanOriginOrOptions === 'object' && spanOriginOrOptions !== null
? spanOriginOrOptions.onRequestSpanEnd
: undefined;

onRequestSpanEnd?.(span, {
instrumentFetchRequestOptions?.onRequestSpanEnd?.(span, {
headers: handlerData.response?.headers,
error: handlerData.error,
});
Expand Down
Loading