Skip to content

Commit

Permalink
internal: Replace sentry/utils by sentry/core (#4352)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonis authored Dec 12, 2024
1 parent 9f0f6c8 commit 98fb43f
Show file tree
Hide file tree
Showing 72 changed files with 100 additions and 99 deletions.
2 changes: 1 addition & 1 deletion dev-packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"devDependencies": {
"@babel/preset-env": "^7.25.3",
"@babel/preset-typescript": "^7.18.6",
"@sentry/core": "8.41.0",
"@sentry/react-native": "6.4.0",
"@sentry/utils": "8.41.0",
"@types/node": "^20.9.3",
"@types/react": "^18.2.64",
"appium": "2.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const { argv } = require('process');

const parseArgs = require('minimist');
const { logger } = require('@sentry/utils');
const { logger } = require('@sentry/core');
logger.enable();

const args = parseArgs(argv.slice(2));
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/e2e-tests/patch-scripts/rn.patch.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const path = require('path');
const { argv, env } = require('process');

const parseArgs = require('minimist');
const { logger } = require('@sentry/utils');
const { logger } = require('@sentry/core');
logger.enable();

const SENTRY_RELEASE = env.SENTRY_RELEASE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const { argv } = require('process');

const parseArgs = require('minimist');
const { logger } = require('@sentry/utils');
const { logger } = require('@sentry/core');
logger.enable();

const args = parseArgs(argv.slice(2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const { argv } = require('process');

const parseArgs = require('minimist');
const { logger } = require('@sentry/utils');
const { logger } = require('@sentry/core');
logger.enable();

const args = parseArgs(argv.slice(2));
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/e2e-tests/patch-scripts/rn.patch.podfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const { argv } = require('process');

const parseArgs = require('minimist');
const { logger } = require('@sentry/utils');
const { logger } = require('@sentry/core');
logger.enable();

const args = parseArgs(argv.slice(2));
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/e2e-tests/patch-scripts/rn.patch.xcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { argv } = require('process');
const xcode = require('xcode');
const parseArgs = require('minimist');
const semver = require('semver');
const { logger } = require('@sentry/utils');
const { logger } = require('@sentry/core');
logger.enable();

const args = parseArgs(argv.slice(2));
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"test:sdk": "npx jest",
"test:tools": "npx jest --config jest.config.tools.js",
"test:watch": "npx jest --watch",
"yalc:add:sentry-javascript": "yalc add @sentry/browser @sentry/core @sentry/react @sentry/types @sentry/utils",
"yalc:add:sentry-javascript": "yalc add @sentry/browser @sentry/core @sentry/react @sentry/types",
"fix": "npx run-s fix:eslint fix:prettier",
"fix:eslint": "eslint --config .eslintrc.js --fix .",
"fix:prettier": "prettier --config ../../.prettierrc.json --ignore-path ../../.prettierignore --write \"{src,test,scripts,plugin/src}/**/**.ts\"",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/breadcrumb.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { severityLevelFromString } from '@sentry/core';
import type { Breadcrumb, SeverityLevel } from '@sentry/types';
import { severityLevelFromString } from '@sentry/utils';

export const DEFAULT_BREADCRUMB_LEVEL: SeverityLevel = 'info';

Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/js/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { eventFromException, eventFromMessage } from '@sentry/browser';
import { BaseClient } from '@sentry/core';
import { BaseClient, dateTimestampInSeconds, logger, SentryError } from '@sentry/core';
import type {
ClientReportEnvelope,
ClientReportItem,
Expand All @@ -11,7 +11,6 @@ import type {
TransportMakeRequestResponse,
UserFeedback,
} from '@sentry/types';
import { dateTimestampInSeconds, logger, SentryError } from '@sentry/utils';
import { Alert } from 'react-native';

import { getDevServer } from './integrations/debugsymbolicatorutils';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/integrations/debugsymbolicator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger } from '@sentry/core';
import type { Event, EventHint, Exception, Integration, StackFrame as SentryStackFrame } from '@sentry/types';
import { logger } from '@sentry/utils';

import type { ExtendedError } from '../utils/error';
import { getFramesToPop, isErrorLike } from '../utils/error';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger } from '@sentry/core';
import type { StackFrame as SentryStackFrame } from '@sentry/types';
import { logger } from '@sentry/utils';

import { ReactNativeLibraries } from '../utils/rnlibraries';
import { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/integrations/devicecontext.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable complexity */
import { logger, severityLevelFromString } from '@sentry/core';
import type { Client, Event, EventHint, Integration } from '@sentry/types';
import { logger, severityLevelFromString } from '@sentry/utils';
import { AppState } from 'react-native';

import { breadcrumbFromObject } from '../breadcrumb';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/integrations/modulesloader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger } from '@sentry/core';
import type { Event, Integration } from '@sentry/types';
import { logger } from '@sentry/utils';

import { NATIVE } from '../wrapper';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/integrations/nativelinkederrors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { exceptionFromError } from '@sentry/browser';
import { isInstanceOf, isPlainObject, isString } from '@sentry/core';
import type {
Client,
DebugImage,
Expand All @@ -10,7 +11,6 @@ import type {
StackFrame,
StackParser,
} from '@sentry/types';
import { isInstanceOf, isPlainObject, isString } from '@sentry/utils';

import type { NativeStackFrames } from '../NativeRNSentry';
import { NATIVE } from '../wrapper';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { captureException, getClient, getCurrentScope } from '@sentry/core';
import { addExceptionMechanism, captureException, getClient, getCurrentScope, logger } from '@sentry/core';
import type { EventHint, Integration, SeverityLevel } from '@sentry/types';
import { addExceptionMechanism, logger } from '@sentry/utils';

import { createSyntheticError, isErrorLike } from '../utils/error';
import { RN_GLOBAL_OBJ } from '../utils/worldwide';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logger } from '@sentry/utils';
import { logger } from '@sentry/core';

import { ReactNativeLibraries } from '../utils/rnlibraries';
import { RN_GLOBAL_OBJ } from '../utils/worldwide';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/integrations/sdkinfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger } from '@sentry/core';
import type { Event, Integration, Package, SdkInfo as SdkInfoType } from '@sentry/types';
import { logger } from '@sentry/utils';

import { isExpoGo, notWeb } from '../utils/environment';
import { SDK_NAME, SDK_PACKAGE_NAME, SDK_VERSION } from '../version';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/integrations/spotlight.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger, serializeEnvelope } from '@sentry/core';
import type { BaseTransportOptions, Client, ClientOptions, Envelope, Integration } from '@sentry/types';
import { logger, serializeEnvelope } from '@sentry/utils';

import { ReactNativeLibraries } from '../utils/rnlibraries';
import { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/integrations/viewhierarchy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger } from '@sentry/core';
import type { Attachment, Event, EventHint, Integration } from '@sentry/types';
import { logger } from '@sentry/utils';

import { NATIVE } from '../wrapper';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/profiling/cache.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeFifoCache } from '@sentry/utils';
import { makeFifoCache } from '@sentry/core';

import type { AndroidCombinedProfileEvent, CombinedProfileEvent } from './types';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/profiling/convertHermesProfile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger } from '@sentry/core';
import type { FrameId, StackId, ThreadCpuFrame, ThreadCpuSample, ThreadCpuStack, ThreadId } from '@sentry/types';
import { logger } from '@sentry/utils';

import { MAX_PROFILE_DURATION_MS } from './constants';
import type * as Hermes from './hermes';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/profiling/debugid.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GLOBAL_OBJ, logger } from '@sentry/core';
import type { DebugImage } from '@sentry/types';
import { GLOBAL_OBJ, logger } from '@sentry/utils';

import { DEFAULT_BUNDLE_NAME } from './hermes';

Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/js/profiling/integration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable complexity */
import { getActiveSpan, getClient, spanIsSampled } from '@sentry/core';
import { getActiveSpan, getClient, logger, spanIsSampled, uuid4 } from '@sentry/core';
import type { Envelope, Event, Integration, Span, ThreadCpuProfile } from '@sentry/types';
import { logger, uuid4 } from '@sentry/utils';
import { Platform } from 'react-native';

import type { ReactNativeClient } from '../client';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/profiling/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable complexity */
import { forEachEnvelopeItem, logger } from '@sentry/core';
import type { Envelope, Event, ThreadCpuProfile } from '@sentry/types';
import { forEachEnvelopeItem, logger } from '@sentry/utils';

import { getDefaultEnvironment } from '../utils/environment';
import { getDebugMetadata } from './debugid';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/replay/CustomMask.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logger } from '@sentry/utils';
import { logger } from '@sentry/core';
import * as React from 'react';
import type { HostComponent, ViewProps } from 'react-native';
import { UIManager, View } from 'react-native';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/replay/mobilereplay.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger } from '@sentry/core';
import type { Client, DynamicSamplingContext, Event, Integration } from '@sentry/types';
import { logger } from '@sentry/utils';

import { isHardCrash } from '../misc';
import { hasHooks } from '../utils/clientutils';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/replay/xhrUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dropUndefinedKeys } from '@sentry/core';
import type { Breadcrumb, BreadcrumbHint, SentryWrappedXMLHttpRequest, XhrBreadcrumbHint } from '@sentry/types';
import { dropUndefinedKeys } from '@sentry/utils';

import type { RequestBody } from './networkUtils';
import { getBodySize, parseContentLengthHeader } from './networkUtils';
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/js/sdk.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* eslint-disable complexity */
import { captureFeedback, getClient, getGlobalScope,getIntegrationsToSetup, getIsolationScope,initAndBind, withScope as coreWithScope } from '@sentry/core';
import { captureFeedback, getClient, getGlobalScope, getIntegrationsToSetup, getIsolationScope, initAndBind, logger, stackParserFromStackParserOptions, withScope as coreWithScope } from '@sentry/core';
import {
defaultStackParser,
makeFetchTransport,
} from '@sentry/react';
import type { Breadcrumb, BreadcrumbHint, Integration, Scope, SendFeedbackParams, UserFeedback } from '@sentry/types';
import { logger, stackParserFromStackParserOptions } from '@sentry/utils';
import * as React from 'react';

import { ReactNativeClient } from './client';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/tools/ModulesCollector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logger } from '@sentry/utils';
import { logger } from '@sentry/core';
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
import { posix, sep } from 'path';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/tools/enableLogger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logger } from '@sentry/utils';
import { logger } from '@sentry/core';

/**
* Enables debug logger when SENTRY_LOG_LEVEL=debug.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/tools/metroMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addContextToFrame, logger } from '@sentry/core';
import type { StackFrame } from '@sentry/types';
import { addContextToFrame, logger } from '@sentry/utils';
import { readFile } from 'fs';
import type { IncomingMessage, ServerResponse } from 'http';
import type { InputConfigT, Middleware } from 'metro-config';
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/js/tools/metroconfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logger } from '@sentry/utils';
import { logger } from '@sentry/core';
import type { MetroConfig, MixedOutput, Module, ReadOnlyGraph } from 'metro';
import type { CustomResolutionContext, CustomResolver, Resolution } from 'metro-resolver';
import * as process from 'process';
Expand Down Expand Up @@ -246,8 +246,8 @@ export function withSentryFramesCollapsed(config: MetroConfig): MetroConfig {
const originalCustomizeFrame = config.symbolicator?.customizeFrame;
const collapseSentryInternalFrames = (frame: MetroFrame): boolean =>
typeof frame.file === 'string' &&
(frame.file.includes('node_modules/@sentry/utils/cjs/instrument.js') ||
frame.file.includes('node_modules/@sentry/utils/cjs/logger.js'));
(frame.file.includes('node_modules/@sentry/core/cjs/instrument.js') ||
frame.file.includes('node_modules/@sentry/core/cjs/logger.js'));

const customizeFrame = (frame: MetroFrame): MetroCustomizeFrameReturnValue => {
const originalOrSentryCustomizeFrame = (
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/tools/sentryBabelTransformerUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logger } from '@sentry/utils';
import { logger } from '@sentry/core';
import * as process from 'process';

import type { BabelTransformer } from './vendor/metro/metroBabelTransformer';
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/js/touchevents.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { addBreadcrumb, getClient, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
import { addBreadcrumb, dropUndefinedKeys, getClient, logger, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
import type { SeverityLevel } from '@sentry/types';
import { dropUndefinedKeys, logger } from '@sentry/utils';
import * as React from 'react';
import type { GestureResponderEvent } from 'react-native';
import { StyleSheet, View } from 'react-native';
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/js/tracing/gesturetracing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { addBreadcrumb, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
import { addBreadcrumb, logger, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
import type { Breadcrumb } from '@sentry/types';
import { logger } from '@sentry/utils';

import { startUserInteractionSpan } from './integrations/userInteraction';
import { UI_ACTION } from './ops';
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/js/tracing/integrations/appStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import {
getCapturedScopesOnSpan,
getClient,
getCurrentScope,
logger,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SentryNonRecordingSpan,
startInactiveSpan,
timestampInSeconds,
} from '@sentry/core';
import type { Client, Event, Integration, SpanJSON, TransactionEvent } from '@sentry/types';
import { logger, timestampInSeconds } from '@sentry/utils';

import {
APP_START_COLD as APP_START_COLD_MEASUREMENT,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/tracing/integrations/nativeFrames.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger, timestampInSeconds } from '@sentry/core';
import type { Client, Event, Integration, Measurements, MeasurementUnit, Span } from '@sentry/types';
import { logger, timestampInSeconds } from '@sentry/utils';

import type { NativeFramesResponse } from '../../NativeRNSentry';
import { AsyncExpiringMap } from '../../utils/AsyncExpiringMap';
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/js/tracing/integrations/stalltracking.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable max-lines */
import { getRootSpan, spanToJSON } from '@sentry/core';
import { getRootSpan, logger, spanToJSON, timestampInSeconds } from '@sentry/core';
import type { Client, Integration, Measurements, MeasurementUnit, Span } from '@sentry/types';
import { logger, timestampInSeconds } from '@sentry/utils';
import type { AppStateStatus } from 'react-native';
import { AppState } from 'react-native';

Expand Down
10 changes: 8 additions & 2 deletions packages/core/src/js/tracing/integrations/userInteraction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { getActiveSpan, getClient, getCurrentScope, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON } from '@sentry/core';
import {
getActiveSpan,
getClient,
getCurrentScope,
logger,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
spanToJSON,
} from '@sentry/core';
import type { Integration, Span, StartSpanOptions } from '@sentry/types';
import { logger } from '@sentry/utils';

import type { ReactNativeClientOptions } from '../../options';
import { onlySampleIfChildSpans } from '../onSpanEndUtils';
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/js/tracing/onSpanEndUtils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getSpanDescendants, SPAN_STATUS_ERROR, spanToJSON } from '@sentry/core';
import { getSpanDescendants, logger, SPAN_STATUS_ERROR, spanToJSON } from '@sentry/core';
import type { Client, Span } from '@sentry/types';
import { logger } from '@sentry/utils';
import type { AppStateStatus } from 'react-native';
import { AppState } from 'react-native';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/js/tracing/reactnativeprofiler.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { timestampInSeconds } from '@sentry/core';
import { getClient, Profiler } from '@sentry/react';
import { timestampInSeconds } from '@sentry/utils';

import { createIntegration } from '../integrations/factory';
import { _captureAppStart, _setRootComponentCreationTimestampMs } from '../tracing/integrations/appStart';
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/js/tracing/reactnavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import {
addBreadcrumb,
getActiveSpan,
getClient,
isPlainObject,
logger,
SEMANTIC_ATTRIBUTE_SENTRY_OP,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SPAN_STATUS_OK,
spanToJSON,
startInactiveSpan,
timestampInSeconds,
} from '@sentry/core';
import type { Client, Integration, Span } from '@sentry/types';
import { isPlainObject, logger, timestampInSeconds } from '@sentry/utils';

import type { NewFrameEvent } from '../utils/sentryeventemitter';
import type { SentryEventEmitterFallback } from '../utils/sentryeventemitterfallback';
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/js/tracing/span.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {
generatePropagationContext,
getActiveSpan,
getClient,
getCurrentScope,
logger,
SEMANTIC_ATTRIBUTE_SENTRY_OP,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
SentryNonRecordingSpan,
Expand All @@ -10,7 +12,6 @@ import {
startIdleSpan as coreStartIdleSpan,
} from '@sentry/core';
import type { Client, Scope, Span, StartSpanOptions } from '@sentry/types';
import { generatePropagationContext, logger } from '@sentry/utils';

import { isRootSpan } from '../utils/span';
import { adjustTransactionDuration, cancelInBackground } from './onSpanEndUtils';
Expand Down
Loading

0 comments on commit 98fb43f

Please sign in to comment.