From 380b389033514d20842085b369007c0b6c6da9d9 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Tue, 25 Feb 2025 11:18:28 -0300 Subject: [PATCH 01/64] update migration numbers on changelog (#4594) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de2c93b5cb..4158e3a41f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ > [!IMPORTANT] -> If you are upgrading to the `6.x` versions of the Sentry React Native SDK from `5.x` or below, +> If you are upgrading to the `7.x` versions of the Sentry React Native SDK from `6.x` or below, > make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first. From 9ad6fb8a5f01941a42849b0ffd1fd6c9f541599c Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Mon, 10 Mar 2025 11:28:22 +0100 Subject: [PATCH 02/64] =?UTF-8?q?fix(appStart):=20Align=20span=C2=A0descri?= =?UTF-8?q?ption=20with=20other=20platforms=20(#4636)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 4 +++ .../src/js/tracing/integrations/appStart.ts | 2 +- .../tracing/integrations/appStart.test.ts | 36 +++++++++---------- .../tracing/reactnavigation.ttid.test.tsx | 6 ++-- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4158e3a41f..a4b903904e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,10 @@ To learn more about the available configuration options visit [the documentation](https://docs.sentry.io/platforms/react-native/manual-setup/expo/expo-sagp/). +### Changes + +Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](https://github.com/getsentry/sentry-react-native/pull/4636)) + ### Fixes - Various crashes and issues of Session Replay on Android. See the Android SDK version bump for more details. ([#4529](https://github.com/getsentry/sentry-react-native/pull/4529)) diff --git a/packages/core/src/js/tracing/integrations/appStart.ts b/packages/core/src/js/tracing/integrations/appStart.ts index 0f96557d4c..f6b31cfd05 100644 --- a/packages/core/src/js/tracing/integrations/appStart.ts +++ b/packages/core/src/js/tracing/integrations/appStart.ts @@ -295,7 +295,7 @@ export const appStartIntegration = ({ const op = appStart.type === 'cold' ? APP_START_COLD_OP : APP_START_WARM_OP; const appStartSpanJSON: SpanJSON = createSpanJSON({ op, - description: appStart.type === 'cold' ? 'Cold App Start' : 'Warm App Start', + description: appStart.type === 'cold' ? 'Cold Start' : 'Warm Start', start_timestamp: appStartTimestampSeconds, timestamp: appStartEndTimestampSeconds, trace_id: event.contexts.trace.trace_id, diff --git a/packages/core/test/tracing/integrations/appStart.test.ts b/packages/core/test/tracing/integrations/appStart.test.ts index 4337e3e2b3..37870481f2 100644 --- a/packages/core/test/tracing/integrations/appStart.test.ts +++ b/packages/core/test/tracing/integrations/appStart.test.ts @@ -151,7 +151,7 @@ describe('App Start Integration', () => { const actualEvent = await captureStandAloneAppStart(); - const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold App Start'); + const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold Start'); const bundleStartSpan = actualEvent!.spans!.find( ({ description }) => description === 'JS Bundle Execution Start', ); @@ -159,7 +159,7 @@ describe('App Start Integration', () => { expect(appStartRootSpan).toEqual( expect.objectContaining(>{ span_id: expect.any(String), - description: 'Cold App Start', + description: 'Cold Start', op: APP_START_COLD_OP, data: { [SEMANTIC_ATTRIBUTE_SENTRY_OP]: APP_START_COLD_OP, @@ -189,7 +189,7 @@ describe('App Start Integration', () => { const actualEvent = await captureStandAloneAppStart(); - const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold App Start'); + const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold Start'); const bundleStartSpan = actualEvent!.spans!.find( ({ description }) => description === 'JS Bundle Execution Before React Root', ); @@ -197,7 +197,7 @@ describe('App Start Integration', () => { expect(appStartRootSpan).toEqual( expect.objectContaining(>{ span_id: expect.any(String), - description: 'Cold App Start', + description: 'Cold Start', op: APP_START_COLD_OP, data: { [SEMANTIC_ATTRIBUTE_SENTRY_OP]: APP_START_COLD_OP, @@ -228,13 +228,13 @@ describe('App Start Integration', () => { const actualEvent = await captureStandAloneAppStart(); - const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold App Start'); + const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold Start'); const nativeSpan = actualEvent!.spans!.find(({ description }) => description === 'test native app start span'); expect(appStartRootSpan).toEqual( expect.objectContaining(>{ span_id: expect.any(String), - description: 'Cold App Start', + description: 'Cold Start', op: APP_START_COLD_OP, data: { [SEMANTIC_ATTRIBUTE_SENTRY_OP]: APP_START_COLD_OP, @@ -465,14 +465,14 @@ describe('App Start Integration', () => { const actualEvent = await processEvent(getMinimalTransactionEvent()); - const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold App Start'); + const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold Start'); const bundleStartSpan = actualEvent!.spans!.find( ({ description }) => description === 'JS Bundle Execution Start', ); expect(appStartRootSpan).toEqual( expect.objectContaining(>{ - description: 'Cold App Start', + description: 'Cold Start', span_id: expect.any(String), op: APP_START_COLD_OP, origin: SPAN_ORIGIN_AUTO_APP_START, @@ -505,14 +505,14 @@ describe('App Start Integration', () => { const actualEvent = await processEvent(getMinimalTransactionEvent()); - const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold App Start'); + const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold Start'); const bundleStartSpan = actualEvent!.spans!.find( ({ description }) => description === 'JS Bundle Execution Before React Root', ); expect(appStartRootSpan).toEqual( expect.objectContaining(>{ - description: 'Cold App Start', + description: 'Cold Start', span_id: expect.any(String), op: APP_START_COLD_OP, origin: SPAN_ORIGIN_AUTO_APP_START, @@ -545,14 +545,14 @@ describe('App Start Integration', () => { const actualEvent = await processEvent(getMinimalTransactionEvent()); - const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold App Start'); + const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold Start'); const bundleStartSpan = actualEvent!.spans!.find( ({ description }) => description === 'JS Bundle Execution Before React Root', ); expect(appStartRootSpan).toEqual( expect.objectContaining(>{ - description: 'Cold App Start', + description: 'Cold Start', span_id: expect.any(String), op: APP_START_COLD_OP, origin: SPAN_ORIGIN_AUTO_APP_START, @@ -586,12 +586,12 @@ describe('App Start Integration', () => { const actualEvent = await processEvent(getMinimalTransactionEvent()); - const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold App Start'); + const appStartRootSpan = actualEvent!.spans!.find(({ description }) => description === 'Cold Start'); const nativeSpan = actualEvent!.spans!.find(({ description }) => description === 'test native app start span'); expect(appStartRootSpan).toEqual( expect.objectContaining(>{ - description: 'Cold App Start', + description: 'Cold Start', span_id: expect.any(String), op: APP_START_COLD_OP, origin: SPAN_ORIGIN_AUTO_APP_START, @@ -802,7 +802,7 @@ function expectEventWithAttachedColdAppStart({ spans: expect.arrayContaining([ { op: APP_START_COLD_OP, - description: 'Cold App Start', + description: 'Cold Start', start_timestamp: appStartTimeMilliseconds / 1000, timestamp: expect.any(Number), trace_id: expect.any(String), @@ -856,7 +856,7 @@ function expectEventWithAttachedWarmAppStart({ spans: expect.arrayContaining([ { op: APP_START_WARM_OP, - description: 'Warm App Start', + description: 'Warm Start', start_timestamp: appStartTimeMilliseconds / 1000, timestamp: expect.any(Number), trace_id: expect.any(String), @@ -913,7 +913,7 @@ function expectEventWithStandaloneColdAppStart( spans: expect.arrayContaining([ { op: APP_START_COLD_OP, - description: 'Cold App Start', + description: 'Cold Start', start_timestamp: appStartTimeMilliseconds / 1000, timestamp: expect.any(Number), trace_id: expect.any(String), @@ -962,7 +962,7 @@ function expectEventWithStandaloneWarmAppStart( spans: expect.arrayContaining([ { op: APP_START_WARM_OP, - description: 'Warm App Start', + description: 'Warm Start', start_timestamp: appStartTimeMilliseconds / 1000, timestamp: expect.any(Number), trace_id: expect.any(String), diff --git a/packages/core/test/tracing/reactnavigation.ttid.test.tsx b/packages/core/test/tracing/reactnavigation.ttid.test.tsx index a0245cff12..f66b484b78 100644 --- a/packages/core/test/tracing/reactnavigation.ttid.test.tsx +++ b/packages/core/test/tracing/reactnavigation.ttid.test.tsx @@ -255,7 +255,7 @@ describe('React Navigation - TTID', () => { type: 'transaction', spans: expect.arrayContaining([ expect.objectContaining>({ - description: 'Cold App Start', + description: 'Cold Start', }), expect.objectContaining>({ data: { @@ -289,7 +289,7 @@ describe('React Navigation - TTID', () => { type: 'transaction', spans: expect.arrayContaining([ expect.objectContaining>({ - description: 'Cold App Start', + description: 'Cold Start', }), expect.objectContaining>({ data: { @@ -319,7 +319,7 @@ describe('React Navigation - TTID', () => { type: 'transaction', spans: expect.arrayContaining([ expect.objectContaining>({ - description: 'Cold App Start', + description: 'Cold Start', }), ]), measurements: expect.objectContaining['measurements']>({ From f5a43d3ce122f0485f6d9959d40b8a15295dde96 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Thu, 13 Mar 2025 12:25:24 +0200 Subject: [PATCH 03/64] chore(deps): Bump Android SDK to v8.3.0 (#4490) --- CHANGELOG.md | 6 ++--- packages/core/android/build.gradle | 2 +- .../io/sentry/react/RNSentryModuleImpl.java | 25 ++++++++----------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4b903904e..cb2c373d86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,9 +38,9 @@ Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](http ### Dependencies -- Bump Android SDK from v7.20.1 to v7.22.0 ([#4529](https://github.com/getsentry/sentry-react-native/pull/4529)) - - [changelog](https://github.com/getsentry/sentry-java/blob/7.x.x/CHANGELOG.md#7220) - - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...7.22.0) +- Bump Android SDK from v7.20.1 to v8.3.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490)) + - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#830) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.3.0) - Bump Cocoa SDK from v8.44.0 to v8.45.0 ([#4537](https://github.com/getsentry/sentry-react-native/pull/4537)) - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8450) - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.44.0...8.45.0) diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index c96506fb3c..13d61a054b 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -54,5 +54,5 @@ android { dependencies { implementation 'com.facebook.react:react-native:+' - api 'io.sentry:sentry-android:7.22.0' + api 'io.sentry:sentry-android:8.3.0' } diff --git a/packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java b/packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java index 486ae72c48..0b626b3188 100644 --- a/packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +++ b/packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java @@ -29,12 +29,12 @@ import com.facebook.react.common.JavascriptException; import com.facebook.react.modules.core.DeviceEventManagerModule; import io.sentry.Breadcrumb; -import io.sentry.HubAdapter; import io.sentry.ILogger; import io.sentry.IScope; import io.sentry.ISentryExecutorService; import io.sentry.ISerializer; import io.sentry.Integration; +import io.sentry.ScopesAdapter; import io.sentry.Sentry; import io.sentry.SentryDate; import io.sentry.SentryDateProvider; @@ -85,6 +85,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.concurrent.CountDownLatch; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -505,7 +506,7 @@ public void fetchNativeFrames(Promise promise) { } public void captureReplay(boolean isHardCrash, Promise promise) { - Sentry.getCurrentHub().getOptions().getReplayController().captureReplay(isHardCrash); + Sentry.getCurrentScopes().getOptions().getReplayController().captureReplay(isHardCrash); promise.resolve(getCurrentReplayId()); } @@ -601,7 +602,7 @@ public void fetchViewHierarchy(Promise promise) { return; } - ISerializer serializer = HubAdapter.getInstance().getOptions().getSerializer(); + ISerializer serializer = ScopesAdapter.getInstance().getOptions().getSerializer(); final @Nullable byte[] bytes = JsonSerializationUtils.bytesFrom(serializer, logger, viewHierarchy); if (bytes == null) { @@ -655,10 +656,6 @@ public void setUser(final ReadableMap userKeys, final ReadableMap userDataKeys) if (userKeys.hasKey("ip_address")) { userInstance.setIpAddress(userKeys.getString("ip_address")); } - - if (userKeys.hasKey("segment")) { - userInstance.setSegment(userKeys.getString("segment")); - } } if (userDataKeys != null) { @@ -807,8 +804,7 @@ private void initializeAndroidProfiler() { (int) SECONDS.toMicros(1) / profilingTracesHz, new SentryFrameMetricsCollector(reactApplicationContext, logger, buildInfo), executorService, - logger, - buildInfo); + logger); } public WritableMap startProfiling(boolean platformProfilers) { @@ -832,7 +828,7 @@ public WritableMap startProfiling(boolean platformProfilers) { } public WritableMap stopProfiling() { - final boolean isDebug = HubAdapter.getInstance().getOptions().isDebug(); + final boolean isDebug = ScopesAdapter.getInstance().getOptions().isDebug(); final WritableMap result = new WritableNativeMap(); File output = null; try { @@ -918,7 +914,7 @@ private String readStringFromFile(File path) throws IOException { } public void fetchNativeDeviceContexts(Promise promise) { - final @NotNull SentryOptions options = HubAdapter.getInstance().getOptions(); + final @NotNull SentryOptions options = ScopesAdapter.getInstance().getOptions(); final @Nullable Context context = this.getReactApplicationContext().getApplicationContext(); final @Nullable IScope currentScope = InternalSentrySdk.getCurrentScope(); fetchNativeDeviceContexts(promise, options, context, currentScope); @@ -955,7 +951,8 @@ protected void fetchNativeDeviceContexts( } public void fetchNativeSdkInfo(Promise promise) { - final @Nullable SdkVersion sdkVersion = HubAdapter.getInstance().getOptions().getSdkVersion(); + final @Nullable SdkVersion sdkVersion = + ScopesAdapter.getInstance().getOptions().getSdkVersion(); if (sdkVersion == null) { promise.resolve(null); } else { @@ -1001,14 +998,14 @@ private void addPackages(SentryEvent event, SdkVersion sdk) { if (eventSdk != null && "sentry.javascript.react-native".equals(eventSdk.getName()) && sdk != null) { - List sentryPackages = sdk.getPackages(); + Set sentryPackages = sdk.getPackageSet(); if (sentryPackages != null) { for (SentryPackage sentryPackage : sentryPackages) { eventSdk.addPackage(sentryPackage.getName(), sentryPackage.getVersion()); } } - List integrations = sdk.getIntegrations(); + Set integrations = sdk.getIntegrationSet(); if (integrations != null) { for (String integration : integrations) { eventSdk.addIntegration(integration); From 6eaf70fe404a76333176b874f12a67f0ab780c0d Mon Sep 17 00:00:00 2001 From: LucasZF Date: Tue, 15 Apr 2025 05:26:23 -0300 Subject: [PATCH 04/64] feat: Bump to Sentry Javascript V9 (#4568) * bump SDKs * bump SDKs * fix build * fix tests * fix tests * fix lint errors * test ts 5.0 * rollback * fix merge conflict with yarn * fix new lint issue * sync yarn.lock with V7 branch and install new packages * ensure we are using the JS version from the default node resolution * update changelog with javascript version bump * fix check type (#4587) * add major changes to the SDK * fix lint * review check: fix changelog PR number / Fix wrapper incorrect null check / removed comment from rnerror handler / removed comment from span / fix test from userInteraction * fix incorrect cli version * fix lint * remove shutdowntimeout from android / use newer wizard version * rollback feedback test change, rollback jest version, fix safe test * return shutdowntimeout * explain tracing sample rate * fix tracing extension test * lint fix * update changelog * fix yarn lock merge/ fix ts-jest version no longer exists / fix core version on samples and e2e * fix lint on addTimeToInitialDisplay * fix issue with UIManager test * moved major changes to the correct spot --- CHANGELOG.md | 42 ++++ dev-packages/e2e-tests/package.json | 2 +- dev-packages/type-check/ts3.8-test/index.ts | 3 + packages/core/package.json | 19 +- packages/core/plugin/src/withSentry.ts | 2 +- .../src/withSentryAndroidGradlePlugin.ts | 2 +- packages/core/src/js/index.ts | 2 - .../src/js/integrations/debugsymbolicator.ts | 2 +- packages/core/src/js/integrations/default.ts | 5 +- .../src/js/integrations/nativelinkederrors.ts | 6 +- .../integrations/reactnativeerrorhandlers.ts | 5 +- .../core/src/js/integrations/screenshot.ts | 4 +- .../core/src/js/integrations/spotlight.ts | 2 +- .../core/src/js/integrations/viewhierarchy.ts | 2 +- packages/core/src/js/options.ts | 8 + .../src/js/profiling/convertHermesProfile.ts | 2 +- packages/core/src/js/profiling/integration.ts | 2 +- packages/core/src/js/profiling/utils.ts | 44 ++-- packages/core/src/js/replay/CustomMask.tsx | 2 +- packages/core/src/js/replay/mobilereplay.ts | 2 +- packages/core/src/js/sdk.tsx | 1 + packages/core/src/js/tools/metroconfig.ts | 6 +- .../src/js/tracing/integrations/appStart.ts | 2 +- .../integrations/timeToDisplayIntegration.ts | 8 +- .../core/src/js/tracing/onSpanEndUtils.ts | 2 +- .../src/js/tracing/reactnativenavigation.ts | 2 +- .../src/js/tracing/reactnativeprofiler.tsx | 3 +- .../core/src/js/tracing/reactnavigation.ts | 2 +- packages/core/src/js/tracing/span.ts | 4 +- .../core/src/js/transports/encodePolyfill.ts | 4 +- .../core/src/js/utils/AsyncExpiringMap.ts | 2 +- packages/core/src/js/utils/envelope.ts | 13 +- packages/core/src/js/utils/environment.ts | 11 +- packages/core/src/js/utils/expomodules.ts | 6 +- packages/core/src/js/wrapper.ts | 2 +- packages/core/test/feedback.test.ts | 21 +- packages/core/test/mocks/client.ts | 2 +- .../core/test/profiling/integration.test.ts | 4 +- .../test/tracing/addTracingExtensions.test.ts | 14 +- .../tracing/integrations/appStart.test.ts | 3 + .../integrations/userInteraction.test.ts | 21 +- .../tracing/reactnavigation.ttid.test.tsx | 2 +- .../tracing/timetodisplaynative.web.test.tsx | 3 + packages/core/test/utils/safe.test.ts | 31 ++- samples/react-native-macos/package.json | 4 +- samples/react-native/package.json | 4 +- yarn.lock | 212 ++++++++++-------- 47 files changed, 319 insertions(+), 228 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4e60dd573..2ccf2dc231 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ ## Unreleased +### Upgrading from 6.x to 7.0 + +Version 7 of the Sentry React Native SDK primarily introduces API cleanup and version support changes. This update contains behavioral changes that will not be caught by type checkers, linters, or tests, so we recommend carefully reading through the entire migration guide instead of relying on automatic tooling. + +Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or higher (unchanged from v6). Lower versions may continue to work, but may not support all features. + ### Dependencies - Bump Bundler Plugins from v3.2.2 to v3.2.4 ([#4693](https://github.com/getsentry/sentry-react-native/pull/4693), [#4707](https://github.com/getsentry/sentry-react-native/pull/4707)) @@ -17,6 +23,39 @@ - [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2430) - [diff](https://github.com/getsentry/sentry-cli/compare/2.42.4...2.43.0) +### Major Changes + +- `ip addresses` is only collected when `sendDefaultPii`: `true` +- Exceptions from `captureConsoleIntegration` are now marked as handled: true by default +- `shutdownTimeout` moved from `core` to `@sentry/react-native` +- `hasTracingEnabled` was renamed to `hasSpansEnabled` +- You can no longer drop spans or return null on `beforeSendSpan` hook + +### Removed types + +- TransactionNamingScheme +- Request +- Scope (prefer using the Scope class) + +### Other removed items. + +- `autoSessionTracking` from options. + To enable session tracking, ensure that `enableAutoSessionTracking` is enabled. + +- `enableTracing`. Instead, set `tracesSampleRate` to a value greater than `zero` to `enable tracing`, `0` to keep tracing integrations active without sampling, or `undefined` to disable the performance integration. + +- `getCurrentHub()`, `Hub`, and `getCurrentHubShim()` +- `spanId` from propagation `context` +- metrics API +- `transactionContext` from `samplingContext` +- `@sentry/utils` package, the exports were moved to `@sentry/core` +- Standalone `Client` interface & deprecate `BaseClient` + +## Other Changes + +- Fork `scope` if custom scope is passed to `startSpanManual` or `startSpan` + + ## 6.11.0-beta.0 ### Features @@ -186,6 +225,9 @@ Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](http ### Dependencies +- Bump JavaScript SDK from v8.54.0 to v9.1.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568)) + - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.1.0/CHANGELOG.md) + - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.1.0) - Bump Android SDK from v7.20.1 to v8.3.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490)) - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#830) - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.3.0) diff --git a/dev-packages/e2e-tests/package.json b/dev-packages/e2e-tests/package.json index 69ceadf907..1be91abf60 100644 --- a/dev-packages/e2e-tests/package.json +++ b/dev-packages/e2e-tests/package.json @@ -13,7 +13,7 @@ "devDependencies": { "@babel/preset-env": "^7.25.3", "@babel/preset-typescript": "^7.18.6", - "@sentry/core": "8.54.0", + "@sentry/core": "9.1.0", "@sentry/react-native": "6.11.0-beta.0", "@types/node": "^20.9.3", "@types/react": "^18.2.64", diff --git a/dev-packages/type-check/ts3.8-test/index.ts b/dev-packages/type-check/ts3.8-test/index.ts index 1e9fda3cd2..94e332746c 100644 --- a/dev-packages/type-check/ts3.8-test/index.ts +++ b/dev-packages/type-check/ts3.8-test/index.ts @@ -3,6 +3,8 @@ declare global { interface IDBObjectStore {} interface Window { fetch: any; + setTimeout: any; + document: any; } interface ShadowRoot {} interface BufferSource {} @@ -19,6 +21,7 @@ declare global { redirectCount: number; } interface PerformanceEntry {} + interface Performance {} } declare module 'react-native' { diff --git a/packages/core/package.json b/packages/core/package.json index 92901958ef..b95acdec6e 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -65,22 +65,21 @@ "react-native": ">=0.65.0" }, "dependencies": { - "@sentry/babel-plugin-component-annotate": "3.2.4", - "@sentry/browser": "8.54.0", + "@sentry/babel-plugin-component-annotate": "3.1.2", + "@sentry/browser": "9.1.0", "@sentry/cli": "2.43.0", - "@sentry/core": "8.54.0", - "@sentry/react": "8.54.0", - "@sentry/types": "8.54.0", - "@sentry/utils": "8.54.0" + "@sentry/core": "9.1.0", + "@sentry/react": "9.1.0", + "@sentry/types": "9.1.0" }, "devDependencies": { "@babel/core": "^7.25.2", "@expo/metro-config": "0.19.5", "@mswjs/interceptors": "^0.25.15", "@react-native/babel-preset": "0.77.1", - "@sentry-internal/eslint-config-sdk": "8.54.0", - "@sentry-internal/eslint-plugin-sdk": "8.54.0", - "@sentry-internal/typescript": "8.54.0", + "@sentry-internal/eslint-config-sdk": "9.1.0", + "@sentry-internal/eslint-plugin-sdk": "9.1.0", + "@sentry-internal/typescript": "9.1.0", "@sentry/wizard": "4.6.0", "@testing-library/react-native": "^12.7.2", "@types/jest": "^29.5.13", @@ -110,7 +109,7 @@ "react-native": "0.77.1", "react-test-renderer": "^18.3.1", "rimraf": "^4.1.1", - "ts-jest": "^29.1.1", + "ts-jest": "^29.3.1", "typescript": "4.9.5", "uglify-js": "^3.17.4", "uuid": "^9.0.1", diff --git a/packages/core/plugin/src/withSentry.ts b/packages/core/plugin/src/withSentry.ts index 70d4c8932b..332957e871 100644 --- a/packages/core/plugin/src/withSentry.ts +++ b/packages/core/plugin/src/withSentry.ts @@ -18,7 +18,7 @@ interface PluginProps { const withSentryPlugin: ConfigPlugin = (config, props) => { const sentryProperties = getSentryProperties(props); - if (props && props.authToken) { + if (props?.authToken) { // If not removed, the plugin config with the authToken will be written to the application package delete props.authToken; } diff --git a/packages/core/plugin/src/withSentryAndroidGradlePlugin.ts b/packages/core/plugin/src/withSentryAndroidGradlePlugin.ts index 27a9a4d904..3154f25aad 100644 --- a/packages/core/plugin/src/withSentryAndroidGradlePlugin.ts +++ b/packages/core/plugin/src/withSentryAndroidGradlePlugin.ts @@ -35,7 +35,7 @@ export function withSentryAndroidGradlePlugin( const withSentryProjectBuildGradle = (config: any): any => { return withProjectBuildGradle(config, (projectBuildGradle: any) => { // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - if (!projectBuildGradle.modResults || !projectBuildGradle.modResults.contents) { + if (!projectBuildGradle.modResults?.contents) { warnOnce('android/build.gradle content is missing or undefined.'); return config; } diff --git a/packages/core/src/js/index.ts b/packages/core/src/js/index.ts index 3aa2bdb71d..fb931312d9 100644 --- a/packages/core/src/js/index.ts +++ b/packages/core/src/js/index.ts @@ -1,6 +1,5 @@ export type { Breadcrumb, - Request, SdkInfo, Event, Exception, @@ -43,7 +42,6 @@ export { getClient, setCurrentClient, addEventProcessor, - metricsDefault as metrics, lastEventId, } from '@sentry/core'; diff --git a/packages/core/src/js/integrations/debugsymbolicator.ts b/packages/core/src/js/integrations/debugsymbolicator.ts index 8529d0eeb6..3ff5bc5169 100644 --- a/packages/core/src/js/integrations/debugsymbolicator.ts +++ b/packages/core/src/js/integrations/debugsymbolicator.ts @@ -143,7 +143,7 @@ function replaceExceptionFramesInException(exception: Exception, frames: SentryS * @param frames StackFrame[] */ function replaceThreadFramesInEvent(event: Event, frames: SentryStackFrame[]): void { - if (event.threads && event.threads.values && event.threads.values[0] && event.threads.values[0].stacktrace) { + if (event.threads?.values?.[0]?.stacktrace) { event.threads.values[0].stacktrace.frames = frames.reverse(); } } diff --git a/packages/core/src/js/integrations/default.ts b/packages/core/src/js/integrations/default.ts index 54b4065ee5..1fbfa987e9 100644 --- a/packages/core/src/js/integrations/default.ts +++ b/packages/core/src/js/integrations/default.ts @@ -93,10 +93,7 @@ export function getDefaultIntegrations(options: ReactNativeClientOptions): Integ // hasTracingEnabled from `@sentry/core` only check if tracesSampler or tracesSampleRate keys are present // that's different from prev imp here and might lead misconfiguration // `tracesSampleRate: undefined` should not enable tracing - const hasTracingEnabled = - options.enableTracing || - typeof options.tracesSampleRate === 'number' || - typeof options.tracesSampler === 'function'; + const hasTracingEnabled = typeof options.tracesSampleRate === 'number' || typeof options.tracesSampler === 'function'; if (hasTracingEnabled && options.enableAppStartTracking) { integrations.push(appStartIntegration()); } diff --git a/packages/core/src/js/integrations/nativelinkederrors.ts b/packages/core/src/js/integrations/nativelinkederrors.ts index 39d8d55879..d920cc8a55 100644 --- a/packages/core/src/js/integrations/nativelinkederrors.ts +++ b/packages/core/src/js/integrations/nativelinkederrors.ts @@ -43,7 +43,7 @@ export const nativeLinkedErrorsIntegration = (options: Partial { @@ -155,7 +156,7 @@ function setupErrorUtilsGlobalHandler(): void { return; } - void client.flush(client.getOptions().shutdownTimeout || 2000).then( + void client.flush((client.getOptions() as ReactNativeClientOptions).shutdownTimeout || 2000).then( () => { defaultHandler(error, isFatal); }, diff --git a/packages/core/src/js/integrations/screenshot.ts b/packages/core/src/js/integrations/screenshot.ts index 6f504fa76e..84bb72c2b4 100644 --- a/packages/core/src/js/integrations/screenshot.ts +++ b/packages/core/src/js/integrations/screenshot.ts @@ -18,13 +18,13 @@ export const screenshotIntegration = (): Integration => { }; async function processEvent(event: Event, hint: EventHint, client: ReactNativeClient): Promise { - const hasException = event.exception && event.exception.values && event.exception.values.length > 0; + const hasException = event.exception?.values?.length > 0; if (!hasException || client.getOptions().beforeScreenshot?.(event, hint) === false) { return event; } const screenshots: ScreenshotAttachment[] | null = await NATIVE.captureScreenshot(); - if (screenshots && screenshots.length > 0) { + if (screenshots?.length > 0) { hint.attachments = [...screenshots, ...(hint?.attachments || [])]; } diff --git a/packages/core/src/js/integrations/spotlight.ts b/packages/core/src/js/integrations/spotlight.ts index b4f62e06da..50191aa132 100644 --- a/packages/core/src/js/integrations/spotlight.ts +++ b/packages/core/src/js/integrations/spotlight.ts @@ -103,7 +103,7 @@ function getHostnameFromString(urlString: string): string | null { const regex = /^(?:\w+:)?\/\/([^/:]+)(:\d+)?(.*)$/; const matches = urlString.match(regex); - if (matches && matches[1]) { + if (matches?.[1]) { return matches[1]; } else { // Invalid URL format diff --git a/packages/core/src/js/integrations/viewhierarchy.ts b/packages/core/src/js/integrations/viewhierarchy.ts index 9b84ece273..d4d4530b15 100644 --- a/packages/core/src/js/integrations/viewhierarchy.ts +++ b/packages/core/src/js/integrations/viewhierarchy.ts @@ -21,7 +21,7 @@ export const viewHierarchyIntegration = (): Integration => { }; async function processEvent(event: Event, hint: EventHint): Promise { - const hasException = event.exception && event.exception.values && event.exception.values.length > 0; + const hasException = event.exception?.values?.length > 0; if (!hasException) { return event; } diff --git a/packages/core/src/js/options.ts b/packages/core/src/js/options.ts index a95de6df4c..14cc743fc2 100644 --- a/packages/core/src/js/options.ts +++ b/packages/core/src/js/options.ts @@ -234,6 +234,14 @@ export interface BaseReactNativeOptions { */ replaysOnErrorSampleRate?: number; + /** + * Controls how many milliseconds to wait before shutting down. The default is 2 seconds. Setting this too low can cause + * problems for sending events from command line applications. Setting it too + * high can cause the application to block for users with network connectivity + * problems. + */ + shutdownTimeout?: number; + /** * Options which are in beta, or otherwise not guaranteed to be stable. */ diff --git a/packages/core/src/js/profiling/convertHermesProfile.ts b/packages/core/src/js/profiling/convertHermesProfile.ts index 39ed9ac752..6db66dd6d5 100644 --- a/packages/core/src/js/profiling/convertHermesProfile.ts +++ b/packages/core/src/js/profiling/convertHermesProfile.ts @@ -163,7 +163,7 @@ function mapStacks( while (currentHermesFrameId !== undefined) { const sentryFrameId = hermesStackFrameIdToSentryFrameIdMap.get(currentHermesFrameId); sentryFrameId !== undefined && stack.push(sentryFrameId); - currentHermesFrameId = hermesStackFrames[currentHermesFrameId] && hermesStackFrames[currentHermesFrameId].parent; + currentHermesFrameId = hermesStackFrames[currentHermesFrameId]?.parent; } stacks.push(stack); } diff --git a/packages/core/src/js/profiling/integration.ts b/packages/core/src/js/profiling/integration.ts index e2e4134fe6..803c116073 100644 --- a/packages/core/src/js/profiling/integration.ts +++ b/packages/core/src/js/profiling/integration.ts @@ -128,7 +128,7 @@ export const hermesProfilingIntegration = (initOptions: HermesProfilingOptions = } const client = getClient(); - const options = client && client.getOptions(); + const options = client?.getOptions?.(); const profilesSampleRate = options && typeof options.profilesSampleRate === 'number' ? options.profilesSampleRate : undefined; diff --git a/packages/core/src/js/profiling/utils.ts b/packages/core/src/js/profiling/utils.ts index c83342b50b..5c6d996e83 100644 --- a/packages/core/src/js/profiling/utils.ts +++ b/packages/core/src/js/profiling/utils.ts @@ -75,12 +75,12 @@ export function enrichCombinedProfileWithEventContext( return null; } - const trace_id = (event.contexts && event.contexts.trace && event.contexts.trace.trace_id) || ''; + const trace_id = event.contexts?.trace?.trace_id || ''; // Log a warning if the profile has an invalid traceId (should be uuidv4). // All profiles and transactions are rejected if this is the case and we want to // warn users that this is happening if they enable debug flag - if (trace_id && trace_id.length !== 32) { + if (trace_id?.length !== 32) { if (__DEV__) { logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`); } @@ -97,25 +97,25 @@ export function enrichCombinedProfileWithEventContext( release: event.release || '', environment: event.environment || getDefaultEnvironment(), os: { - name: (event.contexts && event.contexts.os && event.contexts.os.name) || '', - version: (event.contexts && event.contexts.os && event.contexts.os.version) || '', - build_number: (event.contexts && event.contexts.os && event.contexts.os.build) || '', + name: event.contexts?.os?.name || '', + version: event.contexts?.os?.version || '', + build_number: event.contexts?.os?.build || '', }, device: { - locale: (event.contexts && event.contexts.device && (event.contexts.device.locale as string)) || '', - model: (event.contexts && event.contexts.device && event.contexts.device.model) || '', - manufacturer: (event.contexts && event.contexts.device && event.contexts.device.manufacturer) || '', - architecture: (event.contexts && event.contexts.device && event.contexts.device.arch) || '', - is_emulator: (event.contexts && event.contexts.device && event.contexts.device.simulator) || false, + locale: (event.contexts?.device && (event.contexts.device.locale as string)) || '', + model: event.contexts?.device?.model || '', + manufacturer: event.contexts?.device?.manufacturer || '', + architecture: event.contexts?.device?.arch || '', + is_emulator: event.contexts?.device?.simulator || false, }, transaction: { name: event.transaction || '', id: event.event_id || '', trace_id, - active_thread_id: (profile.transaction && profile.transaction.active_thread_id) || '', + active_thread_id: profile.transaction?.active_thread_id || '', }, debug_meta: { - images: [...getDebugMetadata(), ...((profile.debug_meta && profile.debug_meta.images) || [])], + images: [...getDebugMetadata(), ...(profile.debug_meta?.images || [])], }, }; } @@ -136,19 +136,15 @@ export function enrichAndroidProfileWithEventContext( build_id: profile.build_id || '', device_cpu_frequencies: [], - device_is_emulator: (event.contexts && event.contexts.device && event.contexts.device.simulator) || false, - device_locale: (event.contexts && event.contexts.device && (event.contexts.device.locale as string)) || '', - device_manufacturer: (event.contexts && event.contexts.device && event.contexts.device.manufacturer) || '', - device_model: (event.contexts && event.contexts.device && event.contexts.device.model) || '', - device_os_name: (event.contexts && event.contexts.os && event.contexts.os.name) || '', - device_os_version: (event.contexts && event.contexts.os && event.contexts.os.version) || '', + device_is_emulator: event.contexts?.device?.simulator || false, + device_locale: (event.contexts?.device && (event.contexts.device.locale as string)) || '', + device_manufacturer: event.contexts?.device?.manufacturer || '', + device_model: event.contexts?.device?.model || '', + device_os_name: event.contexts?.os?.name || '', + device_os_version: event.contexts?.os?.version || '', device_physical_memory_bytes: - (event.contexts && - event.contexts.device && - event.contexts.device.memory_size && - Number(event.contexts.device.memory_size).toString(10)) || - '', + (event.contexts?.device?.memory_size && Number(event.contexts.device.memory_size).toString(10)) || '', environment: event.environment || getDefaultEnvironment(), @@ -161,7 +157,7 @@ export function enrichAndroidProfileWithEventContext( transaction_id: event.event_id || '', transaction_name: event.transaction || '', - trace_id: (event.contexts && event.contexts.trace && event.contexts.trace.trace_id) || '', + trace_id: event.contexts?.trace?.trace_id || '', version_name: event.release || '', version_code: event.dist || '', diff --git a/packages/core/src/js/replay/CustomMask.tsx b/packages/core/src/js/replay/CustomMask.tsx index 4608dfbe04..7d84ec1b8c 100644 --- a/packages/core/src/js/replay/CustomMask.tsx +++ b/packages/core/src/js/replay/CustomMask.tsx @@ -34,7 +34,7 @@ const UnmaskFallback = (viewProps: ViewProps): React.ReactElement => { return ; }; -const hasViewManagerConfig = (nativeComponentName: string): boolean => UIManager.hasViewManagerConfig && UIManager.hasViewManagerConfig(nativeComponentName); +const hasViewManagerConfig = (nativeComponentName: string): boolean => UIManager.hasViewManagerConfig?.(nativeComponentName); const Mask = ((): HostComponent | React.ComponentType => { if (isExpoGo() || !hasViewManagerConfig(MaskNativeComponentName)) { diff --git a/packages/core/src/js/replay/mobilereplay.ts b/packages/core/src/js/replay/mobilereplay.ts index 4bdfdd7955..d0db1810f4 100644 --- a/packages/core/src/js/replay/mobilereplay.ts +++ b/packages/core/src/js/replay/mobilereplay.ts @@ -103,7 +103,7 @@ export const mobileReplayIntegration = (initOptions: MobileReplayOptions = defau const options = { ...defaultOptions, ...initOptions }; async function processEvent(event: Event): Promise { - const hasException = event.exception && event.exception.values && event.exception.values.length > 0; + const hasException = event.exception?.values?.length > 0; if (!hasException) { // Event is not an error, will not capture replay return event; diff --git a/packages/core/src/js/sdk.tsx b/packages/core/src/js/sdk.tsx index 5edba50b48..dd6a176322 100644 --- a/packages/core/src/js/sdk.tsx +++ b/packages/core/src/js/sdk.tsx @@ -158,6 +158,7 @@ export function wrap

>( const profilerProps = { ...(options?.profilerProps ?? {}), name: RootComponent.displayName ?? 'Root', + updateProps: {} }; const RootApp: React.FC

= (appProps) => { diff --git a/packages/core/src/js/tools/metroconfig.ts b/packages/core/src/js/tools/metroconfig.ts index e3c71b684f..73c9445b40 100644 --- a/packages/core/src/js/tools/metroconfig.ts +++ b/packages/core/src/js/tools/metroconfig.ts @@ -140,7 +140,7 @@ export function withSentryBabelTransformer( config: MetroConfig, annotateReactComponents: true | { ignoredComponents?: string[] }, ): MetroConfig { - const defaultBabelTransformerPath = config.transformer && config.transformer.babelTransformerPath; + const defaultBabelTransformerPath = config.transformer?.babelTransformerPath; logger.debug('Default Babel transformer path from `config.transformer`:', defaultBabelTransformerPath); if (!defaultBabelTransformerPath) { @@ -270,10 +270,10 @@ export function withSentryFramesCollapsed(config: MetroConfig): MetroConfig { originalCustomization: MetroCustomizeFrame | undefined, ): MetroCustomizeFrame => ({ ...originalCustomization, - collapse: (originalCustomization && originalCustomization.collapse) || collapseSentryInternalFrames(frame), + collapse: originalCustomization?.collapse || collapseSentryInternalFrames(frame), }); - const maybePromiseCustomization = (originalCustomizeFrame && originalCustomizeFrame(frame)) || undefined; + const maybePromiseCustomization = originalCustomizeFrame?.(frame) || undefined; if (maybePromiseCustomization !== undefined && 'then' in maybePromiseCustomization) { return maybePromiseCustomization.then(originalCustomization => diff --git a/packages/core/src/js/tracing/integrations/appStart.ts b/packages/core/src/js/tracing/integrations/appStart.ts index 949ae1e40f..d2a9739e47 100644 --- a/packages/core/src/js/tracing/integrations/appStart.ts +++ b/packages/core/src/js/tracing/integrations/appStart.ts @@ -260,7 +260,7 @@ export const appStartIntegration = ({ return; } - if (!event.contexts || !event.contexts.trace) { + if (!event.contexts?.trace) { logger.warn('[AppStart] Transaction event is missing trace context. Can not attach app start.'); return; } diff --git a/packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts b/packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts index 52cd915634..6f48b4b877 100644 --- a/packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts +++ b/packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts @@ -54,14 +54,14 @@ export const timeToDisplayIntegration = (): Integration => { }); const ttfdSpan = await addTimeToFullDisplay({ event, rootSpanId, transactionStartTimestampSeconds, ttidSpan }); - if (ttidSpan && ttidSpan.start_timestamp && ttidSpan.timestamp) { + if (ttidSpan?.start_timestamp && ttidSpan?.timestamp) { event.measurements['time_to_initial_display'] = { value: (ttidSpan.timestamp - ttidSpan.start_timestamp) * 1000, unit: 'millisecond', }; } - if (ttfdSpan && ttfdSpan.start_timestamp && ttfdSpan.timestamp) { + if (ttfdSpan?.start_timestamp && ttfdSpan?.timestamp) { const durationMs = (ttfdSpan.timestamp - ttfdSpan.start_timestamp) * 1000; if (isDeadlineExceeded(durationMs)) { event.measurements['time_to_full_display'] = event.measurements['time_to_initial_display']; @@ -117,7 +117,7 @@ async function addTimeToInitialDisplay({ }); } - if (ttidSpan && ttidSpan.status && ttidSpan.status !== 'ok') { + if (ttidSpan?.status && ttidSpan.status !== 'ok') { ttidSpan.status = 'ok'; ttidSpan.timestamp = ttidEndTimestampSeconds; logger.debug(`[${INTEGRATION_NAME}] Updated existing ttid span.`, ttidSpan); @@ -214,7 +214,7 @@ async function addTimeToFullDisplay({ const durationMs = (ttfdAdjustedEndTimestampSeconds - transactionStartTimestampSeconds) * 1000; - if (ttfdSpan && ttfdSpan.status && ttfdSpan.status !== 'ok') { + if (ttfdSpan?.status && ttfdSpan.status !== 'ok') { ttfdSpan.status = 'ok'; ttfdSpan.timestamp = ttfdAdjustedEndTimestampSeconds; logger.debug(`[${INTEGRATION_NAME}] Updated existing ttfd span.`, ttfdSpan); diff --git a/packages/core/src/js/tracing/onSpanEndUtils.ts b/packages/core/src/js/tracing/onSpanEndUtils.ts index 40365b33fd..4ae3c027f6 100644 --- a/packages/core/src/js/tracing/onSpanEndUtils.ts +++ b/packages/core/src/js/tracing/onSpanEndUtils.ts @@ -129,7 +129,7 @@ export const cancelInBackground = (client: Client, span: Span): void => { client.on('spanEnd', (endedSpan: Span) => { if (endedSpan === span) { logger.debug(`Removing AppState listener for ${spanToJSON(span).op} transaction.`); - subscription && subscription.remove && subscription.remove(); + subscription?.remove?.(); } }); }; diff --git a/packages/core/src/js/tracing/reactnativenavigation.ts b/packages/core/src/js/tracing/reactnativenavigation.ts index 0b0f696c68..2ce7ef7f5d 100644 --- a/packages/core/src/js/tracing/reactnativenavigation.ts +++ b/packages/core/src/js/tracing/reactnativenavigation.ts @@ -129,7 +129,7 @@ export const reactNativeNavigationIntegration = ({ } latestNavigationSpan = startGenericIdleNavigationSpan( - tracing && tracing.options.beforeStartSpan + tracing?.options.beforeStartSpan ? tracing.options.beforeStartSpan(getDefaultIdleNavigationSpanOptions()) : getDefaultIdleNavigationSpanOptions(), idleSpanOptions, diff --git a/packages/core/src/js/tracing/reactnativeprofiler.tsx b/packages/core/src/js/tracing/reactnativeprofiler.tsx index 4eb6604f83..7a302345eb 100644 --- a/packages/core/src/js/tracing/reactnativeprofiler.tsx +++ b/packages/core/src/js/tracing/reactnativeprofiler.tsx @@ -47,10 +47,9 @@ export class ReactNativeProfiler extends Profiler { return; } - client.addIntegration && client.addIntegration(createIntegration(this.name)); + client.addIntegration?.(createIntegration(this.name)); getAppRegistryIntegration(client).onRunApplication(ReactNativeProfilerGlobalState.onRunApplicationHook); - // eslint-disable-next-line @typescript-eslint/no-floating-promises _captureAppStart({ isManual: false }); } diff --git a/packages/core/src/js/tracing/reactnavigation.ts b/packages/core/src/js/tracing/reactnavigation.ts index 58afcf1f4a..8528466d11 100644 --- a/packages/core/src/js/tracing/reactnavigation.ts +++ b/packages/core/src/js/tracing/reactnavigation.ts @@ -241,7 +241,7 @@ export const reactNavigationIntegration = ({ } latestNavigationSpan = startGenericIdleNavigationSpan( - tracing && tracing.options.beforeStartSpan + tracing?.options.beforeStartSpan ? tracing.options.beforeStartSpan(getDefaultIdleNavigationSpanOptions()) : getDefaultIdleNavigationSpanOptions(), idleSpanOptions, diff --git a/packages/core/src/js/tracing/span.ts b/packages/core/src/js/tracing/span.ts index d7909d8d6b..c4b89b8d74 100644 --- a/packages/core/src/js/tracing/span.ts +++ b/packages/core/src/js/tracing/span.ts @@ -1,6 +1,6 @@ import type { Client, Scope, Span, SpanJSON, StartSpanOptions } from '@sentry/core'; import { - generatePropagationContext, + generateTraceId, getActiveSpan, getClient, getCurrentScope, @@ -104,7 +104,7 @@ export const startIdleSpan = ( return new SentryNonRecordingSpan(); } - getCurrentScope().setPropagationContext(generatePropagationContext()); + getCurrentScope().setPropagationContext({ traceId: generateTraceId(), sampleRand: Math.random() }); const span = coreStartIdleSpan(startSpanOption, { finalTimeout, idleTimeout }); cancelInBackground(client, span); diff --git a/packages/core/src/js/transports/encodePolyfill.ts b/packages/core/src/js/transports/encodePolyfill.ts index 6e84209ed0..3d801561b7 100644 --- a/packages/core/src/js/transports/encodePolyfill.ts +++ b/packages/core/src/js/transports/encodePolyfill.ts @@ -1,3 +1,5 @@ +import { SDK_VERSION } from '@sentry/core'; + import { RN_GLOBAL_OBJ } from '../utils/worldwide'; import { utf8ToBytes } from '../vendor'; @@ -6,7 +8,7 @@ export const useEncodePolyfill = (): void => { (RN_GLOBAL_OBJ.__SENTRY__ as Partial<(typeof RN_GLOBAL_OBJ)['__SENTRY__']>) = {}; } - RN_GLOBAL_OBJ.__SENTRY__.encodePolyfill = encodePolyfill; + RN_GLOBAL_OBJ.__SENTRY__[SDK_VERSION].encodePolyfill = encodePolyfill; }; export const encodePolyfill = (text: string): Uint8Array => { diff --git a/packages/core/src/js/utils/AsyncExpiringMap.ts b/packages/core/src/js/utils/AsyncExpiringMap.ts index 3f3906c9cd..657286ed26 100644 --- a/packages/core/src/js/utils/AsyncExpiringMap.ts +++ b/packages/core/src/js/utils/AsyncExpiringMap.ts @@ -116,7 +116,7 @@ export class AsyncExpiringMap { */ public ttl(key: K): number | undefined { const entry = this._map.get(key); - if (entry && entry.expiresAt) { + if (entry?.expiresAt) { const remainingTime = entry.expiresAt - Date.now(); return remainingTime > 0 ? remainingTime : 0; } diff --git a/packages/core/src/js/utils/envelope.ts b/packages/core/src/js/utils/envelope.ts index f115ca4bd2..ca6cb9a6d0 100644 --- a/packages/core/src/js/utils/envelope.ts +++ b/packages/core/src/js/utils/envelope.ts @@ -22,13 +22,12 @@ export function createUserFeedbackEnvelope( const headers: EventEnvelope[0] = { event_id: feedback.event_id, sent_at: new Date().toISOString(), - ...(metadata && - metadata.sdk && { - sdk: { - name: metadata.sdk.name, - version: metadata.sdk.version, - }, - }), + ...(metadata?.sdk && { + sdk: { + name: metadata.sdk.name, + version: metadata.sdk.version, + }, + }), ...(!!tunnel && !!dsn && { dsn: dsnToString(dsn) }), }; const item = createUserFeedbackEnvelopeItem(feedback); diff --git a/packages/core/src/js/utils/environment.ts b/packages/core/src/js/utils/environment.ts index 214532b031..ad19462a18 100644 --- a/packages/core/src/js/utils/environment.ts +++ b/packages/core/src/js/utils/environment.ts @@ -36,7 +36,7 @@ export function isExpo(): boolean { /** Check if JS runs in Expo Go */ export function isExpoGo(): boolean { const expoConstants = getExpoConstants(); - return (expoConstants && expoConstants.appOwnership) === 'expo'; + return expoConstants?.appOwnership === 'expo'; } /** Check Expo Go version if available */ @@ -75,11 +75,7 @@ export function notMobileOs(): boolean { /** Returns Hermes Version if hermes is present in the runtime */ export function getHermesVersion(): string | undefined { - return ( - RN_GLOBAL_OBJ.HermesInternal && - RN_GLOBAL_OBJ.HermesInternal.getRuntimeProperties && - RN_GLOBAL_OBJ.HermesInternal.getRuntimeProperties()['OSS Release Version'] - ); + return RN_GLOBAL_OBJ.HermesInternal?.getRuntimeProperties?.()['OSS Release Version']; } /** Returns default environment based on __DEV__ */ @@ -91,8 +87,7 @@ export function getDefaultEnvironment(): 'development' | 'production' { export function isRunningInMetroDevServer(): boolean { if ( typeof RN_GLOBAL_OBJ.process !== 'undefined' && - RN_GLOBAL_OBJ.process.env && - RN_GLOBAL_OBJ.process.env.___SENTRY_METRO_DEV_SERVER___ === 'true' + RN_GLOBAL_OBJ.process.env?.___SENTRY_METRO_DEV_SERVER___ === 'true' ) { return true; } diff --git a/packages/core/src/js/utils/expomodules.ts b/packages/core/src/js/utils/expomodules.ts index 349c454d9d..73d4ea7f1e 100644 --- a/packages/core/src/js/utils/expomodules.ts +++ b/packages/core/src/js/utils/expomodules.ts @@ -5,14 +5,12 @@ import { RN_GLOBAL_OBJ } from './worldwide'; * Returns the Expo Constants module if present */ export function getExpoConstants(): ExpoConstants | undefined { - return ( - (RN_GLOBAL_OBJ.expo && RN_GLOBAL_OBJ.expo.modules && RN_GLOBAL_OBJ.expo.modules.ExponentConstants) || undefined - ); + return RN_GLOBAL_OBJ.expo?.modules?.ExponentConstants || undefined; } /** * Returns the Expo Device module if present */ export function getExpoDevice(): ExpoDevice | undefined { - return (RN_GLOBAL_OBJ.expo && RN_GLOBAL_OBJ.expo.modules && RN_GLOBAL_OBJ.expo.modules.ExpoDevice) || undefined; + return RN_GLOBAL_OBJ.expo?.modules?.ExpoDevice || undefined; } diff --git a/packages/core/src/js/wrapper.ts b/packages/core/src/js/wrapper.ts index 598ea7c9db..31152c02b2 100644 --- a/packages/core/src/js/wrapper.ts +++ b/packages/core/src/js/wrapper.ts @@ -37,7 +37,7 @@ import { base64StringFromByteArray, utf8ToBytes } from './vendor'; */ export function getRNSentryModule(): Spec | undefined { return isTurboModuleEnabled() - ? ReactNativeLibraries.TurboModuleRegistry && ReactNativeLibraries.TurboModuleRegistry.get('RNSentry') + ? ReactNativeLibraries.TurboModuleRegistry?.get('RNSentry') : NativeModules.RNSentry; } diff --git a/packages/core/test/feedback.test.ts b/packages/core/test/feedback.test.ts index 6b1831934d..f25bc4eec1 100644 --- a/packages/core/test/feedback.test.ts +++ b/packages/core/test/feedback.test.ts @@ -240,17 +240,17 @@ describe('captureFeedback', () => { const mockTransport = jest.spyOn(client.getTransport()!, 'send'); const traceId = '4C79F60C11214EB38604F4AE0781BFB2'; - const spanId = 'FA90FDEAD5F74052'; + const parentSpanId = 'FA90FDEAD5F74052'; const dsc = { trace_id: traceId, - span_id: spanId, sampled: 'true', }; getCurrentScope().setPropagationContext({ traceId, - spanId, + parentSpanId, dsc, + sampleRand: 1, }); const eventId = captureFeedback({ @@ -264,7 +264,7 @@ describe('captureFeedback', () => { expect(mockTransport).toHaveBeenCalledWith([ { event_id: eventId, - sent_at: expect.any(String), + sent_at: expect.toBeDateString(), }, [ [ @@ -274,7 +274,8 @@ describe('captureFeedback', () => { contexts: { trace: { trace_id: traceId, - span_id: spanId, + parent_span_id: parentSpanId, + span_id: expect.any(String), }, feedback: { message: 'test', @@ -297,7 +298,7 @@ describe('captureFeedback', () => { getDefaultTestClientOptions({ dsn: 'https://dsn@ingest.f00.f00/1', enableSend: true, - enableTracing: true, + tracesSampleRate: 1.0, // We don't care about transactions here... beforeSendTransaction() { return null; @@ -322,12 +323,12 @@ describe('captureFeedback', () => { expect(typeof eventId).toBe('string'); expect(span).toBeDefined(); - const { spanId, traceId } = span!.spanContext(); + const traceId = span!.spanContext().traceId; expect(mockTransport).toHaveBeenCalledWith([ { event_id: eventId, - sent_at: expect.any(String), + sent_at: expect.toBeDateString(), }, [ [ @@ -337,7 +338,7 @@ describe('captureFeedback', () => { contexts: { trace: { trace_id: traceId, - span_id: spanId, + span_id: expect.any(String), }, feedback: { message: 'test', @@ -360,7 +361,7 @@ describe('captureFeedback', () => { getDefaultTestClientOptions({ dsn: 'https://dsn@ingest.f00.f00/1', enableSend: true, - enableTracing: true, + tracesSampleRate: 1.0, // We don't care about transactions here... beforeSendTransaction() { return null; diff --git a/packages/core/test/mocks/client.ts b/packages/core/test/mocks/client.ts index 8a0df75ebc..8db8b51dec 100644 --- a/packages/core/test/mocks/client.ts +++ b/packages/core/test/mocks/client.ts @@ -88,7 +88,7 @@ export class TestClient extends BaseClient { super.sendEvent(event, hint); return; } - TestClient.sendEventCalled && TestClient.sendEventCalled(event); + TestClient.sendEventCalled?.(event); } public sendSession(session: Session): void { diff --git a/packages/core/test/profiling/integration.test.ts b/packages/core/test/profiling/integration.test.ts index 7462d94c6e..d845aa9f57 100644 --- a/packages/core/test/profiling/integration.test.ts +++ b/packages/core/test/profiling/integration.test.ts @@ -344,7 +344,7 @@ function initTestClient( const transportSendMock = jest.fn, Parameters>(); const options: Sentry.ReactNativeOptions = { dsn: MOCK_DSN, - enableTracing: true, + tracesSampleRate: 1.0, enableNativeFramesTracking: false, profilesSampleRate: 1, integrations: integrations => { @@ -430,5 +430,5 @@ function addIntegrationAndForceSetupOnce(integration: Integration): void { } client.addIntegration(integration); - integration.setupOnce && integration.setupOnce(); + integration.setupOnce?.(); } diff --git a/packages/core/test/tracing/addTracingExtensions.test.ts b/packages/core/test/tracing/addTracingExtensions.test.ts index 4d4c5384c3..bb074e36ee 100644 --- a/packages/core/test/tracing/addTracingExtensions.test.ts +++ b/packages/core/test/tracing/addTracingExtensions.test.ts @@ -1,3 +1,4 @@ +import type { Span } from '@sentry/core'; import { getCurrentScope, spanToJSON, startSpanManual } from '@sentry/core'; import { reactNativeTracingIntegration } from '../../src/js'; @@ -55,9 +56,12 @@ describe('Tracing extensions', () => { }); test('transaction start span passes correct values to the child', async () => { - const transaction = startSpanManual({ name: 'parent', op: 'custom', scope: getCurrentScope() }, span => span); - const span = startSpanManual({ name: 'child', scope: getCurrentScope() }, span => span); - span!.end(); + let childSpan: Span = undefined; + const transaction = startSpanManual({ name: 'parent', op: 'custom', scope: getCurrentScope() }, _span => { + childSpan = startSpanManual({ name: 'child', scope: getCurrentScope() }, __span => __span); + return _span; + }); + childSpan!.end(); transaction!.end(); await client.flush(); @@ -70,9 +74,9 @@ describe('Tracing extensions', () => { }), }), ); - expect(spanToJSON(span!)).toEqual( + expect(spanToJSON(childSpan!)).toEqual( expect.objectContaining({ - parent_span_id: transaction!.spanContext().spanId, + parent_span_id: spanToJSON(transaction!).span_id, }), ); }); diff --git a/packages/core/test/tracing/integrations/appStart.test.ts b/packages/core/test/tracing/integrations/appStart.test.ts index 8ae6a63ef0..85d87160a1 100644 --- a/packages/core/test/tracing/integrations/appStart.test.ts +++ b/packages/core/test/tracing/integrations/appStart.test.ts @@ -839,6 +839,7 @@ function getMinimalTransactionEvent({ description: 'Test', span_id: '123', trace_id: '456', + data: {}, }, ], }; @@ -893,6 +894,7 @@ function expectEventWithAttachedColdAppStart({ description: 'Test', span_id: '123', trace_id: '456', + data: {}, }, ]), }); @@ -947,6 +949,7 @@ function expectEventWithAttachedWarmAppStart({ description: 'Test', span_id: '123', trace_id: '456', + data: {}, }, ]), }); diff --git a/packages/core/test/tracing/integrations/userInteraction.test.ts b/packages/core/test/tracing/integrations/userInteraction.test.ts index a026e79c0e..1f86614c36 100644 --- a/packages/core/test/tracing/integrations/userInteraction.test.ts +++ b/packages/core/test/tracing/integrations/userInteraction.test.ts @@ -255,15 +255,20 @@ describe('User Interaction Tracing', () => { }); test('do not start UI event transaction if active transaction on scope', () => { - const activeTransaction = startSpanManual( - { name: 'activeTransactionOnScope', scope: getCurrentScope() }, - (span: Span) => span, - ); - expect(activeTransaction).toBeDefined(); - expect(activeTransaction).toBe(getActiveSpan()); + const placeholderCallback: (span: Span, finish: () => void) => void = (span, finish) => { + // @ts-expect-error no direct access to _name + expect(span._name).toBe('activeTransactionOnScope'); - startUserInteractionSpan(mockedUserInteractionId); - expect(activeTransaction).toBe(getActiveSpan()); + expect(span).toBe(getActiveSpan()); + + startUserInteractionSpan(mockedUserInteractionId); + + expect(span).toBe(getActiveSpan()); + + finish(); + }; + + startSpanManual({ name: 'activeTransactionOnScope', scope: getCurrentScope() }, placeholderCallback); }); test('UI event transaction is canceled when routing transaction starts', () => { diff --git a/packages/core/test/tracing/reactnavigation.ttid.test.tsx b/packages/core/test/tracing/reactnavigation.ttid.test.tsx index 6ab972f3d8..ba01506feb 100644 --- a/packages/core/test/tracing/reactnavigation.ttid.test.tsx +++ b/packages/core/test/tracing/reactnavigation.ttid.test.tsx @@ -678,7 +678,7 @@ function initSentry(sut: ReturnType): const transportSendMock = jest.fn, Parameters>(); const options: Sentry.ReactNativeOptions = { dsn: MOCK_DSN, - enableTracing: true, + tracesSampleRate: 1.0, enableStallTracking: false, integrations: [ sut, diff --git a/packages/core/test/tracing/timetodisplaynative.web.test.tsx b/packages/core/test/tracing/timetodisplaynative.web.test.tsx index 507c33a745..c60dad0a75 100644 --- a/packages/core/test/tracing/timetodisplaynative.web.test.tsx +++ b/packages/core/test/tracing/timetodisplaynative.web.test.tsx @@ -1,6 +1,9 @@ jest.mock('react-native', () => { const RN = jest.requireActual('react-native'); + // Fixes TypeError: Cannot set property UIManager of # which has only a getter + delete RN.UIManager; RN.UIManager = {}; + return RN; }); diff --git a/packages/core/test/utils/safe.test.ts b/packages/core/test/utils/safe.test.ts index 89e063bd35..0e781ef313 100644 --- a/packages/core/test/utils/safe.test.ts +++ b/packages/core/test/utils/safe.test.ts @@ -38,14 +38,31 @@ describe('safe', () => { test('calls given function with correct args', () => { const mockFn = jest.fn(); const actualSafeFunction = safeTracesSampler(mockFn); - actualSafeFunction?.({ name: 'foo', transactionContext: { name: 'foo' } }); + const expectedInheritOrSampleWith = function (fallbackSampleRate: number): number { + return fallbackSampleRate; + }; + actualSafeFunction?.({ + name: 'foo', + transactionContext: { name: 'foo' }, + inheritOrSampleWith: expectedInheritOrSampleWith, + }); expect(mockFn).toBeCalledTimes(1); - expect(mockFn).toBeCalledWith({ name: 'foo', transactionContext: { name: 'foo' } }); + expect(mockFn).toBeCalledWith({ + name: 'foo', + transactionContext: { name: 'foo' }, + inheritOrSampleWith: expectedInheritOrSampleWith, + }); }); test('calls given function amd return its result', () => { const mockFn = jest.fn(() => 0.5); const actualSafeFunction = safeTracesSampler(mockFn); - const actualResult = actualSafeFunction?.({ name: 'foo', transactionContext: { name: 'foo' } }); + const actualResult = actualSafeFunction?.({ + name: 'foo', + transactionContext: { name: 'foo' }, + inheritOrSampleWith: function (fallbackSampleRate: number): number { + return fallbackSampleRate; + }, + }); expect(mockFn).toBeCalledTimes(1); expect(actualResult).toBe(0.5); }); @@ -58,7 +75,13 @@ describe('safe', () => { throw 'Test error'; }); const actualSafeFunction = safeTracesSampler(mockFn); - const actualResult = actualSafeFunction?.({ name: 'foo', transactionContext: { name: 'foo' } }); + const actualResult = actualSafeFunction?.({ + name: 'foo', + transactionContext: { name: 'foo' }, + inheritOrSampleWith: function (fallbackSampleRate: number): number { + return fallbackSampleRate; + }, + }); expect(mockFn).toBeCalledTimes(1); expect(actualResult).toEqual(0); }); diff --git a/samples/react-native-macos/package.json b/samples/react-native-macos/package.json index 302c961d7a..2938c0dde6 100644 --- a/samples/react-native-macos/package.json +++ b/samples/react-native-macos/package.json @@ -16,8 +16,8 @@ "@react-navigation/bottom-tabs": "^6.5.12", "@react-navigation/native": "^6.1.9", "@react-navigation/stack": "^6.3.20", - "@sentry/core": "8.54.0", - "@sentry/react": "8.54.0", + "@sentry/core": "9.1.0", + "@sentry/react": "9.1.0", "@sentry/react-native": "6.11.0-beta.0", "delay": "^6.0.0", "react": "18.2.0", diff --git a/samples/react-native/package.json b/samples/react-native/package.json index 2d73447025..58464514df 100644 --- a/samples/react-native/package.json +++ b/samples/react-native/package.json @@ -27,7 +27,7 @@ "@react-navigation/native": "^7.0.14", "@react-navigation/native-stack": "^7.2.0", "@react-navigation/stack": "^7.1.1", - "@sentry/core": "8.54.0", + "@sentry/core": "9.1.0", "@sentry/react-native": "6.11.0-beta.0", "@shopify/flash-list": "^1.7.3", "axios": "^1.8.3", @@ -74,7 +74,7 @@ "prettier": "2.8.8", "react-test-renderer": "18.3.1", "sentry-react-native-samples-utils": "workspace:^", - "ts-jest": "^29.2.5", + "ts-jest": "^29.3.1", "typescript": "5.0.4" }, "engines": { diff --git a/yarn.lock b/yarn.lock index 9409d0faac..1b8d925c7a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7855,21 +7855,21 @@ __metadata: languageName: node linkType: hard -"@sentry-internal/browser-utils@npm:8.54.0": - version: 8.54.0 - resolution: "@sentry-internal/browser-utils@npm:8.54.0" +"@sentry-internal/browser-utils@npm:9.1.0": + version: 9.1.0 + resolution: "@sentry-internal/browser-utils@npm:9.1.0" dependencies: - "@sentry/core": 8.54.0 - checksum: a6dc51bcf0b6029ebb49dd3478bd216da5aac118512ae247a3fa4c61b809a6caa27ee1531dc49cdab18f340f6a0cb337cc160c217e6af60060cb50aa2ab15abd + "@sentry/core": 9.1.0 + checksum: 08c6b383fe2256d367469269d15f454f9a1345f9ae49ae63682265f0052821b259728907afc3c231186953cca14d08b43a2386fe3e984338f988ae9ae8175064 languageName: node linkType: hard -"@sentry-internal/eslint-config-sdk@npm:8.54.0": - version: 8.54.0 - resolution: "@sentry-internal/eslint-config-sdk@npm:8.54.0" +"@sentry-internal/eslint-config-sdk@npm:9.1.0": + version: 9.1.0 + resolution: "@sentry-internal/eslint-config-sdk@npm:9.1.0" dependencies: - "@sentry-internal/eslint-plugin-sdk": 8.54.0 - "@sentry-internal/typescript": 8.54.0 + "@sentry-internal/eslint-plugin-sdk": 9.1.0 + "@sentry-internal/typescript": 9.1.0 "@typescript-eslint/eslint-plugin": ^5.48.0 "@typescript-eslint/parser": ^5.48.0 eslint-config-prettier: ^6.11.0 @@ -7880,43 +7880,43 @@ __metadata: eslint-plugin-simple-import-sort: ^5.0.3 peerDependencies: eslint: ">=5" - checksum: 4b4ed9e455517ab9ca90f0d9ab8f9a27342dd2635cd3464bda6b06430ab44028c421f4c7a214a034c20514e950380cd7f37f825a0a60d5b6c07d5e7040cbc1b3 + checksum: aef3a7b34b32202303dcc9d75f213a37d471354673bdfd97d31f8909e3e24ffe0d7dff595097c9a0055a5f9addbc91758ea667ca82206368f687a85d669295b3 languageName: node linkType: hard -"@sentry-internal/eslint-plugin-sdk@npm:8.54.0": - version: 8.54.0 - resolution: "@sentry-internal/eslint-plugin-sdk@npm:8.54.0" - checksum: b9f3d9512df82d1e9cbef100b2f19626a1ede9b25eee6ff1f0e163f74f087a9de6dc6705c58c01cedd4b1782b2db31f8c158ee8a05552db8b49315c3917b9d92 +"@sentry-internal/eslint-plugin-sdk@npm:9.1.0": + version: 9.1.0 + resolution: "@sentry-internal/eslint-plugin-sdk@npm:9.1.0" + checksum: 28eab0a957912dbc82c2b308af84a9105b23eb66f582134f14132dec68de114de196114b8ecdef75fd1b91ee4691735d2760585c512775d0d691b45fc09650a3 languageName: node linkType: hard -"@sentry-internal/feedback@npm:8.54.0": - version: 8.54.0 - resolution: "@sentry-internal/feedback@npm:8.54.0" +"@sentry-internal/feedback@npm:9.1.0": + version: 9.1.0 + resolution: "@sentry-internal/feedback@npm:9.1.0" dependencies: - "@sentry/core": 8.54.0 - checksum: e99ca3997609deba59af450b6298dc5125cc7633a59751632cf3b4a7cf12f097cc3ffa9424c483489a0d232a6c577479fe5496355e6a5c2b3ada0c7aa72e7251 + "@sentry/core": 9.1.0 + checksum: 4f0b3335e391d55ffdcac56bfbcbf9fa62ba865ab75c97daf6904cca6f5ea4cce156a78adddd81d3bd4119f9bd8c81e5bb18d330f61c77800cd911c74f776689 languageName: node linkType: hard -"@sentry-internal/replay-canvas@npm:8.54.0": - version: 8.54.0 - resolution: "@sentry-internal/replay-canvas@npm:8.54.0" +"@sentry-internal/replay-canvas@npm:9.1.0": + version: 9.1.0 + resolution: "@sentry-internal/replay-canvas@npm:9.1.0" dependencies: - "@sentry-internal/replay": 8.54.0 - "@sentry/core": 8.54.0 - checksum: ed11de4c3503833d1e3503e521d0945eb393e16c6e5a2da3b5eae8632540a96530e465e8b6947879440ef19aba5f0d13ce36c4400955fcb310de2882c8610887 + "@sentry-internal/replay": 9.1.0 + "@sentry/core": 9.1.0 + checksum: 413fd391dcb0bdae64ce70ea1b37f5935d9449a44172d98363eda64385775573b444ec5e56e700445c20f53ca8a7bca6157889732c5985b6450d5f0f09c3abc3 languageName: node linkType: hard -"@sentry-internal/replay@npm:8.54.0": - version: 8.54.0 - resolution: "@sentry-internal/replay@npm:8.54.0" +"@sentry-internal/replay@npm:9.1.0": + version: 9.1.0 + resolution: "@sentry-internal/replay@npm:9.1.0" dependencies: - "@sentry-internal/browser-utils": 8.54.0 - "@sentry/core": 8.54.0 - checksum: 2d46529612cb279ef53e8fb0f96d9da7b0526e9c3990af27620cb1f10a3f66b81966121d904da08b4ad07c0ae162230dfa39a9572127033b62ca2aae9b9008d8 + "@sentry-internal/browser-utils": 9.1.0 + "@sentry/core": 9.1.0 + checksum: 11ef5a88d3bafd2b5143a150af7b0c77af521a17bf48e1840b2fd2116c55e7acd49ddce3618a1191ccc11b8b38e70ab8c59a030a90557c21499e2e815ce184fb languageName: node linkType: hard @@ -7931,12 +7931,19 @@ __metadata: languageName: node linkType: hard -"@sentry-internal/typescript@npm:8.54.0": - version: 8.54.0 - resolution: "@sentry-internal/typescript@npm:8.54.0" +"@sentry-internal/typescript@npm:9.1.0": + version: 9.1.0 + resolution: "@sentry-internal/typescript@npm:9.1.0" peerDependencies: - typescript: 4.9.5 - checksum: 83cfd303f34dbc5e70fc18e0af788ae37cdc0635258c082924e022b44177bac5c9c589448b368fbeeafb282a22623b5a6ea0e5ef3140c3f54fce1ac222e1920b + typescript: ~5.0.0 + checksum: 76bc7fefc76af9000b3f78f5270349f844261f079775753c36aa46e78dea963c89dbfdeddf4bd36b6c5fc197b4415f9c1883a38287fa4d6a90ded51ae5e97f25 + languageName: node + linkType: hard + +"@sentry/babel-plugin-component-annotate@npm:3.1.2": + version: 3.1.2 + resolution: "@sentry/babel-plugin-component-annotate@npm:3.1.2" + checksum: 4e957d44dde3eacc60d6d33d28523fa16775e3c05603defc9268ad7209ce06da9dba50243e637f64cb12d7bb302b46584dd815754805210517a3b4da91af2c91 languageName: node linkType: hard @@ -7947,16 +7954,16 @@ __metadata: languageName: node linkType: hard -"@sentry/browser@npm:8.54.0": - version: 8.54.0 - resolution: "@sentry/browser@npm:8.54.0" +"@sentry/browser@npm:9.1.0": + version: 9.1.0 + resolution: "@sentry/browser@npm:9.1.0" dependencies: - "@sentry-internal/browser-utils": 8.54.0 - "@sentry-internal/feedback": 8.54.0 - "@sentry-internal/replay": 8.54.0 - "@sentry-internal/replay-canvas": 8.54.0 - "@sentry/core": 8.54.0 - checksum: b125b194877cbdefc76884f6b1b7995d0949f7e7e5c4283c69f01071656df0e571bd0ac1cf1bb47f89f268370dd8b69126db44e2949ee5176a043e615c5bc7e0 + "@sentry-internal/browser-utils": 9.1.0 + "@sentry-internal/feedback": 9.1.0 + "@sentry-internal/replay": 9.1.0 + "@sentry-internal/replay-canvas": 9.1.0 + "@sentry/core": 9.1.0 + checksum: 782ce1b01d3719c0047a2bc5bf3ef0463188a70224109562c6d22341d4fb647992775b2f62a2b45e0a185fb1c4cab49f07298b67c2c290e87e281405f6af8a4c languageName: node linkType: hard @@ -8066,10 +8073,10 @@ __metadata: languageName: node linkType: hard -"@sentry/core@npm:8.54.0": - version: 8.54.0 - resolution: "@sentry/core@npm:8.54.0" - checksum: ad7165a0bc56918cf8b8e5e15c4ceed11358970d8bf4c587a0fb05d8bd2759ee1d965da2a51e705e0e0aaf3a84150ecbf3bd647bfa0dd32bc723b28b91d46a66 +"@sentry/core@npm:9.1.0": + version: 9.1.0 + resolution: "@sentry/core@npm:9.1.0" + checksum: 81713903ab3be8940eae23f22a4efe753f4c14e10f618c0bd79128028dde0810909a93b23a87407658010d5097a620e31ccb91ca50b86ee7eb69a26d80a747f3 languageName: node linkType: hard @@ -8106,16 +8113,15 @@ __metadata: "@expo/metro-config": 0.19.5 "@mswjs/interceptors": ^0.25.15 "@react-native/babel-preset": 0.77.1 - "@sentry-internal/eslint-config-sdk": 8.54.0 - "@sentry-internal/eslint-plugin-sdk": 8.54.0 - "@sentry-internal/typescript": 8.54.0 - "@sentry/babel-plugin-component-annotate": 3.2.4 - "@sentry/browser": 8.54.0 + "@sentry-internal/eslint-config-sdk": 9.1.0 + "@sentry-internal/eslint-plugin-sdk": 9.1.0 + "@sentry-internal/typescript": 9.1.0 + "@sentry/babel-plugin-component-annotate": 3.1.2 + "@sentry/browser": 9.1.0 "@sentry/cli": 2.43.0 - "@sentry/core": 8.54.0 - "@sentry/react": 8.54.0 - "@sentry/types": 8.54.0 - "@sentry/utils": 8.54.0 + "@sentry/core": 9.1.0 + "@sentry/react": 9.1.0 + "@sentry/types": 9.1.0 "@sentry/wizard": 4.6.0 "@testing-library/react-native": ^12.7.2 "@types/jest": ^29.5.13 @@ -8145,7 +8151,7 @@ __metadata: react-native: 0.77.1 react-test-renderer: ^18.3.1 rimraf: ^4.1.1 - ts-jest: ^29.1.1 + ts-jest: ^29.3.1 typescript: 4.9.5 uglify-js: ^3.17.4 uuid: ^9.0.1 @@ -8162,16 +8168,16 @@ __metadata: languageName: unknown linkType: soft -"@sentry/react@npm:8.54.0": - version: 8.54.0 - resolution: "@sentry/react@npm:8.54.0" +"@sentry/react@npm:9.1.0": + version: 9.1.0 + resolution: "@sentry/react@npm:9.1.0" dependencies: - "@sentry/browser": 8.54.0 - "@sentry/core": 8.54.0 + "@sentry/browser": 9.1.0 + "@sentry/core": 9.1.0 hoist-non-react-statics: ^3.3.2 peerDependencies: react: ^16.14.0 || 17.x || 18.x || 19.x - checksum: 6f6d12f4db77f137b7b4361bfe298f9eba19b865e56701f7ba336ffedada683bd4baa962747f8b96a91d3399b1317206689e8a7565fb06b930b71440cd8a00a1 + checksum: 670cfde6f966079e4224bba0a5020f059f7c2c99e2bdd9f4163b0fbb367cb29e407de671be4dac1a684f18a80ae0c65ef0c179143e1772ef3dcc258c80d01ae8 languageName: node linkType: hard @@ -8182,12 +8188,12 @@ __metadata: languageName: node linkType: hard -"@sentry/types@npm:8.54.0": - version: 8.54.0 - resolution: "@sentry/types@npm:8.54.0" +"@sentry/types@npm:9.1.0": + version: 9.1.0 + resolution: "@sentry/types@npm:9.1.0" dependencies: - "@sentry/core": 8.54.0 - checksum: 948095843efa280ee1a1dad5ac6dc20688395c25b344860d22505de14a10b1f873bcbeaaf32ba8506955a789a9c0fb0df4e80b93dfee21b1847423e954d0e616 + "@sentry/core": 9.1.0 + checksum: 9193a6ba72efaaa2605301d0dd54651e240c02e380ce89fc402945a70b5d1da85a4a4f562d9ac99e9e8e64dc988a59ce3b9bbc88be2cd47590acb6ae019e7080 languageName: node linkType: hard @@ -8200,15 +8206,6 @@ __metadata: languageName: node linkType: hard -"@sentry/utils@npm:8.54.0": - version: 8.54.0 - resolution: "@sentry/utils@npm:8.54.0" - dependencies: - "@sentry/core": 8.54.0 - checksum: 063c31528f4d3d0f17be18050c84fad12a8a62fde97ca8e0e10c0cc01323e644d8d1cbba4b95b20de5d62eaee23ba43ae51b479057da4fd59dbccd49ac97277a - languageName: node - linkType: hard - "@sentry/wizard@npm:4.6.0": version: 4.6.0 resolution: "@sentry/wizard@npm:4.6.0" @@ -24505,7 +24502,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:7.6.3, semver@npm:7.x, semver@npm:^7.0.0, semver@npm:^7.1.1, semver@npm:^7.1.3, semver@npm:^7.2.1, semver@npm:^7.3.2, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.0, semver@npm:^7.6.3, semver@npm:~7.6.3": +"semver@npm:7.6.3, semver@npm:7.x, semver@npm:^7.0.0, semver@npm:^7.1.1, semver@npm:^7.1.3, semver@npm:^7.2.1, semver@npm:^7.3.2, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8, semver@npm:^7.5.2, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.0, semver@npm:~7.6.3": version: 7.6.3 resolution: "semver@npm:7.6.3" bin: @@ -24523,6 +24520,15 @@ __metadata: languageName: node linkType: hard +"semver@npm:^7.7.1": + version: 7.7.1 + resolution: "semver@npm:7.7.1" + bin: + semver: bin/semver.js + checksum: 586b825d36874007c9382d9e1ad8f93888d8670040add24a28e06a910aeebd673a2eb9e3bf169c6679d9245e66efb9057e0852e70d9daa6c27372aab1dda7104 + languageName: node + linkType: hard + "send@npm:0.18.0": version: 0.18.0 resolution: "send@npm:0.18.0" @@ -24592,7 +24598,7 @@ __metadata: dependencies: "@babel/preset-env": ^7.25.3 "@babel/preset-typescript": ^7.18.6 - "@sentry/core": 8.54.0 + "@sentry/core": 9.1.0 "@sentry/react-native": 6.11.0-beta.0 "@types/node": ^20.9.3 "@types/react": ^18.2.64 @@ -24658,8 +24664,8 @@ __metadata: "@react-navigation/bottom-tabs": ^6.5.12 "@react-navigation/native": ^6.1.9 "@react-navigation/stack": ^6.3.20 - "@sentry/core": 8.54.0 - "@sentry/react": 8.54.0 + "@sentry/core": 9.1.0 + "@sentry/react": 9.1.0 "@sentry/react-native": 6.11.0-beta.0 "@types/react": ^18.2.65 "@types/react-native-vector-icons": ^6.4.18 @@ -24706,7 +24712,7 @@ __metadata: "@react-navigation/native-stack": ^7.2.0 "@react-navigation/stack": ^7.1.1 "@sentry/babel-plugin-component-annotate": 3.2.4 - "@sentry/core": 8.54.0 + "@sentry/core": 9.1.0 "@sentry/react-native": 6.11.0-beta.0 "@shopify/flash-list": ^1.7.3 "@types/jest": ^29.5.14 @@ -24740,7 +24746,7 @@ __metadata: react-test-renderer: 18.3.1 redux: ^4.2.1 sentry-react-native-samples-utils: "workspace:^" - ts-jest: ^29.2.5 + ts-jest: ^29.3.1 typescript: 5.0.4 languageName: unknown linkType: soft @@ -26318,19 +26324,20 @@ __metadata: languageName: node linkType: hard -"ts-jest@npm:^29.1.1, ts-jest@npm:^29.2.5": - version: 29.2.5 - resolution: "ts-jest@npm:29.2.5" +"ts-jest@npm:^29.3.1": + version: 29.3.1 + resolution: "ts-jest@npm:29.3.1" dependencies: - bs-logger: "npm:^0.2.6" - ejs: "npm:^3.1.10" - fast-json-stable-stringify: "npm:^2.1.0" - jest-util: "npm:^29.0.0" - json5: "npm:^2.2.3" - lodash.memoize: "npm:^4.1.2" - make-error: "npm:^1.3.6" - semver: "npm:^7.6.3" - yargs-parser: "npm:^21.1.1" + bs-logger: ^0.2.6 + ejs: ^3.1.10 + fast-json-stable-stringify: ^2.1.0 + jest-util: ^29.0.0 + json5: ^2.2.3 + lodash.memoize: ^4.1.2 + make-error: ^1.3.6 + semver: ^7.7.1 + type-fest: ^4.38.0 + yargs-parser: ^21.1.1 peerDependencies: "@babel/core": ">=7.0.0-beta.0 <8" "@jest/transform": ^29.0.0 @@ -26351,7 +26358,7 @@ __metadata: optional: true bin: ts-jest: cli.js - checksum: d60d1e1d80936f6002b1bb27f7e062408bc733141b9d666565503f023c340a3196d506c836a4316c5793af81a5f910ab49bb9c13f66e2dc66de4e0f03851dbca + checksum: 7320bbfab2e2cc7d5308fadcfe486d24ffc0018f92bf05946cd3ac75888977ec52887b2beaa99ec5ee3d67b8636b56a1688db447fd2794eeefc498862e850f77 languageName: node linkType: hard @@ -26603,6 +26610,13 @@ __metadata: languageName: node linkType: hard +"type-fest@npm:^4.38.0": + version: 4.39.1 + resolution: "type-fest@npm:4.39.1" + checksum: 71ce0e25822d5d984c8882e3243c42c741f089c003d89222dc361a133698d8ac021c18a9139ba3baf0fee2f523383422b8c5aaa390b1b3a98140f23dd0f44795 + languageName: node + linkType: hard + "type-fest@npm:^4.4.0": version: 4.26.0 resolution: "type-fest@npm:4.26.0" From 90aa0986080c4d6682f29a9e550ebd2b049a9d00 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Tue, 15 Apr 2025 06:17:02 -0300 Subject: [PATCH 05/64] Feat: V7 - JavaScript V9 Add browser session integration (#4732) * bump SDKs * bump SDKs * fix build * fix tests * fix tests * fix lint errors * test ts 5.0 * rollback * fix merge conflict with yarn * fix new lint issue * sync yarn.lock with V7 branch and install new packages * ensure we are using the JS version from the default node resolution * update changelog with javascript version bump * fix check type (#4587) * add major changes to the SDK * fix lint * review check: fix changelog PR number / Fix wrapper incorrect null check / removed comment from rnerror handler / removed comment from span / fix test from userInteraction * fix incorrect cli version * fix lint * remove shutdowntimeout from android / use newer wizard version * rollback feedback test change, rollback jest version, fix safe test * return shutdowntimeout * explain tracing sample rate * fix tracing extension test * lint fix * update changelog * fix yarn lock merge/ fix ts-jest version no longer exists / fix core version on samples and e2e * fix lint on addTimeToInitialDisplay * fix issue with UIManager test * add browserSessionIntegration for web * moved major changes to the correct spot * merge father branch, update changelog about react native web changes * add PR number * Update CHANGELOG.md Co-authored-by: Antonis Lilis * Update CHANGELOG.md Co-authored-by: Antonis Lilis --------- Co-authored-by: Antonis Lilis --- CHANGELOG.md | 4 +-- packages/core/src/js/integrations/default.ts | 5 ++++ packages/core/test/sdk.test.ts | 30 ++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ccf2dc231..58c05d332a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,9 +41,7 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi - `autoSessionTracking` from options. To enable session tracking, ensure that `enableAutoSessionTracking` is enabled. - - `enableTracing`. Instead, set `tracesSampleRate` to a value greater than `zero` to `enable tracing`, `0` to keep tracing integrations active without sampling, or `undefined` to disable the performance integration. - - `getCurrentHub()`, `Hub`, and `getCurrentHubShim()` - `spanId` from propagation `context` - metrics API @@ -54,7 +52,7 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi ## Other Changes - Fork `scope` if custom scope is passed to `startSpanManual` or `startSpan` - +- On React Native Web, `browserSessionIntegration` is added when `enableAutoSessionTracking` is set to `True` ([#4732](https://github.com/getsentry/sentry-react-native/pull/4732)) ## 6.11.0-beta.0 diff --git a/packages/core/src/js/integrations/default.ts b/packages/core/src/js/integrations/default.ts index 1fbfa987e9..024e1fb325 100644 --- a/packages/core/src/js/integrations/default.ts +++ b/packages/core/src/js/integrations/default.ts @@ -1,4 +1,5 @@ /* eslint-disable complexity */ +import { browserSessionIntegration } from '@sentry/browser'; import type { Integration } from '@sentry/core'; import type { ReactNativeClientOptions } from '../options'; @@ -59,6 +60,10 @@ export function getDefaultIntegrations(options: ReactNativeClientOptions): Integ integrations.push(browserApiErrorsIntegration()); integrations.push(browserGlobalHandlersIntegration()); integrations.push(browserLinkedErrorsIntegration()); + + if (options.enableAutoSessionTracking) { + integrations.push(browserSessionIntegration()); + } } // @sentry/react default integrations diff --git a/packages/core/test/sdk.test.ts b/packages/core/test/sdk.test.ts index 268dc742f2..ac99d81872 100644 --- a/packages/core/test/sdk.test.ts +++ b/packages/core/test/sdk.test.ts @@ -620,6 +620,36 @@ describe('Tests the SDK functionality', () => { expectIntegration('HermesProfiling'); }); + it('adds browserSessionIntegration on web when enableAutoSessionTracking is set true', () => { + (NATIVE.isNativeAvailable as jest.Mock).mockImplementation(() => false); + (notWeb as jest.Mock).mockImplementation(() => false); + init({ enableAutoSessionTracking: true }); + + expectIntegration('BrowserSession'); + }); + + it('no browserSessionIntegration on web when enableAutoSessionTracking is set false', () => { + (NATIVE.isNativeAvailable as jest.Mock).mockImplementation(() => false); + (notWeb as jest.Mock).mockImplementation(() => false); + init({ enableAutoSessionTracking: false }); + + expectNotIntegration('BrowserSession'); + }); + + it('no browserSessionIntegration on web when enableAutoSessionTracking is not set', () => { + (NATIVE.isNativeAvailable as jest.Mock).mockImplementation(() => false); + (notWeb as jest.Mock).mockImplementation(() => false); + init({}); + + expectNotIntegration('BrowserSession'); + }); + + it('no browserSessionIntegration on mobile', () => { + init({ enableAutoSessionTracking: true }); + + expectNotIntegration('BrowserSession'); + }); + it('no spotlight integration by default', () => { init({}); From a852e28b133e0f7a7aa559052bb826208d1b9ac9 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Tue, 15 Apr 2025 18:23:36 +0200 Subject: [PATCH 06/64] chore: remove allowSyntheticDefaultImports from TypeScript configuration files (#4753) --- packages/core/tsconfig.build.json | 1 - packages/core/tsconfig.build.tools.json | 1 - packages/core/tsconfig.json | 1 - 3 files changed, 3 deletions(-) diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.json index e5da411ec9..b5b1127a11 100644 --- a/packages/core/tsconfig.build.json +++ b/packages/core/tsconfig.build.json @@ -25,7 +25,6 @@ "target": "es6", "module": "es6", "skipLibCheck": true, - "allowSyntheticDefaultImports": true, "strictBindCallApply": true, "strictNullChecks": false, "importHelpers": false diff --git a/packages/core/tsconfig.build.tools.json b/packages/core/tsconfig.build.tools.json index ac4f55f2cd..ac86a9a64d 100644 --- a/packages/core/tsconfig.build.tools.json +++ b/packages/core/tsconfig.build.tools.json @@ -14,7 +14,6 @@ "target": "es6", "module": "CommonJS", "skipLibCheck": true, - "allowSyntheticDefaultImports": true, "importHelpers": false } } diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 7f757b53ce..8645e59737 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -12,7 +12,6 @@ "plugin/**/*.ts" ], "exclude": ["dist"], - "allowSyntheticDefaultImports": true, "compilerOptions": { "rootDir": ".", "jsx": "react", From 99b28526ffe2f171e19f3d966625b26d1a51239a Mon Sep 17 00:00:00 2001 From: LucasZF Date: Tue, 15 Apr 2025 13:42:36 -0300 Subject: [PATCH 07/64] Ref: Use main carrier on useEncodePolyfill (#4731) * bump SDKs * bump SDKs * fix build * fix tests * fix tests * fix lint errors * test ts 5.0 * rollback * fix merge conflict with yarn * fix new lint issue * sync yarn.lock with V7 branch and install new packages * ensure we are using the JS version from the default node resolution * update changelog with javascript version bump * fix check type (#4587) * add major changes to the SDK * fix lint * review check: fix changelog PR number / Fix wrapper incorrect null check / removed comment from rnerror handler / removed comment from span / fix test from userInteraction * fix incorrect cli version * fix lint * remove shutdowntimeout from android / use newer wizard version * rollback feedback test change, rollback jest version, fix safe test * return shutdowntimeout * explain tracing sample rate * fix tracing extension test * lint fix * update changelog * fix yarn lock merge/ fix ts-jest version no longer exists / fix core version on samples and e2e * fix lint on addTimeToInitialDisplay * fix issue with UIManager test * use main carrier * fix yarn lint * moved major changes to the correct spot --- packages/core/src/js/transports/encodePolyfill.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/core/src/js/transports/encodePolyfill.ts b/packages/core/src/js/transports/encodePolyfill.ts index 3d801561b7..102d1886fb 100644 --- a/packages/core/src/js/transports/encodePolyfill.ts +++ b/packages/core/src/js/transports/encodePolyfill.ts @@ -1,14 +1,16 @@ -import { SDK_VERSION } from '@sentry/core'; +import { getMainCarrier, SDK_VERSION } from '@sentry/core'; -import { RN_GLOBAL_OBJ } from '../utils/worldwide'; +import type { RN_GLOBAL_OBJ } from '../utils/worldwide'; import { utf8ToBytes } from '../vendor'; export const useEncodePolyfill = (): void => { - if (!RN_GLOBAL_OBJ.__SENTRY__) { - (RN_GLOBAL_OBJ.__SENTRY__ as Partial<(typeof RN_GLOBAL_OBJ)['__SENTRY__']>) = {}; + const globalCarriers = getMainCarrier().__SENTRY__; + + if (!globalCarriers) { + (globalCarriers as Partial<(typeof RN_GLOBAL_OBJ)['__SENTRY__']>) = {}; } - RN_GLOBAL_OBJ.__SENTRY__[SDK_VERSION].encodePolyfill = encodePolyfill; + globalCarriers[SDK_VERSION].encodePolyfill = encodePolyfill; }; export const encodePolyfill = (text: string): Uint8Array => { From 51f9b96c8337f9603ab8016fdb2d7b83a9f8ac05 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Wed, 16 Apr 2025 12:43:35 +0300 Subject: [PATCH 08/64] chore(deps): v7: Bump Android SDK to v8.6.0 (#4663) * Bump Android SDK to v8.4.0 * Updates changelog * Bump from 8.4.0 to 8.5.0 * Bump from 8.5.0 to 8.6.0 --------- Co-authored-by: LucasZF --- CHANGELOG.md | 6 +++--- packages/core/android/build.gradle | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58c05d332a..7153d90d85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -226,9 +226,9 @@ Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](http - Bump JavaScript SDK from v8.54.0 to v9.1.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568)) - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.1.0/CHANGELOG.md) - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.1.0) -- Bump Android SDK from v7.20.1 to v8.3.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490)) - - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#830) - - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.3.0) +- Bump Android SDK from v7.20.1 to v8.6.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490), [#4663](https://github.com/getsentry/sentry-react-native/pull/4663)) + - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#860) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.6.0) - Bump Cocoa SDK from v8.44.0 to v8.45.0 ([#4537](https://github.com/getsentry/sentry-react-native/pull/4537)) - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8450) - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.44.0...8.45.0) diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index 13d61a054b..e7eee49a53 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -54,5 +54,5 @@ android { dependencies { implementation 'com.facebook.react:react-native:+' - api 'io.sentry:sentry-android:8.3.0' + api 'io.sentry:sentry-android:8.6.0' } From 2c9bcd9fe118fb05a95536367ff674e7f7d670b6 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Wed, 16 Apr 2025 12:18:49 +0200 Subject: [PATCH 09/64] fix(changelog): Move JS and Android deps to the unreleased section (#4756) --- CHANGELOG.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1281afe6b3..88f77b338e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,12 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi ### Dependencies +- Bump JavaScript SDK from v8.54.0 to v9.1.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568)) + - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.1.0/CHANGELOG.md) + - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.1.0) +- Bump Android SDK from v7.20.1 to v8.6.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490), [#4663](https://github.com/getsentry/sentry-react-native/pull/4663)) + - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#860) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.6.0) - Bump Bundler Plugins from v3.2.2 to v3.3.1 ([#4693](https://github.com/getsentry/sentry-react-native/pull/4693), [#4707](https://github.com/getsentry/sentry-react-native/pull/4707), [#4720](https://github.com/getsentry/sentry-react-native/pull/4720), [#4721](https://github.com/getsentry/sentry-react-native/pull/4721)) - [changelog](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/CHANGELOG.md#331) - [diff](https://github.com/getsentry/sentry-javascript-bundler-plugins/compare/3.2.2...3.3.1) @@ -232,12 +238,9 @@ Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](http ### Dependencies -- Bump JavaScript SDK from v8.54.0 to v9.1.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568)) - - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.1.0/CHANGELOG.md) - - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.1.0) -- Bump Android SDK from v7.20.1 to v8.6.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490), [#4663](https://github.com/getsentry/sentry-react-native/pull/4663)) - - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#860) - - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.6.0) +- Bump Android SDK from v7.20.1 to v7.22.0 ([#4529](https://github.com/getsentry/sentry-react-native/pull/4529)) + - [changelog](https://github.com/getsentry/sentry-java/blob/7.x.x/CHANGELOG.md#7220) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...7.22.0) - Bump Cocoa SDK from v8.44.0 to v8.45.0 ([#4537](https://github.com/getsentry/sentry-react-native/pull/4537)) - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8450) - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.44.0...8.45.0) From 4fabd63fdf591d6f561db961d45685ac6cd86892 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Wed, 16 Apr 2025 12:50:46 +0200 Subject: [PATCH 10/64] chore: bump JavaScript SDK to v9.12.0 (#4752) --- CHANGELOG.md | 9 +- dev-packages/e2e-tests/package.json | 2 +- dev-packages/type-check/ts3.8-test/index.ts | 1 + packages/core/package.json | 14 +- .../tools/fixtures/mockBabelTransformer.js | 3 + samples/react-native-macos/package.json | 4 +- samples/react-native/package.json | 2 +- yarn.lock | 145 +++++++++--------- 8 files changed, 90 insertions(+), 90 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88f77b338e..9e4c98107e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,9 +22,9 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi ### Dependencies -- Bump JavaScript SDK from v8.54.0 to v9.1.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568)) - - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.1.0/CHANGELOG.md) - - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.1.0) +- Bump JavaScript SDK from v8.54.0 to v9.12.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568), [#4752](https://github.com/getsentry/sentry-react-native/pull/4752)) + - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.12.0/CHANGELOG.md) + - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.12.0) - Bump Android SDK from v7.20.1 to v8.6.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490), [#4663](https://github.com/getsentry/sentry-react-native/pull/4663)) - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#860) - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.6.0) @@ -238,9 +238,6 @@ Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](http ### Dependencies -- Bump Android SDK from v7.20.1 to v7.22.0 ([#4529](https://github.com/getsentry/sentry-react-native/pull/4529)) - - [changelog](https://github.com/getsentry/sentry-java/blob/7.x.x/CHANGELOG.md#7220) - - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...7.22.0) - Bump Cocoa SDK from v8.44.0 to v8.45.0 ([#4537](https://github.com/getsentry/sentry-react-native/pull/4537)) - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8450) - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.44.0...8.45.0) diff --git a/dev-packages/e2e-tests/package.json b/dev-packages/e2e-tests/package.json index 1be91abf60..1e4a666698 100644 --- a/dev-packages/e2e-tests/package.json +++ b/dev-packages/e2e-tests/package.json @@ -13,7 +13,7 @@ "devDependencies": { "@babel/preset-env": "^7.25.3", "@babel/preset-typescript": "^7.18.6", - "@sentry/core": "9.1.0", + "@sentry/core": "9.12.0", "@sentry/react-native": "6.11.0-beta.0", "@types/node": "^20.9.3", "@types/react": "^18.2.64", diff --git a/dev-packages/type-check/ts3.8-test/index.ts b/dev-packages/type-check/ts3.8-test/index.ts index 94e332746c..d6cc248482 100644 --- a/dev-packages/type-check/ts3.8-test/index.ts +++ b/dev-packages/type-check/ts3.8-test/index.ts @@ -22,6 +22,7 @@ declare global { } interface PerformanceEntry {} interface Performance {} + interface PerformanceNavigationTiming {} } declare module 'react-native' { diff --git a/packages/core/package.json b/packages/core/package.json index 2b9930a503..e18fef732f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -66,20 +66,20 @@ }, "dependencies": { "@sentry/babel-plugin-component-annotate": "3.3.1", - "@sentry/browser": "9.1.0", + "@sentry/browser": "9.12.0", "@sentry/cli": "2.43.0", - "@sentry/core": "9.1.0", - "@sentry/react": "9.1.0", - "@sentry/types": "9.1.0" + "@sentry/core": "9.12.0", + "@sentry/react": "9.12.0", + "@sentry/types": "9.12.0" }, "devDependencies": { "@babel/core": "^7.25.2", "@expo/metro-config": "0.19.5", "@mswjs/interceptors": "^0.25.15", "@react-native/babel-preset": "0.77.1", - "@sentry-internal/eslint-config-sdk": "9.1.0", - "@sentry-internal/eslint-plugin-sdk": "9.1.0", - "@sentry-internal/typescript": "9.1.0", + "@sentry-internal/eslint-config-sdk": "9.12.0", + "@sentry-internal/eslint-plugin-sdk": "9.12.0", + "@sentry-internal/typescript": "9.12.0", "@sentry/wizard": "4.7.0", "@testing-library/react-native": "^12.7.2", "@types/jest": "^29.5.13", diff --git a/packages/core/test/tools/fixtures/mockBabelTransformer.js b/packages/core/test/tools/fixtures/mockBabelTransformer.js index 17628495a5..0e0aad9bd5 100644 --- a/packages/core/test/tools/fixtures/mockBabelTransformer.js +++ b/packages/core/test/tools/fixtures/mockBabelTransformer.js @@ -1,3 +1,6 @@ +var globals = require('@jest/globals'); +var jest = globals.jest; + module.exports = { transform: jest.fn(), getCacheKey: jest.fn(), diff --git a/samples/react-native-macos/package.json b/samples/react-native-macos/package.json index 2938c0dde6..bad4d716f1 100644 --- a/samples/react-native-macos/package.json +++ b/samples/react-native-macos/package.json @@ -16,8 +16,8 @@ "@react-navigation/bottom-tabs": "^6.5.12", "@react-navigation/native": "^6.1.9", "@react-navigation/stack": "^6.3.20", - "@sentry/core": "9.1.0", - "@sentry/react": "9.1.0", + "@sentry/core": "9.12.0", + "@sentry/react": "9.12.0", "@sentry/react-native": "6.11.0-beta.0", "delay": "^6.0.0", "react": "18.2.0", diff --git a/samples/react-native/package.json b/samples/react-native/package.json index 80c7fc507f..6fb1576ae4 100644 --- a/samples/react-native/package.json +++ b/samples/react-native/package.json @@ -27,7 +27,7 @@ "@react-navigation/native": "^7.0.14", "@react-navigation/native-stack": "^7.2.0", "@react-navigation/stack": "^7.1.1", - "@sentry/core": "9.1.0", + "@sentry/core": "9.12.0", "@sentry/react-native": "6.11.0-beta.0", "@shopify/flash-list": "^1.7.3", "axios": "^1.8.3", diff --git a/yarn.lock b/yarn.lock index 2ca1150ab6..1ea089d174 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8183,68 +8183,67 @@ __metadata: languageName: node linkType: hard -"@sentry-internal/browser-utils@npm:9.1.0": - version: 9.1.0 - resolution: "@sentry-internal/browser-utils@npm:9.1.0" +"@sentry-internal/browser-utils@npm:9.12.0": + version: 9.12.0 + resolution: "@sentry-internal/browser-utils@npm:9.12.0" dependencies: - "@sentry/core": 9.1.0 - checksum: 08c6b383fe2256d367469269d15f454f9a1345f9ae49ae63682265f0052821b259728907afc3c231186953cca14d08b43a2386fe3e984338f988ae9ae8175064 + "@sentry/core": 9.12.0 + checksum: b44b14bffdb7ffe0ea8efd8a8930563af8458c16343f07ed179569cdcb01bc56f99f821ef4782c9fa52d8c500bf4a409cb9ddc3c785bfe887033e7f86449b15f languageName: node linkType: hard -"@sentry-internal/eslint-config-sdk@npm:9.1.0": - version: 9.1.0 - resolution: "@sentry-internal/eslint-config-sdk@npm:9.1.0" +"@sentry-internal/eslint-config-sdk@npm:9.12.0": + version: 9.12.0 + resolution: "@sentry-internal/eslint-config-sdk@npm:9.12.0" dependencies: - "@sentry-internal/eslint-plugin-sdk": 9.1.0 - "@sentry-internal/typescript": 9.1.0 + "@sentry-internal/eslint-plugin-sdk": 9.12.0 + "@sentry-internal/typescript": 9.12.0 "@typescript-eslint/eslint-plugin": ^5.48.0 "@typescript-eslint/parser": ^5.48.0 eslint-config-prettier: ^6.11.0 eslint-plugin-deprecation: ^1.5.0 eslint-plugin-import: ^2.22.0 - eslint-plugin-jest: ^27.2.2 eslint-plugin-jsdoc: ^30.0.3 eslint-plugin-simple-import-sort: ^5.0.3 peerDependencies: eslint: ">=5" - checksum: aef3a7b34b32202303dcc9d75f213a37d471354673bdfd97d31f8909e3e24ffe0d7dff595097c9a0055a5f9addbc91758ea667ca82206368f687a85d669295b3 + checksum: 1d4151bc3a4e566579438c93798d8eb91cf004bad19ccd559981ac2abf56b7a62e3e099101fe558119052ffe3f632ace4e91649def9cb74cc98616a0479013e3 languageName: node linkType: hard -"@sentry-internal/eslint-plugin-sdk@npm:9.1.0": - version: 9.1.0 - resolution: "@sentry-internal/eslint-plugin-sdk@npm:9.1.0" - checksum: 28eab0a957912dbc82c2b308af84a9105b23eb66f582134f14132dec68de114de196114b8ecdef75fd1b91ee4691735d2760585c512775d0d691b45fc09650a3 +"@sentry-internal/eslint-plugin-sdk@npm:9.12.0": + version: 9.12.0 + resolution: "@sentry-internal/eslint-plugin-sdk@npm:9.12.0" + checksum: 2ac6e8aeb1b22689232c8cd77fd19761e6ec7a6a3f7ae0f8940b28bcedf2c364f6bdb44b0e4f604fe471438c33f722c2d5e4c9020b391be85a03e4ea518be4d9 languageName: node linkType: hard -"@sentry-internal/feedback@npm:9.1.0": - version: 9.1.0 - resolution: "@sentry-internal/feedback@npm:9.1.0" +"@sentry-internal/feedback@npm:9.12.0": + version: 9.12.0 + resolution: "@sentry-internal/feedback@npm:9.12.0" dependencies: - "@sentry/core": 9.1.0 - checksum: 4f0b3335e391d55ffdcac56bfbcbf9fa62ba865ab75c97daf6904cca6f5ea4cce156a78adddd81d3bd4119f9bd8c81e5bb18d330f61c77800cd911c74f776689 + "@sentry/core": 9.12.0 + checksum: 6245100c50b48c178bc2b54999ec6c05614b3de3612902d67ac7cafc1e32fbc2735922461ce6afa82d7a5b1d389c98e65b0a822be739345b05e4ab2676f3ac00 languageName: node linkType: hard -"@sentry-internal/replay-canvas@npm:9.1.0": - version: 9.1.0 - resolution: "@sentry-internal/replay-canvas@npm:9.1.0" +"@sentry-internal/replay-canvas@npm:9.12.0": + version: 9.12.0 + resolution: "@sentry-internal/replay-canvas@npm:9.12.0" dependencies: - "@sentry-internal/replay": 9.1.0 - "@sentry/core": 9.1.0 - checksum: 413fd391dcb0bdae64ce70ea1b37f5935d9449a44172d98363eda64385775573b444ec5e56e700445c20f53ca8a7bca6157889732c5985b6450d5f0f09c3abc3 + "@sentry-internal/replay": 9.12.0 + "@sentry/core": 9.12.0 + checksum: 5ff030866e8a88273b320cafd3ce89f2816c58dc57e9f2f4900aa4364d59b6a71655bc618ec32d9f03631d68ce2cc11539567bf18c4564ffd32363c88282bc8e languageName: node linkType: hard -"@sentry-internal/replay@npm:9.1.0": - version: 9.1.0 - resolution: "@sentry-internal/replay@npm:9.1.0" +"@sentry-internal/replay@npm:9.12.0": + version: 9.12.0 + resolution: "@sentry-internal/replay@npm:9.12.0" dependencies: - "@sentry-internal/browser-utils": 9.1.0 - "@sentry/core": 9.1.0 - checksum: 11ef5a88d3bafd2b5143a150af7b0c77af521a17bf48e1840b2fd2116c55e7acd49ddce3618a1191ccc11b8b38e70ab8c59a030a90557c21499e2e815ce184fb + "@sentry-internal/browser-utils": 9.12.0 + "@sentry/core": 9.12.0 + checksum: 47074f5f316860b0909d892132367104b38ad4c75ec6545b3ab484d3af0ec0c873ca2679582769ebf76c80b43ac26347dc33a9cf1e3b79ddb2043eef5dcb3c69 languageName: node linkType: hard @@ -8259,12 +8258,12 @@ __metadata: languageName: node linkType: hard -"@sentry-internal/typescript@npm:9.1.0": - version: 9.1.0 - resolution: "@sentry-internal/typescript@npm:9.1.0" +"@sentry-internal/typescript@npm:9.12.0": + version: 9.12.0 + resolution: "@sentry-internal/typescript@npm:9.12.0" peerDependencies: typescript: ~5.0.0 - checksum: 76bc7fefc76af9000b3f78f5270349f844261f079775753c36aa46e78dea963c89dbfdeddf4bd36b6c5fc197b4415f9c1883a38287fa4d6a90ded51ae5e97f25 + checksum: dfcbb2a0df26196d0ba87d53389784f7291cb01f85a1fe10ad51033c9e01a1f3c5397c08ee3c3fce475f6290e37291ab5d8aca563d2030cc9072232975aeff89 languageName: node linkType: hard @@ -8275,16 +8274,16 @@ __metadata: languageName: node linkType: hard -"@sentry/browser@npm:9.1.0": - version: 9.1.0 - resolution: "@sentry/browser@npm:9.1.0" +"@sentry/browser@npm:9.12.0": + version: 9.12.0 + resolution: "@sentry/browser@npm:9.12.0" dependencies: - "@sentry-internal/browser-utils": 9.1.0 - "@sentry-internal/feedback": 9.1.0 - "@sentry-internal/replay": 9.1.0 - "@sentry-internal/replay-canvas": 9.1.0 - "@sentry/core": 9.1.0 - checksum: 782ce1b01d3719c0047a2bc5bf3ef0463188a70224109562c6d22341d4fb647992775b2f62a2b45e0a185fb1c4cab49f07298b67c2c290e87e281405f6af8a4c + "@sentry-internal/browser-utils": 9.12.0 + "@sentry-internal/feedback": 9.12.0 + "@sentry-internal/replay": 9.12.0 + "@sentry-internal/replay-canvas": 9.12.0 + "@sentry/core": 9.12.0 + checksum: 4acd1e65dd3a4ce6ca2150a1945ace0ab50e482aa0dd39ed1a3fc1fd3be9d7318af2781f947faf594aaee9d32c58650743527de56d0aeb46b8c5aa1867c37e9e languageName: node linkType: hard @@ -8394,10 +8393,10 @@ __metadata: languageName: node linkType: hard -"@sentry/core@npm:9.1.0": - version: 9.1.0 - resolution: "@sentry/core@npm:9.1.0" - checksum: 81713903ab3be8940eae23f22a4efe753f4c14e10f618c0bd79128028dde0810909a93b23a87407658010d5097a620e31ccb91ca50b86ee7eb69a26d80a747f3 +"@sentry/core@npm:9.12.0": + version: 9.12.0 + resolution: "@sentry/core@npm:9.12.0" + checksum: 6bf8b5f7fe91897a598c608a17a6b2024d59c2055e5714629aba280ba7004dae4171481b455d61514367d264b3e2a5b2e82fd0cc264993020cc8fd93ddac03dc languageName: node linkType: hard @@ -8434,15 +8433,15 @@ __metadata: "@expo/metro-config": 0.19.5 "@mswjs/interceptors": ^0.25.15 "@react-native/babel-preset": 0.77.1 - "@sentry-internal/eslint-config-sdk": 9.1.0 - "@sentry-internal/eslint-plugin-sdk": 9.1.0 - "@sentry-internal/typescript": 9.1.0 + "@sentry-internal/eslint-config-sdk": 9.12.0 + "@sentry-internal/eslint-plugin-sdk": 9.12.0 + "@sentry-internal/typescript": 9.12.0 "@sentry/babel-plugin-component-annotate": 3.3.1 - "@sentry/browser": 9.1.0 + "@sentry/browser": 9.12.0 "@sentry/cli": 2.43.0 - "@sentry/core": 9.1.0 - "@sentry/react": 9.1.0 - "@sentry/types": 9.1.0 + "@sentry/core": 9.12.0 + "@sentry/react": 9.12.0 + "@sentry/types": 9.12.0 "@sentry/wizard": 4.7.0 "@testing-library/react-native": ^12.7.2 "@types/jest": ^29.5.13 @@ -8489,16 +8488,16 @@ __metadata: languageName: unknown linkType: soft -"@sentry/react@npm:9.1.0": - version: 9.1.0 - resolution: "@sentry/react@npm:9.1.0" +"@sentry/react@npm:9.12.0": + version: 9.12.0 + resolution: "@sentry/react@npm:9.12.0" dependencies: - "@sentry/browser": 9.1.0 - "@sentry/core": 9.1.0 + "@sentry/browser": 9.12.0 + "@sentry/core": 9.12.0 hoist-non-react-statics: ^3.3.2 peerDependencies: react: ^16.14.0 || 17.x || 18.x || 19.x - checksum: 670cfde6f966079e4224bba0a5020f059f7c2c99e2bdd9f4163b0fbb367cb29e407de671be4dac1a684f18a80ae0c65ef0c179143e1772ef3dcc258c80d01ae8 + checksum: 67f1d406a6a2232de72bfe3fe7cf33a95c925b442b9b2d56d2dcab4b53d40e34a19c6fbfb4bd794858dceb5db0f60ec7b26631bf924c119abb083b8ca789e394 languageName: node linkType: hard @@ -8509,12 +8508,12 @@ __metadata: languageName: node linkType: hard -"@sentry/types@npm:9.1.0": - version: 9.1.0 - resolution: "@sentry/types@npm:9.1.0" +"@sentry/types@npm:9.12.0": + version: 9.12.0 + resolution: "@sentry/types@npm:9.12.0" dependencies: - "@sentry/core": 9.1.0 - checksum: 9193a6ba72efaaa2605301d0dd54651e240c02e380ce89fc402945a70b5d1da85a4a4f562d9ac99e9e8e64dc988a59ce3b9bbc88be2cd47590acb6ae019e7080 + "@sentry/core": 9.12.0 + checksum: 3cbb403828014e5aea7b92ebb9e3dc7c14d4e6bea0f3e0a54b26f33ddd5e68b457c5a217c9db055857202475a380d0a2733cbe24c2727faa2be48a4e12395512 languageName: node linkType: hard @@ -14465,7 +14464,7 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-jest@npm:^27.2.2, eslint-plugin-jest@npm:^27.9.0": +"eslint-plugin-jest@npm:^27.9.0": version: 27.9.0 resolution: "eslint-plugin-jest@npm:27.9.0" dependencies: @@ -25088,7 +25087,7 @@ __metadata: dependencies: "@babel/preset-env": ^7.25.3 "@babel/preset-typescript": ^7.18.6 - "@sentry/core": 9.1.0 + "@sentry/core": 9.12.0 "@sentry/react-native": 6.11.0-beta.0 "@types/node": ^20.9.3 "@types/react": ^18.2.64 @@ -25155,8 +25154,8 @@ __metadata: "@react-navigation/bottom-tabs": ^6.5.12 "@react-navigation/native": ^6.1.9 "@react-navigation/stack": ^6.3.20 - "@sentry/core": 9.1.0 - "@sentry/react": 9.1.0 + "@sentry/core": 9.12.0 + "@sentry/react": 9.12.0 "@sentry/react-native": 6.11.0-beta.0 "@types/react": ^18.2.65 "@types/react-native-vector-icons": ^6.4.18 @@ -25203,7 +25202,7 @@ __metadata: "@react-navigation/native-stack": ^7.2.0 "@react-navigation/stack": ^7.1.1 "@sentry/babel-plugin-component-annotate": 3.3.1 - "@sentry/core": 9.1.0 + "@sentry/core": 9.12.0 "@sentry/react-native": 6.11.0-beta.0 "@shopify/flash-list": ^1.7.3 "@types/jest": ^29.5.14 From 29876df8fd4a6e3a115242da3d31889b51db7479 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Wed, 16 Apr 2025 15:47:17 +0200 Subject: [PATCH 11/64] fix(sdk): Set `{{auto}}` if `user.ip_address` is `undefined` and `sendDefaultPii: true` (#4466) --- CHANGELOG.md | 2 +- packages/core/src/js/client.ts | 14 +- packages/core/test/client.test.ts | 237 +++++++++++++++++++++++++++++- 3 files changed, 249 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e4c98107e..f99bca603c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,7 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi ### Major Changes -- `ip addresses` is only collected when `sendDefaultPii`: `true` +- Set `{{auto}}` if `user.ip_address` is `undefined` and `sendDefaultPii: true` ([#4466](https://github.com/getsentry/sentry-react-native/pull/4466)) - Exceptions from `captureConsoleIntegration` are now marked as handled: true by default - `shutdownTimeout` moved from `core` to `@sentry/react-native` - `hasTracingEnabled` was renamed to `hasSpansEnabled` diff --git a/packages/core/src/js/client.ts b/packages/core/src/js/client.ts index d838167093..4c2911fbbe 100644 --- a/packages/core/src/js/client.ts +++ b/packages/core/src/js/client.ts @@ -10,7 +10,14 @@ import type { TransportMakeRequestResponse, UserFeedback, } from '@sentry/core'; -import { BaseClient, dateTimestampInSeconds, logger, SentryError } from '@sentry/core'; +import { + addAutoIpAddressToSession, + addAutoIpAddressToUser, + BaseClient, + dateTimestampInSeconds, + logger, + SentryError, +} from '@sentry/core'; import { Alert } from 'react-native'; import { getDevServer } from './integrations/debugsymbolicatorutils'; @@ -48,6 +55,11 @@ export class ReactNativeClient extends BaseClient { super(options); this._outcomesBuffer = []; + + if (options.sendDefaultPii === true) { + this.on('postprocessEvent', addAutoIpAddressToUser); + this.on('beforeSendSession', addAutoIpAddressToSession); + } } /** diff --git a/packages/core/test/client.test.ts b/packages/core/test/client.test.ts index 8cb4217356..8e00c06bf9 100644 --- a/packages/core/test/client.test.ts +++ b/packages/core/test/client.test.ts @@ -2,8 +2,21 @@ import * as mockedtimetodisplaynative from './tracing/mockedtimetodisplaynative' jest.mock('../src/js/tracing/timetodisplaynative', () => mockedtimetodisplaynative); import { defaultStackParser } from '@sentry/browser'; -import type { Envelope, Event, Outcome, Transport, TransportMakeRequestResponse } from '@sentry/core'; -import { rejectedSyncPromise, SentryError } from '@sentry/core'; +import type { + Envelope, + Event, + Outcome, + SessionAggregates, + Transport, + TransportMakeRequestResponse, +} from '@sentry/core'; +import { + addAutoIpAddressToSession, + addAutoIpAddressToUser, + makeSession, + rejectedSyncPromise, + SentryError, +} from '@sentry/core'; import * as RN from 'react-native'; import { ReactNativeClient } from '../src/js/client'; @@ -625,6 +638,206 @@ describe('Tests ReactNativeClient', () => { client.recordDroppedEvent('before_send', 'error'); } }); + + describe('ipAddress', () => { + let mockTransportSend: jest.Mock; + let client: ReactNativeClient; + + beforeEach(() => { + mockTransportSend = jest.fn(() => Promise.resolve()); + client = new ReactNativeClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + sendDefaultPii: true, + }); + }); + + test('preserves ip_address null', () => { + client.captureEvent({ + user: { + ip_address: null, + }, + }); + + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user).toEqual( + expect.objectContaining({ ip_address: null }), + ); + }); + + test('preserves ip_address value if set', () => { + client.captureEvent({ + user: { + ip_address: '203.45.167.89', + }, + }); + + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user).toEqual( + expect.objectContaining({ ip_address: '203.45.167.89' }), + ); + }); + + test('adds ip_address {{auto}} to user if set to undefined', () => { + client.captureEvent({ + user: { + ip_address: undefined, + }, + }); + + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user).toEqual( + expect.objectContaining({ ip_address: '{{auto}}' }), + ); + }); + + test('adds ip_address {{auto}} to user if not set', () => { + client.captureEvent({ + user: {}, + }); + + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user).toEqual( + expect.objectContaining({ ip_address: '{{auto}}' }), + ); + }); + + test('adds ip_address {{auto}} to undefined user', () => { + client.captureEvent({}); + + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user).toEqual( + expect.objectContaining({ ip_address: '{{auto}}' }), + ); + }); + + test('does not add ip_address {{auto}} to undefined user if sendDefaultPii is false', () => { + const { client, onSpy } = createClientWithSpy({ + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + sendDefaultPii: false, + }); + + client.captureEvent({}); + + expect(onSpy).not.toHaveBeenCalledWith('postprocessEvent', addAutoIpAddressToUser); + expect( + mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].user?.ip_address, + ).toBeUndefined(); + }); + + test('uses ip address hooks if sendDefaultPii is true', () => { + const { onSpy } = createClientWithSpy({ + sendDefaultPii: true, + }); + + expect(onSpy).toHaveBeenCalledWith('postprocessEvent', addAutoIpAddressToUser); + expect(onSpy).toHaveBeenCalledWith('beforeSendSession', addAutoIpAddressToSession); + }); + + test('does not add ip_address {{auto}} to session if sendDefaultPii is false', () => { + const { client, onSpy } = createClientWithSpy({ + release: 'test', // required for sessions to be sent + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + sendDefaultPii: false, + }); + + const session = makeSession(); + session.ipAddress = undefined; + client.captureSession(session); + + expect(onSpy).not.toHaveBeenCalledWith('beforeSendSession', addAutoIpAddressToSession); + expect( + mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].attrs.ip_address, + ).toBeUndefined(); + }); + + test('does not add ip_address {{auto}} to session aggregate if sendDefaultPii is false', () => { + const { client, onSpy } = createClientWithSpy({ + release: 'test', // required for sessions to be sent + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + sendDefaultPii: false, + }); + + const session: SessionAggregates = { + aggregates: [], + }; + client.sendSession(session); + + expect(onSpy).not.toHaveBeenCalledWith('beforeSendSession', addAutoIpAddressToSession); + expect( + mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].attrs.ip_address, + ).toBeUndefined(); + }); + + test('does not overwrite session aggregate ip_address if already set', () => { + const { client } = createClientWithSpy({ + release: 'test', // required for sessions to be sent + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + sendDefaultPii: true, + }); + + const session: SessionAggregates = { + aggregates: [], + attrs: { + ip_address: '123.45.67.89', + }, + }; + client.sendSession(session); + + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].attrs.ip_address).toBe( + '123.45.67.89', + ); + }); + + test('does add ip_address {{auto}} to session if sendDefaultPii is true', () => { + const { client } = createClientWithSpy({ + release: 'test', // required for sessions to be sent + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + sendDefaultPii: true, + }); + + const session = makeSession(); + session.ipAddress = undefined; + client.captureSession(session); + + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].attrs.ip_address).toBe( + '{{auto}}', + ); + }); + + test('does not overwrite session ip_address if already set', () => { + const { client } = createClientWithSpy({ + release: 'test', // required for sessions to be sent + transport: () => ({ + send: mockTransportSend, + flush: jest.fn(), + }), + sendDefaultPii: true, + }); + + const session = makeSession(); + session.ipAddress = '123.45.67.89'; + client.captureSession(session); + + expect(mockTransportSend.mock.calls[0][firstArg][envelopeItems][0][envelopeItemPayload].attrs.ip_address).toBe( + '123.45.67.89', + ); + }); + }); }); function mockedOptions(options: Partial): ReactNativeClientOptions { @@ -638,3 +851,23 @@ function mockedOptions(options: Partial): ReactNativeC ...options, }; } + +function createClientWithSpy(options: Partial) { + const onSpy = jest.fn(); + class SpyClient extends ReactNativeClient { + public on(hook: string, callback: unknown): () => void { + onSpy(hook, callback); + // @ts-expect-error - the public interface doesn't allow string and unknown + return super.on(hook, callback); + } + } + + return { + client: new SpyClient({ + ...DEFAULT_OPTIONS, + dsn: EXAMPLE_DSN, + ...options, + }), + onSpy, + }; +} From 6f2f83f9abf75e18fdfe6c636ae6a75400672143 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Tue, 22 Apr 2025 17:44:39 +0300 Subject: [PATCH 12/64] chore(deps): v7: Bump Android SDK to v8.8.0 (#4755) * Bump Android SDK to v8.4.0 * Updates changelog * Bump from 8.4.0 to 8.5.0 * Bump from 8.5.0 to 8.6.0 * Bump Android SDK from 8.6 to 8.8 * Update changelog * Moves version bump in the unreleased section --------- Co-authored-by: LucasZF --- CHANGELOG.md | 6 +++--- packages/core/android/build.gradle | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f99bca603c..4f29236e07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,9 +25,9 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi - Bump JavaScript SDK from v8.54.0 to v9.12.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568), [#4752](https://github.com/getsentry/sentry-react-native/pull/4752)) - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.12.0/CHANGELOG.md) - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.12.0) -- Bump Android SDK from v7.20.1 to v8.6.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490), [#4663](https://github.com/getsentry/sentry-react-native/pull/4663)) - - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#860) - - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.6.0) +- Bump Android SDK from v7.20.1 to v8.8.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490), [#4663](https://github.com/getsentry/sentry-react-native/pull/4663), [#4755](https://github.com/getsentry/sentry-react-native/pull/4755)) + - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#880) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.8.0) - Bump Bundler Plugins from v3.2.2 to v3.3.1 ([#4693](https://github.com/getsentry/sentry-react-native/pull/4693), [#4707](https://github.com/getsentry/sentry-react-native/pull/4707), [#4720](https://github.com/getsentry/sentry-react-native/pull/4720), [#4721](https://github.com/getsentry/sentry-react-native/pull/4721)) - [changelog](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/CHANGELOG.md#331) - [diff](https://github.com/getsentry/sentry-javascript-bundler-plugins/compare/3.2.2...3.3.1) diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index e7eee49a53..bffa34b91c 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -54,5 +54,5 @@ android { dependencies { implementation 'com.facebook.react:react-native:+' - api 'io.sentry:sentry-android:8.6.0' + api 'io.sentry:sentry-android:8.8.0' } From 61f61ca5815dafb1d5f1eada9e9dbbc1cba65b9a Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Thu, 24 Apr 2025 09:22:22 +0300 Subject: [PATCH 13/64] chore(deps): v7: Bump Android SDK to v8.9.0 (#4775) * Bump Android to 8.9.0 * Update changelog * Keep only the PR that introduced changes --- CHANGELOG.md | 6 +++--- packages/core/android/build.gradle | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f29236e07..7a69bd548a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,9 +25,9 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi - Bump JavaScript SDK from v8.54.0 to v9.12.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568), [#4752](https://github.com/getsentry/sentry-react-native/pull/4752)) - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.12.0/CHANGELOG.md) - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.12.0) -- Bump Android SDK from v7.20.1 to v8.8.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490), [#4663](https://github.com/getsentry/sentry-react-native/pull/4663), [#4755](https://github.com/getsentry/sentry-react-native/pull/4755)) - - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#880) - - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.8.0) +- Bump Android SDK from v7.20.1 to v8.9.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490)) + - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#890) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.9.0) - Bump Bundler Plugins from v3.2.2 to v3.3.1 ([#4693](https://github.com/getsentry/sentry-react-native/pull/4693), [#4707](https://github.com/getsentry/sentry-react-native/pull/4707), [#4720](https://github.com/getsentry/sentry-react-native/pull/4720), [#4721](https://github.com/getsentry/sentry-react-native/pull/4721)) - [changelog](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/CHANGELOG.md#331) - [diff](https://github.com/getsentry/sentry-javascript-bundler-plugins/compare/3.2.2...3.3.1) diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index bffa34b91c..5631c86165 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -54,5 +54,5 @@ android { dependencies { implementation 'com.facebook.react:react-native:+' - api 'io.sentry:sentry-android:8.8.0' + api 'io.sentry:sentry-android:8.9.0' } From 261f6a94b45d107d75920afc45400f256eefb025 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Mon, 28 Apr 2025 17:44:50 +0300 Subject: [PATCH 14/64] Bump Android from 8.9.0 to 8.10.0 (#4781) --- CHANGELOG.md | 4 ++-- packages/core/android/build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a69bd548a..11264c84f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,8 +26,8 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.12.0/CHANGELOG.md) - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.12.0) - Bump Android SDK from v7.20.1 to v8.9.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490)) - - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#890) - - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.9.0) + - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8100) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.10.0) - Bump Bundler Plugins from v3.2.2 to v3.3.1 ([#4693](https://github.com/getsentry/sentry-react-native/pull/4693), [#4707](https://github.com/getsentry/sentry-react-native/pull/4707), [#4720](https://github.com/getsentry/sentry-react-native/pull/4720), [#4721](https://github.com/getsentry/sentry-react-native/pull/4721)) - [changelog](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/CHANGELOG.md#331) - [diff](https://github.com/getsentry/sentry-javascript-bundler-plugins/compare/3.2.2...3.3.1) diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index 5631c86165..d72655845b 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -54,5 +54,5 @@ android { dependencies { implementation 'com.facebook.react:react-native:+' - api 'io.sentry:sentry-android:8.9.0' + api 'io.sentry:sentry-android:8.10.0' } From 391dc92a01a2ba78dfd00ac215ac545f571adb08 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Tue, 29 Apr 2025 13:24:00 +0200 Subject: [PATCH 15/64] chore(typescript): Enable strictNullChecks for the SDK source (#4760) --- .../core/src/js/feedback/FeedbackWidget.tsx | 38 ++++++------ .../src/js/feedback/FeedbackWidget.types.ts | 58 +++++++++---------- .../src/js/feedback/FeedbackWidgetManager.tsx | 14 +++-- packages/core/src/js/feedback/defaults.ts | 2 +- packages/core/src/js/feedback/integration.ts | 2 +- packages/core/src/js/feedback/utils.ts | 2 +- .../src/js/integrations/debugsymbolicator.ts | 2 +- .../js/integrations/debugsymbolicatorutils.ts | 19 +++++- packages/core/src/js/integrations/default.ts | 4 +- .../core/src/js/integrations/screenshot.ts | 4 +- .../core/src/js/integrations/spotlight.ts | 10 +++- .../core/src/js/integrations/viewhierarchy.ts | 2 +- .../src/js/profiling/convertHermesProfile.ts | 22 +++++-- packages/core/src/js/profiling/debugid.ts | 12 +++- packages/core/src/js/replay/mobilereplay.ts | 2 +- packages/core/src/js/scopeSync.ts | 7 ++- packages/core/src/js/sdk.tsx | 2 +- packages/core/src/js/touchevents.tsx | 6 +- .../src/js/tracing/integrations/appStart.ts | 7 +++ .../js/tracing/integrations/nativeFrames.ts | 2 +- .../integrations/timeToDisplayIntegration.ts | 14 +++-- .../core/src/js/tracing/onSpanEndUtils.ts | 2 +- .../core/src/js/tracing/reactnavigation.ts | 7 ++- packages/core/src/js/tracing/span.ts | 2 +- .../src/js/tracing/timeToDisplayFallback.ts | 2 +- .../core/src/js/transports/encodePolyfill.ts | 12 ++-- .../core/src/js/utils/AsyncExpiringMap.ts | 12 ++-- .../src/js/vendor/base64-js/fromByteArray.ts | 6 ++ packages/core/src/js/wrapper.ts | 2 +- packages/core/tsconfig.build.json | 1 - 30 files changed, 176 insertions(+), 101 deletions(-) diff --git a/packages/core/src/js/feedback/FeedbackWidget.tsx b/packages/core/src/js/feedback/FeedbackWidget.tsx index 7448d9d8b4..95b6e295fb 100644 --- a/packages/core/src/js/feedback/FeedbackWidget.tsx +++ b/packages/core/src/js/feedback/FeedbackWidget.tsx @@ -26,9 +26,7 @@ import { base64ToUint8Array, feedbackAlertDialog, isValidEmail } from './utils' * Implements a feedback form screen that sends feedback to Sentry using Sentry.captureFeedback. */ export class FeedbackWidget extends React.Component { - public static defaultProps: Partial = { - ...defaultConfiguration - } + public static defaultProps = defaultConfiguration; private static _savedState: Omit = { name: '', @@ -67,7 +65,7 @@ export class FeedbackWidget extends React.Component void = () => { const { name, email, description } = this.state; const { onSubmitSuccess, onSubmitError, onFormSubmitted } = this.props; - const text: FeedbackTextConfiguration = this.props; + const text = this.props; const trimmedName = name?.trim(); const trimmedEmail = email?.trim(); @@ -119,14 +117,14 @@ export class FeedbackWidget extends React.Component void = async () => { if (!this.state.filename && !this.state.attachment) { - const imagePickerConfiguration: ImagePickerConfiguration = this.props; - if (imagePickerConfiguration.imagePicker) { - const launchImageLibrary = imagePickerConfiguration.imagePicker.launchImageLibraryAsync + const { imagePicker } = this.props; + if (imagePicker) { + const launchImageLibrary = imagePicker.launchImageLibraryAsync // expo-image-picker library is available - ? () => imagePickerConfiguration.imagePicker.launchImageLibraryAsync({ mediaTypes: ['images'], base64: isWeb() }) + ? () => imagePicker.launchImageLibraryAsync?.({ mediaTypes: ['images'], base64: isWeb() }) // react-native-image-picker library is available - : imagePickerConfiguration.imagePicker.launchImageLibrary - ? () => imagePickerConfiguration.imagePicker.launchImageLibrary({ mediaType: 'photo', includeBase64: isWeb() }) + : imagePicker.launchImageLibrary + ? () => imagePicker.launchImageLibrary?.({ mediaType: 'photo', includeBase64: isWeb() }) : null; if (!launchImageLibrary) { logger.warn('No compatible image picker library found. Please provide a valid image picker library.'); @@ -140,22 +138,22 @@ export class FeedbackWidget extends React.Component 0) { + if (result?.assets && result.assets.length > 0) { if (isWeb()) { - const filename = result.assets[0].fileName; - const imageUri = result.assets[0].uri; - const base64 = result.assets[0].base64; - const data = base64ToUint8Array(base64); - if (data != null) { + const filename = result.assets[0]?.fileName; + const imageUri = result.assets[0]?.uri; + const base64 = result.assets[0]?.base64; + const data = base64 ? base64ToUint8Array(base64) : undefined; + if (data) { this.setState({ filename, attachment: data, attachmentUri: imageUri }); } else { logger.error('Failed to read image data on the web'); } } else { - const filename = result.assets[0].fileName; - const imageUri = result.assets[0].uri; - getDataFromUri(imageUri).then((data) => { - if (data != null) { + const filename = result.assets[0]?.fileName; + const imageUri = result.assets[0]?.uri; + imageUri && getDataFromUri(imageUri).then((data) => { + if (data) { this.setState({ filename, attachment: data, attachmentUri: imageUri }); } else { logger.error('Failed to read image data from uri:', imageUri); diff --git a/packages/core/src/js/feedback/FeedbackWidget.types.ts b/packages/core/src/js/feedback/FeedbackWidget.types.ts index af08c2ffc3..adb300784b 100644 --- a/packages/core/src/js/feedback/FeedbackWidget.types.ts +++ b/packages/core/src/js/feedback/FeedbackWidget.types.ts @@ -21,38 +21,38 @@ export interface FeedbackGeneralConfiguration { * * @default true */ - showBranding?: boolean; + showBranding: boolean; /** * Should the email field be required? */ - isEmailRequired?: boolean; + isEmailRequired: boolean; /** * Should the email field be validated? */ - shouldValidateEmail?: boolean; + shouldValidateEmail: boolean; /** * Should the name field be required? */ - isNameRequired?: boolean; + isNameRequired: boolean; /** * Should the email input field be visible? Note: email will still be collected if set via `Sentry.setUser()` */ - showEmail?: boolean; + showEmail: boolean; /** * Should the name input field be visible? Note: name will still be collected if set via `Sentry.setUser()` */ - showName?: boolean; + showName: boolean; /** * This flag determines whether the "Add Screenshot" button is displayed * @default false */ - enableScreenshot?: boolean; + enableScreenshot: boolean; /** * Fill in email/name input fields with Sentry user context if it exists. @@ -71,32 +71,32 @@ export interface FeedbackTextConfiguration { /** * The label for the Feedback form cancel button that closes dialog */ - cancelButtonLabel?: string; + cancelButtonLabel: string; /** * The label for the Feedback form submit button that sends feedback */ - submitButtonLabel?: string; + submitButtonLabel: string; /** * The title of the Feedback form */ - formTitle?: string; + formTitle: string; /** * Label for the email input */ - emailLabel?: string; + emailLabel: string; /** * Placeholder text for Feedback email input */ - emailPlaceholder?: string; + emailPlaceholder: string; /** * Label for the message input */ - messageLabel?: string; + messageLabel: string; /** * Placeholder text for Feedback message input @@ -106,52 +106,52 @@ export interface FeedbackTextConfiguration { /** * Label for the name input */ - nameLabel?: string; + nameLabel: string; /** * Message after feedback was sent successfully */ - successMessageText?: string; + successMessageText: string; /** * Placeholder text for Feedback name input */ - namePlaceholder?: string; + namePlaceholder: string; /** * Text which indicates that a field is required */ - isRequiredLabel?: string; + isRequiredLabel: string; /** * The label for the button that adds a screenshot and renders the image editor */ - addScreenshotButtonLabel?: string; + addScreenshotButtonLabel: string; /** * The label for the button that removes a screenshot and hides the image editor */ - removeScreenshotButtonLabel?: string; + removeScreenshotButtonLabel: string; /** * The title of the error dialog */ - errorTitle?: string; + errorTitle: string; /** * The error message when the form is invalid */ - formError?: string; + formError: string; /** * The error message when the email is invalid */ - emailError?: string; + emailError: string; /** * Message when there is a generic error */ - genericError?: string; + genericError: string; } /** @@ -161,34 +161,34 @@ export interface FeedbackCallbacks { /** * Callback when form is opened */ - onFormOpen?: () => void; + onFormOpen: () => void; /** * Callback when form is closed and not submitted */ - onFormClose?: () => void; + onFormClose: () => void; /** * Callback when a screenshot is added */ - onAddScreenshot?: (addScreenshot: (uri: string) => void) => void; + onAddScreenshot: (addScreenshot: (uri: string) => void) => void; /** * Callback when feedback is successfully submitted * * After this you'll see a SuccessMessage on the screen for a moment. */ - onSubmitSuccess?: (data: FeedbackFormData) => void; + onSubmitSuccess: (data: FeedbackFormData) => void; /** * Callback when feedback is unsuccessfully submitted */ - onSubmitError?: (error: Error) => void; + onSubmitError: (error: Error) => void; /** * Callback when the feedback form is submitted successfully, and the SuccessMessage is complete, or dismissed */ - onFormSubmitted?: () => void; + onFormSubmitted: () => void; } /** diff --git a/packages/core/src/js/feedback/FeedbackWidgetManager.tsx b/packages/core/src/js/feedback/FeedbackWidgetManager.tsx index 856298382e..4f380842e3 100644 --- a/packages/core/src/js/feedback/FeedbackWidgetManager.tsx +++ b/packages/core/src/js/feedback/FeedbackWidgetManager.tsx @@ -15,6 +15,10 @@ const PULL_DOWN_CLOSE_THRESHOLD = 200; const SLIDE_ANIMATION_DURATION = 200; const BACKGROUND_ANIMATION_DURATION = 200; +const NOOP_SET_VISIBILITY = (): void => { + // No-op +}; + class FeedbackWidgetManager { private static _isVisible = false; private static _setVisibility: (visible: boolean) => void; @@ -28,22 +32,24 @@ class FeedbackWidgetManager { */ public static reset(): void { this._isVisible = false; - this._setVisibility = undefined; + this._setVisibility = NOOP_SET_VISIBILITY; } public static show(): void { - if (this._setVisibility) { + if (this._setVisibility !== NOOP_SET_VISIBILITY) { this._isVisible = true; this._setVisibility(true); } else { // This message should be always shown otherwise it's not possible to use the widget. // eslint-disable-next-line no-console - console.warn('[Sentry] FeedbackWidget requires `Sentry.wrap(RootComponent)` to be called before `showFeedbackWidget()`.'); + console.warn( + '[Sentry] FeedbackWidget requires `Sentry.wrap(RootComponent)` to be called before `showFeedbackWidget()`.', + ); } } public static hide(): void { - if (this._setVisibility) { + if (this._setVisibility !== NOOP_SET_VISIBILITY) { this._isVisible = false; this._setVisibility(false); } else { diff --git a/packages/core/src/js/feedback/defaults.ts b/packages/core/src/js/feedback/defaults.ts index 90d9534874..3152c769fb 100644 --- a/packages/core/src/js/feedback/defaults.ts +++ b/packages/core/src/js/feedback/defaults.ts @@ -19,7 +19,7 @@ const ADD_SCREENSHOT_LABEL = 'Add a screenshot'; const REMOVE_SCREENSHOT_LABEL = 'Remove screenshot'; const GENERIC_ERROR_TEXT = 'Unable to send feedback due to an unexpected error.'; -export const defaultConfiguration: Partial = { +export const defaultConfiguration: FeedbackWidgetProps = { // FeedbackCallbacks onFormOpen: () => { // Does nothing by default diff --git a/packages/core/src/js/feedback/integration.ts b/packages/core/src/js/feedback/integration.ts index 96280cf967..ad2bd0675b 100644 --- a/packages/core/src/js/feedback/integration.ts +++ b/packages/core/src/js/feedback/integration.ts @@ -8,7 +8,7 @@ type FeedbackIntegration = Integration & { options: Partial; }; -export const feedbackIntegration = (initOptions: FeedbackWidgetProps = {}): FeedbackIntegration => { +export const feedbackIntegration = (initOptions: Partial = {}): FeedbackIntegration => { return { name: MOBILE_FEEDBACK_INTEGRATION_NAME, options: initOptions, diff --git a/packages/core/src/js/feedback/utils.ts b/packages/core/src/js/feedback/utils.ts index 9c2826981d..05b8b471f1 100644 --- a/packages/core/src/js/feedback/utils.ts +++ b/packages/core/src/js/feedback/utils.ts @@ -15,7 +15,7 @@ declare global { */ export function isModalSupported(): boolean { const { major, minor } = ReactNativeLibraries.ReactNativeVersion?.version || {}; - return !(isFabricEnabled() && major === 0 && minor < 71); + return !(isFabricEnabled() && major === 0 && minor && minor < 71); } export const isValidEmail = (email: string): boolean => { diff --git a/packages/core/src/js/integrations/debugsymbolicator.ts b/packages/core/src/js/integrations/debugsymbolicator.ts index 3ff5bc5169..ed1c2901d3 100644 --- a/packages/core/src/js/integrations/debugsymbolicator.ts +++ b/packages/core/src/js/integrations/debugsymbolicator.ts @@ -131,7 +131,7 @@ async function convertReactNativeFramesToSentryFrames(frames: ReactNative.StackF * @param event Event * @param frames StackFrame[] */ -function replaceExceptionFramesInException(exception: Exception, frames: SentryStackFrame[]): void { +function replaceExceptionFramesInException(exception: Exception | undefined, frames: SentryStackFrame[]): void { if (exception?.stacktrace) { exception.stacktrace.frames = frames.reverse(); } diff --git a/packages/core/src/js/integrations/debugsymbolicatorutils.ts b/packages/core/src/js/integrations/debugsymbolicatorutils.ts index 2b51171b39..d99f72b261 100644 --- a/packages/core/src/js/integrations/debugsymbolicatorutils.ts +++ b/packages/core/src/js/integrations/debugsymbolicatorutils.ts @@ -20,7 +20,14 @@ export async function fetchSourceContext(frames: SentryStackFrame[]): Promise { }; async function processEvent(event: Event, hint: EventHint, client: ReactNativeClient): Promise { - const hasException = event.exception?.values?.length > 0; + const hasException = event.exception?.values && event.exception.values.length > 0; if (!hasException || client.getOptions().beforeScreenshot?.(event, hint) === false) { return event; } const screenshots: ScreenshotAttachment[] | null = await NATIVE.captureScreenshot(); - if (screenshots?.length > 0) { + if (screenshots && screenshots.length > 0) { hint.attachments = [...screenshots, ...(hint?.attachments || [])]; } diff --git a/packages/core/src/js/integrations/spotlight.ts b/packages/core/src/js/integrations/spotlight.ts index 50191aa132..90af07ccca 100644 --- a/packages/core/src/js/integrations/spotlight.ts +++ b/packages/core/src/js/integrations/spotlight.ts @@ -83,17 +83,23 @@ function sendEnvelopesToSidecar(client: Client, sidecarUrl: string): void { }); } +const DEFAULT_SIDECAR_URL = 'http://localhost:8969/stream'; + /** * Gets the default Spotlight sidecar URL. */ export function getDefaultSidecarUrl(): string { try { - const { url } = ReactNativeLibraries.Devtools?.getDevServer(); + const { url } = ReactNativeLibraries.Devtools?.getDevServer() ?? {}; + if (!url) { + return DEFAULT_SIDECAR_URL; + } + return `http://${getHostnameFromString(url)}:8969/stream`; } catch (_oO) { // We can't load devserver URL } - return 'http://localhost:8969/stream'; + return DEFAULT_SIDECAR_URL; } /** diff --git a/packages/core/src/js/integrations/viewhierarchy.ts b/packages/core/src/js/integrations/viewhierarchy.ts index d4d4530b15..c2c56fa4fc 100644 --- a/packages/core/src/js/integrations/viewhierarchy.ts +++ b/packages/core/src/js/integrations/viewhierarchy.ts @@ -21,7 +21,7 @@ export const viewHierarchyIntegration = (): Integration => { }; async function processEvent(event: Event, hint: EventHint): Promise { - const hasException = event.exception?.values?.length > 0; + const hasException = event.exception?.values && event.exception.values.length > 0; if (!hasException) { return event; } diff --git a/packages/core/src/js/profiling/convertHermesProfile.ts b/packages/core/src/js/profiling/convertHermesProfile.ts index 6db66dd6d5..241c6fd249 100644 --- a/packages/core/src/js/profiling/convertHermesProfile.ts +++ b/packages/core/src/js/profiling/convertHermesProfile.ts @@ -82,11 +82,21 @@ export function mapSamples( hermesStacks: Set; jsThreads: Set; } { + const samples: ThreadCpuSample[] = []; const jsThreads = new Set(); const hermesStacks = new Set(); - const start = Number(hermesSamples[0].ts); - const samples: ThreadCpuSample[] = []; + const firstSample = hermesSamples[0]; + if (!firstSample) { + logger.warn('[Profiling] No samples found in profile.'); + return { + samples, + hermesStacks, + jsThreads, + }; + } + + const start = Number(firstSample.ts); for (const hermesSample of hermesSamples) { jsThreads.add(hermesSample.tid); hermesStacks.add(hermesSample.sf); @@ -130,8 +140,12 @@ function mapFrames(hermesStackFrames: Record { - const hasException = event.exception?.values?.length > 0; + const hasException = event.exception?.values && event.exception.values.length > 0; if (!hasException) { // Event is not an error, will not capture replay return event; diff --git a/packages/core/src/js/scopeSync.ts b/packages/core/src/js/scopeSync.ts index bc9f20c597..bc69ffe86d 100644 --- a/packages/core/src/js/scopeSync.ts +++ b/packages/core/src/js/scopeSync.ts @@ -1,4 +1,5 @@ import type { Breadcrumb, Scope } from '@sentry/core'; +import { logger } from '@sentry/react'; import { DEFAULT_BREADCRUMB_LEVEL } from './breadcrumb'; import { fillTyped } from './utils/fill'; @@ -60,7 +61,11 @@ export function enableSyncToNative(scope: Scope): void { original.call(scope, mergedBreadcrumb, maxBreadcrumbs); const finalBreadcrumb = scope.getLastBreadcrumb(); - NATIVE.addBreadcrumb(finalBreadcrumb); + if (finalBreadcrumb) { + NATIVE.addBreadcrumb(finalBreadcrumb); + } else { + logger.warn('[ScopeSync] Last created breadcrumb is undefined. Skipping sync to native.'); + } return scope; }); diff --git a/packages/core/src/js/sdk.tsx b/packages/core/src/js/sdk.tsx index dd6a176322..c50f1c35f1 100644 --- a/packages/core/src/js/sdk.tsx +++ b/packages/core/src/js/sdk.tsx @@ -63,7 +63,7 @@ export function init(passedOptions: ReactNativeOptions): void { enableSyncToNative(getIsolationScope()); } - const getURLFromDSN = (dsn: string | null): string | undefined => { + const getURLFromDSN = (dsn: string | undefined): string | undefined => { if (!dsn) { return undefined; } diff --git a/packages/core/src/js/touchevents.tsx b/packages/core/src/js/touchevents.tsx index 293391a834..2280597264 100644 --- a/packages/core/src/js/touchevents.tsx +++ b/packages/core/src/js/touchevents.tsx @@ -121,8 +121,12 @@ class TouchEventBoundary extends React.Component { const level = 'info' as SeverityLevel; const root = touchPath[0]; - const detail = label ? label : `${root.name}${root.file ? ` (${root.file})` : ''}`; + if (!root) { + logger.warn('[TouchEvents] No root component found in touch path.'); + return; + } + const detail = label ? label : `${root.name}${root.file ? ` (${root.file})` : ''}`; const crumb = { category: this.props.breadcrumbCategory, data: { path: touchPath }, diff --git a/packages/core/src/js/tracing/integrations/appStart.ts b/packages/core/src/js/tracing/integrations/appStart.ts index acd5096bc4..aa2ce1c70e 100644 --- a/packages/core/src/js/tracing/integrations/appStart.ts +++ b/packages/core/src/js/tracing/integrations/appStart.ts @@ -211,6 +211,13 @@ export const appStartIntegration = ({ }; async function captureStandaloneAppStart(): Promise { + if (!_client) { + // If client is not set, SDK was not initialized, logger is thus disabled + // eslint-disable-next-line no-console + console.warn('[AppStart] Could not capture App Start, missing client, call `Sentry.init` first.'); + return; + } + if (!standalone) { logger.debug( '[AppStart] App start tracking is enabled. App start will be added to the first transaction as a child span.', diff --git a/packages/core/src/js/tracing/integrations/nativeFrames.ts b/packages/core/src/js/tracing/integrations/nativeFrames.ts index ceec914b88..e5dd20f98a 100644 --- a/packages/core/src/js/tracing/integrations/nativeFrames.ts +++ b/packages/core/src/js/tracing/integrations/nativeFrames.ts @@ -60,7 +60,7 @@ export const createNativeFramesIntegrations = (enable: boolean | undefined): Int export const nativeFramesIntegration = (): Integration => { /** The native frames at the finish time of the most recent span. */ let _lastChildSpanEndFrames: NativeFramesResponseWithTimestamp | null = null; - const _spanToNativeFramesAtStartMap: AsyncExpiringMap = new AsyncExpiringMap({ + const _spanToNativeFramesAtStartMap: AsyncExpiringMap = new AsyncExpiringMap({ ttl: START_FRAMES_TIMEOUT_MS, }); const _spanToNativeFramesAtEndMap: AsyncExpiringMap = diff --git a/packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts b/packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts index 6f48b4b877..8b5d0ffc66 100644 --- a/packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts +++ b/packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts @@ -30,7 +30,7 @@ export const timeToDisplayIntegration = (): Integration => { return event; } - const rootSpanId = event.contexts.trace.span_id; + const rootSpanId = event.contexts?.trace?.span_id; if (!rootSpanId) { logger.warn(`[${INTEGRATION_NAME}] No root span id found in transaction.`); return event; @@ -64,7 +64,9 @@ export const timeToDisplayIntegration = (): Integration => { if (ttfdSpan?.start_timestamp && ttfdSpan?.timestamp) { const durationMs = (ttfdSpan.timestamp - ttfdSpan.start_timestamp) * 1000; if (isDeadlineExceeded(durationMs)) { - event.measurements['time_to_full_display'] = event.measurements['time_to_initial_display']; + if (event.measurements['time_to_initial_display']) { + event.measurements['time_to_full_display'] = event.measurements['time_to_initial_display']; + } } else { event.measurements['time_to_full_display'] = { value: durationMs, @@ -100,6 +102,8 @@ async function addTimeToInitialDisplay({ }): Promise { const ttidEndTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttid-${rootSpanId}`); + event.spans = event.spans || []; + let ttidSpan: SpanJSON | undefined = event.spans?.find(span => span.op === UI_LOAD_INITIAL_DISPLAY); if (ttidSpan && (ttidSpan.status === undefined || ttidSpan.status === 'ok') && !ttidEndTimestampSeconds) { @@ -204,11 +208,13 @@ async function addTimeToFullDisplay({ return undefined; } + event.spans = event.spans || []; + let ttfdSpan = event.spans?.find(span => span.op === UI_LOAD_FULL_DISPLAY); let ttfdAdjustedEndTimestampSeconds = ttfdEndTimestampSeconds; - const ttfdIsBeforeTtid = ttidSpan?.timestamp && ttfdEndTimestampSeconds < ttidSpan.timestamp; - if (ttfdIsBeforeTtid) { + const ttfdIsBeforeTtid = ttidSpan.timestamp && ttfdEndTimestampSeconds < ttidSpan.timestamp; + if (ttfdIsBeforeTtid && ttidSpan.timestamp) { ttfdAdjustedEndTimestampSeconds = ttidSpan.timestamp; } diff --git a/packages/core/src/js/tracing/onSpanEndUtils.ts b/packages/core/src/js/tracing/onSpanEndUtils.ts index 4ae3c027f6..cffa13a852 100644 --- a/packages/core/src/js/tracing/onSpanEndUtils.ts +++ b/packages/core/src/js/tracing/onSpanEndUtils.ts @@ -44,7 +44,7 @@ export const adjustTransactionDuration = (client: Client, span: Span, maxDuratio }); }; -export const ignoreEmptyBackNavigation = (client: Client | undefined, span: Span): void => { +export const ignoreEmptyBackNavigation = (client: Client | undefined, span: Span | undefined): void => { if (!client) { logger.warn('Could not hook on spanEnd event because client is not defined.'); return; diff --git a/packages/core/src/js/tracing/reactnavigation.ts b/packages/core/src/js/tracing/reactnavigation.ts index 8528466d11..feebb3b9f7 100644 --- a/packages/core/src/js/tracing/reactnavigation.ts +++ b/packages/core/src/js/tracing/reactnavigation.ts @@ -220,6 +220,7 @@ export const reactNavigationIntegration = ({ const navigationActionType = useDispatchedActionData ? event?.data.action.type : undefined; if ( useDispatchedActionData && + navigationActionType && [ // Process common actions 'PRELOAD', @@ -252,12 +253,12 @@ export const reactNavigationIntegration = ({ ignoreEmptyBackNavigation(getClient(), latestNavigationSpan); } - if (enableTimeToInitialDisplay) { - NATIVE.setActiveSpanId(latestNavigationSpan?.spanContext().spanId); + if (enableTimeToInitialDisplay && latestNavigationSpan) { + NATIVE.setActiveSpanId(latestNavigationSpan.spanContext().spanId); navigationProcessingSpan = startInactiveSpan({ op: 'navigation.processing', name: 'Navigation dispatch to navigation cancelled or screen mounted', - startTime: latestNavigationSpan && spanToJSON(latestNavigationSpan).start_timestamp, + startTime: spanToJSON(latestNavigationSpan).start_timestamp, }); navigationProcessingSpan.setAttribute( SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, diff --git a/packages/core/src/js/tracing/span.ts b/packages/core/src/js/tracing/span.ts index c4b89b8d74..4e3a70ff66 100644 --- a/packages/core/src/js/tracing/span.ts +++ b/packages/core/src/js/tracing/span.ts @@ -127,7 +127,7 @@ export function getDefaultIdleNavigationSpanOptions(): StartSpanOptions { * Checks if the span is a Sentry User Interaction span. */ export function isSentryInteractionSpan(span: Span): boolean { - return [SPAN_ORIGIN_AUTO_INTERACTION, SPAN_ORIGIN_MANUAL_INTERACTION].includes(spanToJSON(span).origin); + return [SPAN_ORIGIN_AUTO_INTERACTION, SPAN_ORIGIN_MANUAL_INTERACTION].includes(spanToJSON(span).origin || ''); } export const SCOPE_SPAN_FIELD = '_sentrySpan'; diff --git a/packages/core/src/js/tracing/timeToDisplayFallback.ts b/packages/core/src/js/tracing/timeToDisplayFallback.ts index cd71b21df0..e854d43477 100644 --- a/packages/core/src/js/tracing/timeToDisplayFallback.ts +++ b/packages/core/src/js/tracing/timeToDisplayFallback.ts @@ -13,6 +13,6 @@ export const addTimeToInitialDisplayFallback = ( spanIdToTimeToInitialDisplayFallback.set(spanId, timestampSeconds); }; -export const getTimeToInitialDisplayFallback = async (spanId: string): Promise => { +export const getTimeToInitialDisplayFallback = async (spanId: string): Promise => { return spanIdToTimeToInitialDisplayFallback.get(spanId); }; diff --git a/packages/core/src/js/transports/encodePolyfill.ts b/packages/core/src/js/transports/encodePolyfill.ts index 102d1886fb..e9244d562a 100644 --- a/packages/core/src/js/transports/encodePolyfill.ts +++ b/packages/core/src/js/transports/encodePolyfill.ts @@ -1,16 +1,12 @@ import { getMainCarrier, SDK_VERSION } from '@sentry/core'; -import type { RN_GLOBAL_OBJ } from '../utils/worldwide'; import { utf8ToBytes } from '../vendor'; export const useEncodePolyfill = (): void => { - const globalCarriers = getMainCarrier().__SENTRY__; - - if (!globalCarriers) { - (globalCarriers as Partial<(typeof RN_GLOBAL_OBJ)['__SENTRY__']>) = {}; - } - - globalCarriers[SDK_VERSION].encodePolyfill = encodePolyfill; + // Based on https://github.com/getsentry/sentry-javascript/blob/f0fc41f6166857cd97a695f5cc9a18caf6a0bf43/packages/core/src/carrier.ts#L49 + const carrier = getMainCarrier(); + const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {}); + (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {}).encodePolyfill = encodePolyfill; }; export const encodePolyfill = (text: string): Uint8Array => { diff --git a/packages/core/src/js/utils/AsyncExpiringMap.ts b/packages/core/src/js/utils/AsyncExpiringMap.ts index 657286ed26..bba14e01f1 100644 --- a/packages/core/src/js/utils/AsyncExpiringMap.ts +++ b/packages/core/src/js/utils/AsyncExpiringMap.ts @@ -7,7 +7,7 @@ export class AsyncExpiringMap { private _ttl: number; private _cleanupIntervalMs: number; private _map: Map | null }>; - private _cleanupInterval: ReturnType; + private _cleanupInterval: ReturnType | undefined; public constructor({ cleanupInterval = 5_000, @@ -30,7 +30,7 @@ export class AsyncExpiringMap { this.startCleanup(); } - if (typeof promise !== 'object' || !('then' in promise)) { + if (typeof promise !== 'object' || !promise || !('then' in promise)) { this._map.set(key, { value: promise, expiresAt: Date.now() + this._ttl, promise: null }); return; } @@ -143,7 +143,9 @@ export class AsyncExpiringMap { * Clear all entries. */ public clear(): void { - clearInterval(this._cleanupInterval); + if (this._cleanupInterval) { + clearInterval(this._cleanupInterval); + } this._map.clear(); } @@ -151,7 +153,9 @@ export class AsyncExpiringMap { * Stop the cleanup interval. */ public stopCleanup(): void { - clearInterval(this._cleanupInterval); + if (this._cleanupInterval) { + clearInterval(this._cleanupInterval); + } } /** diff --git a/packages/core/src/js/vendor/base64-js/fromByteArray.ts b/packages/core/src/js/vendor/base64-js/fromByteArray.ts index 51c046b0a4..11c771f1d5 100644 --- a/packages/core/src/js/vendor/base64-js/fromByteArray.ts +++ b/packages/core/src/js/vendor/base64-js/fromByteArray.ts @@ -28,10 +28,12 @@ const lookup: string[] = []; const code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for (let i = 0, len = code.length; i < len; ++i) { + // @ts-expect-error lookup[i] = code[i]; } function tripletToBase64(num: number): string { + // @ts-expect-error return lookup[(num >> 18) & 0x3f] + lookup[(num >> 12) & 0x3f] + lookup[(num >> 6) & 0x3f] + lookup[num & 0x3f]; } @@ -39,6 +41,7 @@ function encodeChunk(uint8: Uint8Array | number[], start: number, end: number): let tmp; const output = []; for (let i = start; i < end; i += 3) { + // @ts-expect-error tmp = ((uint8[i] << 16) & 0xff0000) + ((uint8[i + 1] << 8) & 0xff00) + (uint8[i + 2] & 0xff); output.push(tripletToBase64(tmp)); } @@ -63,9 +66,12 @@ export function base64StringFromByteArray(uint8: Uint8Array | number[]): string // pad the end with zeros, but make sure to not forget the extra bytes if (extraBytes === 1) { tmp = uint8[len - 1]; + // @ts-expect-error parts.push(`${lookup[tmp >> 2] + lookup[(tmp << 4) & 0x3f]}==`); } else if (extraBytes === 2) { + // @ts-expect-error tmp = (uint8[len - 2] << 8) + uint8[len - 1]; + // @ts-expect-error parts.push(`${lookup[tmp >> 10] + lookup[(tmp >> 4) & 0x3f] + lookup[(tmp << 2) & 0x3f]}=`); } diff --git a/packages/core/src/js/wrapper.ts b/packages/core/src/js/wrapper.ts index 31152c02b2..289af29923 100644 --- a/packages/core/src/js/wrapper.ts +++ b/packages/core/src/js/wrapper.ts @@ -729,7 +729,7 @@ export const NATIVE: SentryNativeWrapper = { return RNSentry.popTimeToDisplayFor(key); } catch (error) { logger.error('Error:', error); - return null; + return Promise.resolve(null); } }, diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.json index b5b1127a11..90d9d08e63 100644 --- a/packages/core/tsconfig.build.json +++ b/packages/core/tsconfig.build.json @@ -26,7 +26,6 @@ "module": "es6", "skipLibCheck": true, "strictBindCallApply": true, - "strictNullChecks": false, "importHelpers": false } } From c68710a5295ab8ce538edd619118a2a23c92b092 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Wed, 30 Apr 2025 18:32:58 +0300 Subject: [PATCH 16/64] chore(deps): v7: Bump Android SDK to v8.11.0 (#4793) --- CHANGELOG.md | 6 +++--- packages/core/android/build.gradle | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11264c84f6..17aea77703 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,9 +25,9 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi - Bump JavaScript SDK from v8.54.0 to v9.12.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568), [#4752](https://github.com/getsentry/sentry-react-native/pull/4752)) - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.12.0/CHANGELOG.md) - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.12.0) -- Bump Android SDK from v7.20.1 to v8.9.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490)) - - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8100) - - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.10.0) +- Bump Android SDK from v7.20.1 to v8.11.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490)) + - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8110) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.11.0) - Bump Bundler Plugins from v3.2.2 to v3.3.1 ([#4693](https://github.com/getsentry/sentry-react-native/pull/4693), [#4707](https://github.com/getsentry/sentry-react-native/pull/4707), [#4720](https://github.com/getsentry/sentry-react-native/pull/4720), [#4721](https://github.com/getsentry/sentry-react-native/pull/4721)) - [changelog](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/CHANGELOG.md#331) - [diff](https://github.com/getsentry/sentry-javascript-bundler-plugins/compare/3.2.2...3.3.1) diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index d72655845b..16d313e639 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -54,5 +54,5 @@ android { dependencies { implementation 'com.facebook.react:react-native:+' - api 'io.sentry:sentry-android:8.10.0' + api 'io.sentry:sentry-android:8.11.0' } From 10c9244be9f97bcf71f3ba01af2a89088a5c8c8c Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Fri, 2 May 2025 06:46:03 +0300 Subject: [PATCH 17/64] chore(deps): v7: Bump Android SDK to v8.11.1 (#4796) --- CHANGELOG.md | 6 +++--- packages/core/android/build.gradle | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17aea77703..9661856452 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,9 +25,9 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi - Bump JavaScript SDK from v8.54.0 to v9.12.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568), [#4752](https://github.com/getsentry/sentry-react-native/pull/4752)) - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.12.0/CHANGELOG.md) - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.12.0) -- Bump Android SDK from v7.20.1 to v8.11.0 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490)) - - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8110) - - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.11.0) +- Bump Android SDK from v7.20.1 to v8.11.1 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490)) + - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8111) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.11.1) - Bump Bundler Plugins from v3.2.2 to v3.3.1 ([#4693](https://github.com/getsentry/sentry-react-native/pull/4693), [#4707](https://github.com/getsentry/sentry-react-native/pull/4707), [#4720](https://github.com/getsentry/sentry-react-native/pull/4720), [#4721](https://github.com/getsentry/sentry-react-native/pull/4721)) - [changelog](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/CHANGELOG.md#331) - [diff](https://github.com/getsentry/sentry-javascript-bundler-plugins/compare/3.2.2...3.3.1) diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index 16d313e639..5cc7aab628 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -54,5 +54,5 @@ android { dependencies { implementation 'com.facebook.react:react-native:+' - api 'io.sentry:sentry-android:8.11.0' + api 'io.sentry:sentry-android:8.11.1' } From a1bd56f74588c898500e0c9c4e3188fa75001c39 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Thu, 8 May 2025 12:13:27 -0300 Subject: [PATCH 18/64] chore(wrap): Remove props `updateProps`, `name` and `children` from wrap options type --- packages/core/src/js/options.ts | 2 +- packages/core/src/js/sdk.tsx | 2 +- .../src/js/tracing/reactnativeprofiler.tsx | 4 +- packages/core/test/wrap.mocked.test.tsx | 111 ++++++++++++++++++ packages/core/test/wrap.test.tsx | 40 +++---- 5 files changed, 133 insertions(+), 26 deletions(-) create mode 100644 packages/core/test/wrap.mocked.test.tsx diff --git a/packages/core/src/js/options.ts b/packages/core/src/js/options.ts index 14cc743fc2..6ecc232ff0 100644 --- a/packages/core/src/js/options.ts +++ b/packages/core/src/js/options.ts @@ -294,7 +294,7 @@ export interface ReactNativeClientOptions export interface ReactNativeWrapperOptions { /** Props for the root React profiler */ - profilerProps?: ProfilerProps; + profilerProps?: Omit; /** Props for the root touch event boundary */ touchEventBoundaryProps?: TouchEventBoundaryProps; diff --git a/packages/core/src/js/sdk.tsx b/packages/core/src/js/sdk.tsx index c50f1c35f1..fefa97d0c1 100644 --- a/packages/core/src/js/sdk.tsx +++ b/packages/core/src/js/sdk.tsx @@ -156,7 +156,7 @@ export function wrap

>( options?: ReactNativeWrapperOptions ): React.ComponentType

{ const profilerProps = { - ...(options?.profilerProps ?? {}), + ...(options?.profilerProps), name: RootComponent.displayName ?? 'Root', updateProps: {} }; diff --git a/packages/core/src/js/tracing/reactnativeprofiler.tsx b/packages/core/src/js/tracing/reactnativeprofiler.tsx index 49ad27df88..72e2483074 100644 --- a/packages/core/src/js/tracing/reactnativeprofiler.tsx +++ b/packages/core/src/js/tracing/reactnativeprofiler.tsx @@ -12,13 +12,15 @@ const ReactNativeProfilerGlobalState = { }, }; +type ProfilerConstructorProps = ConstructorParameters[0]; + /** * Custom profiler for the React Native app root. */ export class ReactNativeProfiler extends Profiler { public readonly name: string = 'ReactNativeProfiler'; - public constructor(props: ConstructorParameters[0]) { + public constructor(props: ProfilerConstructorProps) { _setRootComponentCreationTimestampMs(timestampInSeconds() * 1000); super(props); } diff --git a/packages/core/test/wrap.mocked.test.tsx b/packages/core/test/wrap.mocked.test.tsx new file mode 100644 index 0000000000..dab86de46d --- /dev/null +++ b/packages/core/test/wrap.mocked.test.tsx @@ -0,0 +1,111 @@ +// We can't test wrap with mock and non mocked components, otherwise it will break the RN testing library. +import { render } from '@testing-library/react-native'; +import * as React from 'react'; +import type { ReactNativeWrapperOptions } from 'src/js/options'; + +jest.doMock('../src/js/touchevents', () => { + return { + TouchEventBoundary: ({ children }: { children: React.ReactNode }) => ( + // eslint-disable-next-line react/no-unknown-property +

{children}
+ ), + } +}); + +jest.doMock('../src/js/tracing', () => { + return { + ReactNativeProfiler: jest.fn(({ children }: { children: React.ReactNode }) => ( + // eslint-disable-next-line react/no-unknown-property +
{children}
+ )), + } +}); + +jest.doMock('../src/js/feedback/FeedbackWidgetManager', () => { + return { + FeedbackWidgetProvider: ({ children }: { children: React.ReactNode }) => ( + // eslint-disable-next-line react/no-unknown-property +
{children}
+ ), + }; +}); + + +import { wrap } from '../src/js/sdk'; +import { ReactNativeProfiler } from '../src/js/tracing'; + +describe('Sentry.wrap', () => { + + const DummyComponent: React.FC<{ value?: string }> = ({ value }) =>
{value}
; + + it('should not enforce any keys on the wrapped component', () => { + const Mock: React.FC<{ test: 23 }> = () => <>; + const ActualWrapped = wrap(Mock); + + expect(typeof ActualWrapped.defaultProps).toBe(typeof Mock.defaultProps); + }); + + it('wraps components with Sentry wrappers', () => { + const Wrapped = wrap(DummyComponent); + const renderResult = render(); + + expect(renderResult.toJSON()).toMatchInlineSnapshot(` +
+
+
+
+ wrapped +
+
+
+
+`); + }); + + describe('ReactNativeProfiler', () => { + it('uses given options when set', () => { + const options: ReactNativeWrapperOptions = { + profilerProps: { disabled: false, includeRender: true, includeUpdates: true }, + }; + const Wrapped = wrap(DummyComponent, options); + render(); + + expect(ReactNativeProfiler).toHaveBeenCalledWith( + expect.objectContaining({ + name: 'Root', + disabled: false, + includeRender: true, + includeUpdates: true + }), + expect.anything(), + ); + + expect(ReactNativeProfiler).not.toHaveBeenCalledWith( + expect.objectContaining({ + updateProps: expect.anything(), + }) + ); + }); + + it('ignore updateProps when set', () => { + const { wrap } = jest.requireActual('../src/js/sdk'); + + const Wrapped = wrap(DummyComponent, { updateProps: ['prop'] }); + render(); + + expect(ReactNativeProfiler).toHaveBeenCalledWith( + expect.objectContaining({ + name: 'Root', + updateProps: {}, + }), + expect.anything(), + ); + }); + }); + }); diff --git a/packages/core/test/wrap.test.tsx b/packages/core/test/wrap.test.tsx index f949b36d38..0bac2041c2 100644 --- a/packages/core/test/wrap.test.tsx +++ b/packages/core/test/wrap.test.tsx @@ -1,3 +1,4 @@ +// We can't test wrap with mock and non mocked components, otherwise it will break the RN testing library. import { logger, setCurrentClient } from '@sentry/core'; import { render } from '@testing-library/react-native'; import * as React from 'react'; @@ -7,30 +8,23 @@ import * as AppRegistry from '../src/js/integrations/appRegistry'; import { wrap } from '../src/js/sdk'; import { getDefaultTestClientOptions, TestClient } from './mocks/client'; -describe('Sentry.wrap', () => { - it('should not enforce any keys on the wrapped component', () => { - const Mock: React.FC<{ test: 23 }> = () => <>; - const ActualWrapped = wrap(Mock); +describe('ReactNativeProfiler', () => { + it('should wrap the component and init with a warning when getAppRegistryIntegration returns undefined', () => { + logger.warn = jest.fn(); + const getAppRegistryIntegration = jest.spyOn(AppRegistry, 'getAppRegistryIntegration').mockReturnValueOnce(undefined); + const Mock: React.FC = () => Test; + const client = new TestClient( + getDefaultTestClientOptions(), + ); + setCurrentClient(client); - expect(typeof ActualWrapped.defaultProps).toBe(typeof Mock.defaultProps); - }); - - it('should wrap the component and init with a warning when getAppRegistryIntegration returns undefined', () => { - logger.warn = jest.fn(); - const getAppRegistryIntegration = jest.spyOn(AppRegistry, 'getAppRegistryIntegration').mockReturnValueOnce(undefined); - const Mock: React.FC = () => Test; - const client = new TestClient( - getDefaultTestClientOptions(), - ); - setCurrentClient(client); - - client.init(); - const ActualWrapped = wrap(Mock); + client.init(); + const ActualWrapped = wrap(Mock); - const { getByText } = render(); + const { getByText } = render(); - expect(getAppRegistryIntegration).toHaveBeenCalled(); - expect(logger.warn).toHaveBeenCalledWith('AppRegistryIntegration.onRunApplication not found or invalid.'); - expect(getByText('Test')).toBeTruthy(); + expect(getAppRegistryIntegration).toHaveBeenCalled(); + expect(logger.warn).toHaveBeenCalledWith('AppRegistryIntegration.onRunApplication not found or invalid.'); + expect(getByText('Test')).toBeTruthy(); + }); }); -}); From 1528fb59e18f49d2a9b89d9dcaed28fbbfe43365 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Sun, 11 May 2025 22:30:27 +0200 Subject: [PATCH 19/64] Fix changelog --- CHANGELOG.md | 84 ++++++++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d18316e52..dcab711f53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ ### Upgrading from 6.x to 7.0 -Version 7 of the Sentry React Native SDK primarily introduces API cleanup and version support changes. This update contains behavioral changes that will not be caught by type checkers, linters, or tests, so we recommend carefully reading through the entire migration guide instead of relying on automatic tooling. +Version 7 of the Sentry React Native SDK primarily introduces API cleanup and version support changes based on the Sentry Javascript SDK version 9. This update contains behavioral changes that will not be caught by type checkers, linters, or tests, so we recommend carefully reading through the entire migration guide instead of relying on automatic tooling. Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or higher (unchanged from v6). Lower versions may continue to work, but may not support all features. @@ -19,8 +19,46 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi - Expo Updates Context is passed to native after native init to be available for crashes ([#4808](https://github.com/getsentry/sentry-react-native/pull/4808)) - Expo Updates Context values should all be lowercase ([#4809](https://github.com/getsentry/sentry-react-native/pull/4809)) +### Major Changes + +- Set `{{auto}}` if `user.ip_address` is `undefined` and `sendDefaultPii: true` ([#4466](https://github.com/getsentry/sentry-react-native/pull/4466)) +- Exceptions from `captureConsoleIntegration` are now marked as handled: true by default +- `shutdownTimeout` moved from `core` to `@sentry/react-native` +- `hasTracingEnabled` was renamed to `hasSpansEnabled` +- You can no longer drop spans or return null on `beforeSendSpan` hook + +### Removed types + +- TransactionNamingScheme +- Request +- Scope (prefer using the Scope class) + +### Other removed items. + +- `autoSessionTracking` from options. + To enable session tracking, ensure that `enableAutoSessionTracking` is enabled. +- `enableTracing`. Instead, set `tracesSampleRate` to a value greater than `zero` to `enable tracing`, `0` to keep tracing integrations active without sampling, or `undefined` to disable the performance integration. +- `getCurrentHub()`, `Hub`, and `getCurrentHubShim()` +- `spanId` from propagation `context` +- metrics API +- `transactionContext` from `samplingContext` +- `@sentry/utils` package, the exports were moved to `@sentry/core` +- Standalone `Client` interface & deprecate `BaseClient` + +## Other Changes + +- Fork `scope` if custom scope is passed to `startSpanManual` or `startSpan` +- On React Native Web, `browserSessionIntegration` is added when `enableAutoSessionTracking` is set to `True` ([#4732](https://github.com/getsentry/sentry-react-native/pull/4732)) +Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](https://github.com/getsentry/sentry-react-native/pull/4636)) + ### Dependencies +- Bump JavaScript SDK from v8.54.0 to v9.12.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568), [#4752](https://github.com/getsentry/sentry-react-native/pull/4752)) + - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.12.0/CHANGELOG.md) + - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.12.0) +- Bump Android SDK from v7.20.1 to v8.11.1 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490)) + - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8111) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.11.1) - Bump CLI from v2.43.1 to v2.45.0 ([#4804](https://github.com/getsentry/sentry-react-native/pull/4804), [#4818](https://github.com/getsentry/sentry-react-native/pull/4818)) - [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2450) - [diff](https://github.com/getsentry/sentry-cli/compare/2.43.1...2.45.0) @@ -122,12 +160,6 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi ### Dependencies -- Bump JavaScript SDK from v8.54.0 to v9.12.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568), [#4752](https://github.com/getsentry/sentry-react-native/pull/4752)) - - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.12.0/CHANGELOG.md) - - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.12.0) -- Bump Android SDK from v7.20.1 to v8.11.1 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490)) - - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8111) - - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.11.1) - Bump Bundler Plugins from v3.2.2 to v3.3.1 ([#4693](https://github.com/getsentry/sentry-react-native/pull/4693), [#4707](https://github.com/getsentry/sentry-react-native/pull/4707), [#4720](https://github.com/getsentry/sentry-react-native/pull/4720), [#4721](https://github.com/getsentry/sentry-react-native/pull/4721)) - [changelog](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/main/CHANGELOG.md#331) - [diff](https://github.com/getsentry/sentry-javascript-bundler-plugins/compare/3.2.2...3.3.1) @@ -138,37 +170,6 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8490) - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.48.0...8.49.0) -### Major Changes - -- Set `{{auto}}` if `user.ip_address` is `undefined` and `sendDefaultPii: true` ([#4466](https://github.com/getsentry/sentry-react-native/pull/4466)) -- Exceptions from `captureConsoleIntegration` are now marked as handled: true by default -- `shutdownTimeout` moved from `core` to `@sentry/react-native` -- `hasTracingEnabled` was renamed to `hasSpansEnabled` -- You can no longer drop spans or return null on `beforeSendSpan` hook - -### Removed types - -- TransactionNamingScheme -- Request -- Scope (prefer using the Scope class) - -### Other removed items. - -- `autoSessionTracking` from options. - To enable session tracking, ensure that `enableAutoSessionTracking` is enabled. -- `enableTracing`. Instead, set `tracesSampleRate` to a value greater than `zero` to `enable tracing`, `0` to keep tracing integrations active without sampling, or `undefined` to disable the performance integration. -- `getCurrentHub()`, `Hub`, and `getCurrentHubShim()` -- `spanId` from propagation `context` -- metrics API -- `transactionContext` from `samplingContext` -- `@sentry/utils` package, the exports were moved to `@sentry/core` -- Standalone `Client` interface & deprecate `BaseClient` - -## Other Changes - -- Fork `scope` if custom scope is passed to `startSpanManual` or `startSpan` -- On React Native Web, `browserSessionIntegration` is added when `enableAutoSessionTracking` is set to `True` ([#4732](https://github.com/getsentry/sentry-react-native/pull/4732)) - ## 6.11.0-beta.0 ### Features @@ -324,10 +325,6 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi To learn more about the available configuration options visit [the documentation](https://docs.sentry.io/platforms/react-native/manual-setup/expo/gradle). -### Changes - -Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](https://github.com/getsentry/sentry-react-native/pull/4636)) - ### Fixes - Remove `error:` prefix from `collect-modules.sh` to avoid failing iOS builds ([#4570](https://github.com/getsentry/sentry-react-native/pull/4570)) @@ -338,6 +335,9 @@ Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](http ### Dependencies +- Bump Android SDK from v7.20.1 to v7.22.0 ([#4529](https://github.com/getsentry/sentry-react-native/pull/4529)) + - [changelog](https://github.com/getsentry/sentry-java/blob/7.x.x/CHANGELOG.md#7220) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...7.22.0) - Bump Cocoa SDK from v8.44.0 to v8.45.0 ([#4537](https://github.com/getsentry/sentry-react-native/pull/4537)) - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8450) - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.44.0...8.45.0) From 5ccf41ace2e1b4837f9c916f1b5cbac8022fbc67 Mon Sep 17 00:00:00 2001 From: getsentry-bot Date: Mon, 12 May 2025 04:53:13 +0000 Subject: [PATCH 20/64] release: 7.0.0-alpha.0 --- CHANGELOG.md | 2 +- dev-packages/e2e-tests/package.json | 4 ++-- dev-packages/type-check/package.json | 2 +- dev-packages/utils/package.json | 2 +- lerna.json | 2 +- .../main/java/io/sentry/react/RNSentryVersion.java | 2 +- packages/core/ios/RNSentryVersion.m | 2 +- packages/core/package.json | 2 +- packages/core/src/js/version.ts | 2 +- performance-tests/TestAppPlain/package.json | 2 +- performance-tests/TestAppSentry/package.json | 4 ++-- samples/expo/app.json | 8 ++++---- samples/expo/package.json | 4 ++-- samples/react-native-macos/package.json | 4 ++-- samples/react-native/android/app/build.gradle | 4 ++-- .../ios/sentryreactnativesample/Info.plist | 4 ++-- .../ios/sentryreactnativesampleTests/Info.plist | 4 ++-- samples/react-native/package.json | 4 ++-- yarn.lock | 12 ++++++------ 19 files changed, 35 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcab711f53..2350d4b90c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ > make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first. -## Unreleased +## 7.0.0-alpha.0 ### Upgrading from 6.x to 7.0 diff --git a/dev-packages/e2e-tests/package.json b/dev-packages/e2e-tests/package.json index 7ce8337619..4c394060f6 100644 --- a/dev-packages/e2e-tests/package.json +++ b/dev-packages/e2e-tests/package.json @@ -1,6 +1,6 @@ { "name": "sentry-react-native-e2e-tests", - "version": "6.13.1", + "version": "7.0.0-alpha.0", "private": true, "description": "Sentry React Native End to End Tests Library", "main": "dist/index.js", @@ -14,7 +14,7 @@ "@babel/preset-env": "^7.25.3", "@babel/preset-typescript": "^7.18.6", "@sentry/core": "9.12.0", - "@sentry/react-native": "6.13.1", + "@sentry/react-native": "7.0.0-alpha.0", "@types/node": "^20.9.3", "@types/react": "^18.2.64", "appium": "2.4.1", diff --git a/dev-packages/type-check/package.json b/dev-packages/type-check/package.json index e8a590909d..0a581efbaf 100644 --- a/dev-packages/type-check/package.json +++ b/dev-packages/type-check/package.json @@ -1,7 +1,7 @@ { "name": "sentry-react-native-type-check", "private": true, - "version": "6.13.1", + "version": "7.0.0-alpha.0", "scripts": { "type-check": "./run-type-check.sh" } diff --git a/dev-packages/utils/package.json b/dev-packages/utils/package.json index 7fb07a6374..eed21edba6 100644 --- a/dev-packages/utils/package.json +++ b/dev-packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "sentry-react-native-samples-utils", - "version": "6.13.1", + "version": "7.0.0-alpha.0", "description": "Internal Samples Utils", "main": "index.js", "license": "MIT", diff --git a/lerna.json b/lerna.json index e187962e8b..1c52e304f7 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "6.13.1", + "version": "7.0.0-alpha.0", "packages": [ "packages/*", "dev-packages/*", diff --git a/packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java b/packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java index 8293da5725..d2d288ece5 100644 --- a/packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java +++ b/packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java @@ -2,7 +2,7 @@ class RNSentryVersion { static final String REACT_NATIVE_SDK_PACKAGE_NAME = "npm:@sentry/react-native"; - static final String REACT_NATIVE_SDK_PACKAGE_VERSION = "6.13.1"; + static final String REACT_NATIVE_SDK_PACKAGE_VERSION = "7.0.0-alpha.0"; static final String NATIVE_SDK_NAME = "sentry.native.android.react-native"; static final String ANDROID_SDK_NAME = "sentry.java.android.react-native"; static final String REACT_NATIVE_SDK_NAME = "sentry.javascript.react-native"; diff --git a/packages/core/ios/RNSentryVersion.m b/packages/core/ios/RNSentryVersion.m index 8125437aa6..8d92c2814c 100644 --- a/packages/core/ios/RNSentryVersion.m +++ b/packages/core/ios/RNSentryVersion.m @@ -3,4 +3,4 @@ NSString *const NATIVE_SDK_NAME = @"sentry.cocoa.react-native"; NSString *const REACT_NATIVE_SDK_NAME = @"sentry.javascript.react-native"; NSString *const REACT_NATIVE_SDK_PACKAGE_NAME = @"npm:@sentry/react-native"; -NSString *const REACT_NATIVE_SDK_PACKAGE_VERSION = @"6.13.1"; +NSString *const REACT_NATIVE_SDK_PACKAGE_VERSION = @"7.0.0-alpha.0"; diff --git a/packages/core/package.json b/packages/core/package.json index bcc32f00d7..9a87431ef1 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -2,7 +2,7 @@ "name": "@sentry/react-native", "homepage": "https://github.com/getsentry/sentry-react-native", "repository": "https://github.com/getsentry/sentry-react-native", - "version": "6.13.1", + "version": "7.0.0-alpha.0", "description": "Official Sentry SDK for react-native", "typings": "dist/js/index.d.ts", "types": "dist/js/index.d.ts", diff --git a/packages/core/src/js/version.ts b/packages/core/src/js/version.ts index 62f06878d9..571598ff64 100644 --- a/packages/core/src/js/version.ts +++ b/packages/core/src/js/version.ts @@ -1,3 +1,3 @@ export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native'; export const SDK_NAME = 'sentry.javascript.react-native'; -export const SDK_VERSION = '6.13.1'; +export const SDK_VERSION = '7.0.0-alpha.0'; diff --git a/performance-tests/TestAppPlain/package.json b/performance-tests/TestAppPlain/package.json index a70074ffb1..78a7d9fc43 100644 --- a/performance-tests/TestAppPlain/package.json +++ b/performance-tests/TestAppPlain/package.json @@ -1,6 +1,6 @@ { "name": "TestAppPlain", - "version": "6.13.1", + "version": "7.0.0-alpha.0", "private": true, "scripts": { "android": "react-native run-android", diff --git a/performance-tests/TestAppSentry/package.json b/performance-tests/TestAppSentry/package.json index 4b237a78b3..1b8f080a23 100644 --- a/performance-tests/TestAppSentry/package.json +++ b/performance-tests/TestAppSentry/package.json @@ -1,6 +1,6 @@ { "name": "TestAppSentry", - "version": "6.13.1", + "version": "7.0.0-alpha.0", "private": true, "scripts": { "android": "react-native run-android", @@ -8,7 +8,7 @@ "start": "react-native start" }, "dependencies": { - "@sentry/react-native": "6.13.1", + "@sentry/react-native": "7.0.0-alpha.0", "react": "18.1.0", "react-native": "0.70.15" }, diff --git a/samples/expo/app.json b/samples/expo/app.json index 83887597fb..835208d2c4 100644 --- a/samples/expo/app.json +++ b/samples/expo/app.json @@ -5,7 +5,7 @@ "jsEngine": "hermes", "newArchEnabled": true, "scheme": "sentry-expo-sample", - "version": "6.13.1", + "version": "7.0.0-alpha.0", "orientation": "portrait", "icon": "./assets/icon.png", "userInterfaceStyle": "light", @@ -20,7 +20,7 @@ "ios": { "supportsTablet": true, "bundleIdentifier": "io.sentry.expo.sample", - "buildNumber": "46" + "buildNumber": "47" }, "android": { "adaptiveIcon": { @@ -28,7 +28,7 @@ "backgroundColor": "#ffffff" }, "package": "io.sentry.expo.sample", - "versionCode": 46 + "versionCode": 47 }, "web": { "bundler": "metro", @@ -93,4 +93,4 @@ "url": "https://u.expo.dev/00000000-0000-0000-0000-000000000000" } } -} +} \ No newline at end of file diff --git a/samples/expo/package.json b/samples/expo/package.json index f87d919adf..9b455cc3d5 100644 --- a/samples/expo/package.json +++ b/samples/expo/package.json @@ -1,6 +1,6 @@ { "name": "sentry-react-native-expo-sample", - "version": "6.13.1", + "version": "7.0.0-alpha.0", "main": "expo-router/entry", "scripts": { "start": "expo start", @@ -17,7 +17,7 @@ "eas-build-pre-install": "npm i -g corepack && yarn install --no-immutable --inline-builds && yarn workspace @sentry/react-native build" }, "dependencies": { - "@sentry/react-native": "6.13.1", + "@sentry/react-native": "7.0.0-alpha.0", "@types/react": "~19.0.10", "expo": "^53.0.0", "expo-constants": "~17.1.5", diff --git a/samples/react-native-macos/package.json b/samples/react-native-macos/package.json index 791a75715b..b23d94d0f7 100644 --- a/samples/react-native-macos/package.json +++ b/samples/react-native-macos/package.json @@ -1,6 +1,6 @@ { "name": "sentry-react-native-macos-sample", - "version": "6.13.1", + "version": "7.0.0-alpha.0", "private": true, "scripts": { "start": "react-native start --experimental-debugger", @@ -18,7 +18,7 @@ "@react-navigation/stack": "^6.3.20", "@sentry/core": "9.12.0", "@sentry/react": "9.12.0", - "@sentry/react-native": "6.13.1", + "@sentry/react-native": "7.0.0-alpha.0", "delay": "^6.0.0", "react": "18.2.0", "react-native": "0.73.9", diff --git a/samples/react-native/android/app/build.gradle b/samples/react-native/android/app/build.gradle index 7e1f6c6e9c..60c3ad78f9 100644 --- a/samples/react-native/android/app/build.gradle +++ b/samples/react-native/android/app/build.gradle @@ -136,8 +136,8 @@ android { applicationId "io.sentry.reactnative.sample" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 48 - versionName "6.13.1" + versionCode 49 + versionName "7.0.0-alpha.0" } signingConfigs { diff --git a/samples/react-native/ios/sentryreactnativesample/Info.plist b/samples/react-native/ios/sentryreactnativesample/Info.plist index 1653da2315..1b1fec6a28 100644 --- a/samples/react-native/ios/sentryreactnativesample/Info.plist +++ b/samples/react-native/ios/sentryreactnativesample/Info.plist @@ -19,11 +19,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 6.13.1 + 7.0.0 CFBundleSignature ???? CFBundleVersion - 53 + 54 LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/samples/react-native/ios/sentryreactnativesampleTests/Info.plist b/samples/react-native/ios/sentryreactnativesampleTests/Info.plist index b82d71a808..ca0ae505a3 100644 --- a/samples/react-native/ios/sentryreactnativesampleTests/Info.plist +++ b/samples/react-native/ios/sentryreactnativesampleTests/Info.plist @@ -15,10 +15,10 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 6.13.1 + 7.0.0 CFBundleSignature ???? CFBundleVersion - 53 + 54 diff --git a/samples/react-native/package.json b/samples/react-native/package.json index 683d55410b..d618606ffe 100644 --- a/samples/react-native/package.json +++ b/samples/react-native/package.json @@ -1,6 +1,6 @@ { "name": "sentry-react-native-sample", - "version": "6.13.1", + "version": "7.0.0-alpha.0", "private": true, "scripts": { "postinstall": "patch-package", @@ -28,7 +28,7 @@ "@react-navigation/native-stack": "^7.2.0", "@react-navigation/stack": "^7.1.1", "@sentry/core": "9.12.0", - "@sentry/react-native": "6.13.1", + "@sentry/react-native": "7.0.0-alpha.0", "@shopify/flash-list": "^1.7.3", "delay": "^6.0.0", "react": "18.3.1", diff --git a/yarn.lock b/yarn.lock index b547273b7d..54cefbde31 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8472,7 +8472,7 @@ __metadata: languageName: node linkType: hard -"@sentry/react-native@6.13.1, @sentry/react-native@workspace:packages/core": +"@sentry/react-native@7.0.0-alpha.0, @sentry/react-native@workspace:packages/core": version: 0.0.0-use.local resolution: "@sentry/react-native@workspace:packages/core" dependencies: @@ -10145,7 +10145,7 @@ __metadata: dependencies: "@babel/core": ^7.12.9 "@babel/runtime": ^7.12.5 - "@sentry/react-native": 6.13.1 + "@sentry/react-native": 7.0.0-alpha.0 metro-react-native-babel-preset: ^0.72.3 react: 18.1.0 react-native: 0.70.15 @@ -25482,7 +25482,7 @@ __metadata: "@babel/preset-env": ^7.25.3 "@babel/preset-typescript": ^7.18.6 "@sentry/core": 9.12.0 - "@sentry/react-native": 6.13.1 + "@sentry/react-native": 7.0.0-alpha.0 "@types/node": ^20.9.3 "@types/react": ^18.2.64 appium: 2.4.1 @@ -25511,7 +25511,7 @@ __metadata: "@babel/core": ^7.26.0 "@babel/preset-env": ^7.26.0 "@sentry/babel-plugin-component-annotate": 3.4.0 - "@sentry/react-native": 6.13.1 + "@sentry/react-native": 7.0.0-alpha.0 "@types/node": 20.10.4 "@types/react": ~19.0.10 expo: ^53.0.0 @@ -25551,7 +25551,7 @@ __metadata: "@react-navigation/stack": ^6.3.20 "@sentry/core": 9.12.0 "@sentry/react": 9.12.0 - "@sentry/react-native": 6.13.1 + "@sentry/react-native": 7.0.0-alpha.0 "@types/react": ^18.2.65 "@types/react-native-vector-icons": ^6.4.18 "@types/react-test-renderer": ^18.0.0 @@ -25598,7 +25598,7 @@ __metadata: "@react-navigation/stack": ^7.1.1 "@sentry/babel-plugin-component-annotate": 3.4.0 "@sentry/core": 9.12.0 - "@sentry/react-native": 6.13.1 + "@sentry/react-native": 7.0.0-alpha.0 "@shopify/flash-list": ^1.7.3 "@types/jest": ^29.5.14 "@types/node": ^22.13.1 From 3f74051c9f27720850b02c94c741a79e0df2af43 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Mon, 12 May 2025 12:08:23 +0300 Subject: [PATCH 21/64] Fix v7 other changes section header (#4823) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2350d4b90c..3cda513ebe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,7 +45,7 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi - `@sentry/utils` package, the exports were moved to `@sentry/core` - Standalone `Client` interface & deprecate `BaseClient` -## Other Changes +### Other Changes - Fork `scope` if custom scope is passed to `startSpanManual` or `startSpan` - On React Native Web, `browserSessionIntegration` is added when `enableAutoSessionTracking` is set to `True` ([#4732](https://github.com/getsentry/sentry-react-native/pull/4732)) From 636c53e0ecb119528f25f523b50ffc96a02ad37a Mon Sep 17 00:00:00 2001 From: LucasZF Date: Mon, 12 May 2025 06:28:30 -0300 Subject: [PATCH 22/64] sync changelog (#4824) --- CHANGELOG.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cda513ebe..243284c499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi - Expo Updates Context is passed to native after native init to be available for crashes ([#4808](https://github.com/getsentry/sentry-react-native/pull/4808)) - Expo Updates Context values should all be lowercase ([#4809](https://github.com/getsentry/sentry-react-native/pull/4809)) +- Avoid duplicate network requests (fetch, xhr) by default ([#4816](https://github.com/getsentry/sentry-react-native/pull/4816)) + - `traceFetch` is disabled by default on mobile as RN uses a polyfill which will be traced by `traceXHR` ### Major Changes @@ -69,11 +71,6 @@ Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](http - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8500) - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.49.2...8.50.0) -### Fixes - -- Avoid duplicate network requests (fetch, xhr) by default ([#4816](https://github.com/getsentry/sentry-react-native/pull/4816)) - - `traceFetch` is disabled by default on mobile as RN uses a polyfill which will be traced by `traceXHR` - ## 6.13.1 ### Fixes From a363b09a0ccf6c5a98a327c3ef3d7b9e4bb9d6bf Mon Sep 17 00:00:00 2001 From: LucasZF Date: Wed, 21 May 2025 07:39:53 -0300 Subject: [PATCH 23/64] chore(deps-v7): update Android SDK to v8.12.0 (#4847) * bump android SDK * changelog number --- CHANGELOG.md | 8 ++++++++ packages/core/android/build.gradle | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 243284c499..fa5684843d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ > make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first. +## Unreleased + +### Dependencies + +- Bump Android SDK from v8.11.1 to v8.12.0 ([#4847](https://github.com/getsentry/sentry-react-native/pull/4847)) + - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8120) + - [diff](https://github.com/getsentry/sentry-java/compare/8.11.1...8.12.0) + ## 7.0.0-alpha.0 ### Upgrading from 6.x to 7.0 diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index 5cc7aab628..a8082de50b 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -54,5 +54,5 @@ android { dependencies { implementation 'com.facebook.react:react-native:+' - api 'io.sentry:sentry-android:8.11.1' + api 'io.sentry:sentry-android:8.12.0' } From 80caa110d943c3a87e7dfdbfe556fd69c4784f42 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Mon, 26 May 2025 12:25:09 -0300 Subject: [PATCH 24/64] chore(deps-v7): update Cocoa SDK to v8.51.1 (#4843) * bump cocoa sdk * changelog * Apply suggestions from code review * Update default value test to align with the latest SDK --- CHANGELOG.md | 3 +++ packages/core/RNSentry.podspec | 2 +- .../RNSentryReplayOptionsTests.swift | 14 +++++++------- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa5684843d..c4a0bb261e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ ### Dependencies +- Bump Cocoa SDK from v8.50.2 to v8.51.1 ([#4843](https://github.com/getsentry/sentry-react-native/pull/4843)) + - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8511) + - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.50.0...8.51.1) - Bump Android SDK from v8.11.1 to v8.12.0 ([#4847](https://github.com/getsentry/sentry-react-native/pull/4847)) - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8120) - [diff](https://github.com/getsentry/sentry-java/compare/8.11.1...8.12.0) diff --git a/packages/core/RNSentry.podspec b/packages/core/RNSentry.podspec index ff50ffeed2..070de46982 100644 --- a/packages/core/RNSentry.podspec +++ b/packages/core/RNSentry.podspec @@ -37,7 +37,7 @@ Pod::Spec.new do |s| s.compiler_flags = other_cflags - s.dependency 'Sentry/HybridSDK', '8.50.0' + s.dependency 'Sentry/HybridSDK', '8.51.1' if defined? install_modules_dependencies # Default React Native dependencies for 0.71 and above (new and legacy architecture) diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift index 4d94dba446..b23fac94e2 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayOptionsTests.swift @@ -166,7 +166,7 @@ final class RNSentryReplayOptions: XCTestCase { XCTAssertEqual(actualOptions.sessionReplay.maskAllText, false) XCTAssertEqual(actualOptions.sessionReplay.maskedViewClasses.count, 0) } - + func testEnableExperimentalViewRendererDefault() { let optionsDict = ([ "dsn": "https://abc@def.ingest.sentry.io/1234567", @@ -177,9 +177,9 @@ final class RNSentryReplayOptions: XCTestCase { let actualOptions = try! Options(dict: optionsDict as! [String: Any]) - XCTAssertFalse(actualOptions.sessionReplay.enableExperimentalViewRenderer) + XCTAssertTrue(actualOptions.sessionReplay.enableExperimentalViewRenderer) } - + func testEnableExperimentalViewRendererTrue() { let optionsDict = ([ "dsn": "https://abc@def.ingest.sentry.io/1234567", @@ -193,7 +193,7 @@ final class RNSentryReplayOptions: XCTestCase { XCTAssertTrue(actualOptions.sessionReplay.enableExperimentalViewRenderer) } - + func testEnableExperimentalViewRendererFalse() { let optionsDict = ([ "dsn": "https://abc@def.ingest.sentry.io/1234567", @@ -207,7 +207,7 @@ final class RNSentryReplayOptions: XCTestCase { XCTAssertFalse(actualOptions.sessionReplay.enableExperimentalViewRenderer) } - + func testEnableFastViewRenderingDefault() { let optionsDict = ([ "dsn": "https://abc@def.ingest.sentry.io/1234567", @@ -220,7 +220,7 @@ final class RNSentryReplayOptions: XCTestCase { XCTAssertFalse(actualOptions.sessionReplay.enableFastViewRendering) } - + func testEnableFastViewRenderingTrue() { let optionsDict = ([ "dsn": "https://abc@def.ingest.sentry.io/1234567", @@ -234,7 +234,7 @@ final class RNSentryReplayOptions: XCTestCase { XCTAssertTrue(actualOptions.sessionReplay.enableFastViewRendering) } - + func testEnableFastViewRenderingFalse() { let optionsDict = ([ "dsn": "https://abc@def.ingest.sentry.io/1234567", From c27dafb8fc4f674f268b16cea40f5d440a62b2ff Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Tue, 27 May 2025 12:59:12 +0300 Subject: [PATCH 25/64] Bump Android to 8.13.1 (#4861) --- CHANGELOG.md | 6 +++--- packages/core/android/build.gradle | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4a0bb261e..55b874bcac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,9 +13,9 @@ - Bump Cocoa SDK from v8.50.2 to v8.51.1 ([#4843](https://github.com/getsentry/sentry-react-native/pull/4843)) - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8511) - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.50.0...8.51.1) -- Bump Android SDK from v8.11.1 to v8.12.0 ([#4847](https://github.com/getsentry/sentry-react-native/pull/4847)) - - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8120) - - [diff](https://github.com/getsentry/sentry-java/compare/8.11.1...8.12.0) +- Bump Android SDK from v8.11.1 to v8.13.1 ([#4847](https://github.com/getsentry/sentry-react-native/pull/4847)) + - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8131) + - [diff](https://github.com/getsentry/sentry-java/compare/8.11.1...8.13.1) ## 7.0.0-alpha.0 diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index a8082de50b..8c48b3782a 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -54,5 +54,5 @@ android { dependencies { implementation 'com.facebook.react:react-native:+' - api 'io.sentry:sentry-android:8.12.0' + api 'io.sentry:sentry-android:8.13.1' } From c6d4d0af864c61468569a1602c7623861116bdbb Mon Sep 17 00:00:00 2001 From: LucasZF Date: Tue, 27 May 2025 06:59:41 -0300 Subject: [PATCH 26/64] chore(deps-v7): update Javascript SDK to v9.22.0 (#4860) * bump JS SDK / new lint fixes * update changelog * ignored rule import/first for tests, rolled back tests affected by mock order --- CHANGELOG.md | 3 + dev-packages/e2e-tests/package.json | 2 +- packages/core/.eslintrc.js | 1 + packages/core/package.json | 14 +- packages/core/plugin/src/withSentry.ts | 6 +- packages/core/plugin/src/withSentryAndroid.ts | 1 - .../src/withSentryAndroidGradlePlugin.ts | 5 +- packages/core/plugin/src/withSentryIOS.ts | 1 - .../core/scripts/expo-upload-sourcemaps.js | 4 +- packages/core/src/js/NativeRNSentry.ts | 1 - packages/core/src/js/client.ts | 1 - .../src/js/feedback/FeedbackWidget.styles.ts | 1 - .../core/src/js/feedback/FeedbackWidget.tsx | 1 - .../src/js/feedback/FeedbackWidgetManager.tsx | 1 - packages/core/src/js/feedback/integration.ts | 1 - packages/core/src/js/feedback/lazy.ts | 1 - packages/core/src/js/feedback/utils.ts | 1 - .../core/src/js/integrations/appRegistry.ts | 1 - .../src/js/integrations/debugsymbolicator.ts | 1 - .../js/integrations/debugsymbolicatorutils.ts | 1 - packages/core/src/js/integrations/default.ts | 1 - .../core/src/js/integrations/devicecontext.ts | 1 - .../core/src/js/integrations/expocontext.ts | 1 - .../core/src/js/integrations/modulesloader.ts | 1 - .../src/js/integrations/nativelinkederrors.ts | 1 - .../integrations/reactnativeerrorhandlers.ts | 1 - .../reactnativeerrorhandlersutils.ts | 1 - .../src/js/integrations/reactnativeinfo.ts | 1 - packages/core/src/js/integrations/release.ts | 1 - .../core/src/js/integrations/rewriteframes.ts | 1 - .../core/src/js/integrations/screenshot.ts | 1 - packages/core/src/js/integrations/sdkinfo.ts | 1 - .../core/src/js/integrations/spotlight.ts | 1 - .../core/src/js/integrations/viewhierarchy.ts | 1 - packages/core/src/js/options.ts | 1 - .../src/js/profiling/convertHermesProfile.ts | 1 - packages/core/src/js/profiling/debugid.ts | 1 - packages/core/src/js/profiling/hermes.ts | 1 - packages/core/src/js/profiling/integration.ts | 1 - packages/core/src/js/profiling/types.ts | 1 - packages/core/src/js/profiling/utils.ts | 1 - packages/core/src/js/replay/CustomMask.tsx | 1 - packages/core/src/js/replay/mobilereplay.ts | 1 - packages/core/src/js/replay/xhrUtils.ts | 1 - packages/core/src/js/scopeSync.ts | 1 - packages/core/src/js/sdk.tsx | 1 - packages/core/src/js/tools/collectModules.ts | 1 - packages/core/src/js/tools/metroconfig.ts | 4 +- .../js/tools/sentryBabelTransformerUtils.ts | 3 +- .../src/js/tools/sentryMetroSerializer.ts | 1 - .../core/src/js/tools/vendor/metro/utils.ts | 1 - packages/core/src/js/touchevents.tsx | 1 - .../core/src/js/tracing/gesturetracing.ts | 1 - .../src/js/tracing/integrations/appStart.ts | 3 +- .../js/tracing/integrations/nativeFrames.ts | 1 - .../js/tracing/integrations/stalltracking.ts | 1 - .../integrations/timeToDisplayIntegration.ts | 1 - .../tracing/integrations/userInteraction.ts | 1 - .../core/src/js/tracing/onSpanEndUtils.ts | 1 - .../src/js/tracing/reactnativenavigation.ts | 1 - .../src/js/tracing/reactnativeprofiler.tsx | 1 - .../core/src/js/tracing/reactnativetracing.ts | 1 - .../core/src/js/tracing/reactnavigation.ts | 2 +- packages/core/src/js/tracing/span.ts | 5 +- .../core/src/js/tracing/timetodisplay.tsx | 27 ++-- .../src/js/tracing/timetodisplaynative.tsx | 1 - packages/core/src/js/tracing/utils.ts | 1 - .../core/src/js/transports/encodePolyfill.ts | 1 - packages/core/src/js/transports/native.ts | 1 - packages/core/src/js/utils/environment.ts | 1 - packages/core/src/js/utils/rnlibraries.ts | 1 - packages/core/src/js/utils/safe.ts | 1 - .../core/src/js/utils/sentryeventemitter.ts | 1 - .../js/utils/sentryeventemitterfallback.ts | 1 - packages/core/src/js/utils/worldwide.ts | 1 - packages/core/src/js/wrapper.ts | 1 - packages/core/test/breadcrumb.test.ts | 1 - packages/core/test/client.test.ts | 7 +- .../withSentryAndroidGradlePlugin.test.ts | 3 +- packages/core/test/feedback.test.ts | 1 - .../test/feedback/FeedbackWidget.test.tsx | 5 +- .../feedback/FeedbackWidgetManager.test.tsx | 1 - .../test/integrations/appRegistry.test.ts | 1 - .../integrations/debugsymbolicator.test.ts | 5 +- .../test/integrations/devicecontext.test.ts | 1 - .../test/integrations/eventorigin.test.ts | 1 - .../test/integrations/expocontext.test.ts | 1 - .../integrationsexecutionorder.test.ts | 2 +- .../test/integrations/modulesloader.test.ts | 1 - .../integrations/nativelinkederrors.test.ts | 1 - .../reactnativeerrorhandlers.test.ts | 5 +- .../test/integrations/reactnativeinfo.test.ts | 1 - .../core/test/integrations/release.test.ts | 1 - .../test/integrations/rewriteframes.test.ts | 1 - .../core/test/integrations/sdkinfo.test.ts | 1 - .../core/test/integrations/spotlight.test.ts | 2 +- .../test/integrations/viewhierarchy.test.ts | 1 - packages/core/test/mocks/client.ts | 1 - .../profiling/convertHermesProfile.test.ts | 1 - packages/core/test/profiling/hermes.test.ts | 1 - .../core/test/profiling/integration.test.ts | 2 +- packages/core/test/replay/xhrUtils.test.ts | 1 - packages/core/test/scopeSync.test.ts | 5 +- packages/core/test/sdk.test.ts | 1 - packages/core/test/sdk.withclient.test.ts | 1 - .../tools/fixtures/mockBabelTransformer.js | 1 + .../core/test/tools/metroMiddleware.test.ts | 1 - packages/core/test/tools/metroconfig.test.ts | 3 +- .../test/tools/sentryBabelTransformer.test.ts | 1 - .../test/tools/sentryMetroSerializer.test.ts | 1 - packages/core/test/touchevents.test.tsx | 1 - packages/core/test/trace.test.ts | 1 - .../test/tracing/addTracingExtensions.test.ts | 1 - .../core/test/tracing/gesturetracing.test.ts | 1 - .../test/tracing/idleNavigationSpan.test.ts | 1 - .../tracing/integrations/appStart.test.ts | 1 - .../tracing/integrations/nativeframes.test.ts | 1 - .../stalltracking.background.test.ts | 1 - .../stallTracking/stalltracking.test.ts | 1 - .../integrations/userInteraction.test.ts | 1 - .../tracing/mockedtimetodisplaynative.tsx | 1 - .../tracing/reactnativenavigation.test.ts | 1 - .../test/tracing/reactnativetracing.test.ts | 9 +- .../reactnavigation.stalltracking.test.ts | 1 - .../core/test/tracing/reactnavigation.test.ts | 1 - .../tracing/reactnavigation.ttid.test.tsx | 5 +- .../core/test/tracing/timetodisplay.test.tsx | 26 +-- .../tracing/timetodisplaynative.web.test.tsx | 6 +- packages/core/test/transports/native.test.ts | 1 - .../test/utils/ignorerequirecyclelogs.test.ts | 1 - .../utils/mockedSentryeventemitterfallback.ts | 1 - .../utils/sentryeventemitterfallback.test.ts | 1 - packages/core/test/wrap.mocked.test.tsx | 1 - packages/core/test/wrap.test.tsx | 1 - packages/core/test/wrapper.test.ts | 1 - samples/react-native-macos/package.json | 4 +- samples/react-native/package.json | 2 +- yarn.lock | 152 +++++++++--------- 138 files changed, 161 insertions(+), 269 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55b874bcac..580784c539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ ### Dependencies +- Bump JavaScript SDK from v9.12.0 to v9.22.0 ([#4860](https://github.com/getsentry/sentry-react-native/pull/4860)) + - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.22.0/CHANGELOG.md) + - [diff](https://github.com/getsentry/sentry-javascript/compare/9.12.0...9.22.0) - Bump Cocoa SDK from v8.50.2 to v8.51.1 ([#4843](https://github.com/getsentry/sentry-react-native/pull/4843)) - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8511) - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.50.0...8.51.1) diff --git a/dev-packages/e2e-tests/package.json b/dev-packages/e2e-tests/package.json index 4c394060f6..38c1cfa8aa 100644 --- a/dev-packages/e2e-tests/package.json +++ b/dev-packages/e2e-tests/package.json @@ -13,7 +13,7 @@ "devDependencies": { "@babel/preset-env": "^7.25.3", "@babel/preset-typescript": "^7.18.6", - "@sentry/core": "9.12.0", + "@sentry/core": "9.22.0", "@sentry/react-native": "7.0.0-alpha.0", "@types/node": "^20.9.3", "@types/react": "^18.2.64", diff --git a/packages/core/.eslintrc.js b/packages/core/.eslintrc.js index 8916a1cfd9..c933060182 100644 --- a/packages/core/.eslintrc.js +++ b/packages/core/.eslintrc.js @@ -38,6 +38,7 @@ module.exports = { '@typescript-eslint/no-empty-function': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/unbound-method': 'off', + 'import/first': 'off', }, }, { diff --git a/packages/core/package.json b/packages/core/package.json index 9a87431ef1..cf5eca6992 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -66,20 +66,20 @@ }, "dependencies": { "@sentry/babel-plugin-component-annotate": "3.4.0", - "@sentry/browser": "9.12.0", + "@sentry/browser": "9.22.0", "@sentry/cli": "2.43.0", - "@sentry/core": "9.12.0", - "@sentry/react": "9.12.0", - "@sentry/types": "9.12.0" + "@sentry/core": "9.22.0", + "@sentry/react": "9.22.0", + "@sentry/types": "9.22.0" }, "devDependencies": { "@babel/core": "^7.25.2", "@expo/metro-config": "0.19.5", "@mswjs/interceptors": "^0.25.15", "@react-native/babel-preset": "0.77.1", - "@sentry-internal/eslint-config-sdk": "9.12.0", - "@sentry-internal/eslint-plugin-sdk": "9.12.0", - "@sentry-internal/typescript": "9.12.0", + "@sentry-internal/eslint-config-sdk": "9.22.0", + "@sentry-internal/eslint-plugin-sdk": "9.22.0", + "@sentry-internal/typescript": "9.22.0", "@sentry/wizard": "4.9.0", "@testing-library/react-native": "^12.7.2", "@types/jest": "^29.5.13", diff --git a/packages/core/plugin/src/withSentry.ts b/packages/core/plugin/src/withSentry.ts index 332957e871..2fdee7f063 100644 --- a/packages/core/plugin/src/withSentry.ts +++ b/packages/core/plugin/src/withSentry.ts @@ -1,6 +1,5 @@ import type { ConfigPlugin } from 'expo/config-plugins'; import { createRunOncePlugin } from 'expo/config-plugins'; - import { bold, sdkPackage, warnOnce } from './utils'; import { withSentryAndroid } from './withSentryAndroid'; import type { SentryAndroidGradlePluginOptions } from './withSentryAndroidGradlePlugin'; @@ -50,8 +49,9 @@ const withSentryPlugin: ConfigPlugin = (config, props) => { const missingProjectMessage = '# no project found, falling back to SENTRY_PROJECT environment variable'; const missingOrgMessage = '# no org found, falling back to SENTRY_ORG environment variable'; -const existingAuthTokenMessage = `# DO NOT COMMIT the auth token, use SENTRY_AUTH_TOKEN instead, see https://docs.sentry.io/platforms/react-native/manual-setup/`; -const missingAuthTokenMessage = `# Using SENTRY_AUTH_TOKEN environment variable`; +const existingAuthTokenMessage = + '# DO NOT COMMIT the auth token, use SENTRY_AUTH_TOKEN instead, see https://docs.sentry.io/platforms/react-native/manual-setup/'; +const missingAuthTokenMessage = '# Using SENTRY_AUTH_TOKEN environment variable'; export function getSentryProperties(props: PluginProps | void): string | null { const { organization, project, authToken, url = 'https://sentry.io/' } = props ?? {}; diff --git a/packages/core/plugin/src/withSentryAndroid.ts b/packages/core/plugin/src/withSentryAndroid.ts index 9beaa23883..e8c2cf243e 100644 --- a/packages/core/plugin/src/withSentryAndroid.ts +++ b/packages/core/plugin/src/withSentryAndroid.ts @@ -1,7 +1,6 @@ import type { ConfigPlugin } from 'expo/config-plugins'; import { withAppBuildGradle, withDangerousMod } from 'expo/config-plugins'; import * as path from 'path'; - import { warnOnce, writeSentryPropertiesTo } from './utils'; export const withSentryAndroid: ConfigPlugin = (config, sentryProperties: string) => { diff --git a/packages/core/plugin/src/withSentryAndroidGradlePlugin.ts b/packages/core/plugin/src/withSentryAndroidGradlePlugin.ts index 3154f25aad..d05f240595 100644 --- a/packages/core/plugin/src/withSentryAndroidGradlePlugin.ts +++ b/packages/core/plugin/src/withSentryAndroidGradlePlugin.ts @@ -1,5 +1,4 @@ import { withAppBuildGradle, withProjectBuildGradle } from '@expo/config-plugins'; - import { warnOnce } from './utils'; export interface SentryAndroidGradlePluginOptions { @@ -67,7 +66,7 @@ export function withSentryAndroidGradlePlugin( projectBuildGradle.modResults.contents = updatedContents; } } catch (error) { - warnOnce(`An error occurred while trying to modify build.gradle`); + warnOnce('An error occurred while trying to modify build.gradle'); } return projectBuildGradle; }); @@ -81,7 +80,7 @@ export function withSentryAndroidGradlePlugin( warnOnce('Cannot configure Sentry in android/app/build.gradle because it is not in Groovy.'); return config; } - const sentryPlugin = `apply plugin: "io.sentry.android.gradle"`; + const sentryPlugin = 'apply plugin: "io.sentry.android.gradle"'; const sentryConfig = ` sentry { autoUploadProguardMapping = ${autoUploadProguardMapping ? 'shouldSentryAutoUpload()' : 'false'} diff --git a/packages/core/plugin/src/withSentryIOS.ts b/packages/core/plugin/src/withSentryIOS.ts index db25261839..e10f820282 100644 --- a/packages/core/plugin/src/withSentryIOS.ts +++ b/packages/core/plugin/src/withSentryIOS.ts @@ -2,7 +2,6 @@ import type { ConfigPlugin, XcodeProject } from 'expo/config-plugins'; import { withDangerousMod, withXcodeProject } from 'expo/config-plugins'; import * as path from 'path'; - import { warnOnce, writeSentryPropertiesTo } from './utils'; type BuildPhase = { shellScript: string }; diff --git a/packages/core/scripts/expo-upload-sourcemaps.js b/packages/core/scripts/expo-upload-sourcemaps.js index c282adeb3f..2d696efb03 100755 --- a/packages/core/scripts/expo-upload-sourcemaps.js +++ b/packages/core/scripts/expo-upload-sourcemaps.js @@ -174,7 +174,7 @@ if (!sentryOrg || !sentryProject || !sentryUrl) { console.log(`${SENTRY_URL} resolved to ${sentryUrl} from expo config.`); } else { - sentryUrl = `https://sentry.io/`; + sentryUrl = 'https://sentry.io/'; console.log( `Since it wasn't specified in the Expo config or environment variable, ${SENTRY_URL} now points to ${sentryUrl}.` ); @@ -214,7 +214,7 @@ for (const [assetGroupName, assets] of Object.entries(groupedAssets)) { } const isHermes = assets.find(asset => asset.endsWith('.hbc')); - const windowsCallback = process.platform === "win32" ? 'node ' : ''; + const windowsCallback = process.platform === 'win32' ? 'node ' : ''; execSync(`${windowsCallback}${sentryCliBin} sourcemaps upload ${isHermes ? '--debug-id-reference' : ''} ${assets.join(' ')}`, { env: { ...process.env, diff --git a/packages/core/src/js/NativeRNSentry.ts b/packages/core/src/js/NativeRNSentry.ts index 638623a354..9771814038 100644 --- a/packages/core/src/js/NativeRNSentry.ts +++ b/packages/core/src/js/NativeRNSentry.ts @@ -1,7 +1,6 @@ import type { Package } from '@sentry/core'; import type { TurboModule } from 'react-native'; import { TurboModuleRegistry } from 'react-native'; - import type { UnsafeObject } from './utils/rnlibrariesinterface'; // There has to be only one interface and it has to be named `Spec` diff --git a/packages/core/src/js/client.ts b/packages/core/src/js/client.ts index d6b2d45682..6ed2c172b1 100644 --- a/packages/core/src/js/client.ts +++ b/packages/core/src/js/client.ts @@ -19,7 +19,6 @@ import { SentryError, } from '@sentry/core'; import { Alert } from 'react-native'; - import { getDevServer } from './integrations/debugsymbolicatorutils'; import { defaultSdkInfo } from './integrations/sdkinfo'; import { getDefaultSidecarUrl } from './integrations/spotlight'; diff --git a/packages/core/src/js/feedback/FeedbackWidget.styles.ts b/packages/core/src/js/feedback/FeedbackWidget.styles.ts index aebdb181e3..777ba7c90b 100644 --- a/packages/core/src/js/feedback/FeedbackWidget.styles.ts +++ b/packages/core/src/js/feedback/FeedbackWidget.styles.ts @@ -1,5 +1,4 @@ import type { ViewStyle } from 'react-native'; - import type { FeedbackWidgetStyles } from './FeedbackWidget.types'; const PURPLE = 'rgba(88, 74, 192, 1)'; diff --git a/packages/core/src/js/feedback/FeedbackWidget.tsx b/packages/core/src/js/feedback/FeedbackWidget.tsx index 95b6e295fb..4ee4aab7ec 100644 --- a/packages/core/src/js/feedback/FeedbackWidget.tsx +++ b/packages/core/src/js/feedback/FeedbackWidget.tsx @@ -11,7 +11,6 @@ import { TouchableWithoutFeedback, View } from 'react-native'; - import { isWeb, notWeb } from '../utils/environment'; import { getDataFromUri } from '../wrapper'; import { sentryLogo } from './branding'; diff --git a/packages/core/src/js/feedback/FeedbackWidgetManager.tsx b/packages/core/src/js/feedback/FeedbackWidgetManager.tsx index 2013a08552..8c376d1a69 100644 --- a/packages/core/src/js/feedback/FeedbackWidgetManager.tsx +++ b/packages/core/src/js/feedback/FeedbackWidgetManager.tsx @@ -2,7 +2,6 @@ import { logger } from '@sentry/core'; import * as React from 'react'; import type { NativeScrollEvent, NativeSyntheticEvent} from 'react-native'; import { Animated, Dimensions, Easing, Modal, PanResponder, Platform, ScrollView, View } from 'react-native'; - import { notWeb } from '../utils/environment'; import { FeedbackWidget } from './FeedbackWidget'; import { modalSheetContainer, modalWrapper, topSpacer } from './FeedbackWidget.styles'; diff --git a/packages/core/src/js/feedback/integration.ts b/packages/core/src/js/feedback/integration.ts index ad2bd0675b..dffc442e43 100644 --- a/packages/core/src/js/feedback/integration.ts +++ b/packages/core/src/js/feedback/integration.ts @@ -1,5 +1,4 @@ import { type Integration, getClient } from '@sentry/core'; - import type { FeedbackWidgetProps } from './FeedbackWidget.types'; export const MOBILE_FEEDBACK_INTEGRATION_NAME = 'MobileFeedback'; diff --git a/packages/core/src/js/feedback/lazy.ts b/packages/core/src/js/feedback/lazy.ts index ba02365c2f..25e8f8a768 100644 --- a/packages/core/src/js/feedback/lazy.ts +++ b/packages/core/src/js/feedback/lazy.ts @@ -1,5 +1,4 @@ import { getClient } from '@sentry/core'; - import { feedbackIntegration, MOBILE_FEEDBACK_INTEGRATION_NAME } from './integration'; /** diff --git a/packages/core/src/js/feedback/utils.ts b/packages/core/src/js/feedback/utils.ts index 4308924ab5..be839957ae 100644 --- a/packages/core/src/js/feedback/utils.ts +++ b/packages/core/src/js/feedback/utils.ts @@ -1,5 +1,4 @@ import { Alert } from 'react-native'; - import { isFabricEnabled, isWeb } from '../utils/environment'; import { RN_GLOBAL_OBJ } from '../utils/worldwide'; import { ReactNativeLibraries } from './../utils/rnlibraries'; diff --git a/packages/core/src/js/integrations/appRegistry.ts b/packages/core/src/js/integrations/appRegistry.ts index 2467d73876..25634e0b25 100644 --- a/packages/core/src/js/integrations/appRegistry.ts +++ b/packages/core/src/js/integrations/appRegistry.ts @@ -1,6 +1,5 @@ import type { Client, Integration } from '@sentry/core'; import { getClient, logger } from '@sentry/core'; - import { isWeb } from '../utils/environment'; import { fillTyped } from '../utils/fill'; import { ReactNativeLibraries } from '../utils/rnlibraries'; diff --git a/packages/core/src/js/integrations/debugsymbolicator.ts b/packages/core/src/js/integrations/debugsymbolicator.ts index ed1c2901d3..f17ec90d55 100644 --- a/packages/core/src/js/integrations/debugsymbolicator.ts +++ b/packages/core/src/js/integrations/debugsymbolicator.ts @@ -1,6 +1,5 @@ import type { Event, EventHint, Exception, Integration, StackFrame as SentryStackFrame } from '@sentry/core'; import { logger } from '@sentry/core'; - import type { ExtendedError } from '../utils/error'; import { getFramesToPop, isErrorLike } from '../utils/error'; import type * as ReactNative from '../vendor/react-native'; diff --git a/packages/core/src/js/integrations/debugsymbolicatorutils.ts b/packages/core/src/js/integrations/debugsymbolicatorutils.ts index d99f72b261..8f20790c09 100644 --- a/packages/core/src/js/integrations/debugsymbolicatorutils.ts +++ b/packages/core/src/js/integrations/debugsymbolicatorutils.ts @@ -1,6 +1,5 @@ import type { StackFrame as SentryStackFrame } from '@sentry/core'; import { logger } from '@sentry/core'; - import { ReactNativeLibraries } from '../utils/rnlibraries'; import { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr'; import type * as ReactNative from '../vendor/react-native'; diff --git a/packages/core/src/js/integrations/default.ts b/packages/core/src/js/integrations/default.ts index a710d44807..fd4b7a9627 100644 --- a/packages/core/src/js/integrations/default.ts +++ b/packages/core/src/js/integrations/default.ts @@ -1,7 +1,6 @@ /* eslint-disable complexity */ import { browserSessionIntegration } from '@sentry/browser'; import type { Integration } from '@sentry/core'; - import type { ReactNativeClientOptions } from '../options'; import { reactNativeTracingIntegration } from '../tracing'; import { notWeb } from '../utils/environment'; diff --git a/packages/core/src/js/integrations/devicecontext.ts b/packages/core/src/js/integrations/devicecontext.ts index 27875972a8..9caac21401 100644 --- a/packages/core/src/js/integrations/devicecontext.ts +++ b/packages/core/src/js/integrations/devicecontext.ts @@ -2,7 +2,6 @@ import type { Client, Event, EventHint, Integration } from '@sentry/core'; import { logger, severityLevelFromString } from '@sentry/core'; import { AppState } from 'react-native'; - import { breadcrumbFromObject } from '../breadcrumb'; import type { NativeDeviceContextsResponse } from '../NativeRNSentry'; import { NATIVE } from '../wrapper'; diff --git a/packages/core/src/js/integrations/expocontext.ts b/packages/core/src/js/integrations/expocontext.ts index b805daf118..4cbad7ce8d 100644 --- a/packages/core/src/js/integrations/expocontext.ts +++ b/packages/core/src/js/integrations/expocontext.ts @@ -1,5 +1,4 @@ import { type DeviceContext, type Event, type Integration, type OsContext, logger } from '@sentry/core'; - import type { ReactNativeClient } from '../client'; import { isExpo, isExpoGo } from '../utils/environment'; import { getExpoDevice, getExpoUpdates } from '../utils/expomodules'; diff --git a/packages/core/src/js/integrations/modulesloader.ts b/packages/core/src/js/integrations/modulesloader.ts index 7a31154d33..982c8a1519 100644 --- a/packages/core/src/js/integrations/modulesloader.ts +++ b/packages/core/src/js/integrations/modulesloader.ts @@ -1,6 +1,5 @@ import type { Event, Integration } from '@sentry/core'; import { logger } from '@sentry/core'; - import { NATIVE } from '../wrapper'; const INTEGRATION_NAME = 'ModulesLoader'; diff --git a/packages/core/src/js/integrations/nativelinkederrors.ts b/packages/core/src/js/integrations/nativelinkederrors.ts index d920cc8a55..727ef85638 100644 --- a/packages/core/src/js/integrations/nativelinkederrors.ts +++ b/packages/core/src/js/integrations/nativelinkederrors.ts @@ -11,7 +11,6 @@ import type { StackParser, } from '@sentry/core'; import { isInstanceOf, isPlainObject, isString } from '@sentry/core'; - import type { NativeStackFrames } from '../NativeRNSentry'; import { NATIVE } from '../wrapper'; diff --git a/packages/core/src/js/integrations/reactnativeerrorhandlers.ts b/packages/core/src/js/integrations/reactnativeerrorhandlers.ts index 69775adf3f..b88ba490b1 100644 --- a/packages/core/src/js/integrations/reactnativeerrorhandlers.ts +++ b/packages/core/src/js/integrations/reactnativeerrorhandlers.ts @@ -1,6 +1,5 @@ import type { EventHint, Integration, SeverityLevel } from '@sentry/core'; import { addExceptionMechanism, captureException, getClient, getCurrentScope, logger } from '@sentry/core'; - import type { ReactNativeClientOptions } from '../options'; import { createSyntheticError, isErrorLike } from '../utils/error'; import { RN_GLOBAL_OBJ } from '../utils/worldwide'; diff --git a/packages/core/src/js/integrations/reactnativeerrorhandlersutils.ts b/packages/core/src/js/integrations/reactnativeerrorhandlersutils.ts index 7453f696d6..c7fc9690ab 100644 --- a/packages/core/src/js/integrations/reactnativeerrorhandlersutils.ts +++ b/packages/core/src/js/integrations/reactnativeerrorhandlersutils.ts @@ -1,5 +1,4 @@ import { logger } from '@sentry/core'; - import { ReactNativeLibraries } from '../utils/rnlibraries'; import { RN_GLOBAL_OBJ } from '../utils/worldwide'; diff --git a/packages/core/src/js/integrations/reactnativeinfo.ts b/packages/core/src/js/integrations/reactnativeinfo.ts index b24e20f917..a66ba9da2f 100644 --- a/packages/core/src/js/integrations/reactnativeinfo.ts +++ b/packages/core/src/js/integrations/reactnativeinfo.ts @@ -1,5 +1,4 @@ import type { Context, Event, EventHint, Integration } from '@sentry/core'; - import { getExpoGoVersion, getExpoSdkVersion, diff --git a/packages/core/src/js/integrations/release.ts b/packages/core/src/js/integrations/release.ts index f414f8a9ac..3682bb42b3 100644 --- a/packages/core/src/js/integrations/release.ts +++ b/packages/core/src/js/integrations/release.ts @@ -1,5 +1,4 @@ import type { BaseTransportOptions, Client, ClientOptions, Event, EventHint, Integration } from '@sentry/core'; - import { NATIVE } from '../wrapper'; const INTEGRATION_NAME = 'Release'; diff --git a/packages/core/src/js/integrations/rewriteframes.ts b/packages/core/src/js/integrations/rewriteframes.ts index 09ee8b6398..81c28a3bf9 100644 --- a/packages/core/src/js/integrations/rewriteframes.ts +++ b/packages/core/src/js/integrations/rewriteframes.ts @@ -1,7 +1,6 @@ import type { Integration, StackFrame } from '@sentry/core'; import { rewriteFramesIntegration } from '@sentry/core'; import { Platform } from 'react-native'; - import { isExpo, isHermesEnabled } from '../utils/environment'; export const ANDROID_DEFAULT_BUNDLE_NAME = 'app:///index.android.bundle'; diff --git a/packages/core/src/js/integrations/screenshot.ts b/packages/core/src/js/integrations/screenshot.ts index 11491689ee..3c45ada451 100644 --- a/packages/core/src/js/integrations/screenshot.ts +++ b/packages/core/src/js/integrations/screenshot.ts @@ -1,5 +1,4 @@ import type { Event, EventHint, Integration } from '@sentry/core'; - import type { ReactNativeClient } from '../client'; import type { Screenshot as ScreenshotAttachment } from '../wrapper'; import { NATIVE } from '../wrapper'; diff --git a/packages/core/src/js/integrations/sdkinfo.ts b/packages/core/src/js/integrations/sdkinfo.ts index b90614d5c3..9a5ba222f0 100644 --- a/packages/core/src/js/integrations/sdkinfo.ts +++ b/packages/core/src/js/integrations/sdkinfo.ts @@ -1,6 +1,5 @@ import type { Event, Integration, Package, SdkInfo as SdkInfoType } from '@sentry/core'; import { logger } from '@sentry/core'; - import { isExpoGo, notWeb } from '../utils/environment'; import { SDK_NAME, SDK_PACKAGE_NAME, SDK_VERSION } from '../version'; import { NATIVE } from '../wrapper'; diff --git a/packages/core/src/js/integrations/spotlight.ts b/packages/core/src/js/integrations/spotlight.ts index 90af07ccca..44497bdec9 100644 --- a/packages/core/src/js/integrations/spotlight.ts +++ b/packages/core/src/js/integrations/spotlight.ts @@ -1,6 +1,5 @@ import type { BaseTransportOptions, Client, ClientOptions, Envelope, Integration } from '@sentry/core'; import { logger, serializeEnvelope } from '@sentry/core'; - import { ReactNativeLibraries } from '../utils/rnlibraries'; import { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr'; diff --git a/packages/core/src/js/integrations/viewhierarchy.ts b/packages/core/src/js/integrations/viewhierarchy.ts index c2c56fa4fc..eadb618510 100644 --- a/packages/core/src/js/integrations/viewhierarchy.ts +++ b/packages/core/src/js/integrations/viewhierarchy.ts @@ -1,6 +1,5 @@ import type { Attachment, Event, EventHint, Integration } from '@sentry/core'; import { logger } from '@sentry/core'; - import { NATIVE } from '../wrapper'; const filename: string = 'view-hierarchy.json'; diff --git a/packages/core/src/js/options.ts b/packages/core/src/js/options.ts index 6ecc232ff0..7efc9c87ff 100644 --- a/packages/core/src/js/options.ts +++ b/packages/core/src/js/options.ts @@ -3,7 +3,6 @@ import type { CaptureContext, ClientOptions, Event, EventHint, Options } from '@ import type { Profiler } from '@sentry/react'; import type * as React from 'react'; import { Platform } from 'react-native'; - import type { TouchEventBoundaryProps } from './touchevents'; import { getExpoConstants } from './utils/expomodules'; diff --git a/packages/core/src/js/profiling/convertHermesProfile.ts b/packages/core/src/js/profiling/convertHermesProfile.ts index 241c6fd249..c84cee963e 100644 --- a/packages/core/src/js/profiling/convertHermesProfile.ts +++ b/packages/core/src/js/profiling/convertHermesProfile.ts @@ -1,6 +1,5 @@ import type { FrameId, StackId, ThreadCpuFrame, ThreadCpuSample, ThreadCpuStack, ThreadId } from '@sentry/core'; import { logger } from '@sentry/core'; - import { MAX_PROFILE_DURATION_MS } from './constants'; import type * as Hermes from './hermes'; import { DEFAULT_BUNDLE_NAME } from './hermes'; diff --git a/packages/core/src/js/profiling/debugid.ts b/packages/core/src/js/profiling/debugid.ts index ae05814b15..a03b4db684 100644 --- a/packages/core/src/js/profiling/debugid.ts +++ b/packages/core/src/js/profiling/debugid.ts @@ -1,6 +1,5 @@ import type { DebugImage } from '@sentry/core'; import { GLOBAL_OBJ, logger } from '@sentry/core'; - import { DEFAULT_BUNDLE_NAME } from './hermes'; /** diff --git a/packages/core/src/js/profiling/hermes.ts b/packages/core/src/js/profiling/hermes.ts index d2ed0fec90..5e7dc9d6c6 100644 --- a/packages/core/src/js/profiling/hermes.ts +++ b/packages/core/src/js/profiling/hermes.ts @@ -1,5 +1,4 @@ import { Platform } from 'react-native'; - import { ANDROID_DEFAULT_BUNDLE_NAME, IOS_DEFAULT_BUNDLE_NAME } from '../integrations/rewriteframes'; export type StackFrameId = number; diff --git a/packages/core/src/js/profiling/integration.ts b/packages/core/src/js/profiling/integration.ts index 8a3eb819a7..7564fd9de4 100644 --- a/packages/core/src/js/profiling/integration.ts +++ b/packages/core/src/js/profiling/integration.ts @@ -2,7 +2,6 @@ import type { Envelope, Event, Integration, Span, ThreadCpuProfile } from '@sentry/core'; import { getActiveSpan, getClient, logger, spanIsSampled, uuid4 } from '@sentry/core'; import { Platform } from 'react-native'; - import type { ReactNativeClient } from '../client'; import { isHermesEnabled } from '../utils/environment'; import { isRootSpan } from '../utils/span'; diff --git a/packages/core/src/js/profiling/types.ts b/packages/core/src/js/profiling/types.ts index 871c975403..e483d4ccfc 100644 --- a/packages/core/src/js/profiling/types.ts +++ b/packages/core/src/js/profiling/types.ts @@ -1,5 +1,4 @@ import type { DebugImage, MeasurementUnit, Profile, ThreadCpuFrame, ThreadCpuProfile } from '@sentry/core'; - import type { NativeProfileEvent } from './nativeTypes'; export interface RawThreadCpuProfile extends ThreadCpuProfile { diff --git a/packages/core/src/js/profiling/utils.ts b/packages/core/src/js/profiling/utils.ts index 5c6d996e83..ebdc57e816 100644 --- a/packages/core/src/js/profiling/utils.ts +++ b/packages/core/src/js/profiling/utils.ts @@ -1,7 +1,6 @@ /* eslint-disable complexity */ import type { Envelope, Event, ThreadCpuProfile } from '@sentry/core'; import { forEachEnvelopeItem, logger } from '@sentry/core'; - import { getDefaultEnvironment } from '../utils/environment'; import { getDebugMetadata } from './debugid'; import type { diff --git a/packages/core/src/js/replay/CustomMask.tsx b/packages/core/src/js/replay/CustomMask.tsx index 7d84ec1b8c..d3fae8382d 100644 --- a/packages/core/src/js/replay/CustomMask.tsx +++ b/packages/core/src/js/replay/CustomMask.tsx @@ -2,7 +2,6 @@ import { logger } from '@sentry/core'; import * as React from 'react'; import type { HostComponent, ViewProps } from 'react-native'; import { UIManager, View } from 'react-native'; - import { isExpoGo } from '../utils/environment'; const NativeComponentRegistry: { diff --git a/packages/core/src/js/replay/mobilereplay.ts b/packages/core/src/js/replay/mobilereplay.ts index 3b63e40957..dcb1eaf245 100644 --- a/packages/core/src/js/replay/mobilereplay.ts +++ b/packages/core/src/js/replay/mobilereplay.ts @@ -1,6 +1,5 @@ import type { Client, DynamicSamplingContext, Event, Integration } from '@sentry/core'; import { logger } from '@sentry/core'; - import { isHardCrash } from '../misc'; import { hasHooks } from '../utils/clientutils'; import { isExpoGo, notMobileOs } from '../utils/environment'; diff --git a/packages/core/src/js/replay/xhrUtils.ts b/packages/core/src/js/replay/xhrUtils.ts index 8118296ee5..deb0f3c88c 100644 --- a/packages/core/src/js/replay/xhrUtils.ts +++ b/packages/core/src/js/replay/xhrUtils.ts @@ -1,6 +1,5 @@ import type { Breadcrumb, BreadcrumbHint, SentryWrappedXMLHttpRequest, XhrBreadcrumbHint } from '@sentry/core'; import { dropUndefinedKeys } from '@sentry/core'; - import type { RequestBody } from './networkUtils'; import { getBodySize, parseContentLengthHeader } from './networkUtils'; diff --git a/packages/core/src/js/scopeSync.ts b/packages/core/src/js/scopeSync.ts index bc69ffe86d..78ff027c20 100644 --- a/packages/core/src/js/scopeSync.ts +++ b/packages/core/src/js/scopeSync.ts @@ -1,6 +1,5 @@ import type { Breadcrumb, Scope } from '@sentry/core'; import { logger } from '@sentry/react'; - import { DEFAULT_BREADCRUMB_LEVEL } from './breadcrumb'; import { fillTyped } from './utils/fill'; import { convertToNormalizedObject } from './utils/normalize'; diff --git a/packages/core/src/js/sdk.tsx b/packages/core/src/js/sdk.tsx index fefa97d0c1..657ec2db59 100644 --- a/packages/core/src/js/sdk.tsx +++ b/packages/core/src/js/sdk.tsx @@ -6,7 +6,6 @@ import { makeFetchTransport, } from '@sentry/react'; import * as React from 'react'; - import { ReactNativeClient } from './client'; import { FeedbackWidgetProvider } from './feedback/FeedbackWidgetManager'; import { getDevServer } from './integrations/debugsymbolicatorutils'; diff --git a/packages/core/src/js/tools/collectModules.ts b/packages/core/src/js/tools/collectModules.ts index ed386b2f50..15cca70dfb 100755 --- a/packages/core/src/js/tools/collectModules.ts +++ b/packages/core/src/js/tools/collectModules.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ import { argv } from 'process'; - import ModulesCollector from './ModulesCollector'; const sourceMapPath: string | undefined = argv[2]; diff --git a/packages/core/src/js/tools/metroconfig.ts b/packages/core/src/js/tools/metroconfig.ts index f94a0828ba..6afb2ddc06 100644 --- a/packages/core/src/js/tools/metroconfig.ts +++ b/packages/core/src/js/tools/metroconfig.ts @@ -3,16 +3,16 @@ import type { MetroConfig, MixedOutput, Module, ReadOnlyGraph } from 'metro'; import type { CustomResolutionContext, CustomResolver, Resolution } from 'metro-resolver'; import * as process from 'process'; import { env } from 'process'; - import { enableLogger } from './enableLogger'; +import { withSentryMiddleware } from './metroMiddleware'; import { setSentryBabelTransformerOptions, setSentryDefaultBabelTransformerPathEnv, } from './sentryBabelTransformerUtils'; import { createSentryMetroSerializer, unstable_beforeAssetSerializationPlugin } from './sentryMetroSerializer'; import type { DefaultConfigOptions } from './vendor/expo/expoconfig'; + export * from './sentryMetroSerializer'; -import { withSentryMiddleware } from './metroMiddleware'; enableLogger(); diff --git a/packages/core/src/js/tools/sentryBabelTransformerUtils.ts b/packages/core/src/js/tools/sentryBabelTransformerUtils.ts index 6484291cb9..892e907291 100644 --- a/packages/core/src/js/tools/sentryBabelTransformerUtils.ts +++ b/packages/core/src/js/tools/sentryBabelTransformerUtils.ts @@ -1,7 +1,6 @@ import componentAnnotatePlugin from '@sentry/babel-plugin-component-annotate'; import { logger } from '@sentry/core'; import * as process from 'process'; - import type { BabelTransformer, BabelTransformerArgs } from './vendor/metro/metroBabelTransformer'; export type SentryBabelTransformerOptions = { annotateReactComponents?: { ignoredComponents?: string[] } }; @@ -46,7 +45,7 @@ export function loadDefaultBabelTransformer(): BabelTransformer { export function setSentryBabelTransformerOptions(options: SentryBabelTransformerOptions): void { let optionsString: string | null = null; try { - logger.debug(`Stringifying Sentry Babel transformer options`, options); + logger.debug('Stringifying Sentry Babel transformer options', options); optionsString = JSON.stringify(options); } catch (e) { // eslint-disable-next-line no-console diff --git a/packages/core/src/js/tools/sentryMetroSerializer.ts b/packages/core/src/js/tools/sentryMetroSerializer.ts index fca0979440..bd47d8071b 100644 --- a/packages/core/src/js/tools/sentryMetroSerializer.ts +++ b/packages/core/src/js/tools/sentryMetroSerializer.ts @@ -3,7 +3,6 @@ import * as crypto from 'crypto'; import type { MixedOutput, Module, ReadOnlyGraph } from 'metro'; // eslint-disable-next-line import/no-extraneous-dependencies import * as countLines from 'metro/src/lib/countLines'; - import type { Bundle, MetroSerializer, MetroSerializerOutput, SerializedBundle, VirtualJSOutput } from './utils'; import { createDebugIdSnippet, createSet, determineDebugIdFromBundleSource, stringToUUID } from './utils'; import { createDefaultMetroSerializer } from './vendor/metro/utils'; diff --git a/packages/core/src/js/tools/vendor/metro/utils.ts b/packages/core/src/js/tools/vendor/metro/utils.ts index 4ce9866b17..bcdf75ab1e 100644 --- a/packages/core/src/js/tools/vendor/metro/utils.ts +++ b/packages/core/src/js/tools/vendor/metro/utils.ts @@ -32,7 +32,6 @@ import * as baseJSBundle from 'metro/src/DeltaBundler/Serializers/baseJSBundle'; import * as sourceMapString from 'metro/src/DeltaBundler/Serializers/sourceMapString'; // eslint-disable-next-line import/no-extraneous-dependencies import * as bundleToString from 'metro/src/lib/bundleToString'; - import type { MetroSerializer } from '../../utils'; type NewSourceMapStringExport = { diff --git a/packages/core/src/js/touchevents.tsx b/packages/core/src/js/touchevents.tsx index 2280597264..a9fd41852f 100644 --- a/packages/core/src/js/touchevents.tsx +++ b/packages/core/src/js/touchevents.tsx @@ -3,7 +3,6 @@ import { addBreadcrumb, dropUndefinedKeys, getClient, logger, SEMANTIC_ATTRIBUTE import * as React from 'react'; import type { GestureResponderEvent } from 'react-native'; import { StyleSheet, View } from 'react-native'; - import { createIntegration } from './integrations/factory'; import { startUserInteractionSpan } from './tracing/integrations/userInteraction'; import { UI_ACTION_TOUCH } from './tracing/ops'; diff --git a/packages/core/src/js/tracing/gesturetracing.ts b/packages/core/src/js/tracing/gesturetracing.ts index 4dd012fe7b..8cf0a329f8 100644 --- a/packages/core/src/js/tracing/gesturetracing.ts +++ b/packages/core/src/js/tracing/gesturetracing.ts @@ -1,6 +1,5 @@ import type { Breadcrumb } from '@sentry/core'; import { addBreadcrumb, logger, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core'; - import { startUserInteractionSpan } from './integrations/userInteraction'; import { UI_ACTION } from './ops'; import { SPAN_ORIGIN_AUTO_INTERACTION } from './origin'; diff --git a/packages/core/src/js/tracing/integrations/appStart.ts b/packages/core/src/js/tracing/integrations/appStart.ts index aa2ce1c70e..f3c5149ffa 100644 --- a/packages/core/src/js/tracing/integrations/appStart.ts +++ b/packages/core/src/js/tracing/integrations/appStart.ts @@ -10,7 +10,6 @@ import { startInactiveSpan, timestampInSeconds, } from '@sentry/core'; - import { getAppRegistryIntegration } from '../../integrations/appRegistry'; import { APP_START_COLD as APP_START_COLD_MEASUREMENT, @@ -394,7 +393,7 @@ export const appStartIntegration = ({ event.measurements = event.measurements || {}; event.measurements[measurementKey] = measurementValue; logger.debug( - `[AppStart] Added app start measurement to transaction event.`, + '[AppStart] Added app start measurement to transaction event.', JSON.stringify(measurementValue, undefined, 2), ); } diff --git a/packages/core/src/js/tracing/integrations/nativeFrames.ts b/packages/core/src/js/tracing/integrations/nativeFrames.ts index e5dd20f98a..07093e4ba2 100644 --- a/packages/core/src/js/tracing/integrations/nativeFrames.ts +++ b/packages/core/src/js/tracing/integrations/nativeFrames.ts @@ -1,6 +1,5 @@ import type { Client, Event, Integration, Measurements, MeasurementUnit, Span } from '@sentry/core'; import { logger, timestampInSeconds } from '@sentry/core'; - import type { NativeFramesResponse } from '../../NativeRNSentry'; import { AsyncExpiringMap } from '../../utils/AsyncExpiringMap'; import { isRootSpan } from '../../utils/span'; diff --git a/packages/core/src/js/tracing/integrations/stalltracking.ts b/packages/core/src/js/tracing/integrations/stalltracking.ts index e2b05c8d9d..f0d6c96eaf 100644 --- a/packages/core/src/js/tracing/integrations/stalltracking.ts +++ b/packages/core/src/js/tracing/integrations/stalltracking.ts @@ -3,7 +3,6 @@ import type { Client, Integration, Measurements, MeasurementUnit, Span } from '@ import { getRootSpan, logger, spanToJSON, timestampInSeconds } from '@sentry/core'; import type { AppStateStatus } from 'react-native'; import { AppState } from 'react-native'; - import { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../../measurements'; import { isRootSpan } from '../../utils/span'; import { getLatestChildSpanEndTimestamp, isNearToNow, setSpanMeasurement } from '../utils'; diff --git a/packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts b/packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts index 8b5d0ffc66..d1349708ec 100644 --- a/packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts +++ b/packages/core/src/js/tracing/integrations/timeToDisplayIntegration.ts @@ -1,6 +1,5 @@ import type { Event, Integration, SpanJSON } from '@sentry/core'; import { logger } from '@sentry/core'; - import { NATIVE } from '../../wrapper'; import { UI_LOAD_FULL_DISPLAY, UI_LOAD_INITIAL_DISPLAY } from '../ops'; import { SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from '../origin'; diff --git a/packages/core/src/js/tracing/integrations/userInteraction.ts b/packages/core/src/js/tracing/integrations/userInteraction.ts index 378181016c..a42f71d62e 100644 --- a/packages/core/src/js/tracing/integrations/userInteraction.ts +++ b/packages/core/src/js/tracing/integrations/userInteraction.ts @@ -7,7 +7,6 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanToJSON, } from '@sentry/core'; - import type { ReactNativeClientOptions } from '../../options'; import { onlySampleIfChildSpans } from '../onSpanEndUtils'; import { SPAN_ORIGIN_MANUAL_INTERACTION } from '../origin'; diff --git a/packages/core/src/js/tracing/onSpanEndUtils.ts b/packages/core/src/js/tracing/onSpanEndUtils.ts index cffa13a852..d63913e69f 100644 --- a/packages/core/src/js/tracing/onSpanEndUtils.ts +++ b/packages/core/src/js/tracing/onSpanEndUtils.ts @@ -2,7 +2,6 @@ import type { Client, Span } from '@sentry/core'; import { getSpanDescendants, logger, SPAN_STATUS_ERROR, spanToJSON } from '@sentry/core'; import type { AppStateStatus } from 'react-native'; import { AppState } from 'react-native'; - import { isRootSpan, isSentrySpan } from '../utils/span'; /** diff --git a/packages/core/src/js/tracing/reactnativenavigation.ts b/packages/core/src/js/tracing/reactnativenavigation.ts index 2ce7ef7f5d..33a3275fb0 100644 --- a/packages/core/src/js/tracing/reactnativenavigation.ts +++ b/packages/core/src/js/tracing/reactnativenavigation.ts @@ -7,7 +7,6 @@ import { SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, spanToJSON, } from '@sentry/core'; - import type { EmitterSubscription } from '../utils/rnlibrariesinterface'; import { isSentrySpan } from '../utils/span'; import { ignoreEmptyBackNavigation } from './onSpanEndUtils'; diff --git a/packages/core/src/js/tracing/reactnativeprofiler.tsx b/packages/core/src/js/tracing/reactnativeprofiler.tsx index 72e2483074..0798c92c94 100644 --- a/packages/core/src/js/tracing/reactnativeprofiler.tsx +++ b/packages/core/src/js/tracing/reactnativeprofiler.tsx @@ -1,6 +1,5 @@ import { logger, timestampInSeconds } from '@sentry/core'; import { getClient, Profiler } from '@sentry/react'; - import { getAppRegistryIntegration } from '../integrations/appRegistry'; import { createIntegration } from '../integrations/factory'; import { _captureAppStart, _setRootComponentCreationTimestampMs } from '../tracing/integrations/appStart'; diff --git a/packages/core/src/js/tracing/reactnativetracing.ts b/packages/core/src/js/tracing/reactnativetracing.ts index 8874f6769f..74e56c51b2 100644 --- a/packages/core/src/js/tracing/reactnativetracing.ts +++ b/packages/core/src/js/tracing/reactnativetracing.ts @@ -2,7 +2,6 @@ import { instrumentOutgoingRequests } from '@sentry/browser'; import type { Client, Event, Integration, StartSpanOptions } from '@sentry/core'; import { getClient } from '@sentry/core'; - import { isWeb } from '../utils/environment'; import { getDevServer } from './../integrations/debugsymbolicatorutils'; import { addDefaultOpForSpanFrom, addThreadInfoToSpan, defaultIdleOptions } from './span'; diff --git a/packages/core/src/js/tracing/reactnavigation.ts b/packages/core/src/js/tracing/reactnavigation.ts index feebb3b9f7..360a5ae807 100644 --- a/packages/core/src/js/tracing/reactnavigation.ts +++ b/packages/core/src/js/tracing/reactnavigation.ts @@ -12,7 +12,6 @@ import { startInactiveSpan, timestampInSeconds, } from '@sentry/core'; - import { getAppRegistryIntegration } from '../integrations/appRegistry'; import { isSentrySpan } from '../utils/span'; import { RN_GLOBAL_OBJ } from '../utils/worldwide'; @@ -30,6 +29,7 @@ import { startIdleNavigationSpan as startGenericIdleNavigationSpan, } from './span'; import { addTimeToInitialDisplayFallback } from './timeToDisplayFallback'; + export const INTEGRATION_NAME = 'ReactNavigation'; const NAVIGATION_HISTORY_MAX_SIZE = 200; diff --git a/packages/core/src/js/tracing/span.ts b/packages/core/src/js/tracing/span.ts index 4e3a70ff66..7a94f65d96 100644 --- a/packages/core/src/js/tracing/span.ts +++ b/packages/core/src/js/tracing/span.ts @@ -12,7 +12,6 @@ import { spanToJSON, startIdleSpan as coreStartIdleSpan, } from '@sentry/core'; - import { isRootSpan } from '../utils/span'; import { adjustTransactionDuration, cancelInBackground } from './onSpanEndUtils'; import { @@ -53,7 +52,7 @@ export const startIdleNavigationSpan = ( ): Span | undefined => { const client = getClient(); if (!client) { - logger.warn(`[startIdleNavigationSpan] Can't create route change span, missing client.`); + logger.warn("[startIdleNavigationSpan] Can't create route change span, missing client."); return undefined; } @@ -100,7 +99,7 @@ export const startIdleSpan = ( ): Span => { const client = getClient(); if (!client) { - logger.warn(`[startIdleSpan] Can't create idle span, missing client.`); + logger.warn("[startIdleSpan] Can't create idle span, missing client."); return new SentryNonRecordingSpan(); } diff --git a/packages/core/src/js/tracing/timetodisplay.tsx b/packages/core/src/js/tracing/timetodisplay.tsx index f33216b875..3ffa223c46 100644 --- a/packages/core/src/js/tracing/timetodisplay.tsx +++ b/packages/core/src/js/tracing/timetodisplay.tsx @@ -2,7 +2,6 @@ import type { Span,StartSpanOptions } from '@sentry/core'; import { fill, getActiveSpan, getSpanDescendants, logger, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_STATUS_ERROR, SPAN_STATUS_OK, spanToJSON, startInactiveSpan } from '@sentry/core'; import * as React from 'react'; import { useState } from 'react'; - import { isTurboModuleEnabled } from '../utils/environment'; import { SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from './origin'; import { getRNSentryOnDrawReporter, nativeComponentExists } from './timetodisplaynative'; @@ -99,13 +98,13 @@ export function startTimeToInitialDisplaySpan( ): Span | undefined { const activeSpan = getActiveSpan(); if (!activeSpan) { - logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`); + logger.warn('[TimeToDisplay] No active span found to attach ui.load.initial_display to.'); return undefined; } const existingSpan = getSpanDescendants(activeSpan).find((span) => spanToJSON(span).op === 'ui.load.initial_display'); if (existingSpan) { - logger.debug(`[TimeToDisplay] Found existing ui.load.initial_display span.`); + logger.debug('[TimeToDisplay] Found existing ui.load.initial_display span.'); return existingSpan } @@ -148,7 +147,7 @@ export function startTimeToFullDisplaySpan( ): Span | undefined { const activeSpan = getActiveSpan(); if (!activeSpan) { - logger.warn(`[TimeToDisplay] No active span found to attach ui.load.full_display to.`); + logger.warn('[TimeToDisplay] No active span found to attach ui.load.full_display to.'); return undefined; } @@ -156,13 +155,13 @@ export function startTimeToFullDisplaySpan( const initialDisplaySpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.initial_display'); if (!initialDisplaySpan) { - logger.warn(`[TimeToDisplay] No initial display span found to attach ui.load.full_display to.`); + logger.warn('[TimeToDisplay] No initial display span found to attach ui.load.full_display to.'); return undefined; } const existingSpan = descendantSpans.find((span) => spanToJSON(span).op === 'ui.load.full_display'); if (existingSpan) { - logger.debug(`[TimeToDisplay] Found existing ui.load.full_display span.`); + logger.debug('[TimeToDisplay] Found existing ui.load.full_display span.'); return existingSpan; } @@ -183,7 +182,7 @@ export function startTimeToFullDisplaySpan( fullDisplaySpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'deadline_exceeded' }); fullDisplaySpan.end(spanToJSON(initialDisplaySpan).timestamp); setSpanDurationAsMeasurement('time_to_full_display', fullDisplaySpan); - logger.warn(`[TimeToDisplay] Full display span deadline_exceeded.`); + logger.warn('[TimeToDisplay] Full display span deadline_exceeded.'); }, options.timeoutMs); fill(fullDisplaySpan, 'end', (originalEnd: Span['end']) => (endTimestamp?: Parameters[0]) => { @@ -216,17 +215,17 @@ export function updateInitialDisplaySpan( span?: Span; } = {}): void { if (!span) { - logger.warn(`[TimeToDisplay] No span found or created, possibly performance is disabled.`); + logger.warn('[TimeToDisplay] No span found or created, possibly performance is disabled.'); return; } if (!activeSpan) { - logger.warn(`[TimeToDisplay] No active span found to attach ui.load.initial_display to.`); + logger.warn('[TimeToDisplay] No active span found to attach ui.load.initial_display to.'); return; } if (spanToJSON(span).parent_span_id !== spanToJSON(activeSpan).span_id) { - logger.warn(`[TimeToDisplay] Initial display span is not a child of current active span.`); + logger.warn('[TimeToDisplay] Initial display span is not a child of current active span.'); return; } @@ -251,7 +250,7 @@ export function updateInitialDisplaySpan( function updateFullDisplaySpan(frameTimestampSeconds: number, passedInitialDisplaySpan?: Span): void { const activeSpan = getActiveSpan(); if (!activeSpan) { - logger.warn(`[TimeToDisplay] No active span found to update ui.load.full_display in.`); + logger.warn('[TimeToDisplay] No active span found to update ui.load.full_display in.'); return; } @@ -268,7 +267,7 @@ function updateFullDisplaySpan(frameTimestampSeconds: number, passedInitialDispl isAutoInstrumented: true, }); if (!span) { - logger.warn(`[TimeToDisplay] No TimeToFullDisplay span found or created, possibly performance is disabled.`); + logger.warn('[TimeToDisplay] No TimeToFullDisplay span found or created, possibly performance is disabled.'); return; } @@ -279,7 +278,7 @@ function updateFullDisplaySpan(frameTimestampSeconds: number, passedInitialDispl } if (initialDisplayEndTimestamp > frameTimestampSeconds) { - logger.warn(`[TimeToDisplay] Using initial display end. Full display end frame timestamp is before initial display end.`); + logger.warn('[TimeToDisplay] Using initial display end. Full display end frame timestamp is before initial display end.'); span.end(initialDisplayEndTimestamp); } else { span.end(frameTimestampSeconds); @@ -339,6 +338,6 @@ function createTimeToDisplay({ return ; }; - TimeToDisplayWrapper.displayName = `TimeToDisplayWrapper`; + TimeToDisplayWrapper.displayName = 'TimeToDisplayWrapper'; return TimeToDisplayWrapper; } diff --git a/packages/core/src/js/tracing/timetodisplaynative.tsx b/packages/core/src/js/tracing/timetodisplaynative.tsx index d549fe8b87..217a922db8 100644 --- a/packages/core/src/js/tracing/timetodisplaynative.tsx +++ b/packages/core/src/js/tracing/timetodisplaynative.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import type { HostComponent } from 'react-native'; import { UIManager, View } from 'react-native'; - import { isExpoGo } from '../utils/environment'; import { ReactNativeLibraries } from '../utils/rnlibraries'; import type { RNSentryOnDrawReporterProps } from './timetodisplaynative.types'; diff --git a/packages/core/src/js/tracing/utils.ts b/packages/core/src/js/tracing/utils.ts index 27b49306ac..18dc9d37f4 100644 --- a/packages/core/src/js/tracing/utils.ts +++ b/packages/core/src/js/tracing/utils.ts @@ -12,7 +12,6 @@ import { timestampInSeconds, uuid4, } from '@sentry/core'; - import { RN_GLOBAL_OBJ } from '../utils/worldwide'; export const defaultTransactionSource: TransactionSource = 'component'; diff --git a/packages/core/src/js/transports/encodePolyfill.ts b/packages/core/src/js/transports/encodePolyfill.ts index e9244d562a..3075ad6b92 100644 --- a/packages/core/src/js/transports/encodePolyfill.ts +++ b/packages/core/src/js/transports/encodePolyfill.ts @@ -1,5 +1,4 @@ import { getMainCarrier, SDK_VERSION } from '@sentry/core'; - import { utf8ToBytes } from '../vendor'; export const useEncodePolyfill = (): void => { diff --git a/packages/core/src/js/transports/native.ts b/packages/core/src/js/transports/native.ts index ea0ae88129..c8037ea986 100644 --- a/packages/core/src/js/transports/native.ts +++ b/packages/core/src/js/transports/native.ts @@ -6,7 +6,6 @@ import type { TransportMakeRequestResponse, } from '@sentry/core'; import { makePromiseBuffer } from '@sentry/core'; - import { NATIVE } from '../wrapper'; export const DEFAULT_BUFFER_SIZE = 30; diff --git a/packages/core/src/js/utils/environment.ts b/packages/core/src/js/utils/environment.ts index ad19462a18..fa508d5c21 100644 --- a/packages/core/src/js/utils/environment.ts +++ b/packages/core/src/js/utils/environment.ts @@ -1,5 +1,4 @@ import { Platform } from 'react-native'; - import { RN_GLOBAL_OBJ } from '../utils/worldwide'; import { getExpoConstants } from './expomodules'; import { ReactNativeLibraries } from './rnlibraries'; diff --git a/packages/core/src/js/utils/rnlibraries.ts b/packages/core/src/js/utils/rnlibraries.ts index b05167c2ef..45e2d3f630 100644 --- a/packages/core/src/js/utils/rnlibraries.ts +++ b/packages/core/src/js/utils/rnlibraries.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-var-requires */ import { AppRegistry, Platform, TurboModuleRegistry } from 'react-native'; - import type * as ReactNative from '../vendor/react-native'; import type { ReactNativeLibrariesInterface } from './rnlibrariesinterface'; diff --git a/packages/core/src/js/utils/safe.ts b/packages/core/src/js/utils/safe.ts index 911c0d3de1..3508e31ebb 100644 --- a/packages/core/src/js/utils/safe.ts +++ b/packages/core/src/js/utils/safe.ts @@ -1,5 +1,4 @@ import { logger } from '@sentry/core'; - import type { ReactNativeOptions } from '../options'; type DangerTypesWithoutCallSignature = diff --git a/packages/core/src/js/utils/sentryeventemitter.ts b/packages/core/src/js/utils/sentryeventemitter.ts index 55362df3cd..a066e457dd 100644 --- a/packages/core/src/js/utils/sentryeventemitter.ts +++ b/packages/core/src/js/utils/sentryeventemitter.ts @@ -1,7 +1,6 @@ import { logger } from '@sentry/core'; import type { EmitterSubscription, NativeModule } from 'react-native'; import { NativeEventEmitter } from 'react-native'; - import { getRNSentryModule } from '../wrapper'; export const NewFrameEventName = 'rn_sentry_new_frame'; diff --git a/packages/core/src/js/utils/sentryeventemitterfallback.ts b/packages/core/src/js/utils/sentryeventemitterfallback.ts index 74f1ab58e8..a10b62117b 100644 --- a/packages/core/src/js/utils/sentryeventemitterfallback.ts +++ b/packages/core/src/js/utils/sentryeventemitterfallback.ts @@ -1,5 +1,4 @@ import { logger, timestampInSeconds } from '@sentry/core'; - import { NATIVE } from '../wrapper'; import type { NewFrameEvent, SentryEventEmitter } from './sentryeventemitter'; import { createSentryEventEmitter, NewFrameEventName } from './sentryeventemitter'; diff --git a/packages/core/src/js/utils/worldwide.ts b/packages/core/src/js/utils/worldwide.ts index 03327bac36..85a625f603 100644 --- a/packages/core/src/js/utils/worldwide.ts +++ b/packages/core/src/js/utils/worldwide.ts @@ -1,7 +1,6 @@ import type { InternalGlobal } from '@sentry/core'; import { GLOBAL_OBJ } from '@sentry/core'; import type { ErrorUtils } from 'react-native/types'; - import type { ExpoGlobalObject } from './expoglobalobject'; /** Internal Global object interface with common and Sentry specific properties */ diff --git a/packages/core/src/js/wrapper.ts b/packages/core/src/js/wrapper.ts index 289af29923..f078bd01e7 100644 --- a/packages/core/src/js/wrapper.ts +++ b/packages/core/src/js/wrapper.ts @@ -11,7 +11,6 @@ import type { } from '@sentry/core'; import { logger, normalize, SentryError } from '@sentry/core'; import { NativeModules, Platform } from 'react-native'; - import { isHardCrash } from './misc'; import type { NativeAppStartResponse, diff --git a/packages/core/test/breadcrumb.test.ts b/packages/core/test/breadcrumb.test.ts index e0b7db4c60..9f1609727b 100644 --- a/packages/core/test/breadcrumb.test.ts +++ b/packages/core/test/breadcrumb.test.ts @@ -1,5 +1,4 @@ import type { Breadcrumb } from '@sentry/core'; - import { breadcrumbFromObject } from '../src/js/breadcrumb'; describe('Breadcrumb', () => { diff --git a/packages/core/test/client.test.ts b/packages/core/test/client.test.ts index 8e00c06bf9..14c35b533e 100644 --- a/packages/core/test/client.test.ts +++ b/packages/core/test/client.test.ts @@ -1,6 +1,3 @@ -import * as mockedtimetodisplaynative from './tracing/mockedtimetodisplaynative'; -jest.mock('../src/js/tracing/timetodisplaynative', () => mockedtimetodisplaynative); - import { defaultStackParser } from '@sentry/browser'; import type { Envelope, @@ -18,7 +15,6 @@ import { SentryError, } from '@sentry/core'; import * as RN from 'react-native'; - import { ReactNativeClient } from '../src/js/client'; import type { ReactNativeClientOptions } from '../src/js/options'; import { NativeTransport } from '../src/js/transports/native'; @@ -35,6 +31,9 @@ import { getMockUserFeedback, getSyncPromiseRejectOnFirstCall, } from './testutils'; +import * as mockedtimetodisplaynative from './tracing/mockedtimetodisplaynative'; + +jest.mock('../src/js/tracing/timetodisplaynative', () => mockedtimetodisplaynative); interface MockedReactNative { NativeModules: { diff --git a/packages/core/test/expo-plugin/withSentryAndroidGradlePlugin.test.ts b/packages/core/test/expo-plugin/withSentryAndroidGradlePlugin.test.ts index be48ecea14..861d809faa 100644 --- a/packages/core/test/expo-plugin/withSentryAndroidGradlePlugin.test.ts +++ b/packages/core/test/expo-plugin/withSentryAndroidGradlePlugin.test.ts @@ -1,5 +1,4 @@ import { withAppBuildGradle, withProjectBuildGradle } from '@expo/config-plugins'; - import { warnOnce } from '../../plugin/src/utils'; import type { SentryAndroidGradlePluginOptions } from '../../plugin/src/withSentryAndroidGradlePlugin'; import { withSentryAndroidGradlePlugin } from '../../plugin/src/withSentryAndroidGradlePlugin'; @@ -86,7 +85,7 @@ describe('withSentryAndroidGradlePlugin', () => { }); it('warnOnce if failed to modify build.gradle', () => { - const invalidBuildGradle = `android {}`; + const invalidBuildGradle = 'android {}'; const options: SentryAndroidGradlePluginOptions = { enableAndroidGradlePlugin: true }; (withProjectBuildGradle as jest.Mock).mockImplementation((config, callback) => { diff --git a/packages/core/test/feedback.test.ts b/packages/core/test/feedback.test.ts index f25bc4eec1..ca75063402 100644 --- a/packages/core/test/feedback.test.ts +++ b/packages/core/test/feedback.test.ts @@ -9,7 +9,6 @@ import { withIsolationScope, withScope, } from '@sentry/core'; - import { getDefaultTestClientOptions, TestClient } from './mocks/client'; describe('captureFeedback', () => { diff --git a/packages/core/test/feedback/FeedbackWidget.test.tsx b/packages/core/test/feedback/FeedbackWidget.test.tsx index 70903e1fc9..a03131838a 100644 --- a/packages/core/test/feedback/FeedbackWidget.test.tsx +++ b/packages/core/test/feedback/FeedbackWidget.test.tsx @@ -2,7 +2,6 @@ import { captureFeedback, getClient, setCurrentClient } from '@sentry/core'; import { fireEvent, render, waitFor } from '@testing-library/react-native'; import * as React from 'react'; import { Alert } from 'react-native'; - import { FeedbackWidget } from '../../src/js/feedback/FeedbackWidget'; import type { FeedbackWidgetProps, FeedbackWidgetStyles, ImagePicker } from '../../src/js/feedback/FeedbackWidget.types'; import { MOBILE_FEEDBACK_INTEGRATION_NAME } from '../../src/js/feedback/integration'; @@ -317,7 +316,7 @@ describe('FeedbackWidget', () => { it('calls launchImageLibraryAsync when the expo-image-picker library is integrated', async () => { const mockLaunchImageLibrary = jest.fn().mockResolvedValue({ - assets: [{ fileName: "mock-image.jpg", uri: "file:///mock/path/image.jpg" }], + assets: [{ fileName: 'mock-image.jpg', uri: 'file:///mock/path/image.jpg' }], }); const mockImagePicker: jest.Mocked = { launchImageLibraryAsync: mockLaunchImageLibrary, @@ -334,7 +333,7 @@ describe('FeedbackWidget', () => { it('calls launchImageLibrary when the react-native-image-picker library is integrated', async () => { const mockLaunchImageLibrary = jest.fn().mockResolvedValue({ - assets: [{ fileName: "mock-image.jpg", uri: "file:///mock/path/image.jpg" }], + assets: [{ fileName: 'mock-image.jpg', uri: 'file:///mock/path/image.jpg' }], }); const mockImagePicker: jest.Mocked = { launchImageLibrary: mockLaunchImageLibrary, diff --git a/packages/core/test/feedback/FeedbackWidgetManager.test.tsx b/packages/core/test/feedback/FeedbackWidgetManager.test.tsx index 1749cf0038..9c3a1e2190 100644 --- a/packages/core/test/feedback/FeedbackWidgetManager.test.tsx +++ b/packages/core/test/feedback/FeedbackWidgetManager.test.tsx @@ -2,7 +2,6 @@ import { getClient, logger, setCurrentClient } from '@sentry/core'; import { render } from '@testing-library/react-native'; import * as React from 'react'; import { Text } from 'react-native'; - import { defaultConfiguration } from '../../src/js/feedback/defaults'; import { FeedbackWidgetProvider, resetFeedbackWidgetManager, showFeedbackWidget } from '../../src/js/feedback/FeedbackWidgetManager'; import { feedbackIntegration } from '../../src/js/feedback/integration'; diff --git a/packages/core/test/integrations/appRegistry.test.ts b/packages/core/test/integrations/appRegistry.test.ts index 535616c378..44e7d6a3b8 100644 --- a/packages/core/test/integrations/appRegistry.test.ts +++ b/packages/core/test/integrations/appRegistry.test.ts @@ -1,5 +1,4 @@ import { getOriginalFunction } from '@sentry/core'; - import { appRegistryIntegration } from '../../src/js/integrations/appRegistry'; import * as Environment from '../../src/js/utils/environment'; import { ReactNativeLibraries } from '../../src/js/utils/rnlibraries'; diff --git a/packages/core/test/integrations/debugsymbolicator.test.ts b/packages/core/test/integrations/debugsymbolicator.test.ts index 9ed5728319..265780d01f 100644 --- a/packages/core/test/integrations/debugsymbolicator.test.ts +++ b/packages/core/test/integrations/debugsymbolicator.test.ts @@ -1,7 +1,4 @@ -jest.mock('../../src/js/integrations/debugsymbolicatorutils'); - import type { Client, Event, EventHint, StackFrame } from '@sentry/core'; - import { debugSymbolicatorIntegration } from '../../src/js/integrations/debugsymbolicator'; import { fetchSourceContext, @@ -11,6 +8,8 @@ import { } from '../../src/js/integrations/debugsymbolicatorutils'; import type * as ReactNative from '../../src/js/vendor/react-native'; +jest.mock('../../src/js/integrations/debugsymbolicatorutils'); + async function processEvent(mockedEvent: Event, mockedHint: EventHint): Promise { return debugSymbolicatorIntegration().processEvent!(mockedEvent, mockedHint, {} as Client); } diff --git a/packages/core/test/integrations/devicecontext.test.ts b/packages/core/test/integrations/devicecontext.test.ts index 014b4939eb..2689582ee4 100644 --- a/packages/core/test/integrations/devicecontext.test.ts +++ b/packages/core/test/integrations/devicecontext.test.ts @@ -1,5 +1,4 @@ import type { Client, Event, EventHint, SeverityLevel } from '@sentry/core'; - import { deviceContextIntegration } from '../../src/js/integrations/devicecontext'; import type { NativeDeviceContextsResponse } from '../../src/js/NativeRNSentry'; import { NATIVE } from '../../src/js/wrapper'; diff --git a/packages/core/test/integrations/eventorigin.test.ts b/packages/core/test/integrations/eventorigin.test.ts index dd3e0cbd91..3b5ed14c1c 100644 --- a/packages/core/test/integrations/eventorigin.test.ts +++ b/packages/core/test/integrations/eventorigin.test.ts @@ -1,5 +1,4 @@ import type { Client } from '@sentry/core'; - import { eventOriginIntegration } from '../../src/js/integrations/eventorigin'; describe('Event Origin', () => { diff --git a/packages/core/test/integrations/expocontext.test.ts b/packages/core/test/integrations/expocontext.test.ts index 205fc35b57..47381e8926 100644 --- a/packages/core/test/integrations/expocontext.test.ts +++ b/packages/core/test/integrations/expocontext.test.ts @@ -1,5 +1,4 @@ import { type Client, type Event, getCurrentScope, getGlobalScope, getIsolationScope } from '@sentry/core'; - import { expoContextIntegration, getExpoUpdatesContext, diff --git a/packages/core/test/integrations/integrationsexecutionorder.test.ts b/packages/core/test/integrations/integrationsexecutionorder.test.ts index 08b4a4f5a6..09c1f3fb65 100644 --- a/packages/core/test/integrations/integrationsexecutionorder.test.ts +++ b/packages/core/test/integrations/integrationsexecutionorder.test.ts @@ -1,10 +1,10 @@ import * as mockWrapper from '../mockWrapper'; + jest.mock('../../src/js/wrapper', () => mockWrapper); jest.mock('../../src/js/utils/environment'); import { defaultStackParser } from '@sentry/browser'; import type { Integration } from '@sentry/core'; - import { ReactNativeClient } from '../../src/js/client'; import { getDefaultIntegrations } from '../../src/js/integrations/default'; import type { ReactNativeClientOptions } from '../../src/js/options'; diff --git a/packages/core/test/integrations/modulesloader.test.ts b/packages/core/test/integrations/modulesloader.test.ts index c6fb43bb2f..50b99e66b3 100644 --- a/packages/core/test/integrations/modulesloader.test.ts +++ b/packages/core/test/integrations/modulesloader.test.ts @@ -1,5 +1,4 @@ import type { Client, Event, EventHint } from '@sentry/core'; - import { modulesLoaderIntegration } from '../../src/js/integrations/modulesloader'; import { NATIVE } from '../../src/js/wrapper'; diff --git a/packages/core/test/integrations/nativelinkederrors.test.ts b/packages/core/test/integrations/nativelinkederrors.test.ts index 9dd1a2da1b..60d0b1e6ff 100644 --- a/packages/core/test/integrations/nativelinkederrors.test.ts +++ b/packages/core/test/integrations/nativelinkederrors.test.ts @@ -1,6 +1,5 @@ import { defaultStackParser } from '@sentry/browser'; import type { Client, DebugImage, Event, EventHint, ExtendedError } from '@sentry/core'; - import { nativeLinkedErrorsIntegration } from '../../src/js/integrations/nativelinkederrors'; import type { NativeStackFrames } from '../../src/js/NativeRNSentry'; import { NATIVE } from '../../src/js/wrapper'; diff --git a/packages/core/test/integrations/reactnativeerrorhandlers.test.ts b/packages/core/test/integrations/reactnativeerrorhandlers.test.ts index aff3b6210f..edae04e346 100644 --- a/packages/core/test/integrations/reactnativeerrorhandlers.test.ts +++ b/packages/core/test/integrations/reactnativeerrorhandlers.test.ts @@ -1,12 +1,11 @@ -jest.mock('../../src/js/integrations/reactnativeerrorhandlersutils'); - import type { ExtendedError, Mechanism, SeverityLevel } from '@sentry/core'; import { setCurrentClient } from '@sentry/core'; - import { reactNativeErrorHandlersIntegration } from '../../src/js/integrations/reactnativeerrorhandlers'; import { requireRejectionTracking } from '../../src/js/integrations/reactnativeerrorhandlersutils'; import { getDefaultTestClientOptions, TestClient } from '../mocks/client'; +jest.mock('../../src/js/integrations/reactnativeerrorhandlersutils'); + describe('ReactNativeErrorHandlers', () => { let client: TestClient; let mockDisable: jest.Mock; diff --git a/packages/core/test/integrations/reactnativeinfo.test.ts b/packages/core/test/integrations/reactnativeinfo.test.ts index f7f9f3bfb9..9c6e9b8fc0 100644 --- a/packages/core/test/integrations/reactnativeinfo.test.ts +++ b/packages/core/test/integrations/reactnativeinfo.test.ts @@ -1,5 +1,4 @@ import type { Client, Event, EventHint } from '@sentry/core'; - import type { ReactNativeError } from '../../src/js/integrations/debugsymbolicator'; import type { ReactNativeContext } from '../../src/js/integrations/reactnativeinfo'; import { reactNativeInfoIntegration } from '../../src/js/integrations/reactnativeinfo'; diff --git a/packages/core/test/integrations/release.test.ts b/packages/core/test/integrations/release.test.ts index be3a4f1b10..6a282f7d9b 100644 --- a/packages/core/test/integrations/release.test.ts +++ b/packages/core/test/integrations/release.test.ts @@ -1,5 +1,4 @@ import type { Client } from '@sentry/core'; - import { nativeReleaseIntegration } from '../../src/js/integrations/release'; jest.mock('../../src/js/wrapper', () => ({ diff --git a/packages/core/test/integrations/rewriteframes.test.ts b/packages/core/test/integrations/rewriteframes.test.ts index 45eb9f094c..9230583513 100644 --- a/packages/core/test/integrations/rewriteframes.test.ts +++ b/packages/core/test/integrations/rewriteframes.test.ts @@ -2,7 +2,6 @@ import type { Exception } from '@sentry/browser'; import { defaultStackParser, eventFromException } from '@sentry/browser'; import type { Client, Event, EventHint } from '@sentry/core'; import { Platform } from 'react-native'; - import { createReactNativeRewriteFrames } from '../../src/js/integrations/rewriteframes'; import { isExpo, isHermesEnabled } from '../../src/js/utils/environment'; import { mockFunction } from '../testutils'; diff --git a/packages/core/test/integrations/sdkinfo.test.ts b/packages/core/test/integrations/sdkinfo.test.ts index 912d7f7d93..b166491834 100644 --- a/packages/core/test/integrations/sdkinfo.test.ts +++ b/packages/core/test/integrations/sdkinfo.test.ts @@ -1,5 +1,4 @@ import type { Event, EventHint, Package } from '@sentry/core'; - import { SDK_NAME, SDK_VERSION } from '../../src/js'; import { sdkInfoIntegration } from '../../src/js/integrations/sdkinfo'; import { NATIVE } from '../../src/js/wrapper'; diff --git a/packages/core/test/integrations/spotlight.test.ts b/packages/core/test/integrations/spotlight.test.ts index dba566f260..d65f2c4385 100644 --- a/packages/core/test/integrations/spotlight.test.ts +++ b/packages/core/test/integrations/spotlight.test.ts @@ -1,10 +1,10 @@ import type { HttpRequestEventMap } from '@mswjs/interceptors'; import { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest'; import type { Client, Envelope } from '@sentry/core'; - import { spotlightIntegration } from '../../src/js/integrations/spotlight'; globalThis.XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; + const requestListener = jest.fn(); const interceptor = new XMLHttpRequestInterceptor(); interceptor.on('request', requestListener); diff --git a/packages/core/test/integrations/viewhierarchy.test.ts b/packages/core/test/integrations/viewhierarchy.test.ts index 69020ce8ac..574220d9c3 100644 --- a/packages/core/test/integrations/viewhierarchy.test.ts +++ b/packages/core/test/integrations/viewhierarchy.test.ts @@ -1,5 +1,4 @@ import type { Client, Event, EventHint } from '@sentry/core'; - import { viewHierarchyIntegration } from '../../src/js/integrations/viewhierarchy'; import { NATIVE } from '../../src/js/wrapper'; diff --git a/packages/core/test/mocks/client.ts b/packages/core/test/mocks/client.ts index 183c4ff961..c2aa9c397e 100644 --- a/packages/core/test/mocks/client.ts +++ b/packages/core/test/mocks/client.ts @@ -9,7 +9,6 @@ import { resolvedSyncPromise, setCurrentClient, } from '@sentry/core'; - import type { ReactNativeClientOptions } from '../../src/js/options'; export function getDefaultTestClientOptions(options: Partial = {}): TestClientOptions { diff --git a/packages/core/test/profiling/convertHermesProfile.test.ts b/packages/core/test/profiling/convertHermesProfile.test.ts index 807d662fcd..569f6778fd 100644 --- a/packages/core/test/profiling/convertHermesProfile.test.ts +++ b/packages/core/test/profiling/convertHermesProfile.test.ts @@ -1,5 +1,4 @@ import type { ThreadCpuSample } from '@sentry/core'; - import { convertToSentryProfile, mapSamples } from '../../src/js/profiling/convertHermesProfile'; import type * as Hermes from '../../src/js/profiling/hermes'; import type { RawThreadCpuProfile } from '../../src/js/profiling/types'; diff --git a/packages/core/test/profiling/hermes.test.ts b/packages/core/test/profiling/hermes.test.ts index 21255b95ff..f2c8d64a9c 100644 --- a/packages/core/test/profiling/hermes.test.ts +++ b/packages/core/test/profiling/hermes.test.ts @@ -1,5 +1,4 @@ import type { ThreadCpuFrame } from '@sentry/core'; - import { parseHermesJSStackFrame } from '../../src/js/profiling/convertHermesProfile'; describe('hermes', () => { diff --git a/packages/core/test/profiling/integration.test.ts b/packages/core/test/profiling/integration.test.ts index d83f3e50ec..9fb4e425cc 100644 --- a/packages/core/test/profiling/integration.test.ts +++ b/packages/core/test/profiling/integration.test.ts @@ -1,11 +1,11 @@ import * as mockWrapper from '../mockWrapper'; + jest.mock('../../src/js/wrapper', () => mockWrapper); jest.mock('../../src/js/utils/environment'); jest.mock('../../src/js/profiling/debugid'); import type { Envelope, Event, Integration, Profile, Span, ThreadCpuProfile, Transport } from '@sentry/core'; import { getClient, spanToJSON } from '@sentry/core'; - import * as Sentry from '../../src/js'; import { getDebugMetadata } from '../../src/js/profiling/debugid'; import type { HermesProfilingOptions } from '../../src/js/profiling/integration'; diff --git a/packages/core/test/replay/xhrUtils.test.ts b/packages/core/test/replay/xhrUtils.test.ts index 477e8bc661..f348875dc7 100644 --- a/packages/core/test/replay/xhrUtils.test.ts +++ b/packages/core/test/replay/xhrUtils.test.ts @@ -1,5 +1,4 @@ import type { Breadcrumb } from '@sentry/core'; - import { enrichXhrBreadcrumbsForMobileReplay } from '../../src/js/replay/xhrUtils'; describe('xhrUtils', () => { diff --git a/packages/core/test/scopeSync.test.ts b/packages/core/test/scopeSync.test.ts index 85d14fe27c..7026bc901c 100644 --- a/packages/core/test/scopeSync.test.ts +++ b/packages/core/test/scopeSync.test.ts @@ -1,10 +1,11 @@ -jest.mock('../src/js/wrapper', () => jest.requireActual('./mockWrapper')); import type { Breadcrumb } from '@sentry/core'; import * as SentryCore from '@sentry/core'; import { Scope } from '@sentry/core'; - import { enableSyncToNative } from '../src/js/scopeSync'; import { getDefaultTestClientOptions, TestClient } from './mocks/client'; + +jest.mock('../src/js/wrapper', () => jest.requireActual('./mockWrapper')); + import { NATIVE } from './mockWrapper'; jest.mock('../src/js/wrapper'); diff --git a/packages/core/test/sdk.test.ts b/packages/core/test/sdk.test.ts index 3296a92061..05e2eee7a4 100644 --- a/packages/core/test/sdk.test.ts +++ b/packages/core/test/sdk.test.ts @@ -1,7 +1,6 @@ import type { BaseTransportOptions, Breadcrumb, BreadcrumbHint, ClientOptions, Integration, Scope } from '@sentry/core'; import { initAndBind, logger } from '@sentry/core'; import { makeFetchTransport } from '@sentry/react'; - import { getDevServer } from '../src/js/integrations/debugsymbolicatorutils'; import { init, withScope } from '../src/js/sdk'; import type { ReactNativeTracingIntegration } from '../src/js/tracing'; diff --git a/packages/core/test/sdk.withclient.test.ts b/packages/core/test/sdk.withclient.test.ts index 693d1817a9..c6aeedd81a 100644 --- a/packages/core/test/sdk.withclient.test.ts +++ b/packages/core/test/sdk.withclient.test.ts @@ -1,5 +1,4 @@ import { logger, setCurrentClient } from '@sentry/core'; - import { crashedLastRun, flush } from '../src/js/sdk'; import { getDefaultTestClientOptions, TestClient } from './mocks/client'; import { NATIVE } from './mockWrapper'; diff --git a/packages/core/test/tools/fixtures/mockBabelTransformer.js b/packages/core/test/tools/fixtures/mockBabelTransformer.js index 0e0aad9bd5..707b86771f 100644 --- a/packages/core/test/tools/fixtures/mockBabelTransformer.js +++ b/packages/core/test/tools/fixtures/mockBabelTransformer.js @@ -1,4 +1,5 @@ var globals = require('@jest/globals'); + var jest = globals.jest; module.exports = { diff --git a/packages/core/test/tools/metroMiddleware.test.ts b/packages/core/test/tools/metroMiddleware.test.ts index b1743e27a8..426d3dea69 100644 --- a/packages/core/test/tools/metroMiddleware.test.ts +++ b/packages/core/test/tools/metroMiddleware.test.ts @@ -1,7 +1,6 @@ import { afterEach, beforeEach, describe, expect, it, jest } from '@jest/globals'; import type { StackFrame } from '@sentry/core'; import * as fs from 'fs'; - import * as metroMiddleware from '../../src/js/tools/metroMiddleware'; const { withSentryMiddleware, createSentryMetroMiddleware, stackFramesContextMiddleware } = metroMiddleware; diff --git a/packages/core/test/tools/metroconfig.test.ts b/packages/core/test/tools/metroconfig.test.ts index 2329509754..e4ab6d2529 100644 --- a/packages/core/test/tools/metroconfig.test.ts +++ b/packages/core/test/tools/metroconfig.test.ts @@ -1,7 +1,6 @@ import type { getDefaultConfig } from 'expo/metro-config'; import type { MetroConfig } from 'metro'; import * as process from 'process'; - import { getSentryExpoConfig, withSentryBabelTransformer, @@ -160,7 +159,7 @@ describe('metroconfig', () => { describe.each([ ['new Metro', false, '0.70.0'], ['old Metro', true, '0.67.0'], - ])(`on %s`, (description, oldMetro, metroVersion) => { + ])('on %s', (description, oldMetro, metroVersion) => { beforeEach(() => { jest.resetModules(); // Mock metro/package.json diff --git a/packages/core/test/tools/sentryBabelTransformer.test.ts b/packages/core/test/tools/sentryBabelTransformer.test.ts index 3d6fb99d20..2a7868a5f9 100644 --- a/packages/core/test/tools/sentryBabelTransformer.test.ts +++ b/packages/core/test/tools/sentryBabelTransformer.test.ts @@ -1,5 +1,4 @@ import * as process from 'process'; - import { createSentryBabelTransformer, SENTRY_BABEL_TRANSFORMER_OPTIONS, diff --git a/packages/core/test/tools/sentryMetroSerializer.test.ts b/packages/core/test/tools/sentryMetroSerializer.test.ts index 1d85d2cdb3..411edecde3 100644 --- a/packages/core/test/tools/sentryMetroSerializer.test.ts +++ b/packages/core/test/tools/sentryMetroSerializer.test.ts @@ -3,7 +3,6 @@ import type { MixedOutput, Module } from 'metro'; import CountingSet from 'metro/src/lib/CountingSet'; import * as countLines from 'metro/src/lib/countLines'; import { minify } from 'uglify-js'; - import { createSentryMetroSerializer } from '../../src/js/tools/sentryMetroSerializer'; import { type MetroSerializer, type VirtualJSOutput, createDebugIdSnippet } from '../../src/js/tools/utils'; diff --git a/packages/core/test/touchevents.test.tsx b/packages/core/test/touchevents.test.tsx index 4266f62d4b..32c5504386 100644 --- a/packages/core/test/touchevents.test.tsx +++ b/packages/core/test/touchevents.test.tsx @@ -3,7 +3,6 @@ */ import type { SeverityLevel } from '@sentry/core'; import * as core from '@sentry/core'; - import { TouchEventBoundary } from '../src/js/touchevents'; import { getDefaultTestClientOptions, TestClient } from './mocks/client'; diff --git a/packages/core/test/trace.test.ts b/packages/core/test/trace.test.ts index 0f84d36e20..94b81bcee5 100644 --- a/packages/core/test/trace.test.ts +++ b/packages/core/test/trace.test.ts @@ -1,5 +1,4 @@ import { setCurrentClient, spanToJSON, startSpan } from '@sentry/core'; - import { getDefaultTestClientOptions, TestClient } from './mocks/client'; describe('parentSpanIsAlwaysRootSpan', () => { diff --git a/packages/core/test/tracing/addTracingExtensions.test.ts b/packages/core/test/tracing/addTracingExtensions.test.ts index bb074e36ee..b413ffd429 100644 --- a/packages/core/test/tracing/addTracingExtensions.test.ts +++ b/packages/core/test/tracing/addTracingExtensions.test.ts @@ -1,6 +1,5 @@ import type { Span } from '@sentry/core'; import { getCurrentScope, spanToJSON, startSpanManual } from '@sentry/core'; - import { reactNativeTracingIntegration } from '../../src/js'; import { type TestClient, setupTestClient } from '../mocks/client'; diff --git a/packages/core/test/tracing/gesturetracing.test.ts b/packages/core/test/tracing/gesturetracing.test.ts index 10c5ccf39d..aa57bc199a 100644 --- a/packages/core/test/tracing/gesturetracing.test.ts +++ b/packages/core/test/tracing/gesturetracing.test.ts @@ -1,6 +1,5 @@ import type { Breadcrumb } from '@sentry/core'; import { getActiveSpan, spanToJSON, startSpan } from '@sentry/core'; - import { UI_ACTION } from '../../src/js/tracing'; import { DEFAULT_BREADCRUMB_CATEGORY as DEFAULT_GESTURE_BREADCRUMB_CATEGORY, diff --git a/packages/core/test/tracing/idleNavigationSpan.test.ts b/packages/core/test/tracing/idleNavigationSpan.test.ts index ec4ddf7640..1aae3f4931 100644 --- a/packages/core/test/tracing/idleNavigationSpan.test.ts +++ b/packages/core/test/tracing/idleNavigationSpan.test.ts @@ -1,7 +1,6 @@ import type { Span } from '@sentry/core'; import { getActiveSpan, getCurrentScope, spanToJSON, startSpanManual } from '@sentry/core'; import type { AppState, AppStateStatus } from 'react-native'; - import type { ScopeWithMaybeSpan } from '../../src/js/tracing/span'; import { SCOPE_SPAN_FIELD, startIdleNavigationSpan } from '../../src/js/tracing/span'; import { NATIVE } from '../../src/js/wrapper'; diff --git a/packages/core/test/tracing/integrations/appStart.test.ts b/packages/core/test/tracing/integrations/appStart.test.ts index 926f0edca3..16f53793a7 100644 --- a/packages/core/test/tracing/integrations/appStart.test.ts +++ b/packages/core/test/tracing/integrations/appStart.test.ts @@ -8,7 +8,6 @@ import { setCurrentClient, timestampInSeconds, } from '@sentry/core'; - import { APP_START_COLD as APP_START_COLD_MEASUREMENT, APP_START_WARM as APP_START_WARM_MEASUREMENT, diff --git a/packages/core/test/tracing/integrations/nativeframes.test.ts b/packages/core/test/tracing/integrations/nativeframes.test.ts index 839bdd5d1b..0b426f945d 100644 --- a/packages/core/test/tracing/integrations/nativeframes.test.ts +++ b/packages/core/test/tracing/integrations/nativeframes.test.ts @@ -1,6 +1,5 @@ import type { Event, Measurements } from '@sentry/core'; import { getCurrentScope, getGlobalScope, getIsolationScope, setCurrentClient, startSpan } from '@sentry/core'; - import { nativeFramesIntegration } from '../../../src/js'; import { NATIVE } from '../../../src/js/wrapper'; import { getDefaultTestClientOptions, TestClient } from '../../mocks/client'; diff --git a/packages/core/test/tracing/integrations/stallTracking/stalltracking.background.test.ts b/packages/core/test/tracing/integrations/stallTracking/stalltracking.background.test.ts index 2358c77d1e..bf1eb231ee 100644 --- a/packages/core/test/tracing/integrations/stallTracking/stalltracking.background.test.ts +++ b/packages/core/test/tracing/integrations/stallTracking/stalltracking.background.test.ts @@ -1,5 +1,4 @@ import type { AppStateStatus } from 'react-native'; - import { stallTrackingIntegration } from '../../../../src/js/tracing/integrations/stalltracking'; type StallTrackingWithTestProperties = ReturnType & { diff --git a/packages/core/test/tracing/integrations/stallTracking/stalltracking.test.ts b/packages/core/test/tracing/integrations/stallTracking/stalltracking.test.ts index 12fc59f1ab..1cadf3f7d5 100644 --- a/packages/core/test/tracing/integrations/stallTracking/stalltracking.test.ts +++ b/packages/core/test/tracing/integrations/stallTracking/stalltracking.test.ts @@ -9,7 +9,6 @@ import { startSpanManual, timestampInSeconds, } from '@sentry/core'; - import { stallTrackingIntegration } from '../../../../src/js/tracing/integrations/stalltracking'; import { getDefaultTestClientOptions, TestClient } from '../../../mocks/client'; import { expectNonZeroStallMeasurements, expectStallMeasurements } from './stalltrackingutils'; diff --git a/packages/core/test/tracing/integrations/userInteraction.test.ts b/packages/core/test/tracing/integrations/userInteraction.test.ts index 1f86614c36..eebb00f756 100644 --- a/packages/core/test/tracing/integrations/userInteraction.test.ts +++ b/packages/core/test/tracing/integrations/userInteraction.test.ts @@ -8,7 +8,6 @@ import { startSpanManual, } from '@sentry/core'; import type { AppState, AppStateStatus } from 'react-native'; - import { startUserInteractionSpan, userInteractionIntegration, diff --git a/packages/core/test/tracing/mockedtimetodisplaynative.tsx b/packages/core/test/tracing/mockedtimetodisplaynative.tsx index 6fbc773b53..12c9b7e6ae 100644 --- a/packages/core/test/tracing/mockedtimetodisplaynative.tsx +++ b/packages/core/test/tracing/mockedtimetodisplaynative.tsx @@ -1,6 +1,5 @@ import * as React from 'react'; import { View } from 'react-native'; - import type { RNSentryOnDrawReporterProps } from '../../src/js/tracing/timetodisplaynative.types'; import { NATIVE } from '../mockWrapper'; diff --git a/packages/core/test/tracing/reactnativenavigation.test.ts b/packages/core/test/tracing/reactnativenavigation.test.ts index ebc264d91f..77d02db915 100644 --- a/packages/core/test/tracing/reactnativenavigation.test.ts +++ b/packages/core/test/tracing/reactnativenavigation.test.ts @@ -9,7 +9,6 @@ import { spanToJSON, } from '@sentry/core'; import type { EmitterSubscription } from 'react-native'; - import { reactNativeTracingIntegration } from '../../src/js'; import { SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NATIVE_NAVIGATION } from '../../src/js/tracing/origin'; import type { diff --git a/packages/core/test/tracing/reactnativetracing.test.ts b/packages/core/test/tracing/reactnativetracing.test.ts index 861b94ba1a..7aab318b6d 100644 --- a/packages/core/test/tracing/reactnativetracing.test.ts +++ b/packages/core/test/tracing/reactnativetracing.test.ts @@ -13,6 +13,11 @@ jest.mock('../../src/js/wrapper', () => { }; }); +import { reactNativeTracingIntegration } from '../../src/js/tracing/reactnativetracing'; +import { isWeb } from '../../src/js/utils/environment'; +import type { TestClient } from '../mocks/client'; +import { setupTestClient } from '../mocks/client'; + jest.mock('../../src/js/tracing/utils', () => { const originalUtils = jest.requireActual('../../src/js/tracing/utils'); @@ -32,10 +37,6 @@ jest.mock('@sentry/core', () => { }); jest.mock('../../src/js/utils/environment'); -import { reactNativeTracingIntegration } from '../../src/js/tracing/reactnativetracing'; -import { isWeb } from '../../src/js/utils/environment'; -import type { TestClient } from '../mocks/client'; -import { setupTestClient } from '../mocks/client'; describe('ReactNativeTracing', () => { let client: TestClient; diff --git a/packages/core/test/tracing/reactnavigation.stalltracking.test.ts b/packages/core/test/tracing/reactnavigation.stalltracking.test.ts index 0fbc3b8627..7f4f4ade6e 100644 --- a/packages/core/test/tracing/reactnavigation.stalltracking.test.ts +++ b/packages/core/test/tracing/reactnavigation.stalltracking.test.ts @@ -4,7 +4,6 @@ jest.mock('../../src/js/tracing/utils', () => ({ })); import { getCurrentScope, getGlobalScope, getIsolationScope, setCurrentClient, startSpanManual } from '@sentry/core'; - import { reactNativeTracingIntegration, reactNavigationIntegration } from '../../src/js'; import { stallTrackingIntegration } from '../../src/js/tracing/integrations/stalltracking'; import { isNearToNow } from '../../src/js/tracing/utils'; diff --git a/packages/core/test/tracing/reactnavigation.test.ts b/packages/core/test/tracing/reactnavigation.test.ts index 54a203000f..db55874a91 100644 --- a/packages/core/test/tracing/reactnavigation.test.ts +++ b/packages/core/test/tracing/reactnavigation.test.ts @@ -10,7 +10,6 @@ import { setCurrentClient, spanToJSON, } from '@sentry/core'; - import { nativeFramesIntegration, reactNativeTracingIntegration } from '../../src/js'; import { SPAN_ORIGIN_AUTO_NAVIGATION_REACT_NAVIGATION } from '../../src/js/tracing/origin'; import type { NavigationRoute } from '../../src/js/tracing/reactnavigation'; diff --git a/packages/core/test/tracing/reactnavigation.ttid.test.tsx b/packages/core/test/tracing/reactnavigation.ttid.test.tsx index ba01506feb..fa32655073 100644 --- a/packages/core/test/tracing/reactnavigation.ttid.test.tsx +++ b/packages/core/test/tracing/reactnavigation.ttid.test.tsx @@ -1,11 +1,11 @@ import type { Scope, Span, SpanJSON, TransactionEvent, Transport } from '@sentry/core'; import { getActiveSpan, spanToJSON, timestampInSeconds } from '@sentry/core'; import * as TestRenderer from '@testing-library/react-native' -import * as React from "react"; - +import * as React from 'react'; import * as mockWrapper from '../mockWrapper'; import * as mockedSentryEventEmitter from '../utils/mockedSentryeventemitterfallback'; import * as mockedtimetodisplaynative from './mockedtimetodisplaynative'; + jest.mock('../../src/js/wrapper', () => mockWrapper); jest.mock('../../src/js/utils/environment'); jest.mock('../../src/js/utils/sentryeventemitterfallback', () => mockedSentryEventEmitter); @@ -24,6 +24,7 @@ import { nowInSeconds, secondInFutureTimestampMs } from '../testutils'; import { mockRecordedTimeToDisplay } from './mockedtimetodisplaynative'; import { createMockNavigationAndAttachTo } from './reactnavigationutils'; + const SCOPE_SPAN_FIELD = '_sentrySpan'; type ScopeWithMaybeSpan = Scope & { diff --git a/packages/core/test/tracing/timetodisplay.test.tsx b/packages/core/test/tracing/timetodisplay.test.tsx index 43413abcbc..ab2b8e1744 100644 --- a/packages/core/test/tracing/timetodisplay.test.tsx +++ b/packages/core/test/tracing/timetodisplay.test.tsx @@ -1,30 +1,32 @@ +import type { Event, Measurements, Span, SpanJSON} from '@sentry/core'; import { getCurrentScope, getGlobalScope, getIsolationScope, logger , setCurrentClient, spanToJSON, startSpanManual } from '@sentry/core'; + jest.spyOn(logger, 'warn'); import * as mockWrapper from '../mockWrapper'; + jest.mock('../../src/js/wrapper', () => mockWrapper); import * as mockedtimetodisplaynative from './mockedtimetodisplaynative'; -jest.mock('../../src/js/tracing/timetodisplaynative', () => mockedtimetodisplaynative); -import { isTurboModuleEnabled } from '../../src/js/utils/environment'; -jest.mock('../../src/js/utils/environment', () => ({ - isWeb: jest.fn().mockReturnValue(false), - isTurboModuleEnabled: jest.fn().mockReturnValue(false), -})); +jest.mock('../../src/js/tracing/timetodisplaynative', () => mockedtimetodisplaynative); -import type { Event, Measurements, Span, SpanJSON} from '@sentry/core'; -import * as React from "react"; +import * as React from 'react'; import * as TestRenderer from 'react-test-renderer'; - import { timeToDisplayIntegration } from '../../src/js/tracing/integrations/timeToDisplayIntegration'; import { SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from '../../src/js/tracing/origin'; import { SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '../../src/js/tracing/semanticAttributes'; import { SPAN_THREAD_NAME , SPAN_THREAD_NAME_JAVASCRIPT } from '../../src/js/tracing/span'; import { startTimeToFullDisplaySpan, startTimeToInitialDisplaySpan, TimeToFullDisplay, TimeToInitialDisplay } from '../../src/js/tracing/timetodisplay'; +import { isTurboModuleEnabled } from '../../src/js/utils/environment'; import { getDefaultTestClientOptions, TestClient } from '../mocks/client'; import { nowInSeconds, secondAgoTimestampMs, secondInFutureTimestampMs } from '../testutils'; +jest.mock('../../src/js/utils/environment', () => ({ + isWeb: jest.fn().mockReturnValue(false), + isTurboModuleEnabled: jest.fn().mockReturnValue(false), +})); + const { mockRecordedTimeToDisplay, getMockedOnDrawReportedProps, clearMockedOnDrawReportedProps } = mockedtimetodisplaynative; jest.useFakeTimers({advanceTimers: true}); @@ -321,7 +323,7 @@ function getFullDisplaySpanJSON(spans: SpanJSON[]) { function expectFinishedInitialDisplaySpan(event: Event) { expect(getInitialDisplaySpanJSON(event.spans!)).toEqual(expect.objectContaining>({ data: { - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: "ui.load.initial_display", + [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'ui.load.initial_display', [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY, [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT, }, @@ -337,7 +339,7 @@ function expectFinishedInitialDisplaySpan(event: Event) { function expectFinishedFullDisplaySpan(event: Event) { expect(getFullDisplaySpanJSON(event.spans!)).toEqual(expect.objectContaining>({ data: { - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: "ui.load.full_display", + [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'ui.load.full_display', [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY, [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT, }, @@ -354,7 +356,7 @@ function expectFinishedFullDisplaySpan(event: Event) { function expectDeadlineExceededFullDisplaySpan(event: Event) { expect(getFullDisplaySpanJSON(event.spans!)).toEqual(expect.objectContaining>({ data: { - [SEMANTIC_ATTRIBUTE_SENTRY_OP]: "ui.load.full_display", + [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'ui.load.full_display', [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY, [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT, }, diff --git a/packages/core/test/tracing/timetodisplaynative.web.test.tsx b/packages/core/test/tracing/timetodisplaynative.web.test.tsx index c60dad0a75..6956bc81a2 100644 --- a/packages/core/test/tracing/timetodisplaynative.web.test.tsx +++ b/packages/core/test/tracing/timetodisplaynative.web.test.tsx @@ -7,6 +7,9 @@ jest.mock('react-native', () => { return RN; }); +import { getRNSentryOnDrawReporter } from '../../src/js/tracing/timetodisplaynative'; +import { ReactNativeLibraries } from '../../src/js/utils/rnlibraries'; + jest.mock('../../src/js/utils/rnlibraries', () => { const webLibrary = jest.requireActual('../../src/js/utils/rnlibraries.web'); return { @@ -14,9 +17,6 @@ jest.mock('../../src/js/utils/rnlibraries', () => { }; }); -import { getRNSentryOnDrawReporter } from '../../src/js/tracing/timetodisplaynative'; -import { ReactNativeLibraries } from '../../src/js/utils/rnlibraries'; - describe('timetodisplaynative', () => { test('requireNativeComponent to be undefined', () => { expect(ReactNativeLibraries).toBeDefined(); diff --git a/packages/core/test/transports/native.test.ts b/packages/core/test/transports/native.test.ts index 267f2b4d59..72a0c936ca 100644 --- a/packages/core/test/transports/native.test.ts +++ b/packages/core/test/transports/native.test.ts @@ -1,5 +1,4 @@ import type { Envelope } from '@sentry/core'; - import { NativeTransport } from '../../src/js/transports/native'; jest.mock('../../src/js/wrapper', () => ({ diff --git a/packages/core/test/utils/ignorerequirecyclelogs.test.ts b/packages/core/test/utils/ignorerequirecyclelogs.test.ts index 11f62b9d2c..52b87e691d 100644 --- a/packages/core/test/utils/ignorerequirecyclelogs.test.ts +++ b/packages/core/test/utils/ignorerequirecyclelogs.test.ts @@ -1,5 +1,4 @@ import { LogBox } from 'react-native'; - import { ignoreRequireCycleLogs } from '../../src/js/utils/ignorerequirecyclelogs'; jest.mock('react-native', () => ({ diff --git a/packages/core/test/utils/mockedSentryeventemitterfallback.ts b/packages/core/test/utils/mockedSentryeventemitterfallback.ts index 74ebd4f53a..9ad6dcdf5d 100644 --- a/packages/core/test/utils/mockedSentryeventemitterfallback.ts +++ b/packages/core/test/utils/mockedSentryeventemitterfallback.ts @@ -1,6 +1,5 @@ import { timestampInSeconds } from '@sentry/core'; import * as EventEmitter from 'events'; - import type { NewFrameEvent } from '../../src/js/utils/sentryeventemitter'; import type { SentryEventEmitterFallback } from '../../src/js/utils/sentryeventemitterfallback'; import type { MockInterface } from '../testutils'; diff --git a/packages/core/test/utils/sentryeventemitterfallback.test.ts b/packages/core/test/utils/sentryeventemitterfallback.test.ts index 28353fa490..f55d57a891 100644 --- a/packages/core/test/utils/sentryeventemitterfallback.test.ts +++ b/packages/core/test/utils/sentryeventemitterfallback.test.ts @@ -1,5 +1,4 @@ import { logger } from '@sentry/core'; - import { NewFrameEventName } from '../../src/js/utils/sentryeventemitter'; import { createSentryFallbackEventEmitter } from '../../src/js/utils/sentryeventemitterfallback'; diff --git a/packages/core/test/wrap.mocked.test.tsx b/packages/core/test/wrap.mocked.test.tsx index dab86de46d..a9c62a5a18 100644 --- a/packages/core/test/wrap.mocked.test.tsx +++ b/packages/core/test/wrap.mocked.test.tsx @@ -30,7 +30,6 @@ jest.doMock('../src/js/feedback/FeedbackWidgetManager', () => { }; }); - import { wrap } from '../src/js/sdk'; import { ReactNativeProfiler } from '../src/js/tracing'; diff --git a/packages/core/test/wrap.test.tsx b/packages/core/test/wrap.test.tsx index 0bac2041c2..8282683772 100644 --- a/packages/core/test/wrap.test.tsx +++ b/packages/core/test/wrap.test.tsx @@ -3,7 +3,6 @@ import { logger, setCurrentClient } from '@sentry/core'; import { render } from '@testing-library/react-native'; import * as React from 'react'; import { Text } from 'react-native'; - import * as AppRegistry from '../src/js/integrations/appRegistry'; import { wrap } from '../src/js/sdk'; import { getDefaultTestClientOptions, TestClient } from './mocks/client'; diff --git a/packages/core/test/wrapper.test.ts b/packages/core/test/wrapper.test.ts index 9a260f1a18..a44ce25bc4 100644 --- a/packages/core/test/wrapper.test.ts +++ b/packages/core/test/wrapper.test.ts @@ -1,7 +1,6 @@ import type { Event, EventEnvelope, EventItem, SeverityLevel } from '@sentry/core'; import { createEnvelope, logger } from '@sentry/core'; import * as RN from 'react-native'; - import type { Spec } from '../src/js/NativeRNSentry'; import type { ReactNativeOptions } from '../src/js/options'; import { base64StringFromByteArray, utf8ToBytes } from '../src/js/vendor'; diff --git a/samples/react-native-macos/package.json b/samples/react-native-macos/package.json index b23d94d0f7..05a4dd4438 100644 --- a/samples/react-native-macos/package.json +++ b/samples/react-native-macos/package.json @@ -16,8 +16,8 @@ "@react-navigation/bottom-tabs": "^6.5.12", "@react-navigation/native": "^6.1.9", "@react-navigation/stack": "^6.3.20", - "@sentry/core": "9.12.0", - "@sentry/react": "9.12.0", + "@sentry/core": "9.22.0", + "@sentry/react": "9.22.0", "@sentry/react-native": "7.0.0-alpha.0", "delay": "^6.0.0", "react": "18.2.0", diff --git a/samples/react-native/package.json b/samples/react-native/package.json index d618606ffe..00f4bf4172 100644 --- a/samples/react-native/package.json +++ b/samples/react-native/package.json @@ -27,7 +27,7 @@ "@react-navigation/native": "^7.0.14", "@react-navigation/native-stack": "^7.2.0", "@react-navigation/stack": "^7.1.1", - "@sentry/core": "9.12.0", + "@sentry/core": "9.22.0", "@sentry/react-native": "7.0.0-alpha.0", "@shopify/flash-list": "^1.7.3", "delay": "^6.0.0", diff --git a/yarn.lock b/yarn.lock index 54cefbde31..8d4211db1a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8134,67 +8134,67 @@ __metadata: languageName: node linkType: hard -"@sentry-internal/browser-utils@npm:9.12.0": - version: 9.12.0 - resolution: "@sentry-internal/browser-utils@npm:9.12.0" +"@sentry-internal/browser-utils@npm:9.22.0": + version: 9.22.0 + resolution: "@sentry-internal/browser-utils@npm:9.22.0" dependencies: - "@sentry/core": 9.12.0 - checksum: b44b14bffdb7ffe0ea8efd8a8930563af8458c16343f07ed179569cdcb01bc56f99f821ef4782c9fa52d8c500bf4a409cb9ddc3c785bfe887033e7f86449b15f + "@sentry/core": 9.22.0 + checksum: 59f1739c116bf27c2f25d42cc1227a6de6a1c2102412dc93059321003f068e31f9d9a1d9ced3f395a723dc1318a39c979513149c52663457057f2ea18d72bd40 languageName: node linkType: hard -"@sentry-internal/eslint-config-sdk@npm:9.12.0": - version: 9.12.0 - resolution: "@sentry-internal/eslint-config-sdk@npm:9.12.0" +"@sentry-internal/eslint-config-sdk@npm:9.22.0": + version: 9.22.0 + resolution: "@sentry-internal/eslint-config-sdk@npm:9.22.0" dependencies: - "@sentry-internal/eslint-plugin-sdk": 9.12.0 - "@sentry-internal/typescript": 9.12.0 + "@sentry-internal/eslint-plugin-sdk": 9.22.0 + "@sentry-internal/typescript": 9.22.0 "@typescript-eslint/eslint-plugin": ^5.48.0 "@typescript-eslint/parser": ^5.48.0 eslint-config-prettier: ^6.11.0 eslint-plugin-deprecation: ^1.5.0 eslint-plugin-import: ^2.22.0 eslint-plugin-jsdoc: ^30.0.3 - eslint-plugin-simple-import-sort: ^5.0.3 + eslint-plugin-simple-import-sort: ^6.0.0 peerDependencies: eslint: ">=5" - checksum: 1d4151bc3a4e566579438c93798d8eb91cf004bad19ccd559981ac2abf56b7a62e3e099101fe558119052ffe3f632ace4e91649def9cb74cc98616a0479013e3 + checksum: aef911eec68d47f3a640b80d6d21c0ca9e93eae4fe42d2690f3da0af94c6508dd7e96a7e2648548b4e984a032d7844228bc062226e0162467455ad2ea7097a2f languageName: node linkType: hard -"@sentry-internal/eslint-plugin-sdk@npm:9.12.0": - version: 9.12.0 - resolution: "@sentry-internal/eslint-plugin-sdk@npm:9.12.0" - checksum: 2ac6e8aeb1b22689232c8cd77fd19761e6ec7a6a3f7ae0f8940b28bcedf2c364f6bdb44b0e4f604fe471438c33f722c2d5e4c9020b391be85a03e4ea518be4d9 +"@sentry-internal/eslint-plugin-sdk@npm:9.22.0": + version: 9.22.0 + resolution: "@sentry-internal/eslint-plugin-sdk@npm:9.22.0" + checksum: 01df33662517e496d41436d688f3a196c494c8fee0d83bac226d16be7086153cc632b4ccfeeb134224af1148a7f1c2b0abe1ce76a03ad9b32336a4723d8cf862 languageName: node linkType: hard -"@sentry-internal/feedback@npm:9.12.0": - version: 9.12.0 - resolution: "@sentry-internal/feedback@npm:9.12.0" +"@sentry-internal/feedback@npm:9.22.0": + version: 9.22.0 + resolution: "@sentry-internal/feedback@npm:9.22.0" dependencies: - "@sentry/core": 9.12.0 - checksum: 6245100c50b48c178bc2b54999ec6c05614b3de3612902d67ac7cafc1e32fbc2735922461ce6afa82d7a5b1d389c98e65b0a822be739345b05e4ab2676f3ac00 + "@sentry/core": 9.22.0 + checksum: fe4eaa655915b65bb4ddc76d28c78a03a8e4150f2a12ab34a3cb70061f9f2dbbf00675f60102bf59391ffbbaa52fe3f1a71b195c7649b7947eeba9376660a73c languageName: node linkType: hard -"@sentry-internal/replay-canvas@npm:9.12.0": - version: 9.12.0 - resolution: "@sentry-internal/replay-canvas@npm:9.12.0" +"@sentry-internal/replay-canvas@npm:9.22.0": + version: 9.22.0 + resolution: "@sentry-internal/replay-canvas@npm:9.22.0" dependencies: - "@sentry-internal/replay": 9.12.0 - "@sentry/core": 9.12.0 - checksum: 5ff030866e8a88273b320cafd3ce89f2816c58dc57e9f2f4900aa4364d59b6a71655bc618ec32d9f03631d68ce2cc11539567bf18c4564ffd32363c88282bc8e + "@sentry-internal/replay": 9.22.0 + "@sentry/core": 9.22.0 + checksum: 2a6414d3d51f779110df4e40a4460d8f933f21b73e4a55440964b821d07178d1c31c67c5a992d160c40d10d588a940ebd42624058a94f5d359844de8176713e1 languageName: node linkType: hard -"@sentry-internal/replay@npm:9.12.0": - version: 9.12.0 - resolution: "@sentry-internal/replay@npm:9.12.0" +"@sentry-internal/replay@npm:9.22.0": + version: 9.22.0 + resolution: "@sentry-internal/replay@npm:9.22.0" dependencies: - "@sentry-internal/browser-utils": 9.12.0 - "@sentry/core": 9.12.0 - checksum: 47074f5f316860b0909d892132367104b38ad4c75ec6545b3ab484d3af0ec0c873ca2679582769ebf76c80b43ac26347dc33a9cf1e3b79ddb2043eef5dcb3c69 + "@sentry-internal/browser-utils": 9.22.0 + "@sentry/core": 9.22.0 + checksum: 37e3b9f0db8ee70f1b16c70e07f6c7dc6599eb4f781dc6d82cfcb5c53cea8d57d62da0728da5d4ce731cb7900e555e0aae012daf5e4a8ab57aa2cf3d041b5a6c languageName: node linkType: hard @@ -8209,12 +8209,12 @@ __metadata: languageName: node linkType: hard -"@sentry-internal/typescript@npm:9.12.0": - version: 9.12.0 - resolution: "@sentry-internal/typescript@npm:9.12.0" +"@sentry-internal/typescript@npm:9.22.0": + version: 9.22.0 + resolution: "@sentry-internal/typescript@npm:9.22.0" peerDependencies: typescript: ~5.0.0 - checksum: dfcbb2a0df26196d0ba87d53389784f7291cb01f85a1fe10ad51033c9e01a1f3c5397c08ee3c3fce475f6290e37291ab5d8aca563d2030cc9072232975aeff89 + checksum: bd3ef99b75fd52103b83948830285c04b5d495507f1a15e559245547db0890d7e8a622a1e95f622dfbdbc6871502a5e68af2bf047416273d9c84b748f8733d84 languageName: node linkType: hard @@ -8225,16 +8225,16 @@ __metadata: languageName: node linkType: hard -"@sentry/browser@npm:9.12.0": - version: 9.12.0 - resolution: "@sentry/browser@npm:9.12.0" +"@sentry/browser@npm:9.22.0": + version: 9.22.0 + resolution: "@sentry/browser@npm:9.22.0" dependencies: - "@sentry-internal/browser-utils": 9.12.0 - "@sentry-internal/feedback": 9.12.0 - "@sentry-internal/replay": 9.12.0 - "@sentry-internal/replay-canvas": 9.12.0 - "@sentry/core": 9.12.0 - checksum: 4acd1e65dd3a4ce6ca2150a1945ace0ab50e482aa0dd39ed1a3fc1fd3be9d7318af2781f947faf594aaee9d32c58650743527de56d0aeb46b8c5aa1867c37e9e + "@sentry-internal/browser-utils": 9.22.0 + "@sentry-internal/feedback": 9.22.0 + "@sentry-internal/replay": 9.22.0 + "@sentry-internal/replay-canvas": 9.22.0 + "@sentry/core": 9.22.0 + checksum: 705abac1b2a5c058004938aed4f1d80e1255f560d89eead28d51c67c1ca7b53afc18d77f1fd5ffffbeca69166ed5aab2f006a2d1ebda3f73bc6be0fd4257c5d6 languageName: node linkType: hard @@ -8440,10 +8440,10 @@ __metadata: languageName: node linkType: hard -"@sentry/core@npm:9.12.0": - version: 9.12.0 - resolution: "@sentry/core@npm:9.12.0" - checksum: 6bf8b5f7fe91897a598c608a17a6b2024d59c2055e5714629aba280ba7004dae4171481b455d61514367d264b3e2a5b2e82fd0cc264993020cc8fd93ddac03dc +"@sentry/core@npm:9.22.0": + version: 9.22.0 + resolution: "@sentry/core@npm:9.22.0" + checksum: b9cfc1c3e0e5f886c8656f0b6e917dc9e4b2bd8a3f7539f44e7acd2a0dcf4bd6ddc8fdf99c69f6279cca487ccc604e16fd91d3a824bdf62954164131d4a38b34 languageName: node linkType: hard @@ -8480,15 +8480,15 @@ __metadata: "@expo/metro-config": 0.19.5 "@mswjs/interceptors": ^0.25.15 "@react-native/babel-preset": 0.77.1 - "@sentry-internal/eslint-config-sdk": 9.12.0 - "@sentry-internal/eslint-plugin-sdk": 9.12.0 - "@sentry-internal/typescript": 9.12.0 + "@sentry-internal/eslint-config-sdk": 9.22.0 + "@sentry-internal/eslint-plugin-sdk": 9.22.0 + "@sentry-internal/typescript": 9.22.0 "@sentry/babel-plugin-component-annotate": 3.4.0 - "@sentry/browser": 9.12.0 + "@sentry/browser": 9.22.0 "@sentry/cli": 2.43.0 - "@sentry/core": 9.12.0 - "@sentry/react": 9.12.0 - "@sentry/types": 9.12.0 + "@sentry/core": 9.22.0 + "@sentry/react": 9.22.0 + "@sentry/types": 9.22.0 "@sentry/wizard": 4.9.0 "@testing-library/react-native": ^12.7.2 "@types/jest": ^29.5.13 @@ -8535,16 +8535,16 @@ __metadata: languageName: unknown linkType: soft -"@sentry/react@npm:9.12.0": - version: 9.12.0 - resolution: "@sentry/react@npm:9.12.0" +"@sentry/react@npm:9.22.0": + version: 9.22.0 + resolution: "@sentry/react@npm:9.22.0" dependencies: - "@sentry/browser": 9.12.0 - "@sentry/core": 9.12.0 + "@sentry/browser": 9.22.0 + "@sentry/core": 9.22.0 hoist-non-react-statics: ^3.3.2 peerDependencies: react: ^16.14.0 || 17.x || 18.x || 19.x - checksum: 67f1d406a6a2232de72bfe3fe7cf33a95c925b442b9b2d56d2dcab4b53d40e34a19c6fbfb4bd794858dceb5db0f60ec7b26631bf924c119abb083b8ca789e394 + checksum: 6e70ce8dd221b71993be56b8c346d7d61a4bb8fcbc4ebbb9c920a7b3dae9306e9b1c5888b78ac54728a9f8ed8500d3f3e6afbde5b15a89bb834c9494287b58f5 languageName: node linkType: hard @@ -8555,12 +8555,12 @@ __metadata: languageName: node linkType: hard -"@sentry/types@npm:9.12.0": - version: 9.12.0 - resolution: "@sentry/types@npm:9.12.0" +"@sentry/types@npm:9.22.0": + version: 9.22.0 + resolution: "@sentry/types@npm:9.22.0" dependencies: - "@sentry/core": 9.12.0 - checksum: 3cbb403828014e5aea7b92ebb9e3dc7c14d4e6bea0f3e0a54b26f33ddd5e68b457c5a217c9db055857202475a380d0a2733cbe24c2727faa2be48a4e12395512 + "@sentry/core": 9.22.0 + checksum: 2348ba125fe413d9c163fb1b580ea805f721d505a3beb143a908da0765bfa74ea5455a7a34ab4a5ec744b9af37aa5661f77789a6d4afeb6dd6cab94fd0b5675e languageName: node linkType: hard @@ -14703,12 +14703,12 @@ __metadata: languageName: node linkType: hard -"eslint-plugin-simple-import-sort@npm:^5.0.3": - version: 5.0.3 - resolution: "eslint-plugin-simple-import-sort@npm:5.0.3" +"eslint-plugin-simple-import-sort@npm:^6.0.0": + version: 6.0.1 + resolution: "eslint-plugin-simple-import-sort@npm:6.0.1" peerDependencies: eslint: ">=5.0.0" - checksum: 51d62b5f709aafd5e301cb709753d90e4fb11ac97bdd480f578282a2fe90704f3618294864a9e8585f7803b39d12adfbc6fe3e5b271ddc42ab9aa48585401736 + checksum: 8ad71b877d7a602a10bc0e1284aaccae73b6d19e33b76dc7b8f8bb44bff5d17199036a66d5ca6658665f2ec48686646a6f3269c95a2db023bf915240ee91e48e languageName: node linkType: hard @@ -25481,7 +25481,7 @@ __metadata: dependencies: "@babel/preset-env": ^7.25.3 "@babel/preset-typescript": ^7.18.6 - "@sentry/core": 9.12.0 + "@sentry/core": 9.22.0 "@sentry/react-native": 7.0.0-alpha.0 "@types/node": ^20.9.3 "@types/react": ^18.2.64 @@ -25549,8 +25549,8 @@ __metadata: "@react-navigation/bottom-tabs": ^6.5.12 "@react-navigation/native": ^6.1.9 "@react-navigation/stack": ^6.3.20 - "@sentry/core": 9.12.0 - "@sentry/react": 9.12.0 + "@sentry/core": 9.22.0 + "@sentry/react": 9.22.0 "@sentry/react-native": 7.0.0-alpha.0 "@types/react": ^18.2.65 "@types/react-native-vector-icons": ^6.4.18 @@ -25597,7 +25597,7 @@ __metadata: "@react-navigation/native-stack": ^7.2.0 "@react-navigation/stack": ^7.1.1 "@sentry/babel-plugin-component-annotate": 3.4.0 - "@sentry/core": 9.12.0 + "@sentry/core": 9.22.0 "@sentry/react-native": 7.0.0-alpha.0 "@shopify/flash-list": ^1.7.3 "@types/jest": ^29.5.14 From e171ea380fda5352de556a538ba749b63e1ddff9 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Tue, 27 May 2025 17:56:23 +0200 Subject: [PATCH 27/64] feat(replay): Allow using browserReplayIntegration without isWeb guard (#4858) --- CHANGELOG.md | 8 ++- packages/core/src/js/replay/browserReplay.ts | 42 +++++++++++++- packages/core/src/js/replay/mobilereplay.ts | 6 -- .../core/src/js/replay/replayInterface.ts | 57 +++++++++++++++++++ .../core/test/replay/browserReplay.test.ts | 24 ++++++++ samples/expo/app/_layout.tsx | 13 +++-- 6 files changed, 136 insertions(+), 14 deletions(-) create mode 100644 packages/core/src/js/replay/replayInterface.ts create mode 100644 packages/core/test/replay/browserReplay.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 580784c539..61ca5d02cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ ## Unreleased +### Changes + +- Use `Replay` interface for `browserReplayIntegration` return type ([#4858](https://github.com/getsentry/sentry-react-native/pull/4858)) +- Allow using `browserReplayIntegration` without `isWeb` guard ([#4858](https://github.com/getsentry/sentry-react-native/pull/4858)) + - The integration returns noop in non-browser environments + ### Dependencies - Bump JavaScript SDK from v9.12.0 to v9.22.0 ([#4860](https://github.com/getsentry/sentry-react-native/pull/4860)) @@ -65,7 +71,7 @@ Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or hi - Fork `scope` if custom scope is passed to `startSpanManual` or `startSpan` - On React Native Web, `browserSessionIntegration` is added when `enableAutoSessionTracking` is set to `True` ([#4732](https://github.com/getsentry/sentry-react-native/pull/4732)) -Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](https://github.com/getsentry/sentry-react-native/pull/4636)) +- Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](https://github.com/getsentry/sentry-react-native/pull/4636)) ### Dependencies diff --git a/packages/core/src/js/replay/browserReplay.ts b/packages/core/src/js/replay/browserReplay.ts index b72c0be69f..a918b7e8f1 100644 --- a/packages/core/src/js/replay/browserReplay.ts +++ b/packages/core/src/js/replay/browserReplay.ts @@ -1,8 +1,30 @@ import { replayIntegration } from '@sentry/react'; -const browserReplayIntegration = ( - options: Parameters[0] = {}, -): ReturnType => { +import { notWeb } from '../utils/environment'; +import type { Replay } from './replayInterface'; + +/** + * ReplayConfiguration for browser replay integration. + * + * See the [Configuration documentation](https://docs.sentry.io/platforms/javascript/session-replay/configuration/) for more information. + */ +type ReplayConfiguration = Parameters[0]; + +// https://github.com/getsentry/sentry-javascript/blob/e00cb04f1bbf494067cd8475d392266ba296987a/packages/replay-internal/src/integration.ts#L109 +const INTEGRATION_NAME = 'Replay'; + +/** + * Browser Replay integration for React Native. + * + * See the [Browser Replay documentation](https://docs.sentry.io/platforms/javascript/session-replay/) for more information. + */ +const browserReplayIntegration = (options: ReplayConfiguration = {}): Replay => { + if (notWeb()) { + // This is required because `replayIntegration` browser check doesn't + // work for React Native. + return browserReplayIntegrationNoop(); + } + return replayIntegration({ ...options, mask: ['.sentry-react-native-mask', ...(options.mask || [])], @@ -10,4 +32,18 @@ const browserReplayIntegration = ( }); }; +const browserReplayIntegrationNoop = (): Replay => { + return { + name: INTEGRATION_NAME, + // eslint-disable-next-line @typescript-eslint/no-empty-function + start: () => {}, + // eslint-disable-next-line @typescript-eslint/no-empty-function + startBuffering: () => {}, + stop: () => Promise.resolve(), + flush: () => Promise.resolve(), + getReplayId: () => undefined, + getRecordingMode: () => undefined, + }; +}; + export { browserReplayIntegration }; diff --git a/packages/core/src/js/replay/mobilereplay.ts b/packages/core/src/js/replay/mobilereplay.ts index dcb1eaf245..f430614054 100644 --- a/packages/core/src/js/replay/mobilereplay.ts +++ b/packages/core/src/js/replay/mobilereplay.ts @@ -149,9 +149,6 @@ export const mobileReplayIntegration = (initOptions: MobileReplayOptions = defau // https://github.com/getsentry/sentry-javascript/blob/develop/packages/replay-internal/src/integration.ts#L45 return { name: MOBILE_REPLAY_INTEGRATION_NAME, - setupOnce() { - /* Noop */ - }, setup, processEvent, options: options, @@ -161,9 +158,6 @@ export const mobileReplayIntegration = (initOptions: MobileReplayOptions = defau const mobileReplayIntegrationNoop = (): MobileReplayIntegration => { return { name: MOBILE_REPLAY_INTEGRATION_NAME, - setupOnce() { - /* Noop */ - }, options: defaultOptions, }; }; diff --git a/packages/core/src/js/replay/replayInterface.ts b/packages/core/src/js/replay/replayInterface.ts new file mode 100644 index 0000000000..0308a5a385 --- /dev/null +++ b/packages/core/src/js/replay/replayInterface.ts @@ -0,0 +1,57 @@ +import type { Integration, ReplayRecordingMode } from '@sentry/core'; + +// Based on Replay Class https://github.com/getsentry/sentry-javascript/blob/e00cb04f1bbf494067cd8475d392266ba296987a/packages/replay-internal/src/integration.ts#L50 + +/** + * Common interface for React Native Replay integrations. + * + * Both browser and mobile replay integrations should implement this interface + * to allow user manually control the replay. + */ +export interface Replay extends Integration { + /** + * Start a replay regardless of sampling rate. Calling this will always + * create a new session. Will log a message if replay is already in progress. + * + * Creates or loads a session, attaches listeners to varying events (DOM, + * PerformanceObserver, Recording, Sentry SDK, etc) + */ + start(): void; + + /** + * Start replay buffering. Buffers until `flush()` is called or, if + * `replaysOnErrorSampleRate` > 0, until an error occurs. + */ + startBuffering(): void; + + /** + * Currently, this needs to be manually called (e.g. for tests). Sentry SDK + * does not support a teardown + */ + stop(): Promise; + + /** + * If not in "session" recording mode, flush event buffer which will create a new replay. + * If replay is not enabled, a new session replay is started. + * Unless `continueRecording` is false, the replay will continue to record and + * behave as a "session"-based replay. + * + * Otherwise, queue up a flush. + */ + flush(options?: { continueRecording?: boolean }): Promise; + + /** + * Get the current session ID. + */ + getReplayId(): string | undefined; + + /** + * Get the current recording mode. This can be either `session` or `buffer`. + * + * `session`: Recording the whole session, sending it continuously + * `buffer`: Always keeping the last 60s of recording, requires: + * - having replaysOnErrorSampleRate > 0 to capture replay when an error occurs + * - or calling `flush()` to send the replay + */ + getRecordingMode(): ReplayRecordingMode | undefined; +} diff --git a/packages/core/test/replay/browserReplay.test.ts b/packages/core/test/replay/browserReplay.test.ts new file mode 100644 index 0000000000..be12c27e21 --- /dev/null +++ b/packages/core/test/replay/browserReplay.test.ts @@ -0,0 +1,24 @@ +import { describe, test } from '@jest/globals'; +import * as SentryReact from '@sentry/react'; +import { spyOn } from 'jest-mock'; + +import { browserReplayIntegration } from '../../src/js/replay/browserReplay'; +import * as environment from '../../src/js/utils/environment'; + +describe('Browser Replay', () => { + afterEach(() => { + jest.clearAllMocks(); + }); + + test('should not call replayIntegration if not web', () => { + spyOn(environment, 'notWeb').mockReturnValue(true); + spyOn(SentryReact, 'replayIntegration').mockImplementation(() => { + throw new Error('replayIntegration should not be called'); + }); + + const integration = browserReplayIntegration(); + + expect(integration).toBeDefined(); + expect(SentryReact.replayIntegration).not.toHaveBeenCalled(); + }); +}); diff --git a/samples/expo/app/_layout.tsx b/samples/expo/app/_layout.tsx index b3836cf6d3..f8a06db99f 100644 --- a/samples/expo/app/_layout.tsx +++ b/samples/expo/app/_layout.tsx @@ -10,7 +10,6 @@ import * as Sentry from '@sentry/react-native'; import { ErrorEvent } from '@sentry/core'; import { isExpoGo } from '../utils/isExpoGo'; import { LogBox } from 'react-native'; -import { isWeb } from '../utils/isWeb'; import * as ImagePicker from 'expo-image-picker'; export { @@ -58,13 +57,19 @@ Sentry.init({ }), navigationIntegration, Sentry.reactNativeTracingIntegration(), + Sentry.mobileReplayIntegration({ + maskAllImages: true, + maskAllText: true, + maskAllVectors: true, + }), + Sentry.browserReplayIntegration({ + maskAllInputs: true, + maskAllText: true, + }), Sentry.feedbackIntegration({ imagePicker: ImagePicker, }), ); - if (isWeb()) { - integrations.push(Sentry.browserReplayIntegration()); - } return integrations.filter(i => i.name !== 'Dedupe'); }, enableAutoSessionTracking: true, From 6a8b747dcef73cf48a0557706081a66c1269c285 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Wed, 28 May 2025 11:01:46 +0200 Subject: [PATCH 28/64] fix(lint): In `browserReplay.ts` --- packages/core/src/js/replay/browserReplay.ts | 1 - packages/core/test/replay/browserReplay.test.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/core/src/js/replay/browserReplay.ts b/packages/core/src/js/replay/browserReplay.ts index a918b7e8f1..f316e42d57 100644 --- a/packages/core/src/js/replay/browserReplay.ts +++ b/packages/core/src/js/replay/browserReplay.ts @@ -1,5 +1,4 @@ import { replayIntegration } from '@sentry/react'; - import { notWeb } from '../utils/environment'; import type { Replay } from './replayInterface'; diff --git a/packages/core/test/replay/browserReplay.test.ts b/packages/core/test/replay/browserReplay.test.ts index be12c27e21..7914c08f62 100644 --- a/packages/core/test/replay/browserReplay.test.ts +++ b/packages/core/test/replay/browserReplay.test.ts @@ -1,7 +1,6 @@ import { describe, test } from '@jest/globals'; import * as SentryReact from '@sentry/react'; import { spyOn } from 'jest-mock'; - import { browserReplayIntegration } from '../../src/js/replay/browserReplay'; import * as environment from '../../src/js/utils/environment'; From c5ee1b6ff48fc2a733105006d7366726ab794f6a Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Wed, 28 May 2025 11:55:33 +0200 Subject: [PATCH 29/64] !remove(sdk): Delete deprecated `captureUserFeedback` (#4855) * !remove(sdk): Delete deprecated `captureUserFeedback` * fix changelog * fix unused imports --- CHANGELOG.md | 4 ++++ packages/core/src/js/index.ts | 2 +- packages/core/src/js/sdk.tsx | 28 ++++++++++++---------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61ca5d02cb..2e286bd56c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ ## Unreleased +### Major Changes + +- `Sentry.captureUserFeedback` removed, use `Sentry.captureFeedback` instead ([#4855](https://github.com/getsentry/sentry-react-native/pull/4855)) + ### Changes - Use `Replay` interface for `browserReplayIntegration` return type ([#4858](https://github.com/getsentry/sentry-react-native/pull/4858)) diff --git a/packages/core/src/js/index.ts b/packages/core/src/js/index.ts index fb931312d9..f5de2fd307 100644 --- a/packages/core/src/js/index.ts +++ b/packages/core/src/js/index.ts @@ -60,7 +60,7 @@ export { SDK_NAME, SDK_VERSION } from './version'; export type { ReactNativeOptions } from './options'; export { ReactNativeClient } from './client'; -export { init, wrap, nativeCrash, flush, close, captureUserFeedback, withScope, crashedLastRun } from './sdk'; +export { init, wrap, nativeCrash, flush, close, withScope, crashedLastRun } from './sdk'; export { TouchEventBoundary, withTouchEventBoundary } from './touchevents'; export { diff --git a/packages/core/src/js/sdk.tsx b/packages/core/src/js/sdk.tsx index 657ec2db59..b0f2ad5704 100644 --- a/packages/core/src/js/sdk.tsx +++ b/packages/core/src/js/sdk.tsx @@ -1,6 +1,16 @@ /* eslint-disable complexity */ -import type { Breadcrumb, BreadcrumbHint, Integration, Scope, SendFeedbackParams, UserFeedback } from '@sentry/core'; -import { captureFeedback, getClient, getGlobalScope, getIntegrationsToSetup, getIsolationScope, initAndBind, logger, makeDsn, stackParserFromStackParserOptions, withScope as coreWithScope } from '@sentry/core'; +import type { Breadcrumb, BreadcrumbHint, Integration, Scope } from '@sentry/core'; +import { + getClient, + getGlobalScope, + getIntegrationsToSetup, + getIsolationScope, + initAndBind, + logger, + makeDsn, + stackParserFromStackParserOptions, + withScope as coreWithScope, +} from '@sentry/core'; import { defaultStackParser, makeFetchTransport, @@ -219,20 +229,6 @@ export async function close(): Promise { } } -/** - * Captures user feedback and sends it to Sentry. - * @deprecated Use `Sentry.captureFeedback` instead. - */ -export function captureUserFeedback(feedback: UserFeedback): void { - const feedbackParams: SendFeedbackParams = { - name: feedback.name, - email: feedback.email, - message: feedback.comments, - associatedEventId: feedback.event_id, - }; - captureFeedback(feedbackParams); -} - /** * Creates a new scope with and executes the given operation within. * The scope is automatically removed once the operation From 68bffee21d6306069492df419cf115ea8d0bd449 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Wed, 28 May 2025 12:56:38 +0300 Subject: [PATCH 30/64] chore(deps): v7: update Android SDK to v8.13.2 (#4867) * chore(deps): v7: update Android SDK to v8.13.2 * Fixes lint issues --- CHANGELOG.md | 6 +++--- packages/core/android/build.gradle | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e286bd56c..48a67bee2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,9 +26,9 @@ - Bump Cocoa SDK from v8.50.2 to v8.51.1 ([#4843](https://github.com/getsentry/sentry-react-native/pull/4843)) - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8511) - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.50.0...8.51.1) -- Bump Android SDK from v8.11.1 to v8.13.1 ([#4847](https://github.com/getsentry/sentry-react-native/pull/4847)) - - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8131) - - [diff](https://github.com/getsentry/sentry-java/compare/8.11.1...8.13.1) +- Bump Android SDK from v8.11.1 to v8.13.2 ([#4847](https://github.com/getsentry/sentry-react-native/pull/4847)) + - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8132) + - [diff](https://github.com/getsentry/sentry-java/compare/8.11.1...8.13.2) ## 7.0.0-alpha.0 diff --git a/packages/core/android/build.gradle b/packages/core/android/build.gradle index 8c48b3782a..3bc110cf07 100644 --- a/packages/core/android/build.gradle +++ b/packages/core/android/build.gradle @@ -54,5 +54,5 @@ android { dependencies { implementation 'com.facebook.react:react-native:+' - api 'io.sentry:sentry-android:8.13.1' + api 'io.sentry:sentry-android:8.13.2' } From bea86b01a38659f3017bfd80a5d655745a0ab215 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Tue, 3 Jun 2025 14:34:55 +0200 Subject: [PATCH 31/64] chore(encoding): Use global `TextEncode` when available (#4874) --- CHANGELOG.md | 1 + .../core/src/js/transports/encodePolyfill.ts | 27 ++++++++++++--- packages/core/src/js/utils/carrier.ts | 13 ++++++++ packages/core/src/js/utils/worldwide.ts | 5 +-- .../test/transports/encodePolyfill.test.ts | 33 +++++++++++++++++++ 5 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 packages/core/src/js/utils/carrier.ts create mode 100644 packages/core/test/transports/encodePolyfill.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 098e8909b9..2680686597 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ ### Major Changes - `Sentry.captureUserFeedback` removed, use `Sentry.captureFeedback` instead ([#4855](https://github.com/getsentry/sentry-react-native/pull/4855)) +- Use global `TextEncoder` (available with Hermes in React Native 0.74 or higher) to greatly improve envelope encoding performance. ([#4874](https://github.com/getsentry/sentry-react-native/pull/4874)) ### Changes diff --git a/packages/core/src/js/transports/encodePolyfill.ts b/packages/core/src/js/transports/encodePolyfill.ts index 3075ad6b92..44aad44f6a 100644 --- a/packages/core/src/js/transports/encodePolyfill.ts +++ b/packages/core/src/js/transports/encodePolyfill.ts @@ -1,13 +1,30 @@ -import { getMainCarrier, SDK_VERSION } from '@sentry/core'; +import { getSentryCarrier } from '../utils/carrier'; +import { RN_GLOBAL_OBJ } from '../utils/worldwide'; import { utf8ToBytes } from '../vendor'; export const useEncodePolyfill = (): void => { - // Based on https://github.com/getsentry/sentry-javascript/blob/f0fc41f6166857cd97a695f5cc9a18caf6a0bf43/packages/core/src/carrier.ts#L49 - const carrier = getMainCarrier(); - const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {}); - (__SENTRY__[SDK_VERSION] = __SENTRY__[SDK_VERSION] || {}).encodePolyfill = encodePolyfill; + const carrier = getSentryCarrier(); + + if (RN_GLOBAL_OBJ.TextEncoder) { + // Hermes for RN 0.74 and later includes native TextEncoder + // https://github.com/facebook/hermes/commit/8fb0496d426a8e50d00385148d5fb498a6daa312 + carrier.encodePolyfill = globalEncodeFactory(RN_GLOBAL_OBJ.TextEncoder); + } else { + carrier.encodePolyfill = encodePolyfill; + } }; +/* + * The default encode polyfill is available in Hermes for RN 0.74 and later. + * https://github.com/facebook/hermes/commit/8fb0496d426a8e50d00385148d5fb498a6daa312 + */ +export const globalEncodeFactory = (Encoder: EncoderClass) => (text: string) => new Encoder().encode(text); + +type EncoderClass = Required['TextEncoder']; + +/* + * Encode polyfill runs in JS and might cause performance issues when processing large payloads. (~2+ MB) + */ export const encodePolyfill = (text: string): Uint8Array => { const bytes = new Uint8Array(utf8ToBytes(text)); return bytes; diff --git a/packages/core/src/js/utils/carrier.ts b/packages/core/src/js/utils/carrier.ts new file mode 100644 index 0000000000..707e33ae78 --- /dev/null +++ b/packages/core/src/js/utils/carrier.ts @@ -0,0 +1,13 @@ +import { getMainCarrier, SDK_VERSION as CORE_SDK_VERSION } from '@sentry/core'; + +/* + * Will either get the existing sentry carrier, or create a new one. + * Based on https://github.com/getsentry/sentry-javascript/blob/f0fc41f6166857cd97a695f5cc9a18caf6a0bf43/packages/core/src/carrier.ts#L49 + */ +export const getSentryCarrier = (): SentryCarrier => { + const carrier = getMainCarrier(); + const __SENTRY__ = (carrier.__SENTRY__ = carrier.__SENTRY__ || {}); + return (__SENTRY__[CORE_SDK_VERSION] = __SENTRY__[CORE_SDK_VERSION] || {}); +}; + +type SentryCarrier = Required>['__SENTRY__'][string]; diff --git a/packages/core/src/js/utils/worldwide.ts b/packages/core/src/js/utils/worldwide.ts index e362f2896e..1245657724 100644 --- a/packages/core/src/js/utils/worldwide.ts +++ b/packages/core/src/js/utils/worldwide.ts @@ -36,8 +36,9 @@ export interface ReactNativeInternalGlobal extends InternalGlobal { } type TextEncoder = { - new (): TextEncoder; - encode(input?: string): Uint8Array; + new (): { + encode(input?: string): Uint8Array; + }; }; /** Get's the global object for the current JavaScript runtime */ diff --git a/packages/core/test/transports/encodePolyfill.test.ts b/packages/core/test/transports/encodePolyfill.test.ts new file mode 100644 index 0000000000..6bc319f97f --- /dev/null +++ b/packages/core/test/transports/encodePolyfill.test.ts @@ -0,0 +1,33 @@ +import { SDK_VERSION } from '@sentry/core'; +import { encodePolyfill, useEncodePolyfill } from '../../src/js/transports/encodePolyfill'; +import { RN_GLOBAL_OBJ } from '../../src/js/utils/worldwide'; + +const OriginalTextEncoder = RN_GLOBAL_OBJ.TextEncoder; + +const restoreTextEncoder = (): void => { + RN_GLOBAL_OBJ.TextEncoder = OriginalTextEncoder; +}; + +describe('useEncodePolyfill', () => { + afterEach(() => { + restoreTextEncoder(); + }); + + test('should use global encode factory if TextEncoder is available', () => { + RN_GLOBAL_OBJ.TextEncoder = MockedTextEncoder; + useEncodePolyfill(); + expect(RN_GLOBAL_OBJ.__SENTRY__?.[SDK_VERSION]?.encodePolyfill?.('')).toEqual(new Uint8Array([1, 2, 3])); + }); + + test('should use encode polyfill if TextEncoder is not available', () => { + RN_GLOBAL_OBJ.TextEncoder = undefined; + useEncodePolyfill(); + expect(RN_GLOBAL_OBJ.__SENTRY__?.[SDK_VERSION]?.encodePolyfill).toBe(encodePolyfill); + }); +}); + +class MockedTextEncoder { + public encode(_text: string): Uint8Array { + return new Uint8Array([1, 2, 3]); + } +} From 78c414fcce8049ffedbb38cd6b30fb4edfc60c00 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Wed, 4 Jun 2025 10:12:31 +0200 Subject: [PATCH 32/64] chore(utils): Use single encodeUTF8 impl (#4885) --- CHANGELOG.md | 1 + packages/core/src/js/replay/networkUtils.ts | 16 ++++------------ packages/core/src/js/utils/encode.ts | 14 ++++++++++++++ packages/core/src/js/wrapper.ts | 13 +++++++------ 4 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 packages/core/src/js/utils/encode.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index f7a6d24f78..059f37ed97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ - Use `Replay` interface for `browserReplayIntegration` return type ([#4858](https://github.com/getsentry/sentry-react-native/pull/4858)) - Allow using `browserReplayIntegration` without `isWeb` guard ([#4858](https://github.com/getsentry/sentry-react-native/pull/4858)) - The integration returns noop in non-browser environments +- Use single `encodeUTF8` implementation through the SDK ([#4885](https://github.com/getsentry/sentry-react-native/pull/4885)) ### Fixes diff --git a/packages/core/src/js/replay/networkUtils.ts b/packages/core/src/js/replay/networkUtils.ts index 6834294b33..68493f25d0 100644 --- a/packages/core/src/js/replay/networkUtils.ts +++ b/packages/core/src/js/replay/networkUtils.ts @@ -1,5 +1,4 @@ -import { RN_GLOBAL_OBJ } from '../utils/worldwide'; -import { utf8ToBytes } from '../vendor'; +import { encodeUTF8 } from '../utils/encode'; /** Convert a Content-Length header to number/undefined. */ export function parseContentLengthHeader(header: string | null | undefined): number | undefined { @@ -21,16 +20,16 @@ export function getBodySize(body: RequestBody): number | undefined { try { if (typeof body === 'string') { - return _encode(body).length; + return encodeUTF8(body).length; } if (body instanceof URLSearchParams) { - return _encode(body.toString()).length; + return encodeUTF8(body.toString()).length; } if (body instanceof FormData) { const formDataStr = _serializeFormData(body); - return _encode(formDataStr).length; + return encodeUTF8(formDataStr).length; } if (body instanceof Blob) { @@ -49,13 +48,6 @@ export function getBodySize(body: RequestBody): number | undefined { return undefined; } -function _encode(input: string): number[] | Uint8Array { - if (RN_GLOBAL_OBJ.TextEncoder) { - return new RN_GLOBAL_OBJ.TextEncoder().encode(input); - } - return utf8ToBytes(input); -} - function _serializeFormData(formData: FormData): string { // This is a bit simplified, but gives us a decent estimate // This converts e.g. { name: 'Anne Smith', age: 13 } to 'name=Anne+Smith&age=13' diff --git a/packages/core/src/js/utils/encode.ts b/packages/core/src/js/utils/encode.ts new file mode 100644 index 0000000000..b1d2f2e189 --- /dev/null +++ b/packages/core/src/js/utils/encode.ts @@ -0,0 +1,14 @@ +import { useEncodePolyfill } from '../transports/encodePolyfill'; +import { getSentryCarrier } from './carrier'; + +/** + * Encode a string to UTF8 array. + */ +export function encodeUTF8(input: string): Uint8Array { + const carrier = getSentryCarrier(); + if (!carrier.encodePolyfill) { + useEncodePolyfill(); + } + + return carrier.encodePolyfill!(input); +} diff --git a/packages/core/src/js/wrapper.ts b/packages/core/src/js/wrapper.ts index 54f3cf6621..1caeab0eff 100644 --- a/packages/core/src/js/wrapper.ts +++ b/packages/core/src/js/wrapper.ts @@ -26,10 +26,11 @@ import type * as Hermes from './profiling/hermes'; import type { NativeAndroidProfileEvent, NativeProfileEvent } from './profiling/nativeTypes'; import type { MobileReplayOptions } from './replay/mobilereplay'; import type { RequiredKeysUser } from './user'; +import { encodeUTF8 } from './utils/encode'; import { isTurboModuleEnabled } from './utils/environment'; import { convertToNormalizedObject } from './utils/normalize'; import { ReactNativeLibraries } from './utils/rnlibraries'; -import { base64StringFromByteArray, utf8ToBytes } from './vendor'; +import { base64StringFromByteArray } from './vendor'; /** * Returns the RNSentry module. Dynamically resolves if NativeModule or TurboModule is used. @@ -128,7 +129,7 @@ interface SentryNativeWrapper { encodeToBase64(data: Uint8Array): Promise; } -const EOL = utf8ToBytes('\n'); +const EOL = encodeUTF8('\n'); /** * Our internal interface for calling native functions @@ -165,7 +166,7 @@ export const NATIVE: SentryNativeWrapper = { const [envelopeHeader, envelopeItems] = envelope; const headerString = JSON.stringify(envelopeHeader); - const headerBytes = utf8ToBytes(headerString); + const headerBytes = encodeUTF8(headerString); let envelopeBytes: Uint8Array = new Uint8Array(headerBytes.length + EOL.length); envelopeBytes.set(headerBytes); envelopeBytes.set(EOL, headerBytes.length); @@ -178,14 +179,14 @@ export const NATIVE: SentryNativeWrapper = { let bytesPayload: number[] | Uint8Array | undefined; if (typeof itemPayload === 'string') { bytesContentType = 'text/plain'; - bytesPayload = utf8ToBytes(itemPayload); + bytesPayload = encodeUTF8(itemPayload); } else if (itemPayload instanceof Uint8Array) { bytesContentType = typeof itemHeader.content_type === 'string' ? itemHeader.content_type : 'application/octet-stream'; bytesPayload = itemPayload; } else { bytesContentType = 'application/json'; - bytesPayload = utf8ToBytes(JSON.stringify(itemPayload)); + bytesPayload = encodeUTF8(JSON.stringify(itemPayload)); if (!hardCrashed) { hardCrashed = isHardCrash(itemPayload); } @@ -196,7 +197,7 @@ export const NATIVE: SentryNativeWrapper = { (itemHeader as BaseEnvelopeItemHeaders).length = bytesPayload.length; const serializedItemHeader = JSON.stringify(itemHeader); - const bytesItemHeader = utf8ToBytes(serializedItemHeader); + const bytesItemHeader = encodeUTF8(serializedItemHeader); const newBytes = new Uint8Array( envelopeBytes.length + bytesItemHeader.length + EOL.length + bytesPayload.length + EOL.length, ); From 936481d511639988914a3d27d9fcd83c82a14c1f Mon Sep 17 00:00:00 2001 From: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:39:02 +0200 Subject: [PATCH 33/64] feat(breadcrumbs): Add environment aware defaults for RN/Expo/Web (#4886) --- CHANGELOG.md | 1 + .../core/src/js/integrations/breadcrumbs.ts | 74 +++++++++++++++ packages/core/src/js/integrations/exports.ts | 2 +- .../test/integrations/breadcrumbs.test.ts | 89 +++++++++++++++++++ 4 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 packages/core/src/js/integrations/breadcrumbs.ts create mode 100644 packages/core/test/integrations/breadcrumbs.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 059f37ed97..00695ab9e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ - `Sentry.captureUserFeedback` removed, use `Sentry.captureFeedback` instead ([#4855](https://github.com/getsentry/sentry-react-native/pull/4855)) - Use global `TextEncoder` (available with Hermes in React Native 0.74 or higher) to greatly improve envelope encoding performance. ([#4874](https://github.com/getsentry/sentry-react-native/pull/4874)) +- `breadcrumbsIntegration` disables React Native incompatible options automatically ([#4886](https://github.com/getsentry/sentry-react-native/pull/4886)) ### Changes diff --git a/packages/core/src/js/integrations/breadcrumbs.ts b/packages/core/src/js/integrations/breadcrumbs.ts new file mode 100644 index 0000000000..da3b57eceb --- /dev/null +++ b/packages/core/src/js/integrations/breadcrumbs.ts @@ -0,0 +1,74 @@ +import { breadcrumbsIntegration as browserBreadcrumbsIntegration } from '@sentry/browser'; +import type { Integration } from '@sentry/core'; +import { isWeb } from '../utils/environment'; + +interface BreadcrumbsOptions { + /** + * Log calls to console.log, console.debug, and so on. + */ + console: boolean; + + /** + * Log all click and keypress events. + * + * Only available on web. In React Native this is a no-op. + */ + dom: + | boolean + | { + serializeAttribute?: string | string[]; + maxStringLength?: number; + }; + + /** + * Log HTTP requests done with the global Fetch API. + * + * Disabled by default in React Native because fetch is built on XMLHttpRequest. + * Enabled by default on web. + * + * Setting `fetch: true` and `xhr: true` will cause duplicates in React Native. + */ + fetch: boolean; + + /** + * Log calls to history.pushState and related APIs. + * + * Only available on web. In React Native this is a no-op. + */ + history: boolean; + + /** + * Log whenever we send an event to the server. + */ + sentry: boolean; + + /** + * Log HTTP requests done with the XHR API. + * + * Because React Native global fetch is built on XMLHttpRequest, + * this will also log `fetch` network requests. + * + * Setting `fetch: true` and `xhr: true` will cause duplicates in React Native. + */ + xhr: boolean; +} + +export const breadcrumbsIntegration = (options: Partial = {}): Integration => { + const _options: BreadcrumbsOptions = { + // FIXME: In mobile environment XHR is implemented by native APIs, which are instrumented by the Native SDK. + // This will cause duplicates in React Native. On iOS `NSURLSession` is instrumented by default. On Android + // `OkHttp` is only instrumented by SAGP. + xhr: true, + console: true, + sentry: true, + ...options, + fetch: options.fetch ?? (isWeb() ? true : false), + dom: isWeb() ? options.dom ?? true : false, + history: isWeb() ? options.history ?? true : false, + }; + + // Historically we had very little issue using the browser breadcrumbs integration + // and thus we don't cherry pick the implementation like for example the Sentry Deno SDK does. + // https://github.com/getsentry/sentry-javascript/blob/d007407c2e51d93d6d3933f9dea1e03ff3f4a4ab/packages/deno/src/integrations/breadcrumbs.ts#L34 + return browserBreadcrumbsIntegration(_options); +}; diff --git a/packages/core/src/js/integrations/exports.ts b/packages/core/src/js/integrations/exports.ts index e87a88c615..a1b54de361 100644 --- a/packages/core/src/js/integrations/exports.ts +++ b/packages/core/src/js/integrations/exports.ts @@ -22,9 +22,9 @@ export { userInteractionIntegration } from '../tracing/integrations/userInteract export { createReactNativeRewriteFrames } from './rewriteframes'; export { appRegistryIntegration } from './appRegistry'; export { timeToDisplayIntegration } from '../tracing/integrations/timeToDisplayIntegration'; +export { breadcrumbsIntegration } from './breadcrumbs'; export { - breadcrumbsIntegration, browserApiErrorsIntegration, dedupeIntegration, functionToStringIntegration, diff --git a/packages/core/test/integrations/breadcrumbs.test.ts b/packages/core/test/integrations/breadcrumbs.test.ts new file mode 100644 index 0000000000..e7105667fe --- /dev/null +++ b/packages/core/test/integrations/breadcrumbs.test.ts @@ -0,0 +1,89 @@ +import { breadcrumbsIntegration as browserBreadcrumbsIntegration } from '@sentry/browser'; +import { breadcrumbsIntegration } from '../../src/js/integrations/breadcrumbs'; +import * as environment from '../../src/js/utils/environment'; + +jest.mock('@sentry/browser', () => ({ + breadcrumbsIntegration: jest.fn(), +})); + +describe('breadcrumbsIntegration', () => { + afterEach(() => { + jest.resetAllMocks(); + }); + + it('passes React Native defaults to browserBreadcrumbsIntegration', () => { + jest.spyOn(environment, 'isWeb').mockReturnValue(false); + + breadcrumbsIntegration(); + + expect(browserBreadcrumbsIntegration).toHaveBeenCalledWith({ + xhr: true, + console: true, + sentry: true, + dom: false, // DOM is not available in React Native + fetch: false, // fetch is built on XMLHttpRequest in React Native + history: false, // history is not available in React Native + }); + }); + + it('passes web defaults to browserBreadcrumbsIntegration when isWeb returns true', () => { + jest.spyOn(environment, 'isWeb').mockReturnValue(true); + + breadcrumbsIntegration(); + + expect(browserBreadcrumbsIntegration).toHaveBeenCalledWith({ + // Everything is enabled by default on web + xhr: true, + console: true, + sentry: true, + dom: true, + fetch: true, + history: true, + }); + }); + + it('respects custom options React Native options', () => { + jest.spyOn(environment, 'isWeb').mockReturnValue(false); + + breadcrumbsIntegration({ + xhr: false, + console: false, + sentry: false, + dom: {}, // Integration should not let user enable DOM breadcrumbs on React Native + fetch: true, // If user enables it, we should log fetch requests + history: true, // Integration should not let user enable history breadcrumbs on React Native + }); + + expect(browserBreadcrumbsIntegration).toHaveBeenCalledWith({ + xhr: false, + console: false, + sentry: false, + dom: false, + fetch: true, + history: false, + }); + }); + + it('respects custom options when isWeb returns true', () => { + jest.spyOn(environment, 'isWeb').mockReturnValue(true); + + breadcrumbsIntegration({ + // Everything can be disabled on web + xhr: false, + console: false, + sentry: false, + dom: false, + fetch: false, + history: false, + }); + + expect(browserBreadcrumbsIntegration).toHaveBeenCalledWith({ + xhr: false, + console: false, + sentry: false, + dom: false, + fetch: false, + history: false, + }); + }); +}); From 513afd603deb947d01d4e72386c2dd899404d45e Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Thu, 5 Jun 2025 10:40:15 +0200 Subject: [PATCH 34/64] Update change for beta.0 --- CHANGELOG.md | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c982ec22..1b49090261 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,11 +8,42 @@ ## Unreleased +### Upgrading from 6.x to 7.0 + +Version 7 of the Sentry React Native SDK primarily introduces API cleanup and version support changes based on the Sentry Javascript SDK version 9. This update contains behavioral changes that will not be caught by type checkers, linters, or tests, so we recommend carefully reading through the entire migration guide instead of relying on automatic tooling. + +Version 7 of the SDK is compatible with Sentry self-hosted versions 24.4.2 or higher (unchanged from v6). Lower versions may continue to work, but may not support all features. + ### Major Changes +- Set `{{auto}}` if `user.ip_address` is `undefined` and `sendDefaultPii: true` ([#4466](https://github.com/getsentry/sentry-react-native/pull/4466)) - `Sentry.captureUserFeedback` removed, use `Sentry.captureFeedback` instead ([#4855](https://github.com/getsentry/sentry-react-native/pull/4855)) -- Use global `TextEncoder` (available with Hermes in React Native 0.74 or higher) to improve envelope encoding performance. ([#4874](https://github.com/getsentry/sentry-react-native/pull/4874)) -- `breadcrumbsIntegration` disables React Native incompatible options automatically ([#4886](https://github.com/getsentry/sentry-react-native/pull/4886)) + +### Major Changes from Sentry JS SDK v9 + +- Exceptions from `captureConsoleIntegration` are now marked as handled: true by default +- `shutdownTimeout` moved from `core` to `@sentry/react-native` +- `hasTracingEnabled` was renamed to `hasSpansEnabled` +- You can no longer drop spans or return null on `beforeSendSpan` hook +- Fork `scope` if custom scope is passed to `startSpanManual` or `startSpan` + +#### Removed types + +- TransactionNamingScheme +- Request +- Scope (prefer using the Scope class) + +#### Other removed items. + +- `autoSessionTracking` from options. + To enable session tracking, ensure that `enableAutoSessionTracking` is enabled. +- `enableTracing`. Instead, set `tracesSampleRate` to a value greater than `zero` to `enable tracing`, `0` to keep tracing integrations active without sampling, or `undefined` to disable the performance integration. +- `getCurrentHub()`, `Hub`, and `getCurrentHubShim()` +- `spanId` from propagation `context` +- metrics API +- `transactionContext` from `samplingContext` +- `@sentry/utils` package, the exports were moved to `@sentry/core` +- Standalone `Client` interface & deprecate `BaseClient` ### Changes @@ -20,15 +51,19 @@ - Allow using `browserReplayIntegration` without `isWeb` guard ([#4858](https://github.com/getsentry/sentry-react-native/pull/4858)) - The integration returns noop in non-browser environments - Use single `encodeUTF8` implementation through the SDK ([#4885](https://github.com/getsentry/sentry-react-native/pull/4885)) +- Use global `TextEncoder` (available with Hermes in React Native 0.74 or higher) to improve envelope encoding performance. ([#4874](https://github.com/getsentry/sentry-react-native/pull/4874)) +- `breadcrumbsIntegration` disables React Native incompatible options automatically ([#4886](https://github.com/getsentry/sentry-react-native/pull/4886)) +- On React Native Web, `browserSessionIntegration` is added when `enableAutoSessionTracking` is set to `True` ([#4732](https://github.com/getsentry/sentry-react-native/pull/4732)) +- Change `Cold/Warm App Start` span description to `Cold/Warm Start` ([#4636](https://github.com/getsentry/sentry-react-native/pull/4636)) ### Dependencies -- Bump JavaScript SDK from v9.12.0 to v9.22.0 ([#4860](https://github.com/getsentry/sentry-react-native/pull/4860)) +- Bump JavaScript SDK from v8.54.0 to v9.22.0 ([#4568](https://github.com/getsentry/sentry-react-native/pull/4568), [#4752](https://github.com/getsentry/sentry-react-native/pull/4752), [#4860](https://github.com/getsentry/sentry-react-native/pull/4860)) - [changelog](https://github.com/getsentry/sentry-javascript/blob/9.22.0/CHANGELOG.md) - - [diff](https://github.com/getsentry/sentry-javascript/compare/9.12.0...9.22.0) -- Bump Android SDK from v8.11.1 to v8.13.2 ([#4847](https://github.com/getsentry/sentry-react-native/pull/4847)) + - [diff](https://github.com/getsentry/sentry-javascript/compare/8.54.0...9.22.0) +- Bump Android SDK from v7.20.1 to v8.13.2 ([#4490](https://github.com/getsentry/sentry-react-native/pull/4490), [#4847](https://github.com/getsentry/sentry-react-native/pull/4847)) - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#8132) - - [diff](https://github.com/getsentry/sentry-java/compare/8.11.1...8.13.2) + - [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.13.2) ## 6.15.0 From 4c79e385eac21c4fb0241f40c7f67085d540372c Mon Sep 17 00:00:00 2001 From: getsentry-bot Date: Thu, 5 Jun 2025 09:55:22 +0000 Subject: [PATCH 35/64] release: 7.0.0-beta.0 --- CHANGELOG.md | 2 +- dev-packages/e2e-tests/package.json | 4 ++-- dev-packages/type-check/package.json | 2 +- dev-packages/utils/package.json | 2 +- lerna.json | 4 ++-- .../main/java/io/sentry/react/RNSentryVersion.java | 2 +- packages/core/ios/RNSentryVersion.m | 2 +- packages/core/package.json | 2 +- packages/core/src/js/version.ts | 2 +- performance-tests/TestAppPlain/package.json | 2 +- performance-tests/TestAppSentry/package.json | 4 ++-- samples/expo/app.json | 8 ++++---- samples/expo/package.json | 4 ++-- samples/react-native-macos/package.json | 4 ++-- samples/react-native/android/app/build.gradle | 4 ++-- .../ios/sentryreactnativesample/Info.plist | 2 +- .../ios/sentryreactnativesampleTests/Info.plist | 2 +- samples/react-native/package.json | 4 ++-- yarn.lock | 12 ++++++------ 19 files changed, 34 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b49090261..f71f992a2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ > make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first. -## Unreleased +## 7.0.0-beta.0 ### Upgrading from 6.x to 7.0 diff --git a/dev-packages/e2e-tests/package.json b/dev-packages/e2e-tests/package.json index 38c1cfa8aa..7abb1f21b2 100644 --- a/dev-packages/e2e-tests/package.json +++ b/dev-packages/e2e-tests/package.json @@ -1,6 +1,6 @@ { "name": "sentry-react-native-e2e-tests", - "version": "7.0.0-alpha.0", + "version": "7.0.0-beta.0", "private": true, "description": "Sentry React Native End to End Tests Library", "main": "dist/index.js", @@ -14,7 +14,7 @@ "@babel/preset-env": "^7.25.3", "@babel/preset-typescript": "^7.18.6", "@sentry/core": "9.22.0", - "@sentry/react-native": "7.0.0-alpha.0", + "@sentry/react-native": "7.0.0-beta.0", "@types/node": "^20.9.3", "@types/react": "^18.2.64", "appium": "2.4.1", diff --git a/dev-packages/type-check/package.json b/dev-packages/type-check/package.json index 0a581efbaf..31973ec2ba 100644 --- a/dev-packages/type-check/package.json +++ b/dev-packages/type-check/package.json @@ -1,7 +1,7 @@ { "name": "sentry-react-native-type-check", "private": true, - "version": "7.0.0-alpha.0", + "version": "7.0.0-beta.0", "scripts": { "type-check": "./run-type-check.sh" } diff --git a/dev-packages/utils/package.json b/dev-packages/utils/package.json index eed21edba6..0b32c1eee1 100644 --- a/dev-packages/utils/package.json +++ b/dev-packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "sentry-react-native-samples-utils", - "version": "7.0.0-alpha.0", + "version": "7.0.0-beta.0", "description": "Internal Samples Utils", "main": "index.js", "license": "MIT", diff --git a/lerna.json b/lerna.json index 98dab3cf08..800ed875ae 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "7.0.0-alpha.0", + "version": "7.0.0-beta.0", "packages": [ "packages/*", "dev-packages/*", @@ -8,4 +8,4 @@ "performance-tests/*" ], "npmClient": "yarn" -} +} \ No newline at end of file diff --git a/packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java b/packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java index d2d288ece5..6fd42bfb94 100644 --- a/packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java +++ b/packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java @@ -2,7 +2,7 @@ class RNSentryVersion { static final String REACT_NATIVE_SDK_PACKAGE_NAME = "npm:@sentry/react-native"; - static final String REACT_NATIVE_SDK_PACKAGE_VERSION = "7.0.0-alpha.0"; + static final String REACT_NATIVE_SDK_PACKAGE_VERSION = "7.0.0-beta.0"; static final String NATIVE_SDK_NAME = "sentry.native.android.react-native"; static final String ANDROID_SDK_NAME = "sentry.java.android.react-native"; static final String REACT_NATIVE_SDK_NAME = "sentry.javascript.react-native"; diff --git a/packages/core/ios/RNSentryVersion.m b/packages/core/ios/RNSentryVersion.m index 8d92c2814c..f477d3c6f5 100644 --- a/packages/core/ios/RNSentryVersion.m +++ b/packages/core/ios/RNSentryVersion.m @@ -3,4 +3,4 @@ NSString *const NATIVE_SDK_NAME = @"sentry.cocoa.react-native"; NSString *const REACT_NATIVE_SDK_NAME = @"sentry.javascript.react-native"; NSString *const REACT_NATIVE_SDK_PACKAGE_NAME = @"npm:@sentry/react-native"; -NSString *const REACT_NATIVE_SDK_PACKAGE_VERSION = @"7.0.0-alpha.0"; +NSString *const REACT_NATIVE_SDK_PACKAGE_VERSION = @"7.0.0-beta.0"; diff --git a/packages/core/package.json b/packages/core/package.json index 716866c2e2..4abc8bca2b 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -2,7 +2,7 @@ "name": "@sentry/react-native", "homepage": "https://github.com/getsentry/sentry-react-native", "repository": "https://github.com/getsentry/sentry-react-native", - "version": "7.0.0-alpha.0", + "version": "7.0.0-beta.0", "description": "Official Sentry SDK for react-native", "typings": "dist/js/index.d.ts", "types": "dist/js/index.d.ts", diff --git a/packages/core/src/js/version.ts b/packages/core/src/js/version.ts index 571598ff64..65538378c8 100644 --- a/packages/core/src/js/version.ts +++ b/packages/core/src/js/version.ts @@ -1,3 +1,3 @@ export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native'; export const SDK_NAME = 'sentry.javascript.react-native'; -export const SDK_VERSION = '7.0.0-alpha.0'; +export const SDK_VERSION = '7.0.0-beta.0'; diff --git a/performance-tests/TestAppPlain/package.json b/performance-tests/TestAppPlain/package.json index 78a7d9fc43..b34ca184a5 100644 --- a/performance-tests/TestAppPlain/package.json +++ b/performance-tests/TestAppPlain/package.json @@ -1,6 +1,6 @@ { "name": "TestAppPlain", - "version": "7.0.0-alpha.0", + "version": "7.0.0-beta.0", "private": true, "scripts": { "android": "react-native run-android", diff --git a/performance-tests/TestAppSentry/package.json b/performance-tests/TestAppSentry/package.json index 1b8f080a23..f3edd46323 100644 --- a/performance-tests/TestAppSentry/package.json +++ b/performance-tests/TestAppSentry/package.json @@ -1,6 +1,6 @@ { "name": "TestAppSentry", - "version": "7.0.0-alpha.0", + "version": "7.0.0-beta.0", "private": true, "scripts": { "android": "react-native run-android", @@ -8,7 +8,7 @@ "start": "react-native start" }, "dependencies": { - "@sentry/react-native": "7.0.0-alpha.0", + "@sentry/react-native": "7.0.0-beta.0", "react": "18.1.0", "react-native": "0.70.15" }, diff --git a/samples/expo/app.json b/samples/expo/app.json index 48d4db3dae..9db0be44ec 100644 --- a/samples/expo/app.json +++ b/samples/expo/app.json @@ -5,7 +5,7 @@ "jsEngine": "hermes", "newArchEnabled": true, "scheme": "sentry-expo-sample", - "version": "7.0.0-alpha.0", + "version": "7.0.0-beta.0", "orientation": "portrait", "icon": "./assets/icon.png", "userInterfaceStyle": "light", @@ -20,7 +20,7 @@ "ios": { "supportsTablet": true, "bundleIdentifier": "io.sentry.expo.sample", - "buildNumber": "48" + "buildNumber": "49" }, "android": { "adaptiveIcon": { @@ -28,7 +28,7 @@ "backgroundColor": "#ffffff" }, "package": "io.sentry.expo.sample", - "versionCode": 48 + "versionCode": 49 }, "web": { "bundler": "metro", @@ -90,4 +90,4 @@ "url": "https://u.expo.dev/00000000-0000-0000-0000-000000000000" } } -} +} \ No newline at end of file diff --git a/samples/expo/package.json b/samples/expo/package.json index 60da68a774..4a086e3e4b 100644 --- a/samples/expo/package.json +++ b/samples/expo/package.json @@ -1,6 +1,6 @@ { "name": "sentry-react-native-expo-sample", - "version": "7.0.0-alpha.0", + "version": "7.0.0-beta.0", "main": "expo-router/entry", "scripts": { "start": "expo start", @@ -20,7 +20,7 @@ "eas-build-development-android": "eas build --profile development --platform android" }, "dependencies": { - "@sentry/react-native": "7.0.0-alpha.0", + "@sentry/react-native": "7.0.0-beta.0", "@types/react": "~19.0.10", "expo": "^53.0.0", "expo-constants": "~17.1.5", diff --git a/samples/react-native-macos/package.json b/samples/react-native-macos/package.json index 05a4dd4438..d5322cd612 100644 --- a/samples/react-native-macos/package.json +++ b/samples/react-native-macos/package.json @@ -1,6 +1,6 @@ { "name": "sentry-react-native-macos-sample", - "version": "7.0.0-alpha.0", + "version": "7.0.0-beta.0", "private": true, "scripts": { "start": "react-native start --experimental-debugger", @@ -18,7 +18,7 @@ "@react-navigation/stack": "^6.3.20", "@sentry/core": "9.22.0", "@sentry/react": "9.22.0", - "@sentry/react-native": "7.0.0-alpha.0", + "@sentry/react-native": "7.0.0-beta.0", "delay": "^6.0.0", "react": "18.2.0", "react-native": "0.73.9", diff --git a/samples/react-native/android/app/build.gradle b/samples/react-native/android/app/build.gradle index 2790b06ab3..1d874cb8df 100644 --- a/samples/react-native/android/app/build.gradle +++ b/samples/react-native/android/app/build.gradle @@ -136,8 +136,8 @@ android { applicationId "io.sentry.reactnative.sample" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 49 - versionName "7.0.0-alpha.0" + versionCode 50 + versionName "7.0.0-beta.0" } signingConfigs { diff --git a/samples/react-native/ios/sentryreactnativesample/Info.plist b/samples/react-native/ios/sentryreactnativesample/Info.plist index dcf5165b0a..0518ea35c7 100644 --- a/samples/react-native/ios/sentryreactnativesample/Info.plist +++ b/samples/react-native/ios/sentryreactnativesample/Info.plist @@ -23,7 +23,7 @@ CFBundleSignature ???? CFBundleVersion - 55 + 56 LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/samples/react-native/ios/sentryreactnativesampleTests/Info.plist b/samples/react-native/ios/sentryreactnativesampleTests/Info.plist index e22f8785d3..df0d39cf60 100644 --- a/samples/react-native/ios/sentryreactnativesampleTests/Info.plist +++ b/samples/react-native/ios/sentryreactnativesampleTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 55 + 56 diff --git a/samples/react-native/package.json b/samples/react-native/package.json index 477f5d50b9..cdbcb01b6f 100644 --- a/samples/react-native/package.json +++ b/samples/react-native/package.json @@ -1,6 +1,6 @@ { "name": "sentry-react-native-sample", - "version": "7.0.0-alpha.0", + "version": "7.0.0-beta.0", "private": true, "scripts": { "android": "react-native run-android", @@ -27,7 +27,7 @@ "@react-navigation/native-stack": "7.3.12", "@react-navigation/stack": "7.3.1", "@sentry/core": "9.22.0", - "@sentry/react-native": "7.0.0-alpha.0", + "@sentry/react-native": "7.0.0-beta.0", "@shopify/flash-list": "1.8.0", "delay": "^6.0.0", "react": "19.0.0", diff --git a/yarn.lock b/yarn.lock index b527c7289f..d8f35f6dc5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8878,7 +8878,7 @@ __metadata: languageName: node linkType: hard -"@sentry/react-native@7.0.0-alpha.0, @sentry/react-native@workspace:packages/core": +"@sentry/react-native@7.0.0-beta.0, @sentry/react-native@workspace:packages/core": version: 0.0.0-use.local resolution: "@sentry/react-native@workspace:packages/core" dependencies: @@ -10569,7 +10569,7 @@ __metadata: dependencies: "@babel/core": ^7.12.9 "@babel/runtime": ^7.12.5 - "@sentry/react-native": 7.0.0-alpha.0 + "@sentry/react-native": 7.0.0-beta.0 metro-react-native-babel-preset: ^0.72.3 react: 18.1.0 react-native: 0.70.15 @@ -26310,7 +26310,7 @@ __metadata: "@babel/preset-env": ^7.25.3 "@babel/preset-typescript": ^7.18.6 "@sentry/core": 9.22.0 - "@sentry/react-native": 7.0.0-alpha.0 + "@sentry/react-native": 7.0.0-beta.0 "@types/node": ^20.9.3 "@types/react": ^18.2.64 appium: 2.4.1 @@ -26339,7 +26339,7 @@ __metadata: "@babel/core": ^7.26.0 "@babel/preset-env": ^7.26.0 "@sentry/babel-plugin-component-annotate": 3.5.0 - "@sentry/react-native": 7.0.0-alpha.0 + "@sentry/react-native": 7.0.0-beta.0 "@types/node": 20.10.4 "@types/react": ~19.0.10 expo: ^53.0.0 @@ -26379,7 +26379,7 @@ __metadata: "@react-navigation/stack": ^6.3.20 "@sentry/core": 9.22.0 "@sentry/react": 9.22.0 - "@sentry/react-native": 7.0.0-alpha.0 + "@sentry/react-native": 7.0.0-beta.0 "@types/react": ^18.2.65 "@types/react-native-vector-icons": ^6.4.18 "@types/react-test-renderer": ^18.0.0 @@ -26426,7 +26426,7 @@ __metadata: "@react-navigation/stack": 7.3.1 "@sentry/babel-plugin-component-annotate": 3.5.0 "@sentry/core": 9.22.0 - "@sentry/react-native": 7.0.0-alpha.0 + "@sentry/react-native": 7.0.0-beta.0 "@shopify/flash-list": 1.8.0 "@types/jest": ^29.5.14 "@types/node": ^22.13.1 From 480a5d392f8b7417f8b782967cd9f4e7c11d3c84 Mon Sep 17 00:00:00 2001 From: Petr Chalupa Date: Thu, 5 Jun 2025 16:08:04 +0200 Subject: [PATCH 36/64] fix(environment): remove deprecated `appOwnership` constant (#4893) --- CHANGELOG.md | 6 ++++++ packages/core/src/js/options.ts | 5 ++--- packages/core/src/js/utils/environment.ts | 6 +++--- packages/core/src/js/utils/expoglobalobject.ts | 4 +++- packages/core/src/js/utils/expomodules.ts | 9 ++++++++- samples/expo/app/(tabs)/index.tsx | 7 ++----- 6 files changed, 24 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f71f992a2c..c75ed19cc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ > make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first. +## Unreleased + +### Changes + +- Remove deprecated `appOwnership` constant use in Expo Go detection ([#4893](https://github.com/getsentry/sentry-react-native/pull/4893)) + ## 7.0.0-beta.0 ### Upgrading from 6.x to 7.0 diff --git a/packages/core/src/js/options.ts b/packages/core/src/js/options.ts index 7efc9c87ff..9adeb4c187 100644 --- a/packages/core/src/js/options.ts +++ b/packages/core/src/js/options.ts @@ -4,7 +4,7 @@ import type { Profiler } from '@sentry/react'; import type * as React from 'react'; import { Platform } from 'react-native'; import type { TouchEventBoundaryProps } from './touchevents'; -import { getExpoConstants } from './utils/expomodules'; +import { isExpoGo } from './utils/environment'; type ProfilerProps = React.ComponentProps; type BrowserTransportOptions = Parameters[0]; @@ -315,8 +315,7 @@ export function shouldEnableNativeNagger(userOptions: unknown): boolean { return false; } - const expoConstants = getExpoConstants(); - if (expoConstants && expoConstants.appOwnership === 'expo') { + if (isExpoGo()) { // If the app is running in Expo Go, we don't want to nag return false; } diff --git a/packages/core/src/js/utils/environment.ts b/packages/core/src/js/utils/environment.ts index fa508d5c21..af46053e70 100644 --- a/packages/core/src/js/utils/environment.ts +++ b/packages/core/src/js/utils/environment.ts @@ -1,6 +1,6 @@ import { Platform } from 'react-native'; import { RN_GLOBAL_OBJ } from '../utils/worldwide'; -import { getExpoConstants } from './expomodules'; +import { getExpoConstants, getExpoGo } from './expomodules'; import { ReactNativeLibraries } from './rnlibraries'; /** Checks if the React Native Hermes engine is running */ @@ -34,8 +34,8 @@ export function isExpo(): boolean { /** Check if JS runs in Expo Go */ export function isExpoGo(): boolean { - const expoConstants = getExpoConstants(); - return expoConstants?.appOwnership === 'expo'; + const expoGo = getExpoGo(); + return !!expoGo; } /** Check Expo Go version if available */ diff --git a/packages/core/src/js/utils/expoglobalobject.ts b/packages/core/src/js/utils/expoglobalobject.ts index c36afde03c..e9bef4b2da 100644 --- a/packages/core/src/js/utils/expoglobalobject.ts +++ b/packages/core/src/js/utils/expoglobalobject.ts @@ -7,7 +7,6 @@ * https://github.com/expo/expo/blob/b51b5139f2caa2a9495e4132437d7ca612276158/packages/expo-manifests/src/Manifests.ts */ export interface ExpoConstants { - appOwnership?: 'standalone' | 'expo' | 'guest'; /** * Deprecated. But until removed we can use it as user ID to match the native SDKs. */ @@ -65,10 +64,13 @@ export interface ExpoUpdates { createdAt?: Date | null; } +export type ExpoGo = unknown; + export interface ExpoGlobalObject { modules?: { ExponentConstants?: ExpoConstants; ExpoDevice?: ExpoDevice; ExpoUpdates?: ExpoUpdates; + ExpoGo?: ExpoGo; }; } diff --git a/packages/core/src/js/utils/expomodules.ts b/packages/core/src/js/utils/expomodules.ts index 9f606a4f76..d1a973dd5e 100644 --- a/packages/core/src/js/utils/expomodules.ts +++ b/packages/core/src/js/utils/expomodules.ts @@ -1,4 +1,4 @@ -import type { ExpoConstants, ExpoDevice, ExpoUpdates } from './expoglobalobject'; +import type { ExpoConstants, ExpoDevice, ExpoGo, ExpoUpdates } from './expoglobalobject'; import { RN_GLOBAL_OBJ } from './worldwide'; /** @@ -21,3 +21,10 @@ export function getExpoDevice(): ExpoDevice | undefined { export function getExpoUpdates(): ExpoUpdates | undefined { return RN_GLOBAL_OBJ.expo?.modules?.ExpoUpdates ?? undefined; } + +/** + * Returns the Expo Go module if present + */ +export function getExpoGo(): ExpoGo | undefined { + return RN_GLOBAL_OBJ.expo?.modules?.ExpoGo ?? undefined; +} diff --git a/samples/expo/app/(tabs)/index.tsx b/samples/expo/app/(tabs)/index.tsx index fe6a630adb..64ea1e5adc 100644 --- a/samples/expo/app/(tabs)/index.tsx +++ b/samples/expo/app/(tabs)/index.tsx @@ -1,7 +1,6 @@ import { Button, StyleSheet } from 'react-native'; -import Constants from 'expo-constants'; import * as Sentry from '@sentry/react-native'; -import { reloadAppAsync } from 'expo'; +import { reloadAppAsync, isRunningInExpoGo } from 'expo'; import * as DevClient from 'expo-dev-client'; import { Text, View } from '@/components/Themed'; @@ -11,8 +10,6 @@ import * as WebBrowser from 'expo-web-browser'; import { useUpdates } from 'expo-updates'; import { isWeb } from '../../utils/isWeb'; -const isRunningInExpoGo = Constants.appOwnership === 'expo'; - export default function TabOneScreen() { const { currentlyRunning } = useUpdates(); return ( @@ -65,7 +62,7 @@ export default function TabOneScreen() {