Explorar o código

Merge pull request #2928 from overleaf/jpa-sentry-unified-release-and-env-annotation

[misc] expose release and environment to frontend

GitOrigin-RevId: 2adab7cfb2c63f6d5bc34c367393449c84ef2690
Jakob Ackermann %!s(int64=6) %!d(string=hai) anos
pai
achega
991c4f9876

+ 3 - 0
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

+ 4 - 3
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()
   })

+ 3 - 6
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

+ 2 - 0
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