Skip to content

Commit e17bd91

Browse files
authored
chore: Dedupe @sentry/core imports (#14529)
I noticed we have a whole bunch of files that have multiple imports from `@sentry/core`, so I went over all of those I could find and ran VSCode auto-import-ordering to clean this up. Would be nice to have this taken care of by eslint/biome, but somehow this does not seem to work... :( This for sure does not capture everything, but a good amount of duplication at least.
1 parent af773b1 commit e17bd91

File tree

142 files changed

+473
-501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+473
-501
lines changed

packages/angular/src/sdk.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ import {
44
breadcrumbsIntegration,
55
globalHandlersIntegration,
66
httpContextIntegration,
7+
init as browserInit,
78
linkedErrorsIntegration,
9+
setContext,
810
} from '@sentry/browser';
9-
import { init as browserInit, setContext } from '@sentry/browser';
11+
import type { Client, Integration } from '@sentry/core';
1012
import {
1113
applySdkMetadata,
1214
dedupeIntegration,
1315
functionToStringIntegration,
1416
inboundFiltersIntegration,
17+
logger,
1518
} from '@sentry/core';
16-
import { logger } from '@sentry/core';
17-
import type { Client, Integration } from '@sentry/core';
1819

1920
import { IS_DEBUG_BUILD } from './flags';
2021

packages/aws-serverless/src/sdk.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { existsSync } from 'fs';
22
import { hostname } from 'os';
33
import { basename, resolve } from 'path';
44
import { types } from 'util';
5-
import { logger } from '@sentry/core';
65
import type { Integration, Options, Scope, SdkMetadata, Span } from '@sentry/core';
6+
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, logger } from '@sentry/core';
77
import type { NodeClient, NodeOptions } from '@sentry/node';
88
import {
99
SDK_VERSION,
@@ -19,9 +19,6 @@ import {
1919
} from '@sentry/node';
2020
import type { Context, Handler } from 'aws-lambda';
2121
import { performance } from 'perf_hooks';
22-
23-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core';
24-
2522
import { DEBUG_BUILD } from './debug-build';
2623
import { awsIntegration } from './integration/aws';
2724
import { awsLambdaIntegration } from './integration/awslambda';

packages/browser-utils/src/instrument/dom.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { HandlerDataDom } from '@sentry/core';
2-
32
import { addHandler, addNonEnumerableProperty, fill, maybeInstrument, triggerHandlers, uuid4 } from '@sentry/core';
43
import { WINDOW } from '../types';
54

packages/browser-utils/src/instrument/xhr.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { HandlerDataXhr, SentryWrappedXMLHttpRequest } from '@sentry/core';
2-
32
import { addHandler, isString, maybeInstrument, timestampInSeconds, triggerHandlers } from '@sentry/core';
43
import { WINDOW } from '../types';
54

packages/browser-utils/src/metrics/browserMetrics.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
/* eslint-disable max-lines */
2-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan } from '@sentry/core';
3-
import { setMeasurement } from '@sentry/core';
4-
import { browserPerformanceTimeOrigin, getComponentName, htmlTreeAsString, parseUrl } from '@sentry/core';
52
import type { Measurements, Span, SpanAttributes, StartSpanOptions } from '@sentry/core';
6-
7-
import { spanToJSON } from '@sentry/core';
3+
import {
4+
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
5+
browserPerformanceTimeOrigin,
6+
getActiveSpan,
7+
getComponentName,
8+
htmlTreeAsString,
9+
parseUrl,
10+
setMeasurement,
11+
spanToJSON,
12+
} from '@sentry/core';
813
import { WINDOW } from '../types';
914
import { trackClsAsStandaloneSpan } from './cls';
1015
import {
@@ -228,7 +233,7 @@ export function startTrackingInteractions(): void {
228233
});
229234
}
230235

231-
export { startTrackingINP, registerInpInteractionListener } from './inp';
236+
export { registerInpInteractionListener, startTrackingINP } from './inp';
232237

233238
/**
234239
* Starts tracking the Cumulative Layout Shift on the current page and collects the value and last entry

packages/browser-utils/src/metrics/inp.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
import type { Span, SpanAttributes } from '@sentry/core';
12
import {
23
SEMANTIC_ATTRIBUTE_EXCLUSIVE_TIME,
34
SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_UNIT,
45
SEMANTIC_ATTRIBUTE_SENTRY_MEASUREMENT_VALUE,
56
SEMANTIC_ATTRIBUTE_SENTRY_OP,
67
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
8+
browserPerformanceTimeOrigin,
9+
dropUndefinedKeys,
710
getActiveSpan,
811
getCurrentScope,
912
getRootSpan,
13+
htmlTreeAsString,
1014
spanToJSON,
1115
} from '@sentry/core';
12-
import { browserPerformanceTimeOrigin, dropUndefinedKeys, htmlTreeAsString } from '@sentry/core';
13-
import type { Span, SpanAttributes } from '@sentry/core';
1416
import {
1517
addInpInstrumentationHandler,
1618
addPerformanceInstrumentationHandler,

packages/browser-utils/src/metrics/utils.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import type { SentrySpan } from '@sentry/core';
1+
import type { Integration, SentrySpan, Span, SpanAttributes, SpanTimeInput, StartSpanOptions } from '@sentry/core';
22
import { getClient, getCurrentScope, spanToJSON, startInactiveSpan, withActiveSpan } from '@sentry/core';
3-
import type { Integration, Span, SpanAttributes, SpanTimeInput, StartSpanOptions } from '@sentry/core';
43
import { WINDOW } from '../types';
54

65
/**

packages/browser/src/client.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import type { Scope } from '@sentry/core';
2-
import { applySdkMetadata } from '@sentry/core';
3-
import { BaseClient } from '@sentry/core';
4-
import { getSDKSource, logger } from '@sentry/core';
51
import type {
62
BrowserClientProfilingOptions,
73
BrowserClientReplayOptions,
@@ -10,10 +6,11 @@ import type {
106
EventHint,
117
Options,
128
ParameterizedString,
9+
Scope,
1310
SeverityLevel,
1411
UserFeedback,
1512
} from '@sentry/core';
16-
13+
import { BaseClient, applySdkMetadata, getSDKSource, logger } from '@sentry/core';
1714
import { DEBUG_BUILD } from './debug-build';
1815
import { eventFromException, eventFromMessage } from './eventbuilder';
1916
import { WINDOW } from './helpers';

packages/browser/src/eventbuilder.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
import { getClient } from '@sentry/core';
1+
import type {
2+
Event,
3+
EventHint,
4+
Exception,
5+
ParameterizedString,
6+
SeverityLevel,
7+
StackFrame,
8+
StackParser,
9+
} from '@sentry/core';
210
import {
311
addExceptionMechanism,
412
addExceptionTypeValue,
513
extractExceptionKeysForMessage,
14+
getClient,
615
isDOMError,
716
isDOMException,
817
isError,
@@ -13,15 +22,6 @@ import {
1322
normalizeToSize,
1423
resolvedSyncPromise,
1524
} from '@sentry/core';
16-
import type {
17-
Event,
18-
EventHint,
19-
Exception,
20-
ParameterizedString,
21-
SeverityLevel,
22-
StackFrame,
23-
StackParser,
24-
} from '@sentry/core';
2525

2626
type Prototype = { constructor: (...args: unknown[]) => unknown };
2727

packages/browser/src/helpers.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import { captureException, withScope } from '@sentry/core';
1+
import type { Mechanism, WrappedFunction } from '@sentry/core';
22
import {
33
GLOBAL_OBJ,
44
addExceptionMechanism,
55
addExceptionTypeValue,
66
addNonEnumerableProperty,
7+
captureException,
78
getOriginalFunction,
89
markFunctionWrapped,
10+
withScope,
911
} from '@sentry/core';
10-
import type { Mechanism, WrappedFunction } from '@sentry/core';
1112

1213
export const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;
1314

packages/browser/src/integrations/breadcrumbs.ts

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1+
/* eslint-disable max-lines */
2+
13
import {
24
SENTRY_XHR_DATA_KEY,
35
addClickKeypressInstrumentationHandler,
46
addHistoryInstrumentationHandler,
57
addXhrInstrumentationHandler,
68
} from '@sentry-internal/browser-utils';
7-
import { addBreadcrumb, defineIntegration, getClient } from '@sentry/core';
8-
import {
9-
addConsoleInstrumentationHandler,
10-
addFetchInstrumentationHandler,
11-
getBreadcrumbLogLevelFromHttpStatusCode,
12-
getComponentName,
13-
getEventDescription,
14-
htmlTreeAsString,
15-
logger,
16-
parseUrl,
17-
safeJoin,
18-
severityLevelFromString,
19-
} from '@sentry/core';
209
import type {
2110
Breadcrumb,
2211
Client,
@@ -32,7 +21,21 @@ import type {
3221
XhrBreadcrumbData,
3322
XhrBreadcrumbHint,
3423
} from '@sentry/core';
35-
24+
import {
25+
addBreadcrumb,
26+
addConsoleInstrumentationHandler,
27+
addFetchInstrumentationHandler,
28+
defineIntegration,
29+
getBreadcrumbLogLevelFromHttpStatusCode,
30+
getClient,
31+
getComponentName,
32+
getEventDescription,
33+
htmlTreeAsString,
34+
logger,
35+
parseUrl,
36+
safeJoin,
37+
severityLevelFromString,
38+
} from '@sentry/core';
3639
import { DEBUG_BUILD } from '../debug-build';
3740
import { WINDOW } from '../helpers';
3841

packages/browser/src/integrations/browserapierrors.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { defineIntegration } from '@sentry/core';
2-
import { fill, getFunctionName, getOriginalFunction } from '@sentry/core';
31
import type { IntegrationFn, WrappedFunction } from '@sentry/core';
2+
import { defineIntegration, fill, getFunctionName, getOriginalFunction } from '@sentry/core';
43

54
import { WINDOW, wrap } from '../helpers';
65

packages/browser/src/integrations/contextlines.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { defineIntegration } from '@sentry/core';
2-
import { GLOBAL_OBJ, addContextToFrame, stripUrlQueryAndFragment } from '@sentry/core';
31
import type { Event, IntegrationFn, StackFrame } from '@sentry/core';
2+
import { GLOBAL_OBJ, addContextToFrame, defineIntegration, stripUrlQueryAndFragment } from '@sentry/core';
43

54
const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;
65

packages/browser/src/integrations/globalhandlers.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import { captureEvent, defineIntegration, getClient } from '@sentry/core';
1+
import type { Client, Event, IntegrationFn, Primitive, StackParser } from '@sentry/core';
22
import {
33
UNKNOWN_FUNCTION,
44
addGlobalErrorInstrumentationHandler,
55
addGlobalUnhandledRejectionInstrumentationHandler,
6+
captureEvent,
7+
defineIntegration,
8+
getClient,
69
getLocationHref,
710
isPrimitive,
811
isString,
912
logger,
1013
} from '@sentry/core';
11-
import type { Client, Event, IntegrationFn, Primitive, StackParser } from '@sentry/core';
1214

1315
import type { BrowserClient } from '../client';
1416
import { DEBUG_BUILD } from '../debug-build';

packages/browser/src/integrations/httpclient.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { SENTRY_XHR_DATA_KEY, addXhrInstrumentationHandler } from '@sentry-internal/browser-utils';
2-
import { captureEvent, defineIntegration, getClient, isSentryRequestUrl } from '@sentry/core';
2+
import type { Client, Event as SentryEvent, IntegrationFn, SentryWrappedXMLHttpRequest } from '@sentry/core';
33
import {
44
GLOBAL_OBJ,
55
addExceptionMechanism,
66
addFetchInstrumentationHandler,
7+
captureEvent,
8+
defineIntegration,
9+
getClient,
10+
isSentryRequestUrl,
711
logger,
812
supportsNativeFetch,
913
} from '@sentry/core';
10-
import type { Client, Event as SentryEvent, IntegrationFn, SentryWrappedXMLHttpRequest } from '@sentry/core';
1114

1215
import { DEBUG_BUILD } from '../debug-build';
1316

packages/browser/src/integrations/linkederrors.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { defineIntegration } from '@sentry/core';
2-
import { applyAggregateErrorsToEvent } from '@sentry/core';
31
import type { IntegrationFn } from '@sentry/core';
2+
import { applyAggregateErrorsToEvent, defineIntegration } from '@sentry/core';
43
import { exceptionFromError } from '../eventbuilder';
54

65
interface LinkedErrorsOptions {

packages/browser/src/integrations/reportingobserver.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
import { captureMessage, defineIntegration, getClient, withScope } from '@sentry/core';
2-
import { GLOBAL_OBJ, supportsReportingObserver } from '@sentry/core';
31
import type { Client, IntegrationFn } from '@sentry/core';
2+
import {
3+
GLOBAL_OBJ,
4+
captureMessage,
5+
defineIntegration,
6+
getClient,
7+
supportsReportingObserver,
8+
withScope,
9+
} from '@sentry/core';
410

511
const WINDOW = GLOBAL_OBJ as typeof GLOBAL_OBJ & Window;
612

packages/browser/src/integrations/spotlight.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { getNativeImplementation } from '@sentry-internal/browser-utils';
2-
import { defineIntegration } from '@sentry/core';
3-
import { logger, serializeEnvelope } from '@sentry/core';
42
import type { Client, Envelope, Event, IntegrationFn } from '@sentry/core';
5-
import type { WINDOW } from '../helpers';
6-
3+
import { defineIntegration, logger, serializeEnvelope } from '@sentry/core';
74
import { DEBUG_BUILD } from '../debug-build';
5+
import type { WINDOW } from '../helpers';
86

97
export type SpotlightConnectionOptions = {
108
/**

packages/browser/src/profiling/utils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/* eslint-disable max-lines */
2-
3-
import { DEFAULT_ENVIRONMENT, getClient, spanToJSON } from '@sentry/core';
2+
import type { DebugImage, Envelope, Event, EventEnvelope, Profile, Span, ThreadCpuProfile } from '@sentry/core';
43
import {
4+
DEFAULT_ENVIRONMENT,
55
browserPerformanceTimeOrigin,
66
forEachEnvelopeItem,
7+
getClient,
78
getDebugImagesForResources,
89
logger,
10+
spanToJSON,
911
timestampInSeconds,
1012
uuid4,
1113
} from '@sentry/core';
12-
import type { DebugImage, Envelope, Event, EventEnvelope, Profile, Span, ThreadCpuProfile } from '@sentry/core';
13-
1414
import { DEBUG_BUILD } from '../debug-build';
1515
import { WINDOW } from '../helpers';
1616
import type { JSSelfProfile, JSSelfProfileStack, JSSelfProfiler, JSSelfProfilerConstructor } from './jsSelfProfiling';

packages/browser/src/sdk.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
import { getCurrentScope } from '@sentry/core';
2-
import { functionToStringIntegration, inboundFiltersIntegration } from '@sentry/core';
1+
import { addHistoryInstrumentationHandler } from '@sentry-internal/browser-utils';
32
import {
43
captureSession,
4+
consoleSandbox,
5+
dedupeIntegration,
6+
functionToStringIntegration,
57
getClient,
8+
getCurrentScope,
69
getIntegrationsToSetup,
710
getReportDialogEndpoint,
11+
inboundFiltersIntegration,
812
initAndBind,
913
lastEventId,
14+
logger,
15+
stackParserFromStackParserOptions,
1016
startSession,
17+
supportsFetch,
1118
} from '@sentry/core';
12-
import { consoleSandbox, logger, stackParserFromStackParserOptions, supportsFetch } from '@sentry/core';
1319
import type { Client, DsnLike, Integration, Options, UserFeedback } from '@sentry/core';
14-
15-
import { addHistoryInstrumentationHandler } from '@sentry-internal/browser-utils';
16-
import { dedupeIntegration } from '@sentry/core';
1720
import type { BrowserClientOptions, BrowserOptions } from './client';
1821
import { BrowserClient } from './client';
1922
import { DEBUG_BUILD } from './debug-build';

packages/browser/src/tracing/backgroundtab.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import { SPAN_STATUS_ERROR, getActiveSpan, getRootSpan } from '@sentry/core';
2-
import { spanToJSON } from '@sentry/core';
3-
import { logger } from '@sentry/core';
4-
1+
import { SPAN_STATUS_ERROR, getActiveSpan, getRootSpan, logger, spanToJSON } from '@sentry/core';
52
import { DEBUG_BUILD } from '../debug-build';
63
import { WINDOW } from '../helpers';
74

0 commit comments

Comments
 (0)