diff --git a/packages/core/src/api.ts b/packages/core/src/api.ts index 4dadd5539ba3..c79868c5cb83 100644 --- a/packages/core/src/api.ts +++ b/packages/core/src/api.ts @@ -9,11 +9,20 @@ const SENTRY_API_VERSION = '7'; * Supports both envelopes and regular event requests. **/ 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: Dsn; + /** Create a new instance of API */ - public constructor(public dsn: DsnLike, public metadata: SdkMetadata = {}) { + public constructor(dsn: DsnLike, metadata: SdkMetadata = {}) { + this.dsn = dsn; this._dsnObject = new Dsn(dsn); + this.metadata = metadata; } /** Returns the Dsn object. */ diff --git a/packages/core/src/baseclient.ts b/packages/core/src/baseclient.ts index 8a801ca79b0e..9f4fc8ed3d70 100644 --- a/packages/core/src/baseclient.ts +++ b/packages/core/src/baseclient.ts @@ -40,7 +40,7 @@ import { IntegrationIndex, setupIntegrations } from './integration'; * without a valid Dsn, the SDK will not send any events to Sentry. * * Before sending an event via the backend, it is passed through - * {@link BaseClient.prepareEvent} to add SDK information and scope data + * {@link BaseClient._prepareEvent} to add SDK information and scope data * (breadcrumbs and context). To add more custom information, override this * method and extend the resulting prepared event. * @@ -428,7 +428,7 @@ export abstract class BaseClient implement /** * This function adds all used integrations to the SDK info in the event. - * @param sdkInfo The sdkInfo of the event that will be filled with all integrations. + * @param event The event that will be filled with all integrations. */ protected _applyIntegrationsMetadata(event: Event): void { const sdkInfo = event.sdk; diff --git a/packages/hub/src/hub.ts b/packages/hub/src/hub.ts index 2ce1f3ae256c..dcc5cac30b23 100644 --- a/packages/hub/src/hub.ts +++ b/packages/hub/src/hub.ts @@ -537,6 +537,7 @@ export function getHubFromCarrier(carrier: Carrier): Hub { * This will set passed {@link Hub} on the passed object's __SENTRY__.hub attribute * @param carrier object * @param hub Hub + * @returns A boolean indicating success or failure */ export function setHubOnCarrier(carrier: Carrier, hub: Hub): boolean { if (!carrier) return false; diff --git a/packages/node/test/index.test.ts b/packages/node/test/index.test.ts index 97296a6432da..1221cf442818 100644 --- a/packages/node/test/index.test.ts +++ b/packages/node/test/index.test.ts @@ -69,7 +69,7 @@ describe('SentryNode', () => { }); afterEach(() => { - s.mockReset(); + s.mockRestore(); }); test('record auto breadcrumbs', done => { @@ -98,7 +98,7 @@ describe('SentryNode', () => { }); afterEach(() => { - s.mockReset(); + s.mockRestore(); }); test('capture an exception', done => { diff --git a/packages/serverless/src/gcpfunction/general.ts b/packages/serverless/src/gcpfunction/general.ts index 881b3d0cc649..becad86b5b0f 100644 --- a/packages/serverless/src/gcpfunction/general.ts +++ b/packages/serverless/src/gcpfunction/general.ts @@ -61,3 +61,5 @@ export function configureScopeWithContext(scope: Scope, context: Context): void scope.setTag('server_name', process.env.SENTRY_NAME || hostname()); scope.setContext('gcp.function.context', { ...context } as SentryContext); } + +export { Request, Response }; diff --git a/packages/serverless/test/awsservices.test.ts b/packages/serverless/test/awsservices.test.ts index 917feac2b104..27ebaeb9a69f 100644 --- a/packages/serverless/test/awsservices.test.ts +++ b/packages/serverless/test/awsservices.test.ts @@ -23,7 +23,7 @@ describe('AWSServices', () => { nock.restore(); }); - describe('S3', () => { + describe('S3 tracing', () => { const s3 = new AWS.S3({ accessKeyId: '-', secretAccessKey: '-' }); test('getObject', async () => { diff --git a/packages/serverless/test/google-cloud-grpc.test.ts b/packages/serverless/test/google-cloud-grpc.test.ts index 42c5470e172d..a9d7874d2e80 100644 --- a/packages/serverless/test/google-cloud-grpc.test.ts +++ b/packages/serverless/test/google-cloud-grpc.test.ts @@ -76,7 +76,7 @@ function mockHttp2Session(): FakeSession { return session; } -describe('GoogleCloudGrpc', () => { +describe('GoogleCloudGrpc tracing', () => { beforeAll(() => { new GoogleCloudGrpc().setupOnce(); }); diff --git a/packages/serverless/test/google-cloud-http.test.ts b/packages/serverless/test/google-cloud-http.test.ts index c58513756f5a..28869ffa6d0c 100644 --- a/packages/serverless/test/google-cloud-http.test.ts +++ b/packages/serverless/test/google-cloud-http.test.ts @@ -13,7 +13,7 @@ import { GoogleCloudHttp } from '../src/google-cloud-http'; * Thanks to this, we don't have to do more magic than necessary. Just add and export desired method and assert on it. */ -describe('GoogleCloudHttp', () => { +describe('GoogleCloudHttp tracing', () => { beforeAll(() => { new GoogleCloudHttp().setupOnce(); }); diff --git a/packages/tracing/src/transaction.ts b/packages/tracing/src/transaction.ts index cba9962ac8dd..513981ccf8d0 100644 --- a/packages/tracing/src/transaction.ts +++ b/packages/tracing/src/transaction.ts @@ -37,7 +37,7 @@ export class Transaction extends SpanClass implements TransactionInterface { this._hub = hub as Hub; } - this.name = transactionContext.name ? transactionContext.name : ''; + this.name = transactionContext.name || ''; this._trimEnd = transactionContext.trimEnd; diff --git a/packages/tracing/test/browser/browsertracing.test.ts b/packages/tracing/test/browser/browsertracing.test.ts index 4ab599e3f518..3ff774e4dbd2 100644 --- a/packages/tracing/test/browser/browsertracing.test.ts +++ b/packages/tracing/test/browser/browsertracing.test.ts @@ -25,6 +25,7 @@ jest.mock('@sentry/utils', () => { ...actual, addInstrumentationHandler: ({ callback, type }: any): void => { if (type === 'history') { + // rather than actually add the navigation-change handler, grab a reference to it, so we can trigger it manually mockChangeHistory = callback; } }, @@ -64,17 +65,17 @@ describe('BrowserTracing', () => { }); function createBrowserTracing(setup?: boolean, _options?: Partial): BrowserTracing { - const inst = new BrowserTracing(_options); + const instance = new BrowserTracing(_options); if (setup) { const processor = () => undefined; - inst.setupOnce(processor, () => hub); + instance.setupOnce(processor, () => hub); } - return inst; + return instance; } // These are important enough to check with a test as incorrect defaults could - // break a lot of users configurations. + // break a lot of users' configurations. it('is created with default settings', () => { const browserTracing = createBrowserTracing(); @@ -126,7 +127,7 @@ describe('BrowserTracing', () => { }); describe('tracingOrigins', () => { - it('warns and uses default tracing origins if non are provided', () => { + it('warns and uses default tracing origins if none are provided', () => { const inst = createBrowserTracing(true, { routingInstrumentation: customRoutingInstrumentation, }); diff --git a/packages/tracing/test/hub.test.ts b/packages/tracing/test/hub.test.ts index 001e4cad8a1e..a9beed2201f7 100644 --- a/packages/tracing/test/hub.test.ts +++ b/packages/tracing/test/hub.test.ts @@ -16,21 +16,17 @@ addExtensionMethods(); const mathRandom = jest.spyOn(Math, 'random'); jest.spyOn(Transaction.prototype, 'setMetadata'); +jest.spyOn(logger, 'warn'); +jest.spyOn(logger, 'log'); +jest.spyOn(utilsModule, 'isNodeEnv'); // we have to add things into the real global object (rather than mocking the return value of getGlobalObject) because // there are modules which call getGlobalObject as they load, which is seemingly too early for jest to intervene addDOMPropertiesToGlobal(['XMLHttpRequest', 'Event', 'location', 'document']); describe('Hub', () => { - beforeEach(() => { - jest.spyOn(logger, 'warn'); - jest.spyOn(logger, 'log'); - jest.spyOn(utilsModule, 'isNodeEnv'); - }); - afterEach(() => { jest.clearAllMocks(); - jest.useRealTimers(); }); describe('getTransaction()', () => {