Skip to content

Commit df13f6c

Browse files
committed
feat(v8/core): Move addTracingHeadersToFetchRequest and instrumentFetchRequest to core
1 parent 8879fd5 commit df13f6c

File tree

7 files changed

+9
-21
lines changed

7 files changed

+9
-21
lines changed

packages/tracing-internal/src/common/fetch.ts renamed to packages/core/src/fetch.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
1-
import {
2-
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
3-
SPAN_STATUS_ERROR,
4-
getClient,
5-
getCurrentScope,
6-
getDynamicSamplingContextFromClient,
7-
getDynamicSamplingContextFromSpan,
8-
getIsolationScope,
9-
hasTracingEnabled,
10-
setHttpStatus,
11-
spanToTraceHeader,
12-
startInactiveSpan,
13-
} from '@sentry/core';
141
import type { Client, HandlerDataFetch, Scope, Span, SpanOrigin } from '@sentry/types';
152
import {
163
BAGGAGE_HEADER_NAME,
174
dynamicSamplingContextToSentryBaggageHeader,
185
generateSentryTraceHeader,
196
isInstanceOf,
207
} from '@sentry/utils';
8+
import { getClient, getCurrentScope, getIsolationScope } from './currentScopes';
9+
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from './semanticAttributes';
10+
import { getDynamicSamplingContextFromClient, getDynamicSamplingContextFromSpan, setHttpStatus, SPAN_STATUS_ERROR, startInactiveSpan } from './tracing';
11+
import { hasTracingEnabled } from './utils/hasTracingEnabled';
12+
import { spanToTraceHeader } from './utils/spanUtils';
2113

2214
type PolymorphicRequestHeaders =
2315
| Record<string, string | undefined>
@@ -110,7 +102,6 @@ export function instrumentFetchRequest(
110102
// eslint-disable-next-line @typescript-eslint/no-explicit-any
111103
const options: { [key: string]: any } = handlerData.args[1];
112104

113-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
114105
options.headers = addTracingHeadersToFetchRequest(request, client, scope, options, span);
115106
}
116107

packages/core/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,4 @@ export { metrics } from './metrics/exports';
113113
export type { MetricData } from './metrics/exports';
114114
export { metricsDefault } from './metrics/exports-default';
115115
export { BrowserMetricsAggregator } from './metrics/browser-aggregator';
116+
export { addTracingHeadersToFetchRequest, instrumentFetchRequest } from './fetch';

packages/tracing-internal/src/browser/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
spanToJSON,
1111
spanToTraceHeader,
1212
startInactiveSpan,
13+
instrumentFetchRequest
1314
} from '@sentry/core';
1415
import type { HandlerDataXhr, SentryWrappedXMLHttpRequest, Span } from '@sentry/types';
1516
import {
@@ -23,7 +24,6 @@ import {
2324
stringMatchesSomePattern,
2425
} from '@sentry/utils';
2526

26-
import { instrumentFetchRequest } from '../common/fetch';
2727
import { addPerformanceInstrumentationHandler } from './instrument';
2828
import { WINDOW } from './types';
2929

packages/tracing-internal/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,4 @@ export {
2525
addLcpInstrumentationHandler,
2626
} from './browser';
2727

28-
export { addTracingHeadersToFetchRequest, instrumentFetchRequest } from './common/fetch';
29-
3028
export type { RequestInstrumentationOptions } from './browser';

packages/vercel-edge/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"access": "public"
3030
},
3131
"dependencies": {
32-
"@sentry-internal/tracing": "8.0.0-alpha.2",
3332
"@sentry/core": "8.0.0-alpha.2",
3433
"@sentry/types": "8.0.0-alpha.2",
3534
"@sentry/utils": "8.0.0-alpha.2"

packages/vercel-edge/src/integrations/wintercg-fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { instrumentFetchRequest } from '@sentry-internal/tracing';
21
import {
32
addBreadcrumb,
43
convertIntegrationFnToClass,
54
defineIntegration,
65
getClient,
76
isSentryRequestUrl,
7+
instrumentFetchRequest
88
} from '@sentry/core';
99
import type {
1010
Client,

packages/vercel-edge/test/wintercg-fetch.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as internalTracing from '@sentry-internal/tracing';
21
import * as sentryCore from '@sentry/core';
32
import type { HandlerDataFetch, Integration } from '@sentry/types';
43
import * as sentryUtils from '@sentry/utils';
@@ -14,7 +13,7 @@ class FakeClient extends VercelEdgeClient {
1413
}
1514

1615
const addFetchInstrumentationHandlerSpy = jest.spyOn(sentryUtils, 'addFetchInstrumentationHandler');
17-
const instrumentFetchRequestSpy = jest.spyOn(internalTracing, 'instrumentFetchRequest');
16+
const instrumentFetchRequestSpy = jest.spyOn(sentryCore, 'instrumentFetchRequest');
1817
const addBreadcrumbSpy = jest.spyOn(sentryCore, 'addBreadcrumb');
1918

2019
describe('WinterCGFetch instrumentation', () => {

0 commit comments

Comments
 (0)