Skip to content

Commit 31fcca2

Browse files
chore(deps): update JavaScript SDK to v7.99.0 (#3574)
Co-authored-by: GitHub <[email protected]>
1 parent cbee1f9 commit 31fcca2

20 files changed

+218
-150
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,6 @@ module.exports = {
6666
'@sentry-internal/sdk/no-nullish-coalescing': 'off',
6767
'@sentry-internal/sdk/no-unsupported-es6-methods': 'off',
6868
'@sentry-internal/sdk/no-class-field-initializers': 'off',
69+
'deprecation/deprecation': 'off',
6970
},
7071
};

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ This release contains upgrade of `sentry-android` dependency to major version 7.
1313
- Bump Android SDK from v6.34.0 to v7.3.0 ([#3434](https://github.com/getsentry/sentry-react-native/pull/3434))
1414
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#730)
1515
- [diff](https://github.com/getsentry/sentry-java/compare/6.34.0...7.3.0)
16+
- Bump JavaScript SDK from v7.81.1 to v7.99.0 ([#3426](https://github.com/getsentry/sentry-react-native/pull/3426))
17+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#7990)
18+
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.81.1...7.99.0)
1619

1720
## 5.18.0
1821

package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,22 @@
6666
"react-native": ">=0.65.0"
6767
},
6868
"dependencies": {
69-
"@sentry/browser": "7.81.1",
69+
"@sentry/browser": "7.99.0",
7070
"@sentry/cli": "2.25.2",
71-
"@sentry/core": "7.81.1",
72-
"@sentry/hub": "7.81.1",
73-
"@sentry/integrations": "7.81.1",
74-
"@sentry/react": "7.81.1",
75-
"@sentry/types": "7.81.1",
76-
"@sentry/utils": "7.81.1"
71+
"@sentry/core": "7.99.0",
72+
"@sentry/hub": "7.99.0",
73+
"@sentry/integrations": "7.99.0",
74+
"@sentry/react": "7.99.0",
75+
"@sentry/types": "7.99.0",
76+
"@sentry/utils": "7.99.0"
7777
},
7878
"devDependencies": {
7979
"@babel/core": "^7.23.5",
8080
"@expo/metro-config": "0.16.0",
8181
"@mswjs/interceptors": "^0.25.15",
82-
"@sentry-internal/eslint-config-sdk": "7.81.1",
83-
"@sentry-internal/eslint-plugin-sdk": "7.81.1",
84-
"@sentry-internal/typescript": "7.80.0",
82+
"@sentry-internal/eslint-config-sdk": "7.99.0",
83+
"@sentry-internal/eslint-plugin-sdk": "7.99.0",
84+
"@sentry-internal/typescript": "7.99.0",
8585
"@sentry/wizard": "3.16.3",
8686
"@types/jest": "^29.5.3",
8787
"@types/node": "^20.9.3",

src/js/client.ts

+16-13
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {
4444
super(options);
4545

4646
this._outcomesBuffer = [];
47-
void this._initNativeSdk();
47+
this._initNativeSdk();
4848
}
4949

5050
/**
@@ -159,20 +159,23 @@ export class ReactNativeClient extends BaseClient<ReactNativeClientOptions> {
159159
/**
160160
* Starts native client with dsn and options
161161
*/
162-
private async _initNativeSdk(): Promise<void> {
163-
let didCallNativeInit = false;
164-
165-
try {
166-
didCallNativeInit = await NATIVE.initNativeSdk(this._options);
167-
} catch (_) {
168-
this._showCannotConnectDialog();
169-
} finally {
170-
try {
162+
private _initNativeSdk(): void {
163+
NATIVE.initNativeSdk(this._options)
164+
.then(
165+
(result: boolean) => {
166+
return result;
167+
},
168+
() => {
169+
this._showCannotConnectDialog();
170+
return false;
171+
},
172+
)
173+
.then((didCallNativeInit: boolean) => {
171174
this._options.onReady?.({ didCallNativeInit });
172-
} catch (error) {
175+
})
176+
.then(undefined, error => {
173177
logger.error('The OnReady callback threw an error: ', error);
174-
}
175-
}
178+
});
176179
}
177180

178181
/**

src/js/integrations/debugsymbolicator.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ReactNativeLibraries } from '../utils/rnlibraries';
66
import { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';
77
import type * as ReactNative from '../vendor/react-native';
88

9+
// eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor
910
const INTERNAL_CALLSITES_REGEX = new RegExp(['ReactNativeRenderer-dev\\.js$', 'MessageQueue\\.js$'].join('|'));
1011

1112
/**

src/js/integrations/reactnativeerrorhandlers.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,17 @@ export class ReactNativeErrorHandlers implements Integration {
241241
currentHub.captureEvent(event, hint);
242242

243243
if (!__DEV__) {
244-
void client.flush(options.shutdownTimeout || 2000).then(() => {
245-
defaultHandler(error, isFatal);
246-
});
244+
void client.flush(options.shutdownTimeout || 2000).then(
245+
() => {
246+
defaultHandler(error, isFatal);
247+
},
248+
(reason: unknown) => {
249+
logger.error(
250+
'[ReactNativeErrorHandlers] Error while flushing the event cache after uncaught error.',
251+
reason,
252+
);
253+
},
254+
);
247255
} else {
248256
// If in dev, we call the default handler anyway and hope the error will be sent
249257
// Just for a better dev experience

src/js/integrations/rewriteframes.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { RewriteFrames } from '@sentry/integrations';
2-
import type { StackFrame } from '@sentry/types';
2+
import type { Integration, StackFrame } from '@sentry/types';
33
import { Platform } from 'react-native';
44

55
import { isExpo, isHermesEnabled } from '../utils/environment';
@@ -13,7 +13,7 @@ export const IOS_DEFAULT_BUNDLE_NAME = 'app:///main.jsbundle';
1313
* and removes file://, 'address at' prefixes, CodePush postfix,
1414
* and Expo bundle postfix.
1515
*/
16-
export function createReactNativeRewriteFrames(): RewriteFrames {
16+
export function createReactNativeRewriteFrames(): Integration {
1717
return new RewriteFrames({
1818
iteratee: (frame: StackFrame) => {
1919
if (frame.platform === 'java' || frame.platform === 'cocoa') {

src/js/sdk.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,16 @@ export function captureUserFeedback(feedback: UserFeedback): void {
216216
*
217217
* @param callback that will be enclosed into push/popScope.
218218
*/
219-
export function withScope(callback: (scope: Scope) => void): ReturnType<Hub['withScope']> {
220-
const safeCallback = (scope: Scope): void => {
219+
export function withScope<T>(callback: (scope: Scope) => T): T | undefined {
220+
const safeCallback = (scope: Scope): T | undefined => {
221221
try {
222-
callback(scope);
222+
return callback(scope);
223223
} catch (e) {
224224
logger.error('Error while running withScope callback', e);
225+
return undefined;
225226
}
226227
};
227-
getCurrentHub().withScope(safeCallback);
228+
return getCurrentHub().withScope(safeCallback);
228229
}
229230

230231
/**

src/js/tools/sentryMetroSerializer.ts

+1
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,6 @@ function calculateDebugId(bundle: Bundle): string {
192192
}
193193

194194
function injectDebugId(code: string, debugId: string): string {
195+
// eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor
195196
return code.replace(new RegExp(DEBUG_ID_PLACE_HOLDER, 'g'), debugId);
196197
}

src/js/tracing/addTracingExtensions.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { Hub, Transaction } from '@sentry/core';
1+
import type { Hub, Span, Transaction } from '@sentry/core';
22
import { addTracingExtensions, getCurrentHub, getMainCarrier } from '@sentry/core';
3-
import type { CustomSamplingContext, Span, SpanContext, TransactionContext } from '@sentry/types';
3+
import type { CustomSamplingContext, SpanContext, TransactionContext } from '@sentry/types';
44

55
import { DEFAULT } from '../tracing/ops';
66
import { ReactNativeTracing } from '../tracing/reactnativetracing';

src/js/tracing/nativeframes.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ export class NativeFramesInstrumentation {
6464
* To be called when a transaction is finished
6565
*/
6666
public onTransactionFinish(transaction: Transaction): void {
67-
void this._fetchFramesForTransaction(transaction);
67+
this._fetchFramesForTransaction(transaction).then(undefined, (reason: unknown) => {
68+
logger.error(`[ReactNativeTracing] Error while fetching native frames:`, reason);
69+
});
6870
}
6971

7072
/**

src/js/tracing/reactnativetracing.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ export class ReactNativeTracing implements Integration {
230230
}
231231

232232
if (enableAppStartTracking) {
233-
void this._instrumentAppStart();
233+
this._instrumentAppStart().then(undefined, (reason: unknown) => {
234+
logger.error(`[ReactNativeTracing] Error while instrumenting app start:`, reason);
235+
});
234236
}
235237

236238
if (enableNativeFramesTracking) {

test/client.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,19 @@ describe('Tests ReactNativeClient', () => {
163163
);
164164
});
165165

166+
test('catches errors from onReady callback', () => {
167+
new ReactNativeClient(
168+
mockedOptions({
169+
dsn: EXAMPLE_DSN,
170+
enableNative: true,
171+
onReady: () => {
172+
throw new Error('This error should be caught by the SDK');
173+
},
174+
transport: () => new NativeTransport(),
175+
}),
176+
);
177+
});
178+
166179
test('calls onReady callback with false if Native SDK was not initialized', done => {
167180
new ReactNativeClient(
168181
mockedOptions({

test/e2e/test/utils/fetchEvent.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Event } from '@sentry/types';
2-
import fetch from 'node-fetch';
2+
import fetch, { Request } from 'node-fetch';
33

44
const domain = 'sentry.io';
55
const eventEndpoint = '/api/0/projects/sentry-sdks/sentry-react-native/events/';
@@ -18,9 +18,9 @@ const fetchEvent = async (eventId: string): Promise<ApiEvent> => {
1818
const url = `https://${domain}${eventEndpoint}${eventId}/`;
1919

2020
expect(process.env.SENTRY_AUTH_TOKEN).toBeDefined();
21-
expect(process.env.SENTRY_AUTH_TOKEN.length).toBeGreaterThan(0);
21+
expect(process.env.SENTRY_AUTH_TOKEN?.length).toBeGreaterThan(0);
2222

23-
const request = new fetch.Request(url, {
23+
const request = new Request(url, {
2424
headers: {
2525
Authorization: `Bearer ${process.env.SENTRY_AUTH_TOKEN}`,
2626
'Content-Type': 'application/json',
@@ -51,10 +51,10 @@ const fetchEvent = async (eventId: string): Promise<ApiEvent> => {
5151
}
5252
});
5353

54-
const json: ApiEvent = await fetch(request)
54+
const json: ApiEvent = (await fetch(request)
5555
// tslint:disable-next-line: no-unsafe-any
5656
.then(res => res.json())
57-
.then(retryer);
57+
.then(retryer)) as ApiEvent;
5858

5959
return json;
6060
};

test/integrations/rewriteframes.test.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Exception } from '@sentry/browser';
22
import { defaultStackParser, eventFromException } from '@sentry/browser';
3-
import type { Event } from '@sentry/types';
3+
import type { Client, Event, EventHint } from '@sentry/types';
44
import { Platform } from 'react-native';
55

66
import { createReactNativeRewriteFrames } from '../../src/js/integrations/rewriteframes';
@@ -22,11 +22,15 @@ describe('RewriteFrames', () => {
2222
const error = new Error(options.message);
2323
error.stack = options.stack;
2424
const event = await eventFromException(defaultStackParser, error, HINT, ATTACH_STACKTRACE);
25-
createReactNativeRewriteFrames().process(event);
25+
createReactNativeRewriteFrames().processEvent?.(event, {} as EventHint, {} as Client);
2626
const exception = event.exception?.values?.[0];
2727
return exception;
2828
};
2929

30+
const processEvent = (event: Event): Event | undefined | null | PromiseLike<Event | null> => {
31+
return createReactNativeRewriteFrames().processEvent?.(event, {} as EventHint, {} as Client);
32+
};
33+
3034
beforeEach(() => {
3135
mockFunction(isExpo).mockReturnValue(false);
3236
mockFunction(isHermesEnabled).mockReturnValue(false);
@@ -67,7 +71,7 @@ describe('RewriteFrames', () => {
6771
},
6872
};
6973

70-
const event = createReactNativeRewriteFrames().process(SENTRY_COCOA_EXCEPTION_EVENT);
74+
const event = processEvent(SENTRY_COCOA_EXCEPTION_EVENT) as Event;
7175
expect(event.exception?.values?.[0]).toEqual(EXPECTED_SENTRY_COCOA_EXCEPTION);
7276
});
7377

@@ -101,7 +105,7 @@ describe('RewriteFrames', () => {
101105
},
102106
};
103107

104-
const event = createReactNativeRewriteFrames().process(SENTRY_JVM_EXCEPTION_EVENT);
108+
const event = processEvent(SENTRY_JVM_EXCEPTION_EVENT) as Event;
105109
expect(event.exception?.values?.[0]).toEqual(EXPECTED_SENTRY_JVM_EXCEPTION);
106110
});
107111

test/tracing/gesturetracing.test.ts

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ const getMockScope = () => {
4747
// Placeholder
4848
},
4949
getUser: () => scopeUser,
50+
captureEvent(_event: unknown) {
51+
// Placeholder
52+
},
5053
};
5154
};
5255

0 commit comments

Comments
 (0)