Skip to content

Commit b2738e8

Browse files
github-actions[bot]web-flowkrystofwoldrich
authored
chore(deps): update JavaScript SDK to v7.16.0 (#2561)
Co-authored-by: GitHub <[email protected]> Co-authored-by: Krystof Woldrich <[email protected]>
1 parent 09db9f0 commit b2738e8

File tree

10 files changed

+115
-114
lines changed

10 files changed

+115
-114
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
- Bump Android SDK from v6.4.3 to v6.5.0 ([#2535](https://github.com/getsentry/sentry-react-native/pull/2535))
88
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#650)
99
- [diff](https://github.com/getsentry/sentry-java/compare/6.4.3...6.5.0)
10-
- Bump JavaScript SDK from v7.14.2 to v7.15.0 ([#2536](https://github.com/getsentry/sentry-react-native/pull/2536))
11-
- [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7150)
12-
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.2...7.15.0)
10+
- Bump JavaScript SDK from v7.14.2 to v7.16.0 ([#2536](https://github.com/getsentry/sentry-react-native/pull/2536), [#2561](https://github.com/getsentry/sentry-react-native/pull/2561))
11+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/master/CHANGELOG.md#7160)
12+
- [diff](https://github.com/getsentry/sentry-javascript/compare/7.14.2...7.16.0)
1313
- Bump Cocoa SDK from v7.27.1 to v7.28.0 ([#2548](https://github.com/getsentry/sentry-react-native/pull/2548))
1414
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7280)
1515
- [diff](https://github.com/getsentry/sentry-cocoa/compare/7.27.1...7.28.0)

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@
4040
"react-native": ">=0.56.0"
4141
},
4242
"dependencies": {
43-
"@sentry/browser": "7.15.0",
43+
"@sentry/browser": "7.16.0",
4444
"@sentry/cli": "1.74.4",
45-
"@sentry/core": "7.15.0",
46-
"@sentry/hub": "7.15.0",
47-
"@sentry/integrations": "7.15.0",
48-
"@sentry/react": "7.15.0",
49-
"@sentry/tracing": "7.15.0",
50-
"@sentry/types": "7.15.0",
51-
"@sentry/utils": "7.15.0",
45+
"@sentry/core": "7.16.0",
46+
"@sentry/hub": "7.16.0",
47+
"@sentry/integrations": "7.16.0",
48+
"@sentry/react": "7.16.0",
49+
"@sentry/tracing": "7.16.0",
50+
"@sentry/types": "7.16.0",
51+
"@sentry/utils": "7.16.0",
5252
"@sentry/wizard": "1.2.17"
5353
},
5454
"devDependencies": {
55-
"@sentry-internal/eslint-config-sdk": "7.15.0",
56-
"@sentry-internal/eslint-plugin-sdk": "7.15.0",
55+
"@sentry-internal/eslint-config-sdk": "7.16.0",
56+
"@sentry-internal/eslint-plugin-sdk": "7.16.0",
5757
"@sentry/typescript": "^5.20.1",
5858
"@types/jest": "^26.0.15",
5959
"@types/react": "^16.9.49",

src/js/integrations/reactnativeerrorhandlers.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { getCurrentHub } from '@sentry/core';
22
import { Integration, SeverityLevel } from '@sentry/types';
3-
import { addExceptionMechanism, getGlobalObject, logger } from '@sentry/utils';
3+
import { addExceptionMechanism, logger } from '@sentry/utils';
44

55
import { ReactNativeClient } from '../client';
6+
import { RN_GLOBAL_OBJ } from '../utils/worldwide';
67

78
/** ReactNativeErrorHandlers Options */
89
interface ReactNativeErrorHandlersOptions {
@@ -142,9 +143,7 @@ export class ReactNativeErrorHandlers implements Integration {
142143
// eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies
143144
const Promise = require('promise/setimmediate/es6-extensions');
144145

145-
const _global = getGlobalObject<{ Promise: typeof Promise }>();
146-
147-
if (Promise !== _global.Promise) {
146+
if (Promise !== RN_GLOBAL_OBJ.Promise) {
148147
logger.warn(
149148
'Unhandled promise rejections will not be caught by Sentry. Read about how to fix this on our troubleshooting page.'
150149
);

src/js/sdk.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
getCurrentHub,
77
} from '@sentry/react';
88
import { Integration, Scope, StackFrame, UserFeedback } from '@sentry/types';
9-
import { getGlobalObject, logger, stackParserFromStackParserOptions } from '@sentry/utils';
9+
import { logger, stackParserFromStackParserOptions } from '@sentry/utils';
1010
import * as React from 'react';
1111

1212
import { ReactNativeClient } from './client';
@@ -25,6 +25,7 @@ import { ReactNativeProfiler, ReactNativeTracing } from './tracing';
2525
import { makeReactNativeTransport } from './transports/native';
2626
import { makeUtf8TextEncoder } from './transports/TextEncoder';
2727
import { safeFactory, safeTracesSampler } from './utils/safe';
28+
import { RN_GLOBAL_OBJ } from './utils/worldwide';
2829

2930
const IGNORED_DEFAULT_INTEGRATIONS = [
3031
'GlobalHandlers', // We will use the react-native internal handlers
@@ -130,8 +131,7 @@ export function init(passedOptions: ReactNativeOptions): void {
130131
});
131132
initAndBind(ReactNativeClient, options);
132133

133-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any
134-
if (getGlobalObject<any>().HermesInternal) {
134+
if (RN_GLOBAL_OBJ.HermesInternal) {
135135
getCurrentHub().setTag('hermes', 'true');
136136
}
137137
}

src/js/tracing/reactnavigation.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* eslint-disable max-lines */
22
import { Transaction as TransactionType, TransactionContext } from '@sentry/types';
3-
import { getGlobalObject, logger } from '@sentry/utils';
3+
import { logger } from '@sentry/utils';
44

5+
import { RN_GLOBAL_OBJ } from '../utils/worldwide';
56
import {
67
InternalRoutingInstrumentation,
78
OnConfirmRoute,
@@ -105,14 +106,12 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
105106
*/
106107
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
107108
public registerNavigationContainer(navigationContainerRef: any): void {
108-
const _global = getGlobalObject<{ __sentry_rn_v5_registered?: boolean }>();
109-
110109
/* We prevent duplicate routing instrumentation to be initialized on fast refreshes
111110
112111
Explanation: If the user triggers a fast refresh on the file that the instrumentation is
113112
initialized in, it will initialize a new instance and will cause undefined behavior.
114113
*/
115-
if (!_global.__sentry_rn_v5_registered) {
114+
if (!RN_GLOBAL_OBJ.__sentry_rn_v5_registered) {
116115
if ('current' in navigationContainerRef) {
117116
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
118117
this._navigationContainer = navigationContainerRef.current;
@@ -143,7 +142,7 @@ export class ReactNavigationInstrumentation extends InternalRoutingInstrumentati
143142
}
144143
}
145144

146-
_global.__sentry_rn_v5_registered = true;
145+
RN_GLOBAL_OBJ.__sentry_rn_v5_registered = true;
147146
} else {
148147
logger.warn(
149148
'[ReactNavigationInstrumentation] Received invalid navigation container ref!'

src/js/tracing/reactnavigationv4.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* eslint-disable max-lines */
22
import { Transaction, TransactionContext } from '@sentry/types';
3-
import { getGlobalObject, logger } from '@sentry/utils';
3+
import { logger } from '@sentry/utils';
44

5+
import { RN_GLOBAL_OBJ } from '../utils/worldwide';
56
import {
67
InternalRoutingInstrumentation,
78
OnConfirmRoute,
@@ -124,14 +125,12 @@ class ReactNavigationV4Instrumentation extends InternalRoutingInstrumentation {
124125
*/
125126
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
126127
public registerAppContainer(appContainerRef: any): void {
127-
const _global = getGlobalObject<{ __sentry_rn_v4_registered?: boolean }>();
128-
129128
/* We prevent duplicate routing instrumentation to be initialized on fast refreshes
130129
131130
Explanation: If the user triggers a fast refresh on the file that the instrumentation is
132131
initialized in, it will initialize a new instance and will cause undefined behavior.
133132
*/
134-
if (!_global.__sentry_rn_v4_registered) {
133+
if (!RN_GLOBAL_OBJ.__sentry_rn_v4_registered) {
135134
if ('current' in appContainerRef) {
136135
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
137136
this._appContainer = appContainerRef.current;
@@ -153,7 +152,7 @@ class ReactNavigationV4Instrumentation extends InternalRoutingInstrumentation {
153152
this._initialStateHandled = true;
154153
}
155154

156-
_global.__sentry_rn_v4_registered = true;
155+
RN_GLOBAL_OBJ.__sentry_rn_v4_registered = true;
157156
} else {
158157
logger.warn(
159158
'[ReactNavigationV4Instrumentation] Received invalid app container ref!'

src/js/utils/worldwide.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { GLOBAL_OBJ, InternalGlobal } from '@sentry/utils';
2+
3+
/** Internal Global object interface with common and Sentry specific properties */
4+
export interface ReactNativeInternalGlobal extends InternalGlobal {
5+
__sentry_rn_v4_registered?: boolean;
6+
__sentry_rn_v5_registered?: boolean;
7+
HermesInternal: unknown;
8+
Promise: unknown;
9+
}
10+
11+
/** Get's the global object for the current JavaScript runtime */
12+
export const RN_GLOBAL_OBJ = GLOBAL_OBJ as ReactNativeInternalGlobal;

test/tracing/reactnavigation.test.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import { Transaction } from '@sentry/tracing';
33
import { TransactionContext } from '@sentry/types';
4-
import { getGlobalObject } from '@sentry/utils';
54

65
import {
76
BLANK_TRANSACTION_CONTEXT,
87
NavigationRoute,
98
ReactNavigationInstrumentation,
109
} from '../../src/js/tracing/reactnavigation';
10+
import { RN_GLOBAL_OBJ } from '../../src/js/utils/worldwide';
1111

1212
const dummyRoute = {
1313
name: 'Route',
@@ -36,12 +36,8 @@ const getMockTransaction = () => {
3636
return transaction;
3737
};
3838

39-
const _global = getGlobalObject<{
40-
__sentry_rn_v5_registered?: boolean;
41-
}>();
42-
4339
afterEach(() => {
44-
_global.__sentry_rn_v5_registered = false;
40+
RN_GLOBAL_OBJ.__sentry_rn_v5_registered = false;
4541

4642
jest.resetAllMocks();
4743
});
@@ -120,7 +116,7 @@ describe('ReactNavigationInstrumentation', () => {
120116
someParam: 42,
121117
},
122118
};
123-
// If .getCurrentRoute() is undefined, ignore state change
119+
// If .getCurrentRoute() is undefined, ignore state change
124120
mockNavigationContainerRef.current.currentRoute = undefined;
125121
mockNavigationContainerRef.current.listeners['state']({});
126122

@@ -297,7 +293,7 @@ describe('ReactNavigationInstrumentation', () => {
297293
current: mockNavigationContainer,
298294
});
299295

300-
expect(_global.__sentry_rn_v5_registered).toBe(true);
296+
expect(RN_GLOBAL_OBJ.__sentry_rn_v5_registered).toBe(true);
301297

302298
// eslint-disable-next-line @typescript-eslint/unbound-method
303299
expect(mockNavigationContainer.addListener).toHaveBeenNthCalledWith(
@@ -318,7 +314,7 @@ describe('ReactNavigationInstrumentation', () => {
318314
const mockNavigationContainer = new MockNavigationContainer();
319315
instrumentation.registerNavigationContainer(mockNavigationContainer);
320316

321-
expect(_global.__sentry_rn_v5_registered).toBe(true);
317+
expect(RN_GLOBAL_OBJ.__sentry_rn_v5_registered).toBe(true);
322318

323319
// eslint-disable-next-line @typescript-eslint/unbound-method
324320
expect(mockNavigationContainer.addListener).toHaveBeenNthCalledWith(
@@ -335,15 +331,15 @@ describe('ReactNavigationInstrumentation', () => {
335331
});
336332

337333
test('does not register navigation container if there is an existing one', () => {
338-
_global.__sentry_rn_v5_registered = true;
334+
RN_GLOBAL_OBJ.__sentry_rn_v5_registered = true;
339335

340336
const instrumentation = new ReactNavigationInstrumentation();
341337
const mockNavigationContainer = new MockNavigationContainer();
342338
instrumentation.registerNavigationContainer({
343339
current: mockNavigationContainer,
344340
});
345341

346-
expect(_global.__sentry_rn_v5_registered).toBe(true);
342+
expect(RN_GLOBAL_OBJ.__sentry_rn_v5_registered).toBe(true);
347343

348344
// eslint-disable-next-line @typescript-eslint/unbound-method
349345
expect(mockNavigationContainer.addListener).not.toHaveBeenCalled();

test/tracing/reactnavigationv4.test.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import { Transaction } from '@sentry/tracing';
33
import { TransactionContext } from '@sentry/types';
4-
import { getGlobalObject } from '@sentry/utils';
54

65
import {
76
AppContainerInstance,
@@ -10,6 +9,7 @@ import {
109
NavigationStateV4,
1110
ReactNavigationV4Instrumentation,
1211
} from '../../src/js/tracing/reactnavigationv4';
12+
import { RN_GLOBAL_OBJ } from '../../src/js/utils/worldwide';
1313

1414
const initialRoute = {
1515
routeName: 'Initial Route',
@@ -82,12 +82,8 @@ class MockAppContainer implements AppContainerInstance {
8282
}
8383
}
8484

85-
const _global = getGlobalObject<{
86-
__sentry_rn_v4_registered?: boolean;
87-
}>();
88-
8985
afterEach(() => {
90-
_global.__sentry_rn_v4_registered = false;
86+
RN_GLOBAL_OBJ.__sentry_rn_v4_registered = false;
9187

9288
jest.resetAllMocks();
9389
});
@@ -313,7 +309,7 @@ describe('ReactNavigationV4Instrumentation', () => {
313309
current: mockAppContainer,
314310
});
315311

316-
expect(_global.__sentry_rn_v4_registered).toBe(true);
312+
expect(RN_GLOBAL_OBJ.__sentry_rn_v4_registered).toBe(true);
317313

318314
// eslint-disable-next-line @typescript-eslint/unbound-method
319315
expect(instrumentation.onRouteWillChange).toHaveBeenCalledTimes(1);
@@ -336,7 +332,7 @@ describe('ReactNavigationV4Instrumentation', () => {
336332
const mockAppContainer = new MockAppContainer();
337333
instrumentation.registerAppContainer(mockAppContainer);
338334

339-
expect(_global.__sentry_rn_v4_registered).toBe(true);
335+
expect(RN_GLOBAL_OBJ.__sentry_rn_v4_registered).toBe(true);
340336

341337
// eslint-disable-next-line @typescript-eslint/unbound-method
342338
expect(instrumentation.onRouteWillChange).toHaveBeenCalledTimes(1);
@@ -345,7 +341,7 @@ describe('ReactNavigationV4Instrumentation', () => {
345341
});
346342

347343
test('does not register navigation container if there is an existing one', async () => {
348-
_global.__sentry_rn_v4_registered = true;
344+
RN_GLOBAL_OBJ.__sentry_rn_v4_registered = true;
349345

350346
const instrumentation = new ReactNavigationV4Instrumentation();
351347
const mockTransaction = getMockTransaction();
@@ -361,7 +357,7 @@ describe('ReactNavigationV4Instrumentation', () => {
361357
const mockAppContainer = new MockAppContainer();
362358
instrumentation.registerAppContainer(mockAppContainer);
363359

364-
expect(_global.__sentry_rn_v4_registered).toBe(true);
360+
expect(RN_GLOBAL_OBJ.__sentry_rn_v4_registered).toBe(true);
365361

366362
await new Promise<void>((resolve) => {
367363
setTimeout(() => {

0 commit comments

Comments
 (0)