diff --git a/packages/common/errorreport.js b/packages/common/errorreport.js deleted file mode 100644 index 4f17f456ac068d921d43bf6870f064d89d7fe63b..0000000000000000000000000000000000000000 --- a/packages/common/errorreport.js +++ /dev/null @@ -1,96 +0,0 @@ -import * as Sentry from '@sentry/browser'; - -let _isInitialized = false; -let _canReportEvent = false; - -let sentryDSN = ''; - -/** - * Initializes error reporting. - * - * If a sentry DSN is set we will use sentry, if not we will log to the console. - * - * @param {object} [options] - * @param {boolean} [options.debug=false] Enable debug output - * @param {string} [options.release] The project release - */ -export function init(options) { - let defaults = { - debug: false, - }; - let actual = Object.assign({}, defaults, options); - - if (_isInitialized) throw new Error('Already initialized'); - - let sentryOptions = {debug: actual.debug}; - - if (actual.release) { - sentryOptions['release'] = actual.release; - } - - if (actual.environment) { - sentryOptions['environment'] = actual.environment; - } - - if (!sentryDSN) { - if (options.debug) console.log('No sentry DSN set, sentry disabled'); - - // In case we don't have a sentry config, we still use sentry, but print - // all events into the console don't send them to the server. - // XXX: Dummy DSN needed to make init() work. - sentryOptions['dsn'] = 'http://12345@dummy.dummy/42'; - sentryOptions['beforeSend'] = (event, hint) => { - console.error('ERR-REPORT:', hint.originalException || hint.syntheticException); - return null; - }; - } else { - sentryOptions['dsn'] = sentryDSN; - _canReportEvent = true; - } - - Sentry.init(sentryOptions); - - _isInitialized = true; -} - -/** - * Whether showReportDialog() will work. - */ -export function canReportEvent() { - if (!_isInitialized) throw new Error('Not initialized'); - return _canReportEvent; -} - -/** - * Show a report dialog for user error feedback. - * - * Call canReportEvent() first to see if this will do anything. - */ -export function showReportDialog() { - if (!canReportEvent()) return; - Sentry.showReportDialog(); -} - -/** - * Log an exception - * - * @param {*} exception - */ -export function captureException(exception) { - if (!_isInitialized) throw new Error('Not initialized'); - Sentry.captureException(exception); -} - -/** - * Log a message, returns an internal ID - * - * @param {string} message The message to log - * @param {string} [level=error] The loglevel (error, warning, info, debug) - */ -export function captureMessage(message, level) { - if (!_isInitialized) throw new Error('Not initialized'); - if (!level) level = 'error'; - if (!['error', 'warning', 'info', 'debug'].includes(level)) - throw new Error('Invalid log level'); - Sentry.captureMessage(message, level); -} diff --git a/toolkit-showcase/package.json b/toolkit-showcase/package.json index 46cd807b67a64034966b47ad80e3ce35dc689da9..93b2d3ff22ce0d4d42c207c61884e7b636502cad 100644 --- a/toolkit-showcase/package.json +++ b/toolkit-showcase/package.json @@ -1,6 +1,6 @@ { "name": "dbp-toolkit-showcase", - "version": "0.2.0", + "version": "0.2.1", "main": "src/toolkit-showcase.js", "license": "LGPL-2.1-or-later", "private": true, @@ -40,16 +40,16 @@ "selfsigned": "^2.0.0" }, "dependencies": { - "@dbp-toolkit/app-shell": "^0.2.0", - "@dbp-toolkit/auth": "^0.2.0", - "@dbp-toolkit/common": "^0.2.0", - "@dbp-toolkit/file-handling": "^0.2.0", + "@dbp-toolkit/app-shell": "^0.3.0", + "@dbp-toolkit/auth": "^0.3.0", + "@dbp-toolkit/common": "^0.3.0", + "@dbp-toolkit/file-handling": "^0.3.0", "@dbp-toolkit/font-source-sans-pro": "^0.2.0", - "@dbp-toolkit/language-select": "^0.2.0", - "@dbp-toolkit/notification": "^0.2.0", + "@dbp-toolkit/language-select": "^0.3.0", + "@dbp-toolkit/notification": "^0.3.0", "@dbp-toolkit/organization-select": "^0.2.0", "@dbp-toolkit/person-profile": "^0.2.0", - "@dbp-toolkit/person-select": "^0.2.0", + "@dbp-toolkit/person-select": "^0.3.0", "@open-wc/scoped-elements": "^2.0.0", "@rollup/plugin-replace": "^4.0.0", "highlight.js": "^11.0.0",