Skip to content

Commit c0d52bf

Browse files
Merge remote-tracking branch 'origin/main' into 5.0.0
2 parents d27d9e0 + 5636309 commit c0d52bf

18 files changed

+153
-105
lines changed

.github/workflows/add-platform-label.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
permissions:
1212
issues: write
1313
steps:
14-
- uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90
14+
- uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 # [email protected]
1515
with:
16-
add-labels: "Platform: React-Native"
16+
add-labels: 'Platform: React-Native'
1717
repo-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/buildandtest.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ jobs:
7575
# we want that the matrix keeps running, default is to cancel them if it fails.
7676
fail-fast: false
7777
matrix:
78-
platform: ["ios", "android"]
78+
platform: ['ios', 'android']
7979
dev: [true, false]
8080
steps:
8181
- uses: actions/checkout@v3
8282
- uses: actions/setup-node@v3
8383
with:
84-
node-version: "14"
84+
node-version: '14'
8585
- name: Cache Dependencies
8686
uses: actions/cache@v3
8787
id: cache

.github/workflows/codeql-analysis.yml

+6-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# the `language` matrix defined below to confirm you have the correct set of
1010
# supported CodeQL languages.
1111
#
12-
name: "CodeQL"
12+
name: 'CodeQL'
1313

1414
on:
1515
push:
@@ -18,7 +18,7 @@ on:
1818
# The branches below must be a subset of the branches above
1919
branches: [main]
2020
schedule:
21-
- cron: "27 16 * * 5"
21+
- cron: '27 16 * * 5'
2222

2323
jobs:
2424
analyze:
@@ -28,7 +28,7 @@ jobs:
2828
strategy:
2929
fail-fast: false
3030
matrix:
31-
language: ["javascript"]
31+
language: ['javascript']
3232
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
3333
# Learn more:
3434
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
@@ -39,7 +39,7 @@ jobs:
3939

4040
# Initializes the CodeQL tools for scanning.
4141
- name: Initialize CodeQL
42-
uses: github/codeql-action/init@v2
42+
uses: github/codeql-action/init@e0e5ded33cabb451ae0a9768fc7b0410bad9ad44 # pin@v2
4343
with:
4444
languages: ${{ matrix.language }}
4545
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -50,18 +50,15 @@ jobs:
5050
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5151
# If this step fails, then you should remove it and run the build manually (see below)
5252
- name: Autobuild
53-
uses: github/codeql-action/autobuild@v2
53+
uses: github/codeql-action/autobuild@e0e5ded33cabb451ae0a9768fc7b0410bad9ad44 # pin@v2
5454

5555
# ℹ️ Command-line programs to run using the OS shell.
5656
# 📚 https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
57-
5857
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
5958
# and modify them (or add more) to build your code if your project
6059
# uses a compiled language
61-
6260
#- run: |
6361
# make bootstrap
6462
# make release
65-
6663
- name: Perform CodeQL Analysis
67-
uses: github/codeql-action/analyze@v2
64+
uses: github/codeql-action/analyze@e0e5ded33cabb451ae0a9768fc7b0410bad9ad44 # pin@v2

.github/workflows/e2e.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ jobs:
107107

108108
# Wait until the Appium server starts.
109109
- name: Check Appium Server
110-
uses: nick-fields/retry@b4fa57557dda8c2f30bcb2d19372cc3237190f7f # v2.8.1
110+
uses: nick-fields/retry@b4fa57557dda8c2f30bcb2d19372cc3237190f7f # pin@v2
111111
with:
112112
timeout_seconds: 60
113113
max_attempts: 10
114114
command: curl --output /dev/null --silent --head --fail http://127.0.0.1:4723/sessions
115115

116116
- name: Run tests on Android
117117
if: ${{ matrix.platform == 'android' }}
118-
uses: reactivecircus/android-emulator-runner@d7b53ddc6e44254e1f4cf4a6ad67345837027a66 # v2.26.0
118+
uses: reactivecircus/android-emulator-runner@d7b53ddc6e44254e1f4cf4a6ad67345837027a66 # pin@v2
119119
with:
120120
api-level: 29
121121
emulator-options: -accel on -no-snapshot -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none -camera-front none -timezone US/Pacific

CHANGELOG.md

+22-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,26 @@
44

55
### Fixes
66

7+
- Make `configureScope` callback safe [#2510](https://github.com/getsentry/sentry-react-native/pull/2510)
8+
9+
### Dependencies
10+
11+
- Bump JavaScript SDK from v7.14.0 to v7.14.1 ([#2511](https://github.com/getsentry/sentry-react-native/pull/2511))
12+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7141)
13+
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.0...7.14.1)
14+
- Bump Cocoa SDK from v7.27.0 to v7.27.1 ([#2521](https://github.com/getsentry/sentry-react-native/pull/2521))
15+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7271)
16+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/7.27.0...7.27.1)
17+
- Bump Android SDK from v6.4.2 to v6.4.3 ([#2520](https://github.com/getsentry/sentry-react-native/pull/2520))
18+
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#643)
19+
- [diff](https://github.com/getsentry/sentry-java/compare/6.4.2...6.4.3)
20+
21+
## 4.6.0
22+
23+
### Fixes
24+
725
- SDK Gracefully downgrades when callback throws an error ([#2502](https://github.com/getsentry/sentry-react-native/pull/2502))
26+
- React Navigation v5 ignores when current route is undefined after state changed. ([#2484](https://github.com/getsentry/sentry-react-native/pull/2484))
827

928
### Features
1029

@@ -16,9 +35,9 @@
1635

1736
### Dependencies
1837

19-
- Bump Cocoa SDK from v7.25.1 to v7.26.0 ([#2500](https://github.com/getsentry/sentry-react-native/pull/2500))
20-
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7260)
21-
- [diff](https://github.com/getsentry/sentry-cocoa/compare/7.25.1...7.26.0)
38+
- Bump Cocoa SDK from v7.25.1 to v7.27.0 ([#2500](https://github.com/getsentry/sentry-react-native/pull/2500), [#2506](https://github.com/getsentry/sentry-react-native/pull/2506))
39+
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7270)
40+
- [diff](https://github.com/getsentry/sentry-cocoa/compare/7.25.1...7.27.0)
2241
- Bump JavaScript SDK from v7.13.0 to v7.14.0 ([#2504](https://github.com/getsentry/sentry-react-native/pull/2504))
2342
- [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7140)
2443
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.13.0...7.14.0)

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This repository contains a sample project. It can be used to test the SDK as you
66

77
You need:
88

9-
- nodejs 8 or higher
9+
- nodejs 14 or higher
1010
- yarn 1 or higher
1111

1212
## Building

RNSentry.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
1717
s.preserve_paths = '*.js'
1818

1919
s.dependency 'React-Core'
20-
s.dependency 'Sentry', '7.26.0'
20+
s.dependency 'Sentry', '7.27.1'
2121

2222
s.source_files = 'ios/RNSentry.{h,m}'
2323
s.public_header_files = 'ios/RNSentry.h'

android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ android {
2424

2525
dependencies {
2626
implementation 'com.facebook.react:react-native:+'
27-
api 'io.sentry:sentry-android:6.4.2'
27+
api 'io.sentry:sentry-android:6.4.3'
2828
}

package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@
4040
"react-native": ">=0.56.0"
4141
},
4242
"dependencies": {
43-
"@sentry/browser": "7.14.0",
43+
"@sentry/browser": "7.14.1",
4444
"@sentry/cli": "1.74.4",
45-
"@sentry/core": "7.14.0",
46-
"@sentry/hub": "7.14.0",
47-
"@sentry/integrations": "7.14.0",
48-
"@sentry/react": "7.14.0",
49-
"@sentry/tracing": "7.14.0",
50-
"@sentry/types": "7.14.0",
51-
"@sentry/utils": "7.14.0"
45+
"@sentry/core": "7.14.1",
46+
"@sentry/hub": "7.14.1",
47+
"@sentry/integrations": "7.14.1",
48+
"@sentry/react": "7.14.1",
49+
"@sentry/tracing": "7.14.1",
50+
"@sentry/types": "7.14.1",
51+
"@sentry/utils": "7.14.1"
5252
},
5353
"devDependencies": {
54-
"@sentry-internal/eslint-config-sdk": "7.14.0",
55-
"@sentry-internal/eslint-plugin-sdk": "7.14.0",
54+
"@sentry-internal/eslint-config-sdk": "7.14.1",
55+
"@sentry-internal/eslint-plugin-sdk": "7.14.1",
5656
"@sentry/typescript": "^5.20.1",
5757
"@sentry/wizard": "2.2.0",
5858
"@types/jest": "^26.0.15",

sample/metro.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
const path = require('path');
9-
const blacklist = require('metro-config/src/defaults/blacklist');
9+
const blacklist = require('metro-config/src/defaults/exclusionList');
1010
const resolve = require('metro-resolver/src/resolve');
1111

1212
const parentDir = path.resolve(__dirname, '..');

src/js/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export {
1717
captureException,
1818
captureEvent,
1919
captureMessage,
20-
configureScope,
2120
getHubFromCarrier,
2221
getCurrentHub,
2322
Hub,
@@ -66,6 +65,7 @@ export {
6665
close,
6766
captureUserFeedback,
6867
withScope,
68+
configureScope,
6969
} from './sdk';
7070
export { TouchEventBoundary, withTouchEventBoundary } from './touchevents';
7171

src/js/sdk.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -262,3 +262,18 @@ export function withScope(callback: (scope: Scope) => void): ReturnType<Hub['wit
262262
};
263263
getCurrentHub().withScope(safeCallback);
264264
}
265+
266+
/**
267+
* Callback to set context information onto the scope.
268+
* @param callback Callback function that receives Scope.
269+
*/
270+
export function configureScope(callback: (scope: Scope) => void): ReturnType<Hub['configureScope']> {
271+
const safeCallback = (scope: Scope): void => {
272+
try {
273+
callback(scope);
274+
} catch (e) {
275+
logger.error('Error while running configureScope callback', e);
276+
}
277+
};
278+
getCurrentHub().configureScope(safeCallback);
279+
}

src/js/tracing/reactnavigation.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,11 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
242242

243243
this._pushRecentRouteKey(route.key);
244244
this._latestRoute = route;
245+
246+
// Clear the latest transaction as it has been handled.
247+
this._latestTransaction = undefined;
245248
}
246249
}
247-
248-
// Clear the latest transaction as it has been handled.
249-
this._latestTransaction = undefined;
250250
}
251251

252252
/** Creates final transaction context before confirmation */

test/client.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
envelopeItemPayload,
1414
envelopeItems,
1515
firstArg,
16-
flushPromises,
1716
getMockSession,
1817
getMockUserFeedback,
1918
getSyncPromiseRejectOnFirstCall,

test/sdk.test.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ interface MockedClient {
55
}
66

77
let mockedGetCurrentHubWithScope: jest.Mock;
8+
let mockedGetCurrentHubConfigureScope: jest.Mock;
89

910
jest.mock('@sentry/react', () => {
1011
const actualModule = jest.requireActual('@sentry/react');
@@ -17,10 +18,12 @@ jest.mock('@sentry/react', () => {
1718
...actualModule,
1819
getCurrentHub: jest.fn(() => {
1920
mockedGetCurrentHubWithScope = jest.fn();
21+
mockedGetCurrentHubConfigureScope = jest.fn();
2022
return {
2123
getClient: jest.fn(() => mockClient),
2224
setTag: jest.fn(),
2325
withScope: mockedGetCurrentHubWithScope,
26+
configureScope: mockedGetCurrentHubConfigureScope,
2427
};
2528
}),
2629
defaultIntegrations: [ { name: 'MockedDefaultReactIntegration', setupOnce: jest.fn() } ],
@@ -62,7 +65,7 @@ import { getCurrentHub } from '@sentry/react';
6265
import { Integration, Scope } from '@sentry/types';
6366

6467
import { ReactNativeClientOptions } from '../src/js/options';
65-
import { flush, init, withScope } from '../src/js/sdk';
68+
import { configureScope,flush, init, withScope } from '../src/js/sdk';
6669
import { ReactNativeTracing, ReactNavigationInstrumentation } from '../src/js/tracing';
6770
import { firstArg, secondArg } from './testutils';
6871

@@ -234,6 +237,19 @@ describe('Tests the SDK functionality', () => {
234237
});
235238
});
236239

240+
describe('configureScope', () => {
241+
test('configureScope callback does not throw', () => {
242+
const mockScopeCallback = jest.fn(() => { throw 'Test error' });
243+
244+
configureScope(mockScopeCallback);
245+
246+
expect(() => {
247+
(mockedGetCurrentHubConfigureScope.mock.calls[0][firstArg] as (scope: Scope) => void)({} as any);
248+
}).not.toThrow();
249+
expect(mockScopeCallback).toBeCalledTimes(1);
250+
});
251+
});
252+
237253
describe('integrations', () => {
238254
it('replaces default integrations', () => {
239255
const mockDefaultIntegration = getMockedIntegration();

test/testutils.ts

-2
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,3 @@ export const getSyncPromiseRejectOnFirstCall = <Y extends any[]>(reason: unknown
6464
}
6565
});
6666
};
67-
68-
export const flushPromises = (): Promise<void> => new Promise(setImmediate);

test/tracing/reactnavigation.test.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ const dummyRoute = {
1515
};
1616

1717
class MockNavigationContainer {
18-
currentRoute: NavigationRoute = dummyRoute;
18+
currentRoute: NavigationRoute | undefined = dummyRoute;
1919
listeners: Record<string, (e: any) => void> = {};
2020
addListener: any = jest.fn(
2121
(eventType: string, listener: (e: any) => void): void => {
2222
this.listeners[eventType] = listener;
2323
}
2424
);
25-
getCurrentRoute(): NavigationRoute {
25+
getCurrentRoute(): NavigationRoute | undefined {
2626
return this.currentRoute;
2727
}
2828
}
@@ -120,6 +120,10 @@ describe('ReactNavigationInstrumentation', () => {
120120
someParam: 42,
121121
},
122122
};
123+
// If .getCurrentRoute() is undefined, ignore state change
124+
mockNavigationContainerRef.current.currentRoute = undefined;
125+
mockNavigationContainerRef.current.listeners['state']({});
126+
123127
mockNavigationContainerRef.current.currentRoute = route;
124128
mockNavigationContainerRef.current.listeners['state']({});
125129

0 commit comments

Comments
 (0)