From 991c4f9876bb7256f59b9e4d5c1ac4903a49286e Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Tue, 23 Jun 2020 15:15:49 +0200 Subject: [PATCH] Merge pull request #2928 from overleaf/jpa-sentry-unified-release-and-env-annotation [misc] expose release and environment to frontend GitOrigin-RevId: 2adab7cfb2c63f6d5bc34c367393449c84ef2690 --- services/web/Dockerfile | 3 +++ services/web/app/src/infrastructure/ExpressLocals.js | 7 ++++--- services/web/config/settings.defaults.coffee | 9 +++------ services/web/frontend/js/utils/sentry.js | 2 ++ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/services/web/Dockerfile b/services/web/Dockerfile index f4c23fc7cc..8db198fde0 100644 --- a/services/web/Dockerfile +++ b/services/web/Dockerfile @@ -44,3 +44,6 @@ RUN mkdir -p /app/data/dumpFolder && \ USER node CMD ["node", "--expose-gc", "app.js"] + +ARG SENTRY_RELEASE +ENV SENTRY_RELEASE=$SENTRY_RELEASE diff --git a/services/web/app/src/infrastructure/ExpressLocals.js b/services/web/app/src/infrastructure/ExpressLocals.js index 465ed00ed2..9ec9a1c0e2 100644 --- a/services/web/app/src/infrastructure/ExpressLocals.js +++ b/services/web/app/src/infrastructure/ExpressLocals.js @@ -366,9 +366,10 @@ module.exports = function(webRouter, privateApiRouter, publicApiRouter) { recaptchaDisabled: Settings.recaptcha != null ? Settings.recaptcha.disabled : undefined, validRootDocExtensions: Settings.validRootDocExtensions, - sentryAllowedOriginRegex: - Settings.sentry && Settings.sentry.allowedOriginRegex, - sentryDsn: Settings.sentry != null ? Settings.sentry.publicDSN : undefined + sentryAllowedOriginRegex: Settings.sentry.allowedOriginRegex, + sentryDsn: Settings.sentry.publicDSN, + sentryEnvironment: Settings.sentry.environment, + sentryRelease: Settings.sentry.release } next() }) diff --git a/services/web/config/settings.defaults.coffee b/services/web/config/settings.defaults.coffee index ec954eaec5..6f8aa6a6a4 100644 --- a/services/web/config/settings.defaults.coffee +++ b/services/web/config/settings.defaults.coffee @@ -385,13 +385,10 @@ module.exports = settings = # tenderUrl: "" # # Client-side error logging is provided by getsentry.com - # sentry: - # src: "" + sentry: + environment: process.env['SENTRY_ENVIRONMENT'] + release: process.env['SENTRY_RELEASE'] # publicDSN: "" - # - # src should be either a remote url like - # //cdn.ravenjs.com/1.1.22/jquery,native/raven.min.js - # or a local file in the js/libs directory. # The publicDSN is the token for the client-side getSentry service. # Production Settings diff --git a/services/web/frontend/js/utils/sentry.js b/services/web/frontend/js/utils/sentry.js index 7e1468c831..df8a6bdc3e 100644 --- a/services/web/frontend/js/utils/sentry.js +++ b/services/web/frontend/js/utils/sentry.js @@ -6,6 +6,8 @@ if (window.ExposedSettings.sentryDsn) { Sentry.init({ dsn: window.ExposedSettings.sentryDsn, + release: window.ExposedSettings.sentryRelease, + environment: window.ExposedSettings.sentryEnvironment, // Ignore errors unless they come from our origins // Adapted from: https://docs.sentry.io/platforms/javascript/#decluttering-sentry