From 60563d135d3fa925c774180578c0ca533b1bcad5 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Wed, 14 Nov 2018 14:00:11 +0100 Subject: [PATCH] feat: Update @sentry deps (#99) * feat: Update all deps * fix: Seperate release integration test * feat: Update travis --- .travis.yml | 10 +- __tests__/conversion.ts | 3 +- package.json | 59 ++++---- rollup.config.js | 2 +- src/js/__tests__/integration.ts | 208 +++++++++++++------------- src/js/__tests__/release.ts | 65 ++++++++ src/js/backend.ts | 13 +- src/js/client.ts | 25 +++- src/js/integrations/cordova.ts | 19 ++- src/js/integrations/index.ts | 1 - src/js/integrations/release.ts | 19 ++- src/js/integrations/sdkinformation.ts | 31 ---- src/js/sdk.ts | 7 +- src/js/sentry-cordova.ts | 19 ++- 14 files changed, 284 insertions(+), 197 deletions(-) create mode 100644 src/js/__tests__/release.ts delete mode 100644 src/js/integrations/sdkinformation.ts diff --git a/.travis.yml b/.travis.yml index 878c291..4cdd365 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,13 +16,13 @@ before_install: matrix: include: - script: - - yarn - - yarn build - - yarn test - - yarn codecov + - yarn + - yarn build + - yarn test + - yarn codecov - language: objective-c - osx_image: xcode9.2 + osx_image: xcode9.4 script: .travis/deploy.sh after_success: - npm install -g @zeus-ci/cli diff --git a/__tests__/conversion.ts b/__tests__/conversion.ts index 14ec096..9119638 100644 --- a/__tests__/conversion.ts +++ b/__tests__/conversion.ts @@ -1,10 +1,9 @@ import * as fs from 'fs'; -import * as path from 'path'; describe('JS conversion check', () => { test('Do not require @sentry/browser', () => { const content = fs.readFileSync('dist/js/sentry-cordova.bundle.js'); // expect(content.toString().match(/^[^\*]*@sentry\/browser/gm)).toBeFalsy(); - expect(content.toString().match(/require\(/)).toBeFalsy(); + expect(content.toString().match(/ require\(/)).toBeFalsy(); }); }); diff --git a/package.json b/package.json index 7e9510d..355b600 100644 --- a/package.json +++ b/package.json @@ -24,37 +24,36 @@ ], "description": "Official Sentry SDK for Cordova", "dependencies": { - "@sentry/browser": "4.0.0-beta.12", - "@sentry/core": "4.0.0-beta.12", - "@sentry/hub": "4.0.0-beta.12", - "@sentry/minimal": "4.0.0-beta.12", - "@sentry/types": "4.0.0-beta.12", - "@sentry/utils": "4.0.0-beta.12", - "@sentry/wizard": "^0.10.0" + "@sentry/browser": "~4.3.0", + "@sentry/core": "~4.3.0", + "@sentry/minimal": "~4.3.0", + "@sentry/types": "~4.3.0", + "@sentry/utils": "~4.3.0", + "@sentry/wizard": "^0.12.1" }, "devDependencies": { - "@sentry/typescript": "4.0.0-beta.12", + "@sentry/typescript": "^4.0.0", "@types/cordova": "0.0.34", - "@types/jest": "^22.2.3", - "@types/node": "^9.6.5", - "codecov": "^3.0.0", - "jest": "^22.4.3", - "npm-run-all": "^4.1.2", - "prettier": "^1.12.1", + "@types/jest": "^23.3.8", + "@types/node": "^10.12.1", + "codecov": "^3.1.0", + "jest": "^23.6.0", + "npm-run-all": "^4.1.3", + "prettier": "^1.14.3", "prettier-check": "^2.0.0", - "raven-js": "^3.24.1", - "replace-in-file": "^3.4.0", + "raven-js": "^3.27.0", + "replace-in-file": "^3.4.2", "rimraf": "^2.6.2", - "rollup": "^0.58.0", - "rollup-plugin-commonjs": "^9.1.0", - "rollup-plugin-node-resolve": "^3.3.0", - "rollup-plugin-typescript2": "^0.13.0", - "rollup-plugin-uglify": "^3.0.0", - "ts-jest": "^22.4.4", - "tslint": "^5.9.1", - "tslint-config-prettier": "^1.10.0", - "tslint-eslint-rules": "^5.1.0", - "typescript": "^2.8.1", + "rollup": "^0.66.6", + "rollup-plugin-commonjs": "^9.2.0", + "rollup-plugin-node-resolve": "^3.4.0", + "rollup-plugin-typescript2": "^0.17.2", + "rollup-plugin-uglify": "^6.0.0", + "ts-jest": "^23.10.4", + "tslint": "^5.11.0", + "tslint-config-prettier": "^1.15.0", + "tslint-eslint-rules": "^5.4.0", + "typescript": "^3.1.4", "vrsource-tslint-rules": "^5.8.2" }, "scripts": { @@ -63,9 +62,8 @@ "build": "run-s clean build:typescript build:bundle", "clean": "rimraf dist coverage", "jest": "jest", - "test:browser": "run-s build jest", - "test:watch": "jest --watch --notify", - "test": "run-s test:browser", + "test:watch": "jest --watch", + "test": "jest", "codecov": "codecov", "lint": "run-s lint:prettier lint:tslint", "lint:prettier": "prettier-check \"{src,test}/**/*.ts\"", @@ -82,13 +80,14 @@ "testURL": "http://localhost/", "globals": { "ts-jest": { - "tsConfigFile": "./tsconfig.json" + "tsConfig": "./tsconfig.json" } }, "collectCoverage": true, "transform": { "^.+\\.tsx?$": "ts-jest" }, + "notify": false, "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", "moduleFileExtensions": [ "ts", diff --git a/rollup.config.js b/rollup.config.js index def6c07..1e6d52d 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,5 +1,5 @@ import commonjs from 'rollup-plugin-commonjs'; -import uglify from 'rollup-plugin-uglify'; +import { uglify } from 'rollup-plugin-uglify'; import resolve from 'rollup-plugin-node-resolve'; import typescript from 'rollup-plugin-typescript2'; diff --git a/src/js/__tests__/integration.ts b/src/js/__tests__/integration.ts index 55da9a6..2937c1e 100644 --- a/src/js/__tests__/integration.ts +++ b/src/js/__tests__/integration.ts @@ -8,7 +8,7 @@ import { CordovaClient, init, Integrations, - getDefaultHub, + getCurrentHub, SDK_NAME, SDK_VERSION, SentryEvent, @@ -16,7 +16,7 @@ import { setRelease, } from '../sentry-cordova'; -const dsn = 'https://1e7e9e1f2a51437a802724a538b7051d@sentry.io/304324'; +const dsn = 'https://123@sentry.io/123'; const defaultOptions: CordovaOptions = { dsn, @@ -33,14 +33,12 @@ function callDeviceReady(): void { describe('SentryCordova', () => { beforeEach(() => { + getCurrentHub().pushScope(); (window as any).Cordova = {}; - (window as any).__SENTRY__ = {}; - (window as any).SENTRY_RELEASE = {}; }); afterEach(() => { - jest.resetModules(); - jest.resetAllMocks(); + getCurrentHub().popScope(); jest.clearAllTimers(); clearTimeout(timeout); }); @@ -70,7 +68,13 @@ describe('SentryCordova', () => { callDeviceReady(); (window as any).Cordova.exec = jest.fn( - (resolve: (result: any) => void, reject: (error: any) => void, plugin: string, action: string, value: any) => { + ( + _resolve: (result: any) => void, + _reject: (error: any) => void, + _plugin: string, + action: string, + value: any + ) => { if (action === 'sendEvent') { const event = value[0]; // this is an event expect(event.exception.values[0].type).toBe('Error'); @@ -79,12 +83,17 @@ describe('SentryCordova', () => { } } ); - init(defaultOptions); + + getCurrentHub().bindClient( + new CordovaClient({ + ...defaultOptions, + }) + ); captureException(new Error('yo')); }); test('send with browser fallback', done => { - expect.assertions(3); + expect.assertions(2); callDeviceReady(); (window as any).Cordova.exec = jest.fn((...params: any[]) => { @@ -96,19 +105,19 @@ describe('SentryCordova', () => { } }); - init({ - ...defaultOptions, - shouldSend: (event: SentryEvent) => { - expect(event.sdk!.name).toEqual(SDK_NAME); - expect(event.sdk!.version).toEqual(SDK_VERSION); - expect(event.sdk!.packages).toHaveLength(2); - done(); - return false; - }, - }); - getDefaultHub().pushScope(); + getCurrentHub().bindClient( + new CordovaClient({ + ...defaultOptions, + beforeSend: (event: SentryEvent) => { + expect(event.sdk!.name).toEqual(SDK_NAME); + expect(event.sdk!.version).toEqual(SDK_VERSION); + done(); + return null; + }, + }) + ); + captureMessage('hey'); - getDefaultHub().popScope(); }); test('message', done => { @@ -131,7 +140,12 @@ describe('SentryCordova', () => { params[0](false); } }); - init(defaultOptions); + + getCurrentHub().bindClient( + new CordovaClient({ + ...defaultOptions, + }) + ); captureMessage('bread'); }); }); @@ -148,14 +162,17 @@ describe('SentryCordova', () => { }); callDeviceReady(); - init({ - ...defaultOptions, - afterSend: (event: SentryEvent) => { - expect(event.message).toBe('knife'); - expect(event.breadcrumbs![0].message).toBe('bread'); - done(); - }, - }); + getCurrentHub().bindClient( + new CordovaClient({ + ...defaultOptions, + beforeSend: (event: SentryEvent) => { + expect(event.message).toBe('knife'); + expect(event.breadcrumbs![0].message).toBe('bread'); + done(); + return null; + }, + }) + ); addBreadcrumb({ message: 'bread' }); captureMessage('knife'); }); @@ -173,66 +190,52 @@ describe('SentryCordova', () => { callDeviceReady(); }); - test('setRelease from window', done => { + test('setRelease from window but event should be stronger', done => { expect.assertions(1); - init({ - ...defaultOptions, - integrations: () => [new Integrations.Release()], - afterSend: (event: SentryEvent) => { - expect((event.extra! as any).__sentry_release).toBe('abc'); - done(); - }, - }); + getCurrentHub().bindClient( + new CordovaClient({ + ...defaultOptions, + integrations: () => [new Integrations.Release()], + beforeSend: (event: SentryEvent) => { + expect(event.release).toBe('xyz'); + done(); + return null; + }, + }) + ); (window as any).SENTRY_RELEASE = {}; (window as any).SENTRY_RELEASE.id = 'abc'; - captureMessage('knife'); + captureEvent({ message: 'test', release: 'xyz' }); }); test('cordova integration', done => { expect.assertions(1); - - init({ - ...defaultOptions, - integrations: () => [new Integrations.Cordova()], - afterSend: (event: SentryEvent) => { - expect(event.exception!.values[0].stacktrace!.frames![1].filename).toContain('app://'); - done(); - }, - }); + getCurrentHub().bindClient( + new CordovaClient({ + ...defaultOptions, + integrations: () => [new Integrations.Cordova()], + beforeSend: (event: SentryEvent) => { + expect(event.exception!.values![0].stacktrace!.frames![1].filename).toContain('app://'); + done(); + return null; + }, + }) + ); captureException(new Error('yo')); }); - test('setRelease from window but event should be stronger', done => { - expect.hasAssertions(); - - init({ - ...defaultOptions, - integrations: () => [new Integrations.Release()], - afterSend: (event: SentryEvent) => { - expect(event.release).toBe('xyz'); - done(); - }, - }); - - (window as any).SENTRY_RELEASE = {}; - (window as any).SENTRY_RELEASE.id = 'abc'; - - captureEvent({ message: 'test', release: 'xyz' }); - getDefaultHub().popScope(); - }); - test('setRelease/setDist', done => { expect.assertions(2); - getDefaultHub().pushScope(); - getDefaultHub().bindClient( + getCurrentHub().bindClient( new CordovaClient({ - afterSend: (event: SentryEvent) => { + beforeSend: (event: SentryEvent) => { expect((event.extra! as any).__sentry_release).toBe('xxx'); expect((event.extra! as any).__sentry_dist).toBe('dist'); done(); + return null; }, dsn, }) @@ -240,20 +243,19 @@ describe('SentryCordova', () => { setRelease('xxx'); setDist('dist'); captureMessage('knife'); - getDefaultHub().popScope(); }); test('setRelease setDist on prefilled event', done => { expect.assertions(4); - getDefaultHub().pushScope(); - getDefaultHub().bindClient( + getCurrentHub().bindClient( new CordovaClient({ - afterSend: (event: SentryEvent) => { + beforeSend: (event: SentryEvent) => { expect((event.extra! as any).__sentry_release).toBe('xxx'); expect((event.extra! as any).__sentry_dist).toBe('dist'); expect(event.dist).toBe('1'); expect(event.release).toBe('b'); done(); + return null; }, dsn, }) @@ -261,23 +263,25 @@ describe('SentryCordova', () => { setRelease('xxx'); setDist('dist'); captureEvent({ dist: '1', release: 'b' }); - getDefaultHub().popScope(); }); test('setRelease setDist on empty event', done => { expect.assertions(4); - init({ - ...defaultOptions, - integrations: () => [new Integrations.Release()], - afterSend: (event: SentryEvent) => { - expect((event.extra! as any).__sentry_release).toBe('xxx'); - expect((event.extra! as any).__sentry_dist).toBe('dist'); - expect(event.dist).toBe('dist'); - expect(event.release).toBe('xxx'); - done(); - }, - }); + getCurrentHub().bindClient( + new CordovaClient({ + ...defaultOptions, + integrations: () => [new Integrations.Release()], + beforeSend: (event: SentryEvent) => { + expect((event.extra! as any).__sentry_release).toBe('xxx'); + expect((event.extra! as any).__sentry_dist).toBe('dist'); + expect(event.dist).toBe('dist'); + expect(event.release).toBe('xxx'); + done(); + return null; + }, + }) + ); setRelease('xxx'); setDist('dist'); @@ -286,63 +290,60 @@ describe('SentryCordova', () => { test('setTagsContext', async done => { expect.assertions(1); - getDefaultHub().pushScope(); - getDefaultHub().bindClient( + getCurrentHub().bindClient( new CordovaClient({ - afterSend: (event: SentryEvent) => { + beforeSend: (event: SentryEvent) => { expect(event.tags).toEqual({ jest: 'yo' }); done(); + return null; }, dsn, }) ); configureScope(scope => scope.setTag('jest', 'yo')); captureMessage('knife'); - getDefaultHub().popScope(); }); test('setUserContext', async done => { expect.assertions(1); - getDefaultHub().pushScope(); - getDefaultHub().bindClient( + getCurrentHub().bindClient( new CordovaClient({ - afterSend: (event: SentryEvent) => { + beforeSend: (event: SentryEvent) => { expect(event.user).toEqual({ id: '4433' }); done(); + return null; }, dsn, }) ); configureScope(scope => scope.setUser({ id: '4433' })); captureMessage('knife'); - getDefaultHub().popScope(); }); test('setUserContext', async done => { expect.assertions(1); - getDefaultHub().pushScope(); - getDefaultHub().bindClient( + getCurrentHub().bindClient( new CordovaClient({ - afterSend: (event: SentryEvent) => { + beforeSend: (event: SentryEvent) => { expect((event.extra as any).id).toBe('44335'); done(); + return null; }, dsn, }) ); configureScope(scope => scope.setExtra('id', '44335')); captureMessage('knife'); - getDefaultHub().popScope(); }); test('clearScope', async done => { expect.assertions(1); - getDefaultHub().pushScope(); - getDefaultHub().bindClient( + getCurrentHub().bindClient( new CordovaClient({ - afterSend: (event: SentryEvent) => { - expect((event.extra as any).id).toBeUndefined(); + beforeSend: (event: SentryEvent) => { + expect(event.extra).toBeUndefined(); done(); + return null; }, dsn, }) @@ -350,7 +351,6 @@ describe('SentryCordova', () => { configureScope(scope => scope.setExtra('id', '44335')); configureScope(scope => scope.clear()); captureMessage('knife'); - getDefaultHub().popScope(); }); }); }); diff --git a/src/js/__tests__/release.ts b/src/js/__tests__/release.ts new file mode 100644 index 0000000..588cbd1 --- /dev/null +++ b/src/js/__tests__/release.ts @@ -0,0 +1,65 @@ +import { + captureMessage, + CordovaOptions, + CordovaClient, + Integrations, + getCurrentHub, + SentryEvent, +} from '../sentry-cordova'; + +const dsn = 'https://123@sentry.io/123'; + +const defaultOptions: CordovaOptions = { + dsn, +}; + +let timeout: NodeJS.Timer; +function callDeviceReady(): void { + timeout = setTimeout(() => { + const e = document.createEvent('Events'); + e.initEvent('deviceready', true, false); + document.dispatchEvent(e); + }, 50); +} + +describe('General', () => { + beforeEach(() => { + getCurrentHub().pushScope(); + (window as any).Cordova = {}; + (window as any).Cordova.exec = jest.fn((...params: any[]) => { + if (params[3] === 'sendEvent') { + params[0](false); + } else if (params[3] === 'install') { + params[0](true); + } + }); + callDeviceReady(); + }); + + afterEach(() => { + getCurrentHub().popScope(); + jest.clearAllTimers(); + clearTimeout(timeout); + }); + + test('setRelease from window', done => { + expect.assertions(1); + + getCurrentHub().bindClient( + new CordovaClient({ + ...defaultOptions, + integrations: [new Integrations.Release()], + beforeSend: (event: SentryEvent) => { + expect((event.extra as any).__sentry_release).toBe('abc'); + done(); + return null; + }, + }) + ); + + (window as any).SENTRY_RELEASE = {}; + (window as any).SENTRY_RELEASE.id = 'abc'; + + captureMessage('knife'); + }); +}); diff --git a/src/js/backend.ts b/src/js/backend.ts index ddeb2fd..c69e962 100644 --- a/src/js/backend.ts +++ b/src/js/backend.ts @@ -1,5 +1,5 @@ import { BrowserBackend, BrowserOptions } from '@sentry/browser'; -import { Backend } from '@sentry/core'; +import { BaseBackend } from '@sentry/core'; import { Scope } from '@sentry/hub'; import { Breadcrumb, SentryEvent, SentryResponse, Status } from '@sentry/types'; @@ -15,13 +15,14 @@ declare var document: any; export interface CordovaOptions extends BrowserOptions {} /** The Sentry Cordova SDK Backend. */ -export class CordovaBackend implements Backend { +export class CordovaBackend extends BaseBackend { private browserBackend: BrowserBackend; private deviceReadyCallback: any; /** Creates a new cordova backend instance. */ - public constructor(private readonly options: CordovaOptions = {}) { + public constructor(options: CordovaOptions = {}) { + super(options); this.browserBackend = new BrowserBackend(options); } @@ -104,15 +105,15 @@ export class CordovaBackend implements Backend { * @inheritDoc */ public storeScope(scope: Scope): void { - this.nativeCall('setExtraContext', scope.getExtra()).catch(() => { + this.nativeCall('setExtraContext', (scope as any).extra).catch(() => { // We do nothing since scope is handled and attached to the event. // This only applies to android. }); - this.nativeCall('setTagsContext', scope.getTags()).catch(() => { + this.nativeCall('setTagsContext', (scope as any).tags).catch(() => { // We do nothing since scope is handled and attached to the event. // This only applies to android. }); - this.nativeCall('setUserContext', scope.getUser()).catch(() => { + this.nativeCall('setUserContext', (scope as any).user).catch(() => { // We do nothing since scope is handled and attached to the event. // This only applies to android. }); diff --git a/src/js/client.ts b/src/js/client.ts index e22e6d6..0df4ce6 100644 --- a/src/js/client.ts +++ b/src/js/client.ts @@ -1,5 +1,7 @@ -import { BaseClient } from '@sentry/core'; +import { BaseClient, Scope } from '@sentry/core'; +import { SentryEvent, SentryEventHint } from '@sentry/types'; import { CordovaBackend, CordovaOptions } from './backend'; +import { SDK_NAME, SDK_VERSION } from './version'; /** * The Sentry Cordova SDK Client. @@ -15,4 +17,25 @@ export class CordovaClient extends BaseClient { public constructor(options: CordovaOptions) { super(CordovaBackend, options); } + + /** + * @inheritDoc + */ + protected async prepareEvent(event: SentryEvent, scope?: Scope, hint?: SentryEventHint): Promise { + event.platform = event.platform || 'javascript'; + event.sdk = { + ...event.sdk, + name: SDK_NAME, + packages: [ + ...((event.sdk && event.sdk.packages) || []), + { + name: 'npm:sentry-cordova', + version: SDK_VERSION, + }, + ], + version: SDK_VERSION, + }; + + return super.prepareEvent(event, scope, hint); + } } diff --git a/src/js/integrations/cordova.ts b/src/js/integrations/cordova.ts index 4790801..820bb03 100644 --- a/src/js/integrations/cordova.ts +++ b/src/js/integrations/cordova.ts @@ -1,5 +1,5 @@ import { Integration, SentryEvent } from '@sentry/types'; -import { getDefaultHub } from '@sentry/hub'; +import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core'; import { normalizeData } from '../normalize'; /** Default Breadcrumbs instrumentations */ @@ -7,12 +7,23 @@ export class Cordova implements Integration { /** * @inheritDoc */ - public name: string = 'Cordova'; + public name: string = Cordova.id; /** * @inheritDoc */ - public install(): void { - getDefaultHub().addEventProcessor((event: SentryEvent) => normalizeData(event)); + public static id: string = 'Cordova'; + + /** + * @inheritDoc + */ + public setupOnce(): void { + addGlobalEventProcessor(async (event: SentryEvent) => { + const self = getCurrentHub().getIntegration(Cordova); + if (self) { + return normalizeData(event); + } + return event; + }); } } diff --git a/src/js/integrations/index.ts b/src/js/integrations/index.ts index cee9355..704c9b8 100644 --- a/src/js/integrations/index.ts +++ b/src/js/integrations/index.ts @@ -1,3 +1,2 @@ export { Release } from './release'; export { Cordova } from './cordova'; -export { SDKInformation } from './sdkinformation'; diff --git a/src/js/integrations/release.ts b/src/js/integrations/release.ts index 56d577c..52b44eb 100644 --- a/src/js/integrations/release.ts +++ b/src/js/integrations/release.ts @@ -1,21 +1,28 @@ import { Integration, SentryEvent } from '@sentry/types'; import { getGlobalObject } from '@sentry/utils/misc'; -import { getDefaultHub } from '@sentry/hub'; - -const window: any = getGlobalObject(); +import { addGlobalEventProcessor, getCurrentHub } from '@sentry/core'; /** Default Breadcrumbs instrumentations */ export class Release implements Integration { /** * @inheritDoc */ - public name: string = 'Release'; + public name: string = Release.id; + /** + * @inheritDoc + */ + public static id: string = 'Release'; /** * @inheritDoc */ - public install(): void { - getDefaultHub().addEventProcessor(async (event: SentryEvent) => { + public setupOnce(): void { + addGlobalEventProcessor(async (event: SentryEvent) => { + const self = getCurrentHub().getIntegration(Release); + if (!self) { + return event; + } + const window: any = getGlobalObject(); // __sentry_release & __sentry_dist will be picked up by our native integration. // It should live in extra, native will pic it up there and set it in the event. if (event.extra && event.extra.__sentry_release && !event.release) { diff --git a/src/js/integrations/sdkinformation.ts b/src/js/integrations/sdkinformation.ts deleted file mode 100644 index 8e76ab6..0000000 --- a/src/js/integrations/sdkinformation.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { getDefaultHub } from '@sentry/hub'; -import { Integration, SentryEvent } from '@sentry/types'; -import { SDK_NAME, SDK_VERSION } from '../version'; - -/** Adds SDK info to an event. */ -export class SDKInformation implements Integration { - /** - * @inheritDoc - */ - public name: string = 'SDKInformation'; - - /** - * @inheritDoc - */ - public install(): void { - getDefaultHub().addEventProcessor(async (event: SentryEvent) => ({ - ...event, - sdk: { - name: SDK_NAME, - packages: [ - ...((event.sdk && event.sdk.packages) || []), - { - name: 'npm:sentry-cordova', - version: SDK_VERSION, - }, - ], - version: SDK_VERSION, - }, - })); - } -} diff --git a/src/js/sdk.ts b/src/js/sdk.ts index 30995b4..7424f49 100644 --- a/src/js/sdk.ts +++ b/src/js/sdk.ts @@ -2,12 +2,15 @@ import { defaultIntegrations } from '@sentry/browser'; import { initAndBind } from '@sentry/core'; import { CordovaOptions } from './backend'; import { CordovaClient } from './client'; -import { Cordova, Release, SDKInformation } from './integrations'; +import { Cordova, Release } from './integrations'; import { Scope } from '@sentry/hub'; import { configureScope } from '@sentry/minimal'; export function init(options: CordovaOptions): void { - initAndBind(CordovaClient, options, [...defaultIntegrations, new Cordova(), new Release(), new SDKInformation()]); + if (options.defaultIntegrations === undefined) { + options.defaultIntegrations = [...defaultIntegrations, new Cordova(), new Release()]; + } + initAndBind(CordovaClient, options); } export function setRelease(release: string): void { diff --git a/src/js/sentry-cordova.ts b/src/js/sentry-cordova.ts index 919b71d..c95e1d2 100644 --- a/src/js/sentry-cordova.ts +++ b/src/js/sentry-cordova.ts @@ -1,20 +1,31 @@ export { Breadcrumb, - Integration, Request, SdkInfo, SentryEvent, SentryException, + SentryResponse, Severity, StackFrame, Stacktrace, + Status, Thread, User, } from '@sentry/types'; -export { addBreadcrumb, captureMessage, captureException, captureEvent, configureScope } from '@sentry/minimal'; - -export { getDefaultHub, getHubFromCarrier, Hub, Scope } from '@sentry/hub'; +export { + addGlobalEventProcessor, + addBreadcrumb, + captureException, + captureEvent, + captureMessage, + configureScope, + withScope, + getHubFromCarrier, + getCurrentHub, + Hub, + Scope, +} from '@sentry/core'; export { CordovaBackend, CordovaOptions } from './backend'; export { CordovaClient } from './client';