Skip to content
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

Moves the deprecated makeFifoCache implementation in the SDK #4353

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
- Bump Android SDK from v7.18.0 to v7.18.1 ([#4329](https://github.com/getsentry/sentry-react-native/pull/4329))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#7181)
- [diff](https://github.com/getsentry/sentry-java/compare/7.18.0...7.18.1)
- Bump JavaScript SDK from v8.40.0 to v8.41.0 ([#4351](https://github.com/getsentry/sentry-react-native/pull/4351))
- [changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#8410)
- [diff](https://github.com/getsentry/sentry-javascript/compare/8.40.0...8.41.0)

## 6.4.0-beta.1

Expand Down
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-beta.1",
"@sentry/utils": "8.40.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
17 changes: 8 additions & 9 deletions 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 Expand Up @@ -66,21 +66,20 @@
},
"dependencies": {
"@sentry/babel-plugin-component-annotate": "2.20.1",
"@sentry/browser": "8.40.0",
"@sentry/browser": "8.41.0",
"@sentry/cli": "2.39.1",
"@sentry/core": "8.40.0",
"@sentry/react": "8.40.0",
"@sentry/types": "8.40.0",
"@sentry/utils": "8.40.0"
"@sentry/core": "8.41.0",
"@sentry/react": "8.41.0",
"@sentry/types": "8.41.0"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@expo/metro-config": "0.19.5",
"@mswjs/interceptors": "^0.25.15",
"@react-native/babel-preset": "0.76.3",
"@sentry-internal/eslint-config-sdk": "8.40.0",
"@sentry-internal/eslint-plugin-sdk": "8.40.0",
"@sentry-internal/typescript": "8.40.0",
"@sentry-internal/eslint-config-sdk": "8.41.0",
"@sentry-internal/eslint-plugin-sdk": "8.41.0",
"@sentry-internal/typescript": "8.41.0",
"@sentry/wizard": "3.36.0",
"@testing-library/react-native": "^12.7.2",
"@types/jest": "^29.5.3",
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
71 changes: 69 additions & 2 deletions packages/core/src/js/profiling/cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,72 @@
import { makeFifoCache } from '@sentry/utils';

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

export const PROFILE_QUEUE = makeFifoCache<string, CombinedProfileEvent | AndroidCombinedProfileEvent>(20);

/**
* Creates a cache that evicts keys in fifo order
* @param size {Number}
*/
function makeFifoCache<Key extends string, Value>(
size: number,
): {
get: (key: Key) => Value | undefined;
add: (key: Key, value: Value) => void;
delete: (key: Key) => boolean;
clear: () => void;
size: () => number;
} {
// Maintain a fifo queue of keys, we cannot rely on Object.keys as the browser may not support it.
let evictionOrder: Key[] = [];
let cache: Record<string, Value> = {};

return {
add(key: Key, value: Value) {
while (evictionOrder.length >= size) {
// shift is O(n) but this is small size and only happens if we are
// exceeding the cache size so it should be fine.
const evictCandidate = evictionOrder.shift();

if (evictCandidate !== undefined) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete cache[evictCandidate];
}
}

// in case we have a collision, delete the old key.
if (cache[key]) {
this.delete(key);
}

evictionOrder.push(key);
cache[key] = value;
},
clear() {
cache = {};
evictionOrder = [];
},
get(key: Key): Value | undefined {
return cache[key];
},
size() {
return evictionOrder.length;
},
// Delete cache key and return true if it existed, false otherwise.
delete(key: Key): boolean {
if (!cache[key]) {
return false;
}

// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete cache[key];

for (let i = 0; i < evictionOrder.length; i++) {
if (evictionOrder[i] === key) {
evictionOrder.splice(i, 1);
break;
}
}

return true;
},
};
}
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
Loading
Loading