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 12 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
8 changes: 5 additions & 3 deletions packages/browser/src/eventbuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ export function eventFromPlainObject(
},
};

if (syntheticException) {
if (syntheticException && event.exception?.values?.[0]) {
timfish marked this conversation as resolved.
Show resolved Hide resolved
const frames = parseStackFrames(syntheticException);
if (frames.length) {
event.stacktrace = { frames };
event.exception.values[0].stacktrace = { frames };
}
}

Expand Down Expand Up @@ -273,7 +273,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: [{ stacktrace: { frames } }],
};
}
}

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;
}
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);
});
});
2 changes: 1 addition & 1 deletion packages/eslint-config-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"sentry"
],
"engines": {
"node": ">=6"
"node": ">=8"
},
"main": "src/index.js",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"sentry"
],
"engines": {
"node": ">=6"
"node": ">=8"
},
"main": "src/index.js",
"publishConfig": {
Expand Down
8 changes: 3 additions & 5 deletions packages/gatsby/gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ exports.onClientEntry = function (_, pluginParams) {
const areOptionsDefined = areSentryOptionsDefined(pluginParams);

if (isIntialized) {
window.Sentry = Sentry; // For backwards compatibility
if (areOptionsDefined) {
console.warn(
'Sentry Logger [Warn]: The SDK was initialized in the Sentry config file, but options were found in the Gatsby config. ' +
'These have been ignored, merge them to the Sentry config if you want to use them.\n' +
'Learn more about the Gatsby SDK on https://docs.sentry.io/platforms/javascript/guides/gatsby/',
'These have been ignored, merge them to the Sentry config if you want to use them.\n' +
'Learn more about the Gatsby SDK on https://docs.sentry.io/platforms/javascript/guides/gatsby/',
);
}
return;
Expand All @@ -20,7 +19,7 @@ exports.onClientEntry = function (_, pluginParams) {
if (!areOptionsDefined) {
console.error(
'Sentry Logger [Error]: No config for the Gatsby SDK was found.\n' +
'Learn how to configure it on https://docs.sentry.io/platforms/javascript/guides/gatsby/',
'Learn how to configure it on https://docs.sentry.io/platforms/javascript/guides/gatsby/',
);
return;
}
Expand All @@ -32,7 +31,6 @@ exports.onClientEntry = function (_, pluginParams) {
dsn: __SENTRY_DSN__,
...pluginParams,
});
window.Sentry = Sentry; // For backwards compatibility
};

function isSentryInitialized() {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"gatsby-plugin"
],
"engines": {
"node": ">=6"
"node": ">=8"
},
"main": "build/dist/index.js",
"module": "build/esm/index.js",
Expand Down
Loading