Skip to content

Commit 99410e9

Browse files
committed
Merge branch 'main' into antonis/extract-android-sdk-init
2 parents dcb7e2e + 2dc8f22 commit 99410e9

File tree

11 files changed

+171
-116
lines changed

11 files changed

+171
-116
lines changed

.github/workflows/e2e.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,15 @@ jobs:
162162
strategy:
163163
fail-fast: false # keeps matrix running if one fails
164164
matrix:
165-
rn-version: ['0.65.3', '0.76.0']
165+
rn-version: ['0.65.3', '0.76.6']
166166
rn-architecture: ['legacy', 'new']
167167
platform: ['android', 'ios']
168168
build-type: ['production']
169169
ios-use-frameworks: ['no', 'static', 'dynamic']
170170
engine: ['hermes', 'jsc']
171171
include:
172172
- platform: ios
173-
rn-version: '0.76.0'
173+
rn-version: '0.76.6'
174174
runs-on: macos-14
175175
- platform: ios
176176
rn-version: '0.65.3'
@@ -179,7 +179,7 @@ jobs:
179179
runs-on: ubuntu-latest
180180
exclude:
181181
# exclude JSC for new RN versions (keeping the matrix manageable)
182-
- rn-version: '0.76.0'
182+
- rn-version: '0.76.6'
183183
engine: 'jsc'
184184
# exclude all rn versions lower than 0.70.0 for new architecture
185185
- rn-version: '0.65.3'
@@ -298,15 +298,15 @@ jobs:
298298
strategy:
299299
fail-fast: false # keeps matrix running if one fails
300300
matrix:
301-
rn-version: ['0.65.3', '0.76.0']
301+
rn-version: ['0.65.3', '0.76.6']
302302
rn-architecture: ['legacy', 'new']
303303
platform: ['android', 'ios']
304304
build-type: ['production']
305305
ios-use-frameworks: ['no'] # test only no framworks
306306
engine: ['hermes', 'jsc']
307307
include:
308308
- platform: ios
309-
rn-version: '0.76.0'
309+
rn-version: '0.76.6'
310310
runs-on: macos-15
311311
- platform: ios
312312
rn-version: '0.65.3'
@@ -320,7 +320,7 @@ jobs:
320320
# e2e test only the default combinations
321321
- rn-version: '0.65.3'
322322
engine: 'hermes'
323-
- rn-version: '0.76.0'
323+
- rn-version: '0.76.6'
324324
engine: 'jsc'
325325

326326
steps:

.github/workflows/sample-application-expo.yml

+5
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ jobs:
131131
run: |
132132
npx expo export -p web
133133
134+
- name: Export Expo
135+
working-directory: samples/expo
136+
run: |
137+
npx expo export
138+
134139
- name: Upload logs
135140
if: ${{ always() }}
136141
uses: actions/upload-artifact@v4

CHANGELOG.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,25 @@
1111
### Fixes
1212

1313
- Use proper SDK name for Session Replay tags ([#4428](https://github.com/getsentry/sentry-react-native/pull/4428))
14+
- Use `makeDsn` from `core` to extract the URL from DSN avoiding unimplemented `URL.protocol` errors ([#4395](https://github.com/getsentry/sentry-react-native/pull/4395))
1415

1516
### Changes
1617

1718
- Rename `navigation.processing` span to more expressive `Navigation dispatch to screen A mounted/navigation cancelled` ([#4423](https://github.com/getsentry/sentry-react-native/pull/4423))
1819
- Add RN SDK package to `sdk.packages` for Cocoa ([#4381](https://github.com/getsentry/sentry-react-native/pull/4381))
1920

21+
### Internal
22+
23+
- Initialize `RNSentryTimeToDisplay` during native module `init` on iOS ([#4443](https://github.com/getsentry/sentry-react-native/pull/4443))
24+
2025
### Dependencies
2126

2227
- Bump CLI from v2.39.1 to v2.40.0 ([#4412](https://github.com/getsentry/sentry-react-native/pull/4412))
2328
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2400)
2429
- [diff](https://github.com/getsentry/sentry-cli/compare/2.39.1...2.40.0)
25-
- Bump JavaScript SDK from v8.47.0 to v8.48.0 ([#4421](https://github.com/getsentry/sentry-react-native/pull/4421))
26-
- [changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#8480)
27-
- [diff](https://github.com/getsentry/sentry-javascript/compare/8.47.0...8.48.0)
30+
- Bump JavaScript SDK from v8.47.0 to v8.50.0 ([#4421](https://github.com/getsentry/sentry-react-native/pull/4421), [#4449](https://github.com/getsentry/sentry-react-native/pull/4449), [#4453](https://github.com/getsentry/sentry-react-native/pull/4453))
31+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#8500)
32+
- [diff](https://github.com/getsentry/sentry-javascript/compare/8.47.0...8.50.0)
2833

2934
### Internal
3035

dev-packages/e2e-tests/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"devDependencies": {
1414
"@babel/preset-env": "^7.25.3",
1515
"@babel/preset-typescript": "^7.18.6",
16-
"@sentry/core": "8.48.0",
16+
"@sentry/core": "8.50.0",
1717
"@sentry/react-native": "6.5.0",
1818
"@types/node": "^20.9.3",
1919
"@types/react": "^18.2.64",

packages/core/ios/RNSentry.mm

+8-2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ + (BOOL)requiresMainQueueSetup
7878
return YES;
7979
}
8080

81+
- (instancetype)init
82+
{
83+
if (self = [super init]) {
84+
_timeToDisplay = [[RNSentryTimeToDisplay alloc] init];
85+
}
86+
return self;
87+
}
88+
8189
RCT_EXPORT_MODULE()
8290

8391
RCT_EXPORT_METHOD(initNativeSdk
@@ -152,8 +160,6 @@ - (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)
152160
[mutableOptions removeObjectForKey:@"tracesSampler"];
153161
[mutableOptions removeObjectForKey:@"enableTracing"];
154162

155-
_timeToDisplay = [[RNSentryTimeToDisplay alloc] init];
156-
157163
#if SENTRY_TARGET_REPLAY_SUPPORTED
158164
[RNSentryReplay updateOptions:mutableOptions];
159165
#endif

packages/core/ios/RNSentryVersion.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
NSString *const NATIVE_SDK_NAME = @"sentry.cocoa.react-native";
44
NSString *const REACT_NATIVE_SDK_PACKAGE_NAME = @"npm:@sentry/react-native";
5-
NSString *const REACT_NATIVE_SDK_PACKAGE_VERSION = @"6.4.0";
5+
NSString *const REACT_NATIVE_SDK_PACKAGE_VERSION = @"6.5.0";

packages/core/package.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,21 @@
6666
},
6767
"dependencies": {
6868
"@sentry/babel-plugin-component-annotate": "2.20.1",
69-
"@sentry/browser": "8.48.0",
69+
"@sentry/browser": "8.50.0",
7070
"@sentry/cli": "2.40.0",
71-
"@sentry/core": "8.48.0",
72-
"@sentry/react": "8.48.0",
73-
"@sentry/types": "8.48.0",
74-
"@sentry/utils": "8.48.0"
71+
"@sentry/core": "8.50.0",
72+
"@sentry/react": "8.50.0",
73+
"@sentry/types": "8.50.0",
74+
"@sentry/utils": "8.50.0"
7575
},
7676
"devDependencies": {
7777
"@babel/core": "^7.25.2",
7878
"@expo/metro-config": "0.19.5",
7979
"@mswjs/interceptors": "^0.25.15",
8080
"@react-native/babel-preset": "0.76.3",
81-
"@sentry-internal/eslint-config-sdk": "8.48.0",
82-
"@sentry-internal/eslint-plugin-sdk": "8.48.0",
83-
"@sentry-internal/typescript": "8.48.0",
81+
"@sentry-internal/eslint-config-sdk": "8.50.0",
82+
"@sentry-internal/eslint-plugin-sdk": "8.50.0",
83+
"@sentry-internal/typescript": "8.50.0",
8484
"@sentry/wizard": "3.38.0",
8585
"@testing-library/react-native": "^12.7.2",
8686
"@types/jest": "^29.5.3",

packages/core/src/js/sdk.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable complexity */
22
import type { Breadcrumb, BreadcrumbHint, Integration, Scope, SendFeedbackParams, UserFeedback } from '@sentry/core';
3-
import { captureFeedback, getClient, getGlobalScope, getIntegrationsToSetup, getIsolationScope, initAndBind, logger, stackParserFromStackParserOptions, withScope as coreWithScope } from '@sentry/core';
3+
import { captureFeedback, getClient, getGlobalScope, getIntegrationsToSetup, getIsolationScope, initAndBind, logger, makeDsn, stackParserFromStackParserOptions, withScope as coreWithScope } from '@sentry/core';
44
import {
55
defaultStackParser,
66
makeFetchTransport,
@@ -66,13 +66,13 @@ export function init(passedOptions: ReactNativeOptions): void {
6666
if (!dsn) {
6767
return undefined;
6868
}
69-
try {
70-
const url = new URL(dsn);
71-
return `${url.protocol}//${url.host}`;
72-
} catch (e) {
73-
logger.error('Failed to extract url from DSN', e);
69+
const dsnComponents = makeDsn(dsn);
70+
if (!dsnComponents) {
71+
logger.error('Failed to extract url from DSN: ', dsn);
7472
return undefined;
7573
}
74+
const port = dsnComponents.port ? `:${dsnComponents.port}` : '';
75+
return `${dsnComponents.protocol}://${dsnComponents.host}${port}`;
7676
};
7777

7878
const userBeforeBreadcrumb = safeFactory(passedOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' });

packages/core/test/sdk.test.ts

+50-11
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ describe('Tests the SDK functionality', () => {
321321
expect(result).toBeNull();
322322
});
323323

324-
it('should filters out dsn breadcrumbs', () => {
324+
it('should filter out dsn breadcrumbs', () => {
325325
(getDevServer as jest.Mock).mockReturnValue({ url: 'http://localhost:8081' });
326326

327327
const mockBeforeBreadcrumb = (breadcrumb: Breadcrumb, _hint?: BreadcrumbHint) => {
@@ -345,37 +345,76 @@ describe('Tests the SDK functionality', () => {
345345
expect(result).toBeNull();
346346
});
347347

348-
it('should keep breadcrumbs matching dsn if the url parsing fails for dsn', () => {
348+
it('should filter out dsn breadcrumbs that the ports match', () => {
349349
(getDevServer as jest.Mock).mockReturnValue({ url: 'http://localhost:8081' });
350350

351351
const mockBeforeBreadcrumb = (breadcrumb: Breadcrumb, _hint?: BreadcrumbHint) => {
352352
return breadcrumb;
353353
};
354354

355-
// Mock the URL constructor to throw an exception for this test case
356-
const originalURL = (global as any).URL;
357-
jest.spyOn(global as any, 'URL').mockImplementationOnce(() => {
358-
throw new Error('Failed to parse DSN URL');
359-
});
355+
const passedOptions = {
356+
dsn: 'https://[email protected]:8181/1234567',
357+
beforeBreadcrumb: mockBeforeBreadcrumb,
358+
};
359+
360+
init(passedOptions);
361+
362+
const breadcrumb: Breadcrumb = {
363+
type: 'http',
364+
data: { url: 'https://selfhosted.app.server:8181/api' },
365+
};
366+
367+
const result = usedOptions()?.beforeBreadcrumb!(breadcrumb);
368+
369+
expect(result).toBeNull();
370+
});
371+
372+
it('should keep breadcrumbs if the ports do not match', () => {
373+
(getDevServer as jest.Mock).mockReturnValue({ url: 'http://localhost:8081' });
374+
375+
const mockBeforeBreadcrumb = (breadcrumb: Breadcrumb, _hint?: BreadcrumbHint) => {
376+
return breadcrumb;
377+
};
360378

361379
const passedOptions = {
362-
dsn: 'https://[email protected]/1234567',
380+
dsn: 'https://[email protected]:8181/1234567',
363381
beforeBreadcrumb: mockBeforeBreadcrumb,
364382
};
365383

366384
init(passedOptions);
367385

368386
const breadcrumb: Breadcrumb = {
369387
type: 'http',
370-
data: { url: 'https://def.ingest.sentry.io/1234567' },
388+
data: { url: 'https://selfhosted.app.server:8080/api' },
371389
};
372390

373391
const result = usedOptions()?.beforeBreadcrumb!(breadcrumb);
374392

375393
expect(result).toEqual(breadcrumb);
394+
});
395+
396+
it('should keep breadcrumbs if the url parsing fails for dsn', () => {
397+
(getDevServer as jest.Mock).mockReturnValue({ url: 'http://localhost:8081' });
398+
399+
const mockBeforeBreadcrumb = (breadcrumb: Breadcrumb, _hint?: BreadcrumbHint) => {
400+
return breadcrumb;
401+
};
402+
403+
const passedOptions = {
404+
dsn: 'invalid-dsn',
405+
beforeBreadcrumb: mockBeforeBreadcrumb,
406+
};
407+
408+
init(passedOptions);
376409

377-
// Restore the original URL constructor
378-
(global as any).URL = originalURL;
410+
const breadcrumb: Breadcrumb = {
411+
type: 'http',
412+
data: { url: 'https://def.ingest.sentry.io/1234567' },
413+
};
414+
415+
const result = usedOptions()?.beforeBreadcrumb!(breadcrumb);
416+
417+
expect(result).toEqual(breadcrumb);
379418
});
380419

381420
it('should keep non dev server or dsn breadcrumbs', () => {

samples/react-native-macos/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"@react-navigation/bottom-tabs": "^6.5.12",
1717
"@react-navigation/native": "^6.1.9",
1818
"@react-navigation/stack": "^6.3.20",
19-
"@sentry/core": "8.48.0",
20-
"@sentry/react": "8.48.0",
19+
"@sentry/core": "8.50.0",
20+
"@sentry/react": "8.50.0",
2121
"@sentry/react-native": "6.5.0",
2222
"delay": "^6.0.0",
2323
"react": "18.2.0",

0 commit comments

Comments
 (0)