Skip to content

ref(core): Remove internal utils-hoist re-export #16114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
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
2 changes: 1 addition & 1 deletion packages/core/src/currentScopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getGlobalSingleton, getMainCarrier } from './carrier';
import type { Client } from './client';
import { Scope } from './scope';
import type { TraceContext } from './types-hoist';
import { generateSpanId } from './utils-hoist';
import { generateSpanId } from './utils-hoist/propagationContext';

/**
* Get the currently active scope.
Expand Down
150 changes: 148 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,155 @@ export type { ReportDialogOptions } from './report-dialog';
export { _INTERNAL_captureLog, _INTERNAL_flushLogsBuffer } from './logs/exports';
export { consoleLoggingIntegration } from './logs/console-integration';

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

export type { FeatureFlag } from './featureFlags';

export { applyAggregateErrorsToEvent } from './utils-hoist/aggregate-errors';
export { getBreadcrumbLogLevelFromHttpStatusCode } from './utils-hoist/breadcrumb-log-level';
export { getComponentName, getLocationHref, htmlTreeAsString } from './utils-hoist/browser';
export { dsnFromString, dsnToString, makeDsn } from './utils-hoist/dsn';
// eslint-disable-next-line deprecation/deprecation
export { SentryError } from './utils-hoist/error';
export { GLOBAL_OBJ } from './utils-hoist/worldwide';
export type { InternalGlobal } from './utils-hoist/worldwide';
export { addConsoleInstrumentationHandler } from './utils-hoist/instrument/console';
export { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler } from './utils-hoist/instrument/fetch';
export { addGlobalErrorInstrumentationHandler } from './utils-hoist/instrument/globalError';
export { addGlobalUnhandledRejectionInstrumentationHandler } from './utils-hoist/instrument/globalUnhandledRejection';
export {
addHandler,
maybeInstrument,
resetInstrumentationHandlers,
triggerHandlers,
} from './utils-hoist/instrument/handlers';
export {
isDOMError,
isDOMException,
isElement,
isError,
isErrorEvent,
isEvent,
isInstanceOf,
isParameterizedString,
isPlainObject,
isPrimitive,
isRegExp,
isString,
isSyntheticEvent,
isThenable,
isVueViewModel,
} from './utils-hoist/is';
export { isBrowser } from './utils-hoist/isBrowser';
export { CONSOLE_LEVELS, consoleSandbox, logger, originalConsoleMethods } from './utils-hoist/logger';
export type { Logger } from './utils-hoist/logger';
export {
addContextToFrame,
addExceptionMechanism,
addExceptionTypeValue,
checkOrSetAlreadyCaught,
getEventDescription,
parseSemver,
uuid4,
} from './utils-hoist/misc';
export { isNodeEnv, loadModule } from './utils-hoist/node';
export { normalize, normalizeToSize, normalizeUrlToBase } from './utils-hoist/normalize';
export {
addNonEnumerableProperty,
convertToPlainObject,
// eslint-disable-next-line deprecation/deprecation
dropUndefinedKeys,
extractExceptionKeysForMessage,
fill,
getOriginalFunction,
markFunctionWrapped,
objectify,
} from './utils-hoist/object';
export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './utils-hoist/path';
export { makePromiseBuffer, SENTRY_BUFFER_FULL_ERROR } from './utils-hoist/promisebuffer';
export type { PromiseBuffer } from './utils-hoist/promisebuffer';
export { severityLevelFromString } from './utils-hoist/severity';
export {
UNKNOWN_FUNCTION,
createStackParser,
getFramesFromEvent,
getFunctionName,
stackParserFromStackParserOptions,
stripSentryFramesAndReverse,
} from './utils-hoist/stacktrace';
export { filenameIsInApp, node, nodeStackLineParser } from './utils-hoist/node-stack-trace';
export { isMatchingPattern, safeJoin, snipLine, stringMatchesSomePattern, truncate } from './utils-hoist/string';
export {
isNativeFunction,
supportsDOMError,
supportsDOMException,
supportsErrorEvent,
supportsFetch,
supportsHistory,
supportsNativeFetch,
supportsReferrerPolicy,
supportsReportingObserver,
} from './utils-hoist/supports';
export { SyncPromise, rejectedSyncPromise, resolvedSyncPromise } from './utils-hoist/syncpromise';
export { browserPerformanceTimeOrigin, dateTimestampInSeconds, timestampInSeconds } from './utils-hoist/time';
export {
TRACEPARENT_REGEXP,
extractTraceparentData,
generateSentryTraceHeader,
propagationContextFromHeaders,
} from './utils-hoist/tracing';
export { getSDKSource, isBrowserBundle } from './utils-hoist/env';
export type { SdkSource } from './utils-hoist/env';
export {
addItemToEnvelope,
createAttachmentEnvelopeItem,
createEnvelope,
createEventEnvelopeHeaders,
createSpanEnvelopeItem,
envelopeContainsItemType,
envelopeItemTypeToDataCategory,
forEachEnvelopeItem,
getSdkMetadataForEnvelopeHeader,
parseEnvelope,
serializeEnvelope,
} from './utils-hoist/envelope';
export { createClientReportEnvelope } from './utils-hoist/clientreport';
export {
DEFAULT_RETRY_AFTER,
disabledUntil,
isRateLimited,
parseRetryAfterHeader,
updateRateLimits,
} from './utils-hoist/ratelimit';
export type { RateLimits } from './utils-hoist/ratelimit';
export {
MAX_BAGGAGE_STRING_LENGTH,
SENTRY_BAGGAGE_KEY_PREFIX,
SENTRY_BAGGAGE_KEY_PREFIX_REGEX,
baggageHeaderToDynamicSamplingContext,
dynamicSamplingContextToSentryBaggageHeader,
parseBaggageHeader,
objectToBaggageHeader,
} from './utils-hoist/baggage';
export {
getSanitizedUrlString,
parseUrl,
stripUrlQueryAndFragment,
parseStringToURLObject,
isURLObjectRelative,
getSanitizedUrlStringFromUrlObject,
} from './utils-hoist/url';
export {
eventFromMessage,
eventFromUnknownInput,
exceptionFromError,
parseStackFrames,
} from './utils-hoist/eventbuilder';
export { callFrameToStackFrame, watchdogTimer } from './utils-hoist/anr';
export { LRUMap } from './utils-hoist/lru';
export { generateTraceId, generateSpanId } from './utils-hoist/propagationContext';
export { vercelWaitUntil } from './utils-hoist/vercelWaitUntil';
export { SDK_VERSION } from './utils-hoist/version';
export { getDebugImagesForResources, getFilenameToDebugIdMap } from './utils-hoist/debug-ids';
export { escapeStringForRegex } from './utils-hoist/vendor/escapeStringForRegex';
12 changes: 5 additions & 7 deletions packages/core/src/integrations/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { addBreadcrumb } from '../breadcrumbs';
import { getClient } from '../currentScopes';
import { defineIntegration } from '../integration';
import type { ConsoleLevel } from '../types-hoist';
import {
CONSOLE_LEVELS,
GLOBAL_OBJ,
addConsoleInstrumentationHandler,
safeJoin,
severityLevelFromString,
} from '../utils-hoist';
import { addConsoleInstrumentationHandler } from '../utils-hoist/instrument/console';
import { CONSOLE_LEVELS } from '../utils-hoist/logger';
import { severityLevelFromString } from '../utils-hoist/severity';
import { safeJoin } from '../utils-hoist/string';
import { GLOBAL_OBJ } from '../utils-hoist/worldwide';

interface ConsoleIntegrationOptions {
levels: ConsoleLevel[];
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/integrations/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// https://github.com/supabase-community/sentry-integration-js

/* eslint-disable max-lines */
import { logger, isPlainObject } from '../utils-hoist';

import type { IntegrationFn } from '../types-hoist';
import { setHttpStatus, startSpan } from '../tracing';
import { addBreadcrumb } from '../breadcrumbs';
Expand All @@ -12,6 +10,8 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '
import { captureException } from '../exports';
import { SPAN_STATUS_ERROR, SPAN_STATUS_OK } from '../tracing';
import { DEBUG_BUILD } from '../debug-build';
import { logger } from '../utils-hoist/logger';
import { isPlainObject } from '../utils-hoist/is';

const AUTH_OPERATIONS_TO_INSTRUMENT = [
'reauthenticate',
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/logs/console-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { DEBUG_BUILD } from '../debug-build';
import { defineIntegration } from '../integration';
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../semanticAttributes';
import type { ConsoleLevel, IntegrationFn } from '../types-hoist';
import { CONSOLE_LEVELS, GLOBAL_OBJ, addConsoleInstrumentationHandler, logger, safeJoin } from '../utils-hoist';
import { CONSOLE_LEVELS, logger } from '../utils-hoist/logger';
import { GLOBAL_OBJ } from '../utils-hoist/worldwide';
import { addConsoleInstrumentationHandler } from '../utils-hoist/instrument/console';
import { safeJoin } from '../utils-hoist/string';
import { _INTERNAL_captureLog } from './exports';

interface CaptureConsoleOptions {
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/logs/envelope.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { createEnvelope } from '../utils-hoist';

import type { DsnComponents, SdkMetadata, SerializedOtelLog } from '../types-hoist';
import type { OtelLogEnvelope, OtelLogItem } from '../types-hoist/envelope';
import { dsnToString } from '../utils-hoist';
import { dsnToString } from '../utils-hoist/dsn';
import { createEnvelope } from '../utils-hoist/envelope';

/**
* Creates OTEL log envelope item for a serialized OTEL log.
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/logs/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import { DEBUG_BUILD } from '../debug-build';
import { SEVERITY_TEXT_TO_SEVERITY_NUMBER } from './constants';
import type { SerializedLogAttribute, SerializedOtelLog } from '../types-hoist';
import type { Log } from '../types-hoist/log';
import { isParameterizedString, logger } from '../utils-hoist';
import { _getSpanForScope } from '../utils/spanOnScope';
import { createOtelLogEnvelope } from './envelope';
import { logger } from '../utils-hoist/logger';
import { isParameterizedString } from '../utils-hoist/is';

const MAX_LOG_BUFFER_SIZE = 100;

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/mcp-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
} from './semanticAttributes';
import { startSpan } from './tracing';
import { logger } from './utils-hoist';
import { logger } from './utils-hoist/logger';

interface MCPServerInstance {
// The first arg is always a name, the last arg should always be a callback function (ie a handler).
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/server-runtime-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { logger } from './utils-hoist/logger';
import { uuid4 } from './utils-hoist/misc';
import { resolvedSyncPromise } from './utils-hoist/syncpromise';
import { _INTERNAL_flushLogsBuffer } from './logs/exports';
import { isPrimitive } from './utils-hoist';
import { isPrimitive } from './utils-hoist/is';

// TODO: Make this configurable
const DEFAULT_LOG_FLUSH_INTERVAL = 5000;
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/session.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { SerializedSession, Session, SessionContext, SessionStatus } from './types-hoist';
import { timestampInSeconds, uuid4 } from './utils-hoist';
import { uuid4 } from './utils-hoist/misc';
import { timestampInSeconds } from './utils-hoist/time';

/**
* Creates a new `Session` object by setting certain default parameters. If optional @param context
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { getClient, withScope } from './currentScopes';
import { captureException } from './exports';
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from './semanticAttributes';
import { startSpanManual } from './tracing';
import { addNonEnumerableProperty } from './utils-hoist';
import { normalize } from './utils-hoist/normalize';
import { addNonEnumerableProperty } from './utils-hoist/object';

interface SentryTrpcMiddlewareOptions {
/** Whether to include procedure inputs in reported events. Defaults to `false`. */
Expand Down
Loading
Loading