From d253621128cf795e89c74e3188efc9722e60d1ca Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 18 Nov 2024 16:04:54 +0100 Subject: [PATCH] ref(utils): Explicitly export API in `@sentry/utils` (#14338) Resolves https://github.com/getsentry/sentry-javascript/issues/14211 --- packages/utils/src/index.ts | 209 ++++++++++++++++++++++++++++-------- yarn.lock | 12 --- 2 files changed, 167 insertions(+), 54 deletions(-) diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 2a89826313e8..e60bc3bec409 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -1,43 +1,168 @@ -export * from './aggregate-errors'; -export * from './array'; -export * from './breadcrumb-log-level'; -export * from './browser'; -export * from './dsn'; -export * from './error'; -export * from './worldwide'; -export * from './instrument'; -export * from './is'; -export * from './isBrowser'; -export * from './logger'; -export * from './memo'; -export * from './misc'; -export * from './node'; -export * from './normalize'; -export * from './object'; -export * from './path'; -export * from './promisebuffer'; +export { applyAggregateErrorsToEvent } from './aggregate-errors'; +export { flatten } from './array'; +export { getBreadcrumbLogLevelFromHttpStatusCode } from './breadcrumb-log-level'; +export { getComponentName, getDomElement, getLocationHref, htmlTreeAsString } from './browser'; +export { dsnFromString, dsnToString, makeDsn } from './dsn'; +export { SentryError } from './error'; +export { GLOBAL_OBJ, getGlobalSingleton } from './worldwide'; +export type { InternalGlobal } from './worldwide'; +export { addConsoleInstrumentationHandler } from './instrument/console'; +export { addFetchEndInstrumentationHandler, addFetchInstrumentationHandler } from './instrument/fetch'; +export { addGlobalErrorInstrumentationHandler } from './instrument/globalError'; +export { addGlobalUnhandledRejectionInstrumentationHandler } from './instrument/globalUnhandledRejection'; +export { + addHandler, + maybeInstrument, + resetInstrumentationHandlers, + triggerHandlers, +} from './instrument/handlers'; +export { + isDOMError, + isDOMException, + isElement, + isError, + isErrorEvent, + isEvent, + isInstanceOf, + isParameterizedString, + isPlainObject, + isPrimitive, + isRegExp, + isString, + isSyntheticEvent, + isThenable, + isVueViewModel, +} from './is'; +export { isBrowser } from './isBrowser'; +export { CONSOLE_LEVELS, consoleSandbox, logger, originalConsoleMethods } from './logger'; +export { memoBuilder } from './memo'; +export { + addContextToFrame, + addExceptionMechanism, + addExceptionTypeValue, + arrayify, + checkOrSetAlreadyCaught, + getEventDescription, + parseSemver, + uuid4, +} from './misc'; +export { dynamicRequire, isNodeEnv, loadModule } from './node'; +export { normalize, normalizeToSize, normalizeUrlToBase } from './normalize'; +export { + addNonEnumerableProperty, + convertToPlainObject, + dropUndefinedKeys, + extractExceptionKeysForMessage, + fill, + getOriginalFunction, + markFunctionWrapped, + objectify, + urlEncode, +} from './object'; +export { basename, dirname, isAbsolute, join, normalizePath, relative, resolve } from './path'; +export { makePromiseBuffer } from './promisebuffer'; +export type { PromiseBuffer } from './promisebuffer'; + // TODO: Remove requestdata export once equivalent integration is used everywhere -export * from './requestdata'; -export * from './severity'; -export * from './stacktrace'; -export * from './node-stack-trace'; -export * from './string'; -export * from './supports'; -export * from './syncpromise'; -export * from './time'; -export * from './tracing'; -export * from './env'; -export * from './envelope'; -export * from './clientreport'; -export * from './ratelimit'; -export * from './baggage'; -export * from './url'; -export * from './cache'; -export * from './eventbuilder'; -export * from './anr'; -export * from './lru'; -export * from './buildPolyfills'; -export * from './propagationContext'; -export * from './vercelWaitUntil'; -export * from './version'; -export * from './debug-ids'; +export { + DEFAULT_USER_INCLUDES, + addNormalizedRequestDataToEvent, + addRequestDataToEvent, + // eslint-disable-next-line deprecation/deprecation + extractPathForTransaction, + extractRequestData, + winterCGHeadersToDict, + winterCGRequestToRequestData, +} from './requestdata'; +export type { + AddRequestDataToEventOptions, + // eslint-disable-next-line deprecation/deprecation + TransactionNamingScheme, +} from './requestdata'; + +export { severityLevelFromString, validSeverityLevels } from './severity'; +export { + UNKNOWN_FUNCTION, + createStackParser, + getFramesFromEvent, + getFunctionName, + stackParserFromStackParserOptions, + stripSentryFramesAndReverse, +} from './stacktrace'; +export { filenameIsInApp, node, nodeStackLineParser } from './node-stack-trace'; +export { isMatchingPattern, safeJoin, snipLine, stringMatchesSomePattern, truncate } from './string'; +export { + isNativeFunction, + supportsDOMError, + supportsDOMException, + supportsErrorEvent, + supportsFetch, + supportsNativeFetch, + supportsReferrerPolicy, + supportsReportingObserver, +} from './supports'; +export { SyncPromise, rejectedSyncPromise, resolvedSyncPromise } from './syncpromise'; +export { + _browserPerformanceTimeOriginMode, + browserPerformanceTimeOrigin, + dateTimestampInSeconds, + timestampInSeconds, +} from './time'; +export { + TRACEPARENT_REGEXP, + extractTraceparentData, + generateSentryTraceHeader, + propagationContextFromHeaders, +} from './tracing'; +export { getSDKSource, isBrowserBundle } from './env'; +export type { SdkSource } from './env'; +export { + addItemToEnvelope, + createAttachmentEnvelopeItem, + createEnvelope, + createEventEnvelopeHeaders, + createSpanEnvelopeItem, + envelopeContainsItemType, + envelopeItemTypeToDataCategory, + forEachEnvelopeItem, + getSdkMetadataForEnvelopeHeader, + parseEnvelope, + serializeEnvelope, +} from './envelope'; +export { createClientReportEnvelope } from './clientreport'; +export { + DEFAULT_RETRY_AFTER, + disabledUntil, + isRateLimited, + parseRetryAfterHeader, + updateRateLimits, +} from './ratelimit'; +export type { RateLimits } from './ratelimit'; +export { + BAGGAGE_HEADER_NAME, + MAX_BAGGAGE_STRING_LENGTH, + SENTRY_BAGGAGE_KEY_PREFIX, + SENTRY_BAGGAGE_KEY_PREFIX_REGEX, + baggageHeaderToDynamicSamplingContext, + dynamicSamplingContextToSentryBaggageHeader, + parseBaggageHeader, +} from './baggage'; + +export { getNumberOfUrlSegments, getSanitizedUrlString, parseUrl, stripUrlQueryAndFragment } from './url'; +export { makeFifoCache } from './cache'; +export { eventFromMessage, eventFromUnknownInput, exceptionFromError, parseStackFrames } from './eventbuilder'; +export { callFrameToStackFrame, watchdogTimer } from './anr'; +export { LRUMap } from './lru'; +export { generatePropagationContext } from './propagationContext'; +export { vercelWaitUntil } from './vercelWaitUntil'; +export { SDK_VERSION } from './version'; +export { getDebugImagesForResources, getFilenameToDebugIdMap } from './debug-ids'; +export { escapeStringForRegex } from './vendor/escapeStringForRegex'; +export { supportsHistory } from './vendor/supportsHistory'; + +export { _asyncNullishCoalesce } from './buildPolyfills/_asyncNullishCoalesce'; +export { _asyncOptionalChain } from './buildPolyfills/_asyncOptionalChain'; +export { _asyncOptionalChainDelete } from './buildPolyfills/_asyncOptionalChainDelete'; +export { _nullishCoalesce } from './buildPolyfills/_nullishCoalesce'; +export { _optionalChain } from './buildPolyfills/_optionalChain'; +export { _optionalChainDelete } from './buildPolyfills/_optionalChainDelete'; diff --git a/yarn.lock b/yarn.lock index 1e0aafbf7b8c..320f57f45de4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6747,13 +6747,6 @@ path-to-regexp "3.3.0" tslib "2.7.0" -"@nestjs/event-emitter@^2.0.0": - version "2.1.1" - resolved "https://registry.yarnpkg.com/@nestjs/event-emitter/-/event-emitter-2.1.1.tgz#4e34edc487c507edbe6d02033e3dd014a19210f9" - integrity sha512-6L6fBOZTyfFlL7Ih/JDdqlCzZeCW0RjCX28wnzGyg/ncv5F/EOeT1dfopQr1loBRQ3LTgu8OWM7n4zLN4xigsg== - dependencies: - eventemitter2 "6.4.9" - "@nestjs/platform-express@10.4.6": version "10.4.6" resolved "https://registry.yarnpkg.com/@nestjs/platform-express/-/platform-express-10.4.6.tgz#6c39c522fa66036b4256714fea203fbeb49fc4de" @@ -18124,11 +18117,6 @@ eventemitter-asyncresource@^1.0.0: resolved "https://registry.yarnpkg.com/eventemitter-asyncresource/-/eventemitter-asyncresource-1.0.0.tgz#734ff2e44bf448e627f7748f905d6bdd57bdb65b" integrity sha512-39F7TBIV0G7gTelxwbEqnwhp90eqCPON1k0NwNfwhgKn4Co4ybUbj2pECcXT0B3ztRKZ7Pw1JujUUgmQJHcVAQ== -eventemitter2@6.4.9: - version "6.4.9" - resolved "https://registry.yarnpkg.com/eventemitter2/-/eventemitter2-6.4.9.tgz#41f2750781b4230ed58827bc119d293471ecb125" - integrity sha512-JEPTiaOt9f04oa6NOkc4aH+nVp5I3wEjpHbIPqfgCdD5v5bUzy7xQqwcVO2aDQgOWhI28da57HksMrzK9HlRxg== - eventemitter3@^4.0.0, eventemitter3@^4.0.4: version "4.0.7" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f"