Skip to content

Commit a3d0224

Browse files
authored
ref(core): Remove internal utils-hoist re-export (#16114)
This gets rid of the internal `utils-hoist` barrel file and blanket re-export from it in core.
1 parent 88ba26b commit a3d0224

File tree

13 files changed

+181
-170
lines changed

13 files changed

+181
-170
lines changed

packages/core/src/currentScopes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getGlobalSingleton, getMainCarrier } from './carrier';
33
import type { Client } from './client';
44
import { Scope } from './scope';
55
import type { TraceContext } from './types-hoist';
6-
import { generateSpanId } from './utils-hoist';
6+
import { generateSpanId } from './utils-hoist/propagationContext';
77

88
/**
99
* Get the currently active scope.

packages/core/src/index.ts

+148-2
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,155 @@ export type { ReportDialogOptions } from './report-dialog';
120120
export { _INTERNAL_captureLog, _INTERNAL_flushLogsBuffer } from './logs/exports';
121121
export { consoleLoggingIntegration } from './logs/console-integration';
122122

123-
// TODO: Make this structure pretty again and don't do "export *"
124-
export * from './utils-hoist/index';
125123
// TODO: Make this structure pretty again and don't do "export *"
126124
export * from './types-hoist/index';
127125

128126
export type { FeatureFlag } from './featureFlags';
127+
128+
export { applyAggregateErrorsToEvent } from './utils-hoist/aggregate-errors';
129+
export { getBreadcrumbLogLevelFromHttpStatusCode } from './utils-hoist/breadcrumb-log-level';
130+
export { getComponentName, getLocationHref, htmlTreeAsString } from './utils-hoist/browser';
131+
export { dsnFromString, dsnToString, makeDsn } from './utils-hoist/dsn';
132+
// eslint-disable-next-line deprecation/deprecation
133+
export { SentryError } from './utils-hoist/error';
134+
export { GLOBAL_OBJ } from './utils-hoist/worldwide';
135+
export type { InternalGlobal } from './utils-hoist/worldwide';
136+
export { addConsoleInstrumentationHandler } from './utils-hoist/instrument/console';
137+
export { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler } from './utils-hoist/instrument/fetch';
138+
export { addGlobalErrorInstrumentationHandler } from './utils-hoist/instrument/globalError';
139+
export { addGlobalUnhandledRejectionInstrumentationHandler } from './utils-hoist/instrument/globalUnhandledRejection';
140+
export {
141+
addHandler,
142+
maybeInstrument,
143+
resetInstrumentationHandlers,
144+
triggerHandlers,
145+
} from './utils-hoist/instrument/handlers';
146+
export {
147+
isDOMError,
148+
isDOMException,
149+
isElement,
150+
isError,
151+
isErrorEvent,
152+
isEvent,
153+
isInstanceOf,
154+
isParameterizedString,
155+
isPlainObject,
156+
isPrimitive,
157+
isRegExp,
158+
isString,
159+
isSyntheticEvent,
160+
isThenable,
161+
isVueViewModel,
162+
} from './utils-hoist/is';
163+
export { isBrowser } from './utils-hoist/isBrowser';
164+
export { CONSOLE_LEVELS, consoleSandbox, logger, originalConsoleMethods } from './utils-hoist/logger';
165+
export type { Logger } from './utils-hoist/logger';
166+
export {
167+
addContextToFrame,
168+
addExceptionMechanism,
169+
addExceptionTypeValue,
170+
checkOrSetAlreadyCaught,
171+
getEventDescription,
172+
parseSemver,
173+
uuid4,
174+
} from './utils-hoist/misc';
175+
export { isNodeEnv, loadModule } from './utils-hoist/node';
176+
export { normalize, normalizeToSize, normalizeUrlToBase } from './utils-hoist/normalize';
177+
export {
178+
addNonEnumerableProperty,
179+
convertToPlainObject,
180+
// eslint-disable-next-line deprecation/deprecation
181+
dropUndefinedKeys,
182+
extractExceptionKeysForMessage,
183+
fill,
184+
getOriginalFunction,
185+
markFunctionWrapped,
186+
objectify,
187+
} from './utils-hoist/object';
188+
export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './utils-hoist/path';
189+
export { makePromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from './utils-hoist/promisebuffer';
190+
export type { PromiseBuffer } from './utils-hoist/promisebuffer';
191+
export { severityLevelFromString } from './utils-hoist/severity';
192+
export {
193+
UNKNOWN_FUNCTION,
194+
createStackParser,
195+
getFramesFromEvent,
196+
getFunctionName,
197+
stackParserFromStackParserOptions,
198+
stripSentryFramesAndReverse,
199+
} from './utils-hoist/stacktrace';
200+
export { filenameIsInApp, node, nodeStackLineParser } from './utils-hoist/node-stack-trace';
201+
export { isMatchingPattern, safeJoin, snipLine, stringMatchesSomePattern, truncate } from './utils-hoist/string';
202+
export {
203+
isNativeFunction,
204+
supportsDOMError,
205+
supportsDOMException,
206+
supportsErrorEvent,
207+
supportsFetch,
208+
supportsHistory,
209+
supportsNativeFetch,
210+
supportsReferrerPolicy,
211+
supportsReportingObserver,
212+
} from './utils-hoist/supports';
213+
export { SyncPromise, rejectedSyncPromise, resolvedSyncPromise } from './utils-hoist/syncpromise';
214+
export { browserPerformanceTimeOrigin, dateTimestampInSeconds, timestampInSeconds } from './utils-hoist/time';
215+
export {
216+
TRACEPARENT_REGEXP,
217+
extractTraceparentData,
218+
generateSentryTraceHeader,
219+
propagationContextFromHeaders,
220+
} from './utils-hoist/tracing';
221+
export { getSDKSource, isBrowserBundle } from './utils-hoist/env';
222+
export type { SdkSource } from './utils-hoist/env';
223+
export {
224+
addItemToEnvelope,
225+
createAttachmentEnvelopeItem,
226+
createEnvelope,
227+
createEventEnvelopeHeaders,
228+
createSpanEnvelopeItem,
229+
envelopeContainsItemType,
230+
envelopeItemTypeToDataCategory,
231+
forEachEnvelopeItem,
232+
getSdkMetadataForEnvelopeHeader,
233+
parseEnvelope,
234+
serializeEnvelope,
235+
} from './utils-hoist/envelope';
236+
export { createClientReportEnvelope } from './utils-hoist/clientreport';
237+
export {
238+
DEFAULT_RETRY_AFTER,
239+
disabledUntil,
240+
isRateLimited,
241+
parseRetryAfterHeader,
242+
updateRateLimits,
243+
} from './utils-hoist/ratelimit';
244+
export type { RateLimits } from './utils-hoist/ratelimit';
245+
export {
246+
MAX_BAGGAGE_STRING_LENGTH,
247+
SENTRY_BAGGAGE_KEY_PREFIX,
248+
SENTRY_BAGGAGE_KEY_PREFIX_REGEX,
249+
baggageHeaderToDynamicSamplingContext,
250+
dynamicSamplingContextToSentryBaggageHeader,
251+
parseBaggageHeader,
252+
objectToBaggageHeader,
253+
} from './utils-hoist/baggage';
254+
export {
255+
getSanitizedUrlString,
256+
parseUrl,
257+
stripUrlQueryAndFragment,
258+
parseStringToURLObject,
259+
isURLObjectRelative,
260+
getSanitizedUrlStringFromUrlObject,
261+
} from './utils-hoist/url';
262+
export {
263+
eventFromMessage,
264+
eventFromUnknownInput,
265+
exceptionFromError,
266+
parseStackFrames,
267+
} from './utils-hoist/eventbuilder';
268+
export { callFrameToStackFrame, watchdogTimer } from './utils-hoist/anr';
269+
export { LRUMap } from './utils-hoist/lru';
270+
export { generateTraceId, generateSpanId } from './utils-hoist/propagationContext';
271+
export { vercelWaitUntil } from './utils-hoist/vercelWaitUntil';
272+
export { SDK_VERSION } from './utils-hoist/version';
273+
export { getDebugImagesForResources, getFilenameToDebugIdMap } from './utils-hoist/debug-ids';
274+
export { escapeStringForRegex } from './utils-hoist/vendor/escapeStringForRegex';

packages/core/src/integrations/console.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import { addBreadcrumb } from '../breadcrumbs';
22
import { getClient } from '../currentScopes';
33
import { defineIntegration } from '../integration';
44
import type { ConsoleLevel } from '../types-hoist';
5-
import {
6-
CONSOLE_LEVELS,
7-
GLOBAL_OBJ,
8-
addConsoleInstrumentationHandler,
9-
safeJoin,
10-
severityLevelFromString,
11-
} from '../utils-hoist';
5+
import { addConsoleInstrumentationHandler } from '../utils-hoist/instrument/console';
6+
import { CONSOLE_LEVELS } from '../utils-hoist/logger';
7+
import { severityLevelFromString } from '../utils-hoist/severity';
8+
import { safeJoin } from '../utils-hoist/string';
9+
import { GLOBAL_OBJ } from '../utils-hoist/worldwide';
1210

1311
interface ConsoleIntegrationOptions {
1412
levels: ConsoleLevel[];

packages/core/src/integrations/supabase.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// https://github.com/supabase-community/sentry-integration-js
33

44
/* eslint-disable max-lines */
5-
import { logger, isPlainObject } from '../utils-hoist';
6-
75
import type { IntegrationFn } from '../types-hoist';
86
import { setHttpStatus, startSpan } from '../tracing';
97
import { addBreadcrumb } from '../breadcrumbs';
@@ -12,6 +10,8 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '
1210
import { captureException } from '../exports';
1311
import { SPAN_STATUS_ERROR, SPAN_STATUS_OK } from '../tracing';
1412
import { DEBUG_BUILD } from '../debug-build';
13+
import { logger } from '../utils-hoist/logger';
14+
import { isPlainObject } from '../utils-hoist/is';
1515

1616
const AUTH_OPERATIONS_TO_INSTRUMENT = [
1717
'reauthenticate',

packages/core/src/logs/console-integration.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { DEBUG_BUILD } from '../debug-build';
33
import { defineIntegration } from '../integration';
44
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
55
import type { ConsoleLevel, IntegrationFn } from '../types-hoist';
6-
import { CONSOLE_LEVELS, GLOBAL_OBJ, addConsoleInstrumentationHandler, logger, safeJoin } from '../utils-hoist';
6+
import { CONSOLE_LEVELS, logger } from '../utils-hoist/logger';
7+
import { GLOBAL_OBJ } from '../utils-hoist/worldwide';
8+
import { addConsoleInstrumentationHandler } from '../utils-hoist/instrument/console';
9+
import { safeJoin } from '../utils-hoist/string';
710
import { _INTERNAL_captureLog } from './exports';
811

912
interface CaptureConsoleOptions {

packages/core/src/logs/envelope.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { createEnvelope } from '../utils-hoist';
2-
31
import type { DsnComponents, SdkMetadata, SerializedOtelLog } from '../types-hoist';
42
import type { OtelLogEnvelope, OtelLogItem } from '../types-hoist/envelope';
5-
import { dsnToString } from '../utils-hoist';
3+
import { dsnToString } from '../utils-hoist/dsn';
4+
import { createEnvelope } from '../utils-hoist/envelope';
65

76
/**
87
* Creates OTEL log envelope item for a serialized OTEL log.

packages/core/src/logs/exports.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ import { DEBUG_BUILD } from '../debug-build';
55
import { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants';
66
import type { SerializedLogAttribute, SerializedOtelLog } from '../types-hoist';
77
import type { Log } from '../types-hoist/log';
8-
import { isParameterizedString, logger } from '../utils-hoist';
98
import { _getSpanForScope } from '../utils/spanOnScope';
109
import { createOtelLogEnvelope } from './envelope';
10+
import { logger } from '../utils-hoist/logger';
11+
import { isParameterizedString } from '../utils-hoist/is';
1112

1213
const MAX_LOG_BUFFER_SIZE = 100;
1314

packages/core/src/mcp-server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
66
} from './semanticAttributes';
77
import { startSpan } from './tracing';
8-
import { logger } from './utils-hoist';
8+
import { logger } from './utils-hoist/logger';
99

1010
interface MCPServerInstance {
1111
// The first arg is always a name, the last arg should always be a callback function (ie a handler).

packages/core/src/server-runtime-client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { logger } from './utils-hoist/logger';
2323
import { uuid4 } from './utils-hoist/misc';
2424
import { resolvedSyncPromise } from './utils-hoist/syncpromise';
2525
import { _INTERNAL_flushLogsBuffer } from './logs/exports';
26-
import { isPrimitive } from './utils-hoist';
26+
import { isPrimitive } from './utils-hoist/is';
2727

2828
// TODO: Make this configurable
2929
const DEFAULT_LOG_FLUSH_INTERVAL = 5000;

packages/core/src/session.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { SerializedSession, Session, SessionContext, SessionStatus } from './types-hoist';
2-
import { timestampInSeconds, uuid4 } from './utils-hoist';
2+
import { uuid4 } from './utils-hoist/misc';
3+
import { timestampInSeconds } from './utils-hoist/time';
34

45
/**
56
* Creates a new `Session` object by setting certain default parameters. If optional @param context

packages/core/src/trpc.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { getClient, withScope } from './currentScopes';
22
import { captureException } from './exports';
33
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from './semanticAttributes';
44
import { startSpanManual } from './tracing';
5-
import { addNonEnumerableProperty } from './utils-hoist';
65
import { normalize } from './utils-hoist/normalize';
6+
import { addNonEnumerableProperty } from './utils-hoist/object';
77

88
interface SentryTrpcMiddlewareOptions {
99
/** Whether to include procedure inputs in reported events. Defaults to `false`. */

0 commit comments

Comments
 (0)