Skip to content

Commit 84138d2

Browse files
committed
Merge branch 'master' of https://github.com/getsentry/sentry-javascript into onur/playwright-browser-tests
2 parents c3d35b6 + 626102f commit 84138d2

File tree

4 files changed

+276
-250
lines changed

4 files changed

+276
-250
lines changed

packages/ember/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"lint:hbs": "ember-template-lint .",
2424
"lint:js": "eslint . --cache --cache-location '../../eslintcache/'",
2525
"pack": "npm pack",
26-
"prepublishOnly": "ember ts:precompile",
27-
"postpublish": "ember ts:clean",
26+
"prepack": "ember ts:precompile",
27+
"postpack": "ember ts:clean",
2828
"start": "ember serve",
2929
"test": "ember try:each",
3030
"test:all": "node ./scripts/run-CI-tests.js"
@@ -35,10 +35,10 @@
3535
"@sentry/tracing": "6.16.1",
3636
"@sentry/types": "6.16.1",
3737
"@sentry/utils": "6.16.1",
38-
"ember-auto-import": "^1.12.0",
38+
"ember-auto-import": "^1.12.0 || ^2.2.0",
3939
"ember-cli-babel": "~7.26.6",
40-
"ember-cli-htmlbars": "^5.7.1",
41-
"ember-cli-typescript": "~3.1.4"
40+
"ember-cli-htmlbars": "^6.0.1",
41+
"ember-cli-typescript": "^4.2.1"
4242
},
4343
"devDependencies": {
4444
"@ember/optional-features": "~1.3.0",
@@ -75,7 +75,8 @@
7575
"eslint-plugin-ember": "~8.6.0",
7676
"eslint-plugin-node": "^11.1.0",
7777
"loader.js": "~4.7.0",
78-
"qunit-dom": "~1.2.0"
78+
"qunit-dom": "~1.2.0",
79+
"webpack": "^5.65.0"
7980
},
8081
"engines": {
8182
"node": "10.* || >= 12"

packages/react/src/errorboundary.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { captureException, ReportDialogOptions, Scope, showReportDialog, withScope } from '@sentry/browser';
2-
import { logger, parseSemver } from '@sentry/utils';
2+
import { logger } from '@sentry/utils';
33
import hoistNonReactStatics from 'hoist-non-react-statics';
44
import * as React from 'react';
55

6-
const reactVersion = parseSemver(React.version);
6+
export function isAtLeastReact17(version: string): boolean {
7+
const major = version.match(/^([^.]+)/);
8+
return major !== null && parseInt(major[0]) >= 17;
9+
}
710

811
export const UNKNOWN_COMPONENT = 'unknown';
912

@@ -71,7 +74,7 @@ class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundarySta
7174
// If on React version >= 17, create stack trace from componentStack param and links
7275
// to to the original error using `error.cause` otherwise relies on error param for stacktrace.
7376
// Linking errors requires the `LinkedErrors` integration be enabled.
74-
if (reactVersion.major && reactVersion.major >= 17) {
77+
if (isAtLeastReact17(React.version)) {
7578
const errorBoundaryError = new Error(error.message);
7679
errorBoundaryError.name = `React ErrorBoundary ${errorBoundaryError.name}`;
7780
errorBoundaryError.stack = componentStack;

packages/react/test/errorboundary.test.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import { fireEvent, render, screen } from '@testing-library/react';
33
import * as React from 'react';
44
import { useState } from 'react';
55

6-
import { ErrorBoundary, ErrorBoundaryProps, UNKNOWN_COMPONENT, withErrorBoundary } from '../src/errorboundary';
6+
import {
7+
ErrorBoundary,
8+
ErrorBoundaryProps,
9+
isAtLeastReact17,
10+
UNKNOWN_COMPONENT,
11+
withErrorBoundary,
12+
} from '../src/errorboundary';
713

814
const mockCaptureException = jest.fn();
915
const mockShowReportDialog = jest.fn();
@@ -326,3 +332,17 @@ describe('ErrorBoundary', () => {
326332
});
327333
});
328334
});
335+
336+
describe('isAtLeastReact17', () => {
337+
test.each([
338+
['React 15 with no patch', '15.0', false],
339+
['React 15 with no patch and no minor', '15.5', false],
340+
['React 16', '16.0.4', false],
341+
['React 17', '17.0.0', true],
342+
['React 17 with no patch', '17.4', true],
343+
['React 17 with no patch and no minor', '17', true],
344+
['React 18', '18.0.0', true],
345+
])('%s', (_: string, input: string, output: ReturnType<typeof isAtLeastReact17>) => {
346+
expect(isAtLeastReact17(input)).toBe(output);
347+
});
348+
});

0 commit comments

Comments
 (0)