Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into lforst-refactor-pro…
Browse files Browse the repository at this point in the history
…xy-loader
  • Loading branch information
lforst committed Jan 10, 2023
2 parents 2be79a5 + 009cfd7 commit 7ad52b9
Show file tree
Hide file tree
Showing 44 changed files with 4,250 additions and 161 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@

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

## 7.30.0

- feat(core): Add `addIntegration` method to client (#6651)
- feat(core): Add `replay_event` type for events (#6481)
- feat(gatsby): Support Gatsby v5 (#6635)
- feat(integrations): Add HTTPClient integration (#6500)
- feat(node): Add `LocalVariables` integration to capture local variables to stack frames (#6478)
- feat(node): Check for invalid url in node transport (#6623)
- feat(replay): Remove `replayType` from tags and into `replay_event` (#6658)
- feat(transport): Return result through Transport send (#6626)
- fix(nextjs): Don't wrap `res.json` and `res.send` (#6674)
- fix(nextjs): Don't write to `res.end` to fix `next export` (#6682)
- fix(nextjs): Exclude SDK from Edge runtime bundles (#6683)
- fix(replay): Allow Replay to be used in Electron renderers with nodeIntegration enabled (#6644)
- fix(utils): Ignore stack frames over 1kb (#6627)
- ref(angular) Add error-like objects handling (#6446)
- ref(nextjs): Remove `instrumentSever` (#6592)

Work in this release contributed by @rjoonas, @Naddiseo, and @theofidry. Thank you for your contributions!

## 7.29.0

This update includes a change to the `@sentry/nextjs` SDK that may increase response times of requests in applications
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lerna": "3.4.0",
"version": "7.29.0",
"version": "7.30.0",
"packages": "packages/*",
"npmClient": "yarn",
"useWorkspaces": true
Expand Down
8 changes: 4 additions & 4 deletions packages/angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry/angular",
"version": "7.29.0",
"version": "7.30.0",
"description": "Official Sentry SDK for Angular",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/angular",
Expand All @@ -21,9 +21,9 @@
"rxjs": "^6.5.5 || ^7.x"
},
"dependencies": {
"@sentry/browser": "7.29.0",
"@sentry/types": "7.29.0",
"@sentry/utils": "7.29.0",
"@sentry/browser": "7.30.0",
"@sentry/types": "7.30.0",
"@sentry/utils": "7.30.0",
"tslib": "^2.0.0"
},
"devDependencies": {
Expand Down
39 changes: 32 additions & 7 deletions packages/angular/src/errorhandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpErrorResponse } from '@angular/common/http';
import { ErrorHandler as AngularErrorHandler, Inject, Injectable } from '@angular/core';
import * as Sentry from '@sentry/browser';
import { captureException } from '@sentry/browser';
import { addExceptionMechanism } from '@sentry/utils';
import { addExceptionMechanism, isString } from '@sentry/utils';

import { runOutsideAngular } from './zone';

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

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

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

type ErrorCandidate = {
name?: unknown;
message?: unknown;
stack?: unknown;
};

function isErrorOrErrorLikeObject(value: unknown): value is Error {
if (value instanceof Error) {
return true;
}

if (value === null || typeof value !== 'object') {
return false;
}

const candidate = value as ErrorCandidate;

return (
isString(candidate.name) &&
isString(candidate.name) &&
isString(candidate.message) &&
(undefined === candidate.stack || isString(candidate.stack))
);
}

/**
* Implementation of Angular's ErrorHandler provider that can be used as a drop-in replacement for the stock one.
*/
Expand Down Expand Up @@ -117,16 +142,16 @@ class SentryErrorHandler implements AngularErrorHandler {
protected _defaultExtractor(errorCandidate: unknown): unknown {
const error = tryToUnwrapZonejsError(errorCandidate);

// We can handle messages and Error objects directly.
if (typeof error === 'string' || error instanceof Error) {
return error;
}

// If it's http module error, extract as much information from it as we can.
if (error instanceof HttpErrorResponse) {
return extractHttpModuleError(error);
}

// We can handle messages and Error objects directly.
if (typeof error === 'string' || isErrorOrErrorLikeObject(error)) {
return error;
}

// Nothing was extracted, fallback to default error message.
return null;
}
Expand Down
33 changes: 9 additions & 24 deletions packages/angular/test/errorhandler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CustomError extends Error {
}

class ErrorLikeShapedClass implements Partial<Error> {
constructor(public message: string) {}
constructor(public name: string, public message: string) {}
}

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

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

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

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

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

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

Expand Down Expand Up @@ -194,12 +191,12 @@ describe('SentryErrorHandler', () => {
});

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

createErrorHandler().handleError(err);

expect(captureExceptionSpy).toHaveBeenCalledTimes(1);
expect(captureExceptionSpy).toHaveBeenCalledWith('Handled unknown error', expect.any(Function));
expect(captureExceptionSpy).toHaveBeenCalledWith(err, expect.any(Function));
});

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

expect(captureExceptionSpy).toHaveBeenCalledTimes(1);
// TODO: to be changed; see https://github.com/getsentry/sentry-javascript/issues/6332
expect(captureExceptionSpy).toHaveBeenCalledWith(
'Http failure response for (unknown url): undefined undefined',
expect.any(Function),
);
expect(captureExceptionSpy).toHaveBeenCalledWith(errorLikeWithoutStack, expect.any(Function));
});

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

expect(captureExceptionSpy).toHaveBeenCalledTimes(1);
// TODO: to be changed; see https://github.com/getsentry/sentry-javascript/issues/6332
expect(captureExceptionSpy).toHaveBeenCalledWith(
'Http failure response for (unknown url): undefined undefined',
expect.any(Function),
);
expect(captureExceptionSpy).toHaveBeenCalledWith(errorLikeWithStack, expect.any(Function));
});

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

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

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

createErrorHandler().handleError(err);

expect(captureExceptionSpy).toHaveBeenCalledTimes(1);
expect(captureExceptionSpy).toHaveBeenCalledWith(
'Http failure response for (unknown url): undefined undefined',
expect.any(Function),
);
expect(captureExceptionSpy).toHaveBeenCalledWith(innerErr, expect.any(Function));
});

it('extracts an `HttpErrorResponse` with an instance of a class that does not extend Error and does not have an error-like shape', () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry/browser",
"version": "7.29.0",
"version": "7.30.0",
"description": "Official Sentry SDK for browsers",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser",
Expand All @@ -16,10 +16,10 @@
"access": "public"
},
"dependencies": {
"@sentry/core": "7.29.0",
"@sentry/replay": "7.29.0",
"@sentry/types": "7.29.0",
"@sentry/utils": "7.29.0",
"@sentry/core": "7.30.0",
"@sentry/replay": "7.30.0",
"@sentry/types": "7.30.0",
"@sentry/utils": "7.30.0",
"tslib": "^1.9.3"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry/core",
"version": "7.29.0",
"version": "7.30.0",
"description": "Base implementation for all Sentry JavaScript SDKs",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/core",
Expand All @@ -16,8 +16,8 @@
"access": "public"
},
"dependencies": {
"@sentry/types": "7.29.0",
"@sentry/utils": "7.29.0",
"@sentry/types": "7.30.0",
"@sentry/utils": "7.30.0",
"tslib": "^1.9.3"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const SDK_VERSION = '7.29.0';
export const SDK_VERSION = '7.30.0';
2 changes: 1 addition & 1 deletion packages/e2e-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry-internal/e2e-tests",
"version": "7.29.0",
"version": "7.30.0",
"license": "MIT",
"engines": {
"node": ">=10"
Expand Down
10 changes: 5 additions & 5 deletions packages/ember/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry/ember",
"version": "7.29.0",
"version": "7.30.0",
"description": "Official Sentry SDK for Ember.js",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/ember",
Expand Down Expand Up @@ -30,10 +30,10 @@
},
"dependencies": {
"@embroider/macros": "^1.9.0",
"@sentry/browser": "7.29.0",
"@sentry/tracing": "7.29.0",
"@sentry/types": "7.29.0",
"@sentry/utils": "7.29.0",
"@sentry/browser": "7.30.0",
"@sentry/tracing": "7.30.0",
"@sentry/types": "7.30.0",
"@sentry/utils": "7.30.0",
"ember-auto-import": "^1.12.1 || ^2.4.3",
"ember-cli-babel": "^7.26.11",
"ember-cli-htmlbars": "^6.1.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-config-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry-internal/eslint-config-sdk",
"version": "7.29.0",
"version": "7.30.0",
"description": "Official Sentry SDK eslint config",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/eslint-config-sdk",
Expand All @@ -19,8 +19,8 @@
"access": "public"
},
"dependencies": {
"@sentry-internal/eslint-plugin-sdk": "7.29.0",
"@sentry-internal/typescript": "7.29.0",
"@sentry-internal/eslint-plugin-sdk": "7.30.0",
"@sentry-internal/typescript": "7.30.0",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",
"eslint-config-prettier": "^6.11.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry-internal/eslint-plugin-sdk",
"version": "7.29.0",
"version": "7.30.0",
"description": "Official Sentry SDK eslint plugin",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/eslint-plugin-sdk",
Expand Down
10 changes: 5 additions & 5 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry/gatsby",
"version": "7.29.0",
"version": "7.30.0",
"description": "Official Sentry SDK for Gatsby.js",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/gatsby",
Expand All @@ -20,10 +20,10 @@
"access": "public"
},
"dependencies": {
"@sentry/react": "7.29.0",
"@sentry/tracing": "7.29.0",
"@sentry/types": "7.29.0",
"@sentry/utils": "7.29.0",
"@sentry/react": "7.30.0",
"@sentry/tracing": "7.30.0",
"@sentry/types": "7.30.0",
"@sentry/utils": "7.30.0",
"@sentry/webpack-plugin": "1.19.0"
},
"peerDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/hub/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sentry/hub",
"version": "7.29.0",
"version": "7.30.0",
"description": "Sentry hub which handles global state managment.",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/hub",
Expand All @@ -16,9 +16,9 @@
"access": "public"
},
"dependencies": {
"@sentry/core": "7.29.0",
"@sentry/types": "7.29.0",
"@sentry/utils": "7.29.0",
"@sentry/core": "7.30.0",
"@sentry/types": "7.30.0",
"@sentry/utils": "7.30.0",
"tslib": "^1.9.3"
},
"scripts": {
Expand Down
Loading

0 comments on commit 7ad52b9

Please sign in to comment.