Skip to content

Commit 2d00b51

Browse files
committed
Merge branch 'master' of https://github.com/getsentry/sentry-javascript into onur/test-bundles
2 parents f69b8a9 + 1bf9883 commit 2d00b51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1697
-1196
lines changed

.github/workflows/jira.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Create JIRA issue
2+
3+
on:
4+
issues:
5+
types: [labeled]
6+
7+
jobs:
8+
createIssue:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: getsentry/ga-jira-integration@main
12+
with:
13+
JIRA_API_HOST: ${{secrets.JIRA_BASEURL}}
14+
JIRA_API_TOKEN: ${{secrets.JIRA_APITOKEN}}
15+
JIRA_EMAIL: ${{secrets.JIRA_USEREMAIL}}
16+
TRIGGER_LABEL: "Jira"
17+
JIRA_PROJECT_ID: WEB
18+
JIRA_ISSUE_NAME: Story

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
## 6.17.9
8+
9+
- fix(gatsby): Add missing React peer dependency ([#4576](https://github.com/getsentry/sentry-javascript/pull/4576))
10+
- fix(types): Use Sentry event type instead of dom one ([#4584](https://github.com/getsentry/sentry-javascript/pull/4584))
11+
12+
Work in this release contributed by @aaronadamsCA. Thank you for your contribution!
13+
14+
## 6.17.8
15+
16+
- feat(types): Add Envelope types ([#4527](https://github.com/getsentry/sentry-javascript/pull/4527))
17+
- fix(build): Remove node code from CDN bundles ([#4548](https://github.com/getsentry/sentry-javascript/pull/4548))
18+
- fix(build): Prevent unused utils code in integration bundles ([#4547](https://github.com/getsentry/sentry-javascript/pull/4547))
19+
- fix(tracing): Export BrowserTracing directly in CDN bundle ([#4570](https://github.com/getsentry/sentry-javascript/pull/4570))
20+
- fix(utils): Use apply in console instrumentation ([#4568](https://github.com/getsentry/sentry-javascript/pull/4568))
21+
- ref(core): Log `normalizeDepth` when normalization is skipped([#4574](https://github.com/getsentry/sentry-javascript/pull/4574))
22+
23+
Work in this release contributed by @mydea. Thank you for your contribution!
24+
725
## 6.17.7
826

927
- fix(utils): Make new non-enumerable properties mutable ([#4528](https://github.com/getsentry/sentry-javascript/pull/4528))

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"lerna": "3.4.0",
3-
"version": "6.17.7",
3+
"version": "6.17.9",
44
"packages": "packages/*",
55
"npmClient": "yarn",
66
"useWorkspaces": true

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
],
5252
"devDependencies": {
5353
"@google-cloud/storage": "^5.7.0",
54+
"@rollup/plugin-commonjs": "^21.0.1",
55+
"@rollup/plugin-node-resolve": "^13.1.3",
5456
"@rollup/plugin-replace": "^3.0.1",
5557
"@size-limit/preset-small-lib": "^4.5.5",
5658
"@strictsoftware/typedoc-plugin-monorepo": "^0.3.1",
@@ -72,6 +74,7 @@
7274
"prettier": "2.5.1",
7375
"replace-in-file": "^4.0.0",
7476
"rimraf": "^3.0.2",
77+
"rollup": "^2.67.1",
7578
"rollup-plugin-license": "^2.6.1",
7679
"rollup-plugin-terser": "^7.0.2",
7780
"rollup-plugin-typescript2": "^0.31.2",

packages/angular/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/angular",
3-
"version": "6.17.7",
3+
"version": "6.17.9",
44
"description": "Official Sentry SDK for Angular",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/angular",
@@ -21,9 +21,9 @@
2121
"@angular/router": "10.x || 11.x || 12.x || 13.x"
2222
},
2323
"dependencies": {
24-
"@sentry/browser": "6.17.7",
25-
"@sentry/types": "6.17.7",
26-
"@sentry/utils": "6.17.7",
24+
"@sentry/browser": "6.17.9",
25+
"@sentry/types": "6.17.9",
26+
"@sentry/utils": "6.17.9",
2727
"rxjs": "^6.6.0",
2828
"tslib": "^1.9.3"
2929
},

packages/browser/package.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/browser",
3-
"version": "6.17.7",
3+
"version": "6.17.9",
44
"description": "Official Sentry SDK for browsers",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser",
@@ -16,9 +16,9 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/core": "6.17.7",
20-
"@sentry/types": "6.17.7",
21-
"@sentry/utils": "6.17.7",
19+
"@sentry/core": "6.17.9",
20+
"@sentry/types": "6.17.9",
21+
"@sentry/utils": "6.17.9",
2222
"tslib": "^1.9.3"
2323
},
2424
"devDependencies": {
@@ -40,9 +40,6 @@
4040
"karma-webkit-launcher": "^1.0.2",
4141
"node-fetch": "^2.6.0",
4242
"playwright": "^1.17.1",
43-
"rollup": "^1.10.1",
44-
"rollup-plugin-commonjs": "^9.3.4",
45-
"rollup-plugin-node-resolve": "^4.2.3",
4643
"sinon": "^7.3.2",
4744
"webpack": "^4.30.0"
4845
},

packages/browser/rollup.config.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { terser } from 'rollup-plugin-terser';
22
import typescript from 'rollup-plugin-typescript2';
33
import license from 'rollup-plugin-license';
4-
import resolve from 'rollup-plugin-node-resolve';
5-
import commonjs from 'rollup-plugin-commonjs';
4+
import resolve from '@rollup/plugin-node-resolve';
65
import replace from '@rollup/plugin-replace';
76

87
const commitHash = require('child_process')
@@ -72,7 +71,6 @@ const plugins = [
7271
resolve({
7372
mainFields: ['module'],
7473
}),
75-
commonjs(),
7674
];
7775

7876
const bundleConfig = {
@@ -82,6 +80,7 @@ const bundleConfig = {
8280
name: 'Sentry',
8381
sourcemap: true,
8482
strict: false,
83+
esModule: false,
8584
},
8685
context: 'window',
8786
plugins: [

packages/browser/src/eventbuilder.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import {
1111
resolvedSyncPromise,
1212
} from '@sentry/utils';
1313

14-
import { eventFromPlainObject, eventFromStacktrace, prepareFramesForEvent } from './parsers';
15-
import { computeStackTrace } from './tracekit';
14+
import { eventFromError, eventFromPlainObject, parseStackFrames } from './parsers';
1615

1716
/**
1817
* Creates an {@link Event} from all inputs to `captureException` and non-primitive inputs to `captureMessage`.
@@ -68,10 +67,7 @@ export function eventFromUnknownInput(
6867
if (isErrorEvent(exception as ErrorEvent) && (exception as ErrorEvent).error) {
6968
// If it is an ErrorEvent with `error` property, extract it to get actual Error
7069
const errorEvent = exception as ErrorEvent;
71-
// eslint-disable-next-line no-param-reassign
72-
exception = errorEvent.error;
73-
event = eventFromStacktrace(computeStackTrace(exception as Error));
74-
return event;
70+
return eventFromError(errorEvent.error as Error);
7571
}
7672

7773
// If it is a `DOMError` (which is a legacy API, but still supported in some browsers) then we just extract the name
@@ -85,7 +81,7 @@ export function eventFromUnknownInput(
8581
const domException = exception as DOMException;
8682

8783
if ('stack' in (exception as Error)) {
88-
event = eventFromStacktrace(computeStackTrace(exception as Error));
84+
event = eventFromError(exception as Error);
8985
} else {
9086
const name = domException.name || (isDOMError(domException) ? 'DOMError' : 'DOMException');
9187
const message = domException.message ? `${name}: ${domException.message}` : name;
@@ -100,8 +96,7 @@ export function eventFromUnknownInput(
10096
}
10197
if (isError(exception as Error)) {
10298
// we have a real Error object, do nothing
103-
event = eventFromStacktrace(computeStackTrace(exception as Error));
104-
return event;
99+
return eventFromError(exception as Error);
105100
}
106101
if (isPlainObject(exception) || isEvent(exception)) {
107102
// If it's a plain object or an instance of `Event` (the built-in JS kind, not this SDK's `Event` type), serialize
@@ -148,10 +143,8 @@ export function eventFromString(
148143
};
149144

150145
if (options.attachStacktrace && syntheticException) {
151-
const stacktrace = computeStackTrace(syntheticException);
152-
const frames = prepareFramesForEvent(stacktrace.stack);
153146
event.stacktrace = {
154-
frames,
147+
frames: parseStackFrames(syntheticException),
155148
};
156149
}
157150

packages/browser/src/integrations/linkederrors.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core';
22
import { Event, EventHint, Exception, ExtendedError, Integration } from '@sentry/types';
33
import { isInstanceOf } from '@sentry/utils';
44

5-
import { exceptionFromStacktrace } from '../parsers';
6-
import { computeStackTrace } from '../tracekit';
5+
import { exceptionFromError } from '../parsers';
76

87
const DEFAULT_KEY = 'cause';
98
const DEFAULT_LIMIT = 5;
@@ -73,7 +72,6 @@ export function _walkErrorTree(limit: number, error: ExtendedError, key: string,
7372
if (!isInstanceOf(error[key], Error) || stack.length + 1 >= limit) {
7473
return stack;
7574
}
76-
const stacktrace = computeStackTrace(error[key]);
77-
const exception = exceptionFromStacktrace(stacktrace);
75+
const exception = exceptionFromError(error[key]);
7876
return _walkErrorTree(limit, error[key], key, [exception, ...stack]);
7977
}

packages/browser/src/parsers.ts

Lines changed: 55 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
12
import { Event, Exception, StackFrame } from '@sentry/types';
2-
import { extractExceptionKeysForMessage, isEvent, normalizeToSize } from '@sentry/utils';
3+
import { createStackParser, extractExceptionKeysForMessage, isEvent, normalizeToSize } from '@sentry/utils';
34

4-
import { computeStackTrace, StackTrace as TraceKitStackTrace } from './tracekit';
5-
6-
const STACKTRACE_LIMIT = 50;
5+
import { chrome, gecko, opera10, opera11, winjs } from './stack-parsers';
76

87
/**
98
* This function creates an exception from an TraceKitStackTrace
109
* @param stacktrace TraceKitStackTrace that will be converted to an exception
1110
* @hidden
1211
*/
13-
export function exceptionFromStacktrace(stacktrace: TraceKitStackTrace): Exception {
14-
const frames = prepareFramesForEvent(stacktrace.stack);
12+
export function exceptionFromError(ex: Error): Exception {
13+
// Get the frames first since Opera can lose the stack if we touch anything else first
14+
const frames = parseStackFrames(ex);
1515

1616
const exception: Exception = {
17-
type: stacktrace.name,
18-
value: stacktrace.message,
17+
type: ex && ex.name,
18+
value: extractMessage(ex),
1919
};
2020

2121
if (frames && frames.length) {
@@ -54,10 +54,8 @@ export function eventFromPlainObject(
5454
};
5555

5656
if (syntheticException) {
57-
const stacktrace = computeStackTrace(syntheticException);
58-
const frames = prepareFramesForEvent(stacktrace.stack);
5957
event.stacktrace = {
60-
frames,
58+
frames: parseStackFrames(syntheticException),
6159
};
6260
}
6361

@@ -67,48 +65,63 @@ export function eventFromPlainObject(
6765
/**
6866
* @hidden
6967
*/
70-
export function eventFromStacktrace(stacktrace: TraceKitStackTrace): Event {
71-
const exception = exceptionFromStacktrace(stacktrace);
72-
68+
export function eventFromError(ex: Error): Event {
7369
return {
7470
exception: {
75-
values: [exception],
71+
values: [exceptionFromError(ex)],
7672
},
7773
};
7874
}
7975

80-
/**
81-
* @hidden
82-
*/
83-
export function prepareFramesForEvent(stack: StackFrame[]): StackFrame[] {
84-
if (!stack.length) {
85-
return [];
76+
/** Parses stack frames from an error */
77+
export function parseStackFrames(ex: Error & { framesToPop?: number; stacktrace?: string }): StackFrame[] {
78+
// Access and store the stacktrace property before doing ANYTHING
79+
// else to it because Opera is not very good at providing it
80+
// reliably in other circumstances.
81+
const stacktrace = ex.stacktrace || ex.stack || '';
82+
83+
const popSize = getPopSize(ex);
84+
85+
try {
86+
// The order of the parsers in important
87+
return createStackParser(opera10, opera11, chrome, winjs, gecko)(stacktrace, popSize);
88+
} catch (e) {
89+
// no-empty
8690
}
8791

88-
let localStack = stack;
92+
return [];
93+
}
8994

90-
const firstFrameFunction = localStack[0].function || '';
91-
const lastFrameFunction = localStack[localStack.length - 1].function || '';
95+
// Based on our own mapping pattern - https://github.com/getsentry/sentry/blob/9f08305e09866c8bd6d0c24f5b0aabdd7dd6c59c/src/sentry/lang/javascript/errormapping.py#L83-L108
96+
const reactMinifiedRegexp = /Minified React error #\d+;/i;
9297

93-
// If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
94-
if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
95-
localStack = localStack.slice(1);
96-
}
98+
function getPopSize(ex: Error & { framesToPop?: number }): number {
99+
if (ex) {
100+
if (typeof ex.framesToPop === 'number') {
101+
return ex.framesToPop;
102+
}
97103

98-
// If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call)
99-
if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
100-
localStack = localStack.slice(0, -1);
104+
if (reactMinifiedRegexp.test(ex.message)) {
105+
return 1;
106+
}
101107
}
102108

103-
// The frame where the crash happened, should be the last entry in the array
104-
return localStack
105-
.slice(0, STACKTRACE_LIMIT)
106-
.map(frame => ({
107-
filename: frame.filename || localStack[0].filename,
108-
function: frame.function || '?',
109-
lineno: frame.lineno,
110-
colno: frame.colno,
111-
in_app: true,
112-
}))
113-
.reverse();
109+
return 0;
110+
}
111+
112+
/**
113+
* There are cases where stacktrace.message is an Event object
114+
* https://github.com/getsentry/sentry-javascript/issues/1949
115+
* In this specific case we try to extract stacktrace.message.error.message
116+
*/
117+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
118+
function extractMessage(ex: any): string {
119+
const message = ex && ex.message;
120+
if (!message) {
121+
return 'No error message';
122+
}
123+
if (message.error && typeof message.error.message === 'string') {
124+
return message.error.message;
125+
}
126+
return message;
114127
}

0 commit comments

Comments
 (0)