Skip to content

Commit 4c8dc37

Browse files
committed
Merge branch 'master' into feat-replays-add-mask-and-unmask-options
2 parents be11ca5 + 9f06d48 commit 4c8dc37

File tree

142 files changed

+6016
-1218
lines changed

Some content is hidden

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

142 files changed

+6016
-1218
lines changed

CHANGELOG.md

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

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

7+
## 7.30.0
8+
9+
- feat(core): Add `addIntegration` method to client (#6651)
10+
- feat(core): Add `replay_event` type for events (#6481)
11+
- feat(gatsby): Support Gatsby v5 (#6635)
12+
- feat(integrations): Add HTTPClient integration (#6500)
13+
- feat(node): Add `LocalVariables` integration to capture local variables to stack frames (#6478)
14+
- feat(node): Check for invalid url in node transport (#6623)
15+
- feat(replay): Remove `replayType` from tags and into `replay_event` (#6658)
16+
- feat(transport): Return result through Transport send (#6626)
17+
- fix(nextjs): Don't wrap `res.json` and `res.send` (#6674)
18+
- fix(nextjs): Don't write to `res.end` to fix `next export` (#6682)
19+
- fix(nextjs): Exclude SDK from Edge runtime bundles (#6683)
20+
- fix(replay): Allow Replay to be used in Electron renderers with nodeIntegration enabled (#6644)
21+
- fix(utils): Ignore stack frames over 1kb (#6627)
22+
- ref(angular) Add error-like objects handling (#6446)
23+
- ref(nextjs): Remove `instrumentSever` (#6592)
24+
25+
Work in this release contributed by @rjoonas, @Naddiseo, and @theofidry. Thank you for your contributions!
26+
27+
## 7.29.0
28+
29+
This update includes a change to the `@sentry/nextjs` SDK that may increase response times of requests in applications
30+
deployed to Vercel or AWS lambdas to ensure that error events are sent consistently.
31+
Additionally, Next.js applications deployed to Vercel or AWS lambdas may also see an uptick in sent transactions. (for
32+
more information see #6578)
33+
34+
- feat(core): Add `getSdkMetadata` to `Client` (#6643)
35+
- feat(nextjs): Send events consistently on platforms that don't support streaming (#6578)
36+
- feat(replay): Use new `prepareEvent` util & ensure dropping replays works (#6522)
37+
- feat(types): Upstream some replay types (#6506)
38+
- fix(replay): Envelope send should be awaited in try/catch (#6625)
39+
- fix(replay): Improve handling of `maskAllText` selector (#6637)
40+
- fix(tracing): Don't finish React Router 6 `pageload` transactions early (#6609)
41+
742
## 7.28.1
843

944
- fix(replay): Do not mangle `_metadata` in client options (#6600)

docs/event-sending.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ This document gives an outline for how event sending works, and which which plac
7777
## Replay (WIP)
7878

7979
* `replay.sendReplayRequest()`
80-
* `createPayload()`
81-
* `getReplayEvent()`
80+
* `createRecordingData()`
81+
* `prepareReplayEvent()`
8282
* `client._prepareEvent()` (see baseclient)
8383
* `baseclient._applyClientOptions()`
8484
* `baseclient._applyIntegrationsMetadata()`

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": "7.28.1",
3+
"version": "7.29.0",
44
"packages": "packages/*",
55
"npmClient": "yarn",
66
"useWorkspaces": true

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": "7.28.1",
3+
"version": "7.29.0",
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
"rxjs": "^6.5.5 || ^7.x"
2222
},
2323
"dependencies": {
24-
"@sentry/browser": "7.28.1",
25-
"@sentry/types": "7.28.1",
26-
"@sentry/utils": "7.28.1",
24+
"@sentry/browser": "7.29.0",
25+
"@sentry/types": "7.29.0",
26+
"@sentry/utils": "7.29.0",
2727
"tslib": "^2.0.0"
2828
},
2929
"devDependencies": {

packages/angular/src/errorhandler.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { HttpErrorResponse } from '@angular/common/http';
22
import { ErrorHandler as AngularErrorHandler, Inject, Injectable } from '@angular/core';
33
import * as Sentry from '@sentry/browser';
44
import { captureException } from '@sentry/browser';
5-
import { addExceptionMechanism } from '@sentry/utils';
5+
import { addExceptionMechanism, isString } from '@sentry/utils';
66

77
import { runOutsideAngular } from './zone';
88

@@ -32,7 +32,7 @@ function tryToUnwrapZonejsError(error: unknown): unknown | Error {
3232

3333
function extractHttpModuleError(error: HttpErrorResponse): string | Error {
3434
// The `error` property of http exception can be either an `Error` object, which we can use directly...
35-
if (error.error instanceof Error) {
35+
if (isErrorOrErrorLikeObject(error.error)) {
3636
return error.error;
3737
}
3838

@@ -50,6 +50,31 @@ function extractHttpModuleError(error: HttpErrorResponse): string | Error {
5050
return error.message;
5151
}
5252

53+
type ErrorCandidate = {
54+
name?: unknown;
55+
message?: unknown;
56+
stack?: unknown;
57+
};
58+
59+
function isErrorOrErrorLikeObject(value: unknown): value is Error {
60+
if (value instanceof Error) {
61+
return true;
62+
}
63+
64+
if (value === null || typeof value !== 'object') {
65+
return false;
66+
}
67+
68+
const candidate = value as ErrorCandidate;
69+
70+
return (
71+
isString(candidate.name) &&
72+
isString(candidate.name) &&
73+
isString(candidate.message) &&
74+
(undefined === candidate.stack || isString(candidate.stack))
75+
);
76+
}
77+
5378
/**
5479
* Implementation of Angular's ErrorHandler provider that can be used as a drop-in replacement for the stock one.
5580
*/
@@ -117,16 +142,16 @@ class SentryErrorHandler implements AngularErrorHandler {
117142
protected _defaultExtractor(errorCandidate: unknown): unknown {
118143
const error = tryToUnwrapZonejsError(errorCandidate);
119144

120-
// We can handle messages and Error objects directly.
121-
if (typeof error === 'string' || error instanceof Error) {
122-
return error;
123-
}
124-
125145
// If it's http module error, extract as much information from it as we can.
126146
if (error instanceof HttpErrorResponse) {
127147
return extractHttpModuleError(error);
128148
}
129149

150+
// We can handle messages and Error objects directly.
151+
if (typeof error === 'string' || isErrorOrErrorLikeObject(error)) {
152+
return error;
153+
}
154+
130155
// Nothing was extracted, fallback to default error message.
131156
return null;
132157
}

packages/angular/test/errorhandler.test.ts

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CustomError extends Error {
3333
}
3434

3535
class ErrorLikeShapedClass implements Partial<Error> {
36-
constructor(public message: string) {}
36+
constructor(public name: string, public message: string) {}
3737
}
3838

3939
function createErrorEvent(message: string, innerError: any): ErrorEvent {
@@ -118,8 +118,7 @@ describe('SentryErrorHandler', () => {
118118
createErrorHandler().handleError(errorLikeWithoutStack);
119119

120120
expect(captureExceptionSpy).toHaveBeenCalledTimes(1);
121-
// TODO: to be changed; see https://github.com/getsentry/sentry-javascript/issues/6332
122-
expect(captureExceptionSpy).toHaveBeenCalledWith('Handled unknown error', expect.any(Function));
121+
expect(captureExceptionSpy).toHaveBeenCalledWith(errorLikeWithoutStack, expect.any(Function));
123122
});
124123

125124
it('extracts an error-like object with a stack', () => {
@@ -132,8 +131,7 @@ describe('SentryErrorHandler', () => {
132131
createErrorHandler().handleError(errorLikeWithStack);
133132

134133
expect(captureExceptionSpy).toHaveBeenCalledTimes(1);
135-
// TODO: to be changed; see https://github.com/getsentry/sentry-javascript/issues/6332
136-
expect(captureExceptionSpy).toHaveBeenCalledWith('Handled unknown error', expect.any(Function));
134+
expect(captureExceptionSpy).toHaveBeenCalledWith(errorLikeWithStack, expect.any(Function));
137135
});
138136

139137
it('extracts an object that could look like an error but is not (does not have a message)', () => {
@@ -150,7 +148,6 @@ describe('SentryErrorHandler', () => {
150148

151149
it('extracts an object that could look like an error but is not (does not have an explicit name)', () => {
152150
const notErr: Partial<Error> = {
153-
// missing name; but actually is always there as part of the Object prototype
154151
message: 'something failed.',
155152
};
156153

@@ -194,12 +191,12 @@ describe('SentryErrorHandler', () => {
194191
});
195192

196193
it('extracts an instance of class not extending Error but that has an error-like shape', () => {
197-
const err = new ErrorLikeShapedClass('something happened');
194+
const err = new ErrorLikeShapedClass('sentry-error', 'something happened');
198195

199196
createErrorHandler().handleError(err);
200197

201198
expect(captureExceptionSpy).toHaveBeenCalledTimes(1);
202-
expect(captureExceptionSpy).toHaveBeenCalledWith('Handled unknown error', expect.any(Function));
199+
expect(captureExceptionSpy).toHaveBeenCalledWith(err, expect.any(Function));
203200
});
204201

205202
it('extracts an instance of a class that does not extend Error and does not have an error-like shape', () => {
@@ -304,11 +301,7 @@ describe('SentryErrorHandler', () => {
304301
createErrorHandler().handleError(err);
305302

306303
expect(captureExceptionSpy).toHaveBeenCalledTimes(1);
307-
// TODO: to be changed; see https://github.com/getsentry/sentry-javascript/issues/6332
308-
expect(captureExceptionSpy).toHaveBeenCalledWith(
309-
'Http failure response for (unknown url): undefined undefined',
310-
expect.any(Function),
311-
);
304+
expect(captureExceptionSpy).toHaveBeenCalledWith(errorLikeWithoutStack, expect.any(Function));
312305
});
313306

314307
it('extracts an `HttpErrorResponse` with error-like object with a stack', () => {
@@ -322,11 +315,7 @@ describe('SentryErrorHandler', () => {
322315
createErrorHandler().handleError(err);
323316

324317
expect(captureExceptionSpy).toHaveBeenCalledTimes(1);
325-
// TODO: to be changed; see https://github.com/getsentry/sentry-javascript/issues/6332
326-
expect(captureExceptionSpy).toHaveBeenCalledWith(
327-
'Http failure response for (unknown url): undefined undefined',
328-
expect.any(Function),
329-
);
318+
expect(captureExceptionSpy).toHaveBeenCalledWith(errorLikeWithStack, expect.any(Function));
330319
});
331320

332321
it('extracts an `HttpErrorResponse` with an object that could look like an error but is not (does not have a message)', () => {
@@ -347,7 +336,6 @@ describe('SentryErrorHandler', () => {
347336

348337
it('extracts an `HttpErrorResponse` with an object that could look like an error but is not (does not have an explicit name)', () => {
349338
const notErr: Partial<Error> = {
350-
// missing name; but actually is always there as part of the Object prototype
351339
message: 'something failed.',
352340
};
353341
const err = new HttpErrorResponse({ error: notErr });
@@ -453,16 +441,13 @@ describe('SentryErrorHandler', () => {
453441
});
454442

455443
it('extracts an `HttpErrorResponse` with an instance of class not extending Error but that has an error-like shape', () => {
456-
const innerErr = new ErrorLikeShapedClass('something happened');
444+
const innerErr = new ErrorLikeShapedClass('sentry-error', 'something happened');
457445
const err = new HttpErrorResponse({ error: innerErr });
458446

459447
createErrorHandler().handleError(err);
460448

461449
expect(captureExceptionSpy).toHaveBeenCalledTimes(1);
462-
expect(captureExceptionSpy).toHaveBeenCalledWith(
463-
'Http failure response for (unknown url): undefined undefined',
464-
expect.any(Function),
465-
);
450+
expect(captureExceptionSpy).toHaveBeenCalledWith(innerErr, expect.any(Function));
466451
});
467452

468453
it('extracts an `HttpErrorResponse` with an instance of a class that does not extend Error and does not have an error-like shape', () => {

packages/browser/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tmp.js

packages/browser/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/browser",
3-
"version": "7.28.1",
3+
"version": "7.29.0",
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,10 +16,10 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/core": "7.28.1",
20-
"@sentry/replay": "7.28.1",
21-
"@sentry/types": "7.28.1",
22-
"@sentry/utils": "7.28.1",
19+
"@sentry/core": "7.29.0",
20+
"@sentry/replay": "7.29.0",
21+
"@sentry/types": "7.29.0",
22+
"@sentry/utils": "7.29.0",
2323
"tslib": "^1.9.3"
2424
},
2525
"devDependencies": {

packages/browser/src/client.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import { BaseClient, getEnvelopeEndpointWithUrlEncodedAuth, Scope, SDK_VERSION } from '@sentry/core';
2-
import {
3-
BrowserClientReplayOptions,
4-
ClientOptions,
5-
Event,
6-
EventHint,
7-
Options,
8-
Severity,
9-
SeverityLevel,
10-
} from '@sentry/types';
2+
import type { BrowserClientReplayOptions } from '@sentry/types';
3+
import { ClientOptions, Event, EventHint, Options, Severity, SeverityLevel } from '@sentry/types';
114
import { createClientReportEnvelope, dsnToString, logger, serializeEnvelope } from '@sentry/utils';
125

136
import { eventFromException, eventFromMessage } from './eventbuilder';

packages/browser/src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,5 @@ export interface ReportDialogOptions {
179179
errorFormEntry?: string;
180180
successMessage?: string;
181181
/** Callback after reportDialog showed up */
182-
onLoad?(): void;
182+
onLoad?(this: void): void;
183183
}

packages/browser/src/integrations/httpcontext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class HttpContext implements Integration {
3636
...(referrer && { Referer: referrer }),
3737
...(userAgent && { 'User-Agent': userAgent }),
3838
};
39-
const request = { ...(url && { url }), headers };
39+
const request = { ...event.request, ...(url && { url }), headers };
4040

4141
return { ...event, request };
4242
}

packages/browser/src/sdk.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ export function showReportDialog(options: ReportDialogOptions = {}, hub: Hub = g
164164
script.src = getReportDialogEndpoint(dsn, options);
165165

166166
if (options.onLoad) {
167-
// eslint-disable-next-line @typescript-eslint/unbound-method
168167
script.onload = options.onLoad;
169168
}
170169

packages/browser/test/unit/sdk.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
/* eslint-disable @typescript-eslint/unbound-method */
2-
import { Scope } from '@sentry/core';
3-
import { createTransport } from '@sentry/core';
2+
import { createTransport, Scope } from '@sentry/core';
43
import { MockIntegration } from '@sentry/core/test/lib/sdk.test';
54
import { Client, Integration } from '@sentry/types';
65
import { resolvedSyncPromise } from '@sentry/utils';
76

87
import { BrowserOptions } from '../../src';
98
import { init } from '../../src/sdk';
10-
// eslint-disable-next-line no-var
11-
declare var global: any;
129

1310
const PUBLIC_DSN = 'https://username@domain/123';
1411

packages/browser/test/unit/tracekit/chromium.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,4 +547,30 @@ describe('Tracekit - Chrome Tests', () => {
547547
},
548548
});
549549
});
550+
551+
it('should drop frames that are over 1kb', () => {
552+
const LONG_STR = 'A'.repeat(1040);
553+
554+
const LONG_FRAME = {
555+
message: 'bad',
556+
name: 'Error',
557+
stack: `Error: bad
558+
at aha (http://localhost:5000/:39:5)
559+
at Foo.testMethod (http://localhost:5000/${LONG_STR}:44:7)
560+
at http://localhost:5000/:50:19`,
561+
};
562+
563+
const ex = exceptionFromError(parser, LONG_FRAME);
564+
565+
expect(ex).toEqual({
566+
value: 'bad',
567+
type: 'Error',
568+
stacktrace: {
569+
frames: [
570+
{ filename: 'http://localhost:5000/', function: '?', lineno: 50, colno: 19, in_app: true },
571+
{ filename: 'http://localhost:5000/', function: 'aha', lineno: 39, colno: 5, in_app: true },
572+
],
573+
},
574+
});
575+
});
550576
});

packages/core/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/core",
3-
"version": "7.28.1",
3+
"version": "7.29.0",
44
"description": "Base implementation for all Sentry JavaScript SDKs",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/core",
@@ -16,8 +16,8 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/types": "7.28.1",
20-
"@sentry/utils": "7.28.1",
19+
"@sentry/types": "7.29.0",
20+
"@sentry/utils": "7.29.0",
2121
"tslib": "^1.9.3"
2222
},
2323
"scripts": {

0 commit comments

Comments
 (0)