Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
97e6ff3
[v7] feat: Remove references to @sentry/apm (#4845)
AbhiPrasad Apr 7, 2022
57d37c2
[v7] feat(core): Delete API class (#4848)
AbhiPrasad Apr 7, 2022
424df27
[v7] feat: Delete deprecated `startSpan` and `child` methods (#4849)
AbhiPrasad Apr 7, 2022
5a7f145
feat(core): Remove whitelistUrls/blacklistUrls (#4850)
AbhiPrasad Apr 7, 2022
f855260
feat(gatsby): Remove Sentry from window (#4857)
AbhiPrasad Apr 7, 2022
f1e9da2
feat(hub): Remove getActiveDomain (#4858)
AbhiPrasad Apr 7, 2022
55b0570
feat(types): Remove deprecated user dsn field (#4864)
AbhiPrasad Apr 7, 2022
2fc13c6
feat(hub): Remove setTransaction scope method (#4865)
AbhiPrasad Apr 7, 2022
20c7773
[v7] feat: Drop support for Node 6 (#4851)
AbhiPrasad Apr 7, 2022
244eb0e
[v7] feat(tracing): Rename registerRequestInstrumentation -> instrume…
AbhiPrasad Apr 7, 2022
285ca26
fix(test): Increase MongoMemoryServer creation timeout (#4881)
Lms24 Apr 7, 2022
fb1b74f
[v7] feat(node): Remove deprecated `frameContextLines` (#4884)
timfish Apr 7, 2022
81b10fb
[v7] feat(browser): Remove top level eventbuilder exports (#4887)
timfish Apr 7, 2022
a0792da
Merge branch '7.x' of https://github.com/getsentry/sentry-javascript …
timfish Apr 8, 2022
79084f2
Mostly working
timfish Apr 8, 2022
52047b6
Lint
timfish Apr 8, 2022
14a10dc
make generic across all javascript
timfish Apr 8, 2022
dc765c7
Merge remote-tracking branch 'upstream/7.x' into v7/configurable-stac…
timfish Apr 8, 2022
0988600
Fix build
timfish Apr 8, 2022
c6e8a60
export nodeStackParser
timfish Apr 8, 2022
03b5d5c
Fix test
timfish Apr 8, 2022
7943990
Merge 'upstream/7.x' into v7/configurable-stack-parser
timfish Apr 12, 2022
623fcfd
Fix tests from bad merge
timfish Apr 12, 2022
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
Prev Previous commit
Next Next commit
[v7] feat(core): Delete API class (#4848)
Removes the deprecated `API` class.
  • Loading branch information
AbhiPrasad authored and Lms24 committed Apr 7, 2022
commit 57d37c29249d5c71eac486c86e5bb91a4c3c4159
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
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://[email protected]:1234/subpath/123';
const dsnPublic = 'https://[email protected]:1234/subpath/123';
const legacyDsn = 'https://abc:[email protected]: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);
});
});