Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of deprecated event.stacktrace #4885

Merged
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [6, 8, 10, 12, 14, 16]
node: [8, 10, 12, 14, 16]
steps:
- name: Check out current commit (${{ env.HEAD_COMMIT }})
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "Sentry",
"license": "MIT",
"engines": {
"node": ">=6"
"node": ">=8"
},
"main": "dist/index.js",
"module": "esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "Sentry",
"license": "BSD-3-Clause",
"engines": {
"node": ">=6"
"node": ">=8"
},
"main": "build/npm/dist/index.js",
"module": "build/npm/esm/index.js",
Expand Down
6 changes: 0 additions & 6 deletions packages/browser/src/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ export interface BrowserOptions extends Options {
* By default, all errors will be sent.
*/
denyUrls?: Array<string | RegExp>;

/** @deprecated use {@link Options.allowUrls} instead. */
whitelistUrls?: Array<string | RegExp>;

/** @deprecated use {@link Options.denyUrls} instead. */
blacklistUrls?: Array<string | RegExp>;
}

/**
Expand Down
7 changes: 5 additions & 2 deletions packages/browser/src/eventbuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export function eventFromPlainObject(
if (syntheticException) {
const frames = parseStackFrames(syntheticException);
if (frames.length) {
event.stacktrace = { frames };
// event.exception.values[0] has been set above
(event.exception as { values: Exception[] }).values[0].stacktrace = { frames };
AbhiPrasad marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -273,7 +274,9 @@ export function eventFromString(input: string, syntheticException?: Error, attac
if (attachStacktrace && syntheticException) {
const frames = parseStackFrames(syntheticException);
if (frames.length) {
event.stacktrace = { frames };
event.exception = {
values: [{ value: input, stacktrace: { frames } }],
timfish marked this conversation as resolved.
Show resolved Hide resolved
};
}
}

Expand Down
2 changes: 0 additions & 2 deletions packages/browser/src/integrations/dedupe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ function _getFramesFromEvent(event: Event): StackFrame[] | undefined {
} catch (_oO) {
return undefined;
}
} else if (event.stacktrace) {
return event.stacktrace.frames;
timfish marked this conversation as resolved.
Show resolved Hide resolved
}
return undefined;
}
4 changes: 2 additions & 2 deletions packages/browser/test/integration/suites/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ describe('API', function () {
return runInSandbox(sandbox, function () {
throwNonError();
}).then(function (summary) {
assert.isAtLeast(summary.events[0].stacktrace.frames.length, 1);
assert.isAtMost(summary.events[0].stacktrace.frames.length, 3);
assert.isAtLeast(summary.events[0].exception.values[0].stacktrace.frames.length, 1);
assert.isAtMost(summary.events[0].exception.values[0].stacktrace.frames.length, 3);
});
});

Expand Down
13 changes: 0 additions & 13 deletions packages/browser/test/integration/suites/breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ describe('breadcrumbs', function () {
assert.equal(summary.breadcrumbHints.length, 1);
assert.equal(summary.breadcrumbHints[0].name, 'click');
assert.equal(summary.breadcrumbHints[0].event.target.tagName, 'INPUT');
// There should be no expection, if there is one it means we threw it
assert.isUndefined(summary.events[0].exception);
}
});
});
Expand Down Expand Up @@ -265,9 +263,6 @@ describe('breadcrumbs', function () {

assert.equal(summary.breadcrumbs[1].category, 'ui.input');
assert.equal(summary.breadcrumbs[1].message, 'body > form#foo-form > input[name="foo"]');

// There should be no expection, if there is one it means we threw it
assert.isUndefined(summary.events[0].exception);
}
});
});
Expand All @@ -288,8 +283,6 @@ describe('breadcrumbs', function () {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
// There should be no expection, if there is one it means we threw it
assert.isUndefined(summary.events[0].exception);
assert.equal(summary.breadcrumbs.length, 0);
}
});
Expand All @@ -309,8 +302,6 @@ describe('breadcrumbs', function () {
// The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs
assert.lengthOf(summary.events, 1);
} else {
// There should be no expection, if there is one it means we threw it
assert.isUndefined(summary.events[0].exception);
assert.equal(summary.breadcrumbs.length, 0);
}
});
Expand Down Expand Up @@ -472,7 +463,6 @@ describe('breadcrumbs', function () {
assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
assert.equal(summary.breadcrumbHints[0].global, false);
assert.equal(summary.breadcrumbHints[1].global, false);
assert.isUndefined(summary.events[0].exception);
}
});
});
Expand Down Expand Up @@ -507,7 +497,6 @@ describe('breadcrumbs', function () {
assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]');
assert.equal(summary.breadcrumbHints[0].global, false);
assert.equal(summary.breadcrumbHints[1].global, false);
assert.isUndefined(summary.events[0].exception);
}
});
});
Expand Down Expand Up @@ -538,7 +527,6 @@ describe('breadcrumbs', function () {
assert.equal(summary.breadcrumbs[1].message, 'body > form#foo-form > div.contenteditable');
assert.equal(summary.breadcrumbHints[0].global, false);
assert.equal(summary.breadcrumbHints[1].global, false);
assert.isUndefined(summary.events[0].exception);
}
});
});
Expand Down Expand Up @@ -706,7 +694,6 @@ describe('breadcrumbs', function () {
assert.equal(summary.breadcrumbs.length, 2);
assert.equal(summary.breadcrumbHints[0].global, true);
assert.equal(summary.breadcrumbHints[1].global, true);
assert.isUndefined(summary.events[0].exception);
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"author": "Sentry",
"license": "BSD-3-Clause",
"engines": {
"node": ">=6"
"node": ">=8"
},
"main": "build/dist/index.js",
"module": "build/esm/index.js",
Expand Down
69 changes: 1 addition & 68 deletions packages/core/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,73 +17,6 @@ export interface APIDetails {
readonly tunnel?: string;
}

/**
* Helper class to provide urls, headers and metadata that can be used to form
* different types of requests to Sentry endpoints.
* Supports both envelopes and regular event requests.
*
* @deprecated Please use APIDetails
**/
export class API {
/** The DSN as passed to Sentry.init() */
public dsn: DsnLike;

/** Metadata about the SDK (name, version, etc) for inclusion in envelope headers */
public metadata: SdkMetadata;

/** The internally used Dsn object. */
private readonly _dsnObject: DsnComponents;

/** The envelope tunnel to use. */
private readonly _tunnel?: string;

/** Create a new instance of API */
public constructor(dsn: DsnLike, metadata: SdkMetadata = {}, tunnel?: string) {
this.dsn = dsn;
this._dsnObject = makeDsn(dsn);
this.metadata = metadata;
this._tunnel = tunnel;
}

/** Returns the Dsn object. */
public getDsn(): DsnComponents {
return this._dsnObject;
}

/** Does this transport force envelopes? */
public forceEnvelope(): boolean {
return !!this._tunnel;
}

/** Returns the prefix to construct Sentry ingestion API endpoints. */
public getBaseApiEndpoint(): string {
return getBaseApiEndpoint(this._dsnObject);
}

/** Returns the store endpoint URL. */
public getStoreEndpoint(): string {
return getStoreEndpoint(this._dsnObject);
}

/**
* Returns the store endpoint URL with auth in the query string.
*
* Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests.
*/
public getStoreEndpointWithUrlEncodedAuth(): string {
return getStoreEndpointWithUrlEncodedAuth(this._dsnObject);
}

/**
* Returns the envelope endpoint URL with auth in the query string.
*
* Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests.
*/
public getEnvelopeEndpointWithUrlEncodedAuth(): string {
return getEnvelopeEndpointWithUrlEncodedAuth(this._dsnObject, this._tunnel);
}
}

/** Initializes API Details */
export function initAPIDetails(dsn: DsnLike, metadata?: SdkMetadata, tunnel?: string): APIDetails {
return {
Expand Down Expand Up @@ -117,7 +50,7 @@ function _encodedAuth(dsn: DsnComponents): string {
}

/** Returns the store endpoint URL. */
function getStoreEndpoint(dsn: DsnComponents): string {
export function getStoreEndpoint(dsn: DsnComponents): string {
return _getIngestEndpoint(dsn, 'store');
}

Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export {
} from '@sentry/minimal';
export { addGlobalEventProcessor, getCurrentHub, getHubFromCarrier, Hub, makeMain, Scope, Session } from '@sentry/hub';
export {
// eslint-disable-next-line deprecation/deprecation
API,
APIDetails,
getEnvelopeEndpointWithUrlEncodedAuth,
getStoreEndpointWithUrlEncodedAuth,
Expand Down
26 changes: 2 additions & 24 deletions packages/core/src/integrations/inboundfilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ export interface InboundFiltersOptions {
denyUrls: Array<string | RegExp>;
ignoreErrors: Array<string | RegExp>;
ignoreInternal: boolean;

/** @deprecated use {@link InboundFiltersOptions.allowUrls} instead. */
whitelistUrls: Array<string | RegExp>;
/** @deprecated use {@link InboundFiltersOptions.denyUrls} instead. */
blacklistUrls: Array<string | RegExp>;
}

/** Inbound filters configurable by the user */
Expand Down Expand Up @@ -60,22 +55,8 @@ export function _mergeOptions(
clientOptions: Partial<InboundFiltersOptions> = {},
): Partial<InboundFiltersOptions> {
return {
allowUrls: [
// eslint-disable-next-line deprecation/deprecation
...(internalOptions.whitelistUrls || []),
...(internalOptions.allowUrls || []),
// eslint-disable-next-line deprecation/deprecation
...(clientOptions.whitelistUrls || []),
...(clientOptions.allowUrls || []),
],
denyUrls: [
// eslint-disable-next-line deprecation/deprecation
...(internalOptions.blacklistUrls || []),
...(internalOptions.denyUrls || []),
// eslint-disable-next-line deprecation/deprecation
...(clientOptions.blacklistUrls || []),
...(clientOptions.denyUrls || []),
],
allowUrls: [...(internalOptions.allowUrls || []), ...(clientOptions.allowUrls || [])],
denyUrls: [...(internalOptions.denyUrls || []), ...(clientOptions.denyUrls || [])],
ignoreErrors: [
...(internalOptions.ignoreErrors || []),
...(clientOptions.ignoreErrors || []),
Expand Down Expand Up @@ -189,9 +170,6 @@ function _getLastValidUrl(frames: StackFrame[] = []): string | null {

function _getEventFilterUrl(event: Event): string | null {
try {
if (event.stacktrace) {
return _getLastValidUrl(event.stacktrace.frames);
}
let frames;
try {
// @ts-ignore we only care about frames if the whole thing here is defined
Expand Down
39 changes: 25 additions & 14 deletions packages/core/test/lib/api.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
/* eslint-disable deprecation/deprecation */
import { makeDsn } from '@sentry/utils';

import { API, getReportDialogEndpoint, getRequestHeaders } from '../../src/api';
import {
getEnvelopeEndpointWithUrlEncodedAuth,
getReportDialogEndpoint,
getRequestHeaders,
getStoreEndpoint,
getStoreEndpointWithUrlEncodedAuth,
initAPIDetails,
} from '../../src/api';

const ingestDsn = 'https://abc@xxxx.ingest.sentry.io:1234/subpath/123';
const dsnPublic = 'https://abc@sentry.io:1234/subpath/123';
const legacyDsn = 'https://abc:123@sentry.io:1234/subpath/123';
const tunnel = 'https://hello.com/world';

const ingestDsnAPI = initAPIDetails(ingestDsn);
const dsnPublicAPI = initAPIDetails(dsnPublic);

describe('API', () => {
test('getStoreEndpoint', () => {
expect(new API(dsnPublic).getStoreEndpointWithUrlEncodedAuth()).toEqual(
expect(getStoreEndpointWithUrlEncodedAuth(dsnPublicAPI.dsn)).toEqual(
'https://sentry.io:1234/subpath/api/123/store/?sentry_key=abc&sentry_version=7',
);
expect(new API(dsnPublic).getStoreEndpoint()).toEqual('https://sentry.io:1234/subpath/api/123/store/');
expect(new API(ingestDsn).getStoreEndpoint()).toEqual('https://xxxx.ingest.sentry.io:1234/subpath/api/123/store/');
expect(getStoreEndpoint(dsnPublicAPI.dsn)).toEqual('https://sentry.io:1234/subpath/api/123/store/');
expect(getStoreEndpoint(ingestDsnAPI.dsn)).toEqual('https://xxxx.ingest.sentry.io:1234/subpath/api/123/store/');
});

test('getEnvelopeEndpoint', () => {
expect(new API(dsnPublic).getEnvelopeEndpointWithUrlEncodedAuth()).toEqual(
expect(getEnvelopeEndpointWithUrlEncodedAuth(dsnPublicAPI.dsn)).toEqual(
'https://sentry.io:1234/subpath/api/123/envelope/?sentry_key=abc&sentry_version=7',
);
expect(new API(dsnPublic, {}, tunnel).getEnvelopeEndpointWithUrlEncodedAuth()).toEqual(tunnel);
const dsnPublicAPIWithTunnel = initAPIDetails(dsnPublic, {}, tunnel);
expect(getEnvelopeEndpointWithUrlEncodedAuth(dsnPublicAPIWithTunnel.dsn, tunnel)).toEqual(tunnel);
});

test('getRequestHeaders', () => {
Expand Down Expand Up @@ -118,13 +129,13 @@ describe('API', () => {
);
});

test('getDsn', () => {
expect(new API(dsnPublic).getDsn().host).toEqual(makeDsn(dsnPublic).host);
expect(new API(dsnPublic).getDsn().path).toEqual(makeDsn(dsnPublic).path);
expect(new API(dsnPublic).getDsn().pass).toEqual(makeDsn(dsnPublic).pass);
expect(new API(dsnPublic).getDsn().port).toEqual(makeDsn(dsnPublic).port);
expect(new API(dsnPublic).getDsn().protocol).toEqual(makeDsn(dsnPublic).protocol);
expect(new API(dsnPublic).getDsn().projectId).toEqual(makeDsn(dsnPublic).projectId);
expect(new API(dsnPublic).getDsn().publicKey).toEqual(makeDsn(dsnPublic).publicKey);
test('initAPIDetails dsn', () => {
expect(dsnPublicAPI.dsn.host).toEqual(makeDsn(dsnPublic).host);
expect(dsnPublicAPI.dsn.path).toEqual(makeDsn(dsnPublic).path);
expect(dsnPublicAPI.dsn.pass).toEqual(makeDsn(dsnPublic).pass);
expect(dsnPublicAPI.dsn.port).toEqual(makeDsn(dsnPublic).port);
expect(dsnPublicAPI.dsn.protocol).toEqual(makeDsn(dsnPublic).protocol);
expect(dsnPublicAPI.dsn.projectId).toEqual(makeDsn(dsnPublic).projectId);
expect(dsnPublicAPI.dsn.publicKey).toEqual(makeDsn(dsnPublic).publicKey);
});
});
Loading