diff --git a/libraries/logger/.nvmrc b/libraries/logger/.nvmrc index ed5ddf35fc..62e05d11a6 100644 --- a/libraries/logger/.nvmrc +++ b/libraries/logger/.nvmrc @@ -1 +1,2 @@ -10.19.0 \ No newline at end of file +10.21.0 + diff --git a/libraries/logger/logging-manager.js b/libraries/logger/logging-manager.js index 79d1be9108..e809e0e580 100644 --- a/libraries/logger/logging-manager.js +++ b/libraries/logger/logging-manager.js @@ -128,13 +128,11 @@ const Logger = (module.exports = { this.raven.captureException(error, { tags, extra, level }) // put a flag on the errors to avoid reporting them multiple times - const result = [] for (key in attributes) { value = attributes[key] if (value instanceof Error) { value.reportedToSentry = true } - return result } } catch (err) { // ignore Raven errors diff --git a/libraries/logger/package-lock.json b/libraries/logger/package-lock.json index 8a6d285d9c..2359ebcbd7 100644 --- a/libraries/logger/package-lock.json +++ b/libraries/logger/package-lock.json @@ -1,6 +1,6 @@ { "name": "logger-sharelatex", - "version": "1.9.0", + "version": "1.9.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -140,9 +140,9 @@ } }, "@overleaf/o-error": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@overleaf/o-error/-/o-error-2.1.0.tgz", - "integrity": "sha512-Zd9sks9LrLw8ErHt/cXeWIkyxWAqNAvNGn7wIjLQJH6TTEEW835PWOhpch+hQwwWsTxWIx/JDj+IpZ3ouw925g==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@overleaf/o-error/-/o-error-3.0.0.tgz", + "integrity": "sha512-LsM2s6Iy9G97ktPo0ys4VxtI/m3ahc1ZHwjo5XnhXtjeIkkkVAehsrcRRoV/yWepPjymB0oZonhcfojpjYR/tg==" }, "@protobufjs/aspromise": { "version": "1.1.2", diff --git a/libraries/logger/package.json b/libraries/logger/package.json index 9eae161913..25ff5f5df9 100644 --- a/libraries/logger/package.json +++ b/libraries/logger/package.json @@ -7,7 +7,7 @@ "url": "http://github.com/sharelatex/logger-sharelatex.git" }, "license": "AGPL-3.0-only", - "version": "1.9.0", + "version": "2.0.0", "scripts": { "test": "mocha test/**/*.js", "format": "prettier-eslint '**/*.js' --list-different", @@ -16,7 +16,7 @@ }, "dependencies": { "@google-cloud/logging-bunyan": "^2.0.0", - "@overleaf/o-error": "^2.0.0", + "@overleaf/o-error": "^3.0.0", "bunyan": "1.8.12", "raven": "1.1.3", "yn": "^3.1.1" diff --git a/libraries/logger/test/unit/loggingManagerTests.js b/libraries/logger/test/unit/loggingManagerTests.js index dc77b31f7c..d236776a81 100644 --- a/libraries/logger/test/unit/loggingManagerTests.js +++ b/libraries/logger/test/unit/loggingManagerTests.js @@ -259,6 +259,32 @@ describe('LoggingManager', function() { this.logger.error({ foo: 'bar' }, 'message') this.captureException.callCount.should.equal(10) }) + + describe('reportedToSentry', function() { + it('should mark the error as reported to sentry', function() { + const err = new Error() + this.logger.error({ err }, 'message') + expect(this.captureException.called).to.equal(true) + expect(err.reportedToSentry).to.equal(true) + }) + + it('should mark two errors as reported to sentry', function() { + const err1 = new Error() + const err2 = new Error() + this.logger.error({ err: err1, err2 }, 'message') + expect(this.captureException.called).to.equal(true) + expect(err1.reportedToSentry).to.equal(true) + expect(err2.reportedToSentry).to.equal(true) + }) + + it('should not mark arbitrary objects as reported to sentry', function() { + const err = new Error() + const ctx = { foo: 'bar' } + this.logger.error({ err, ctx }, 'message') + expect(this.captureException.called).to.equal(true) + expect(ctx.reportedToSentry).to.equal(undefined) + }) + }) }) describe('checkLogLevel', function() {