diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim
index 6328bf8f..b114c764 100644
--- a/app/views/layouts/application.html.slim
+++ b/app/views/layouts/application.html.slim
@@ -20,12 +20,12 @@ html lang="#{I18n.locale || I18n.default_locale}"
script type="text/javascript"
| I18n.defaultLocale = "#{I18n.default_locale}";
| I18n.locale = "#{I18n.locale}";
- - unless Sentry.configuration.environment == "development"
+ - if SentryJavascript.active?
| Sentry.init({
| dsn: 'https://2616b10855e04ce1b748775203ff0f7c@o257002.ingest.sentry.io/5667283',
| attachStacktrace: true,
- | release: "#{Sentry.configuration.release}",
- | environment: "#{Sentry.configuration.environment}",
+ | release: "#{SentryJavascript.release}",
+ | environment: "#{SentryJavascript.environment}",
| });
- if @current_user
| Sentry.configureScope(function(scope) {
diff --git a/config/initializers/sentry_javascript.rb b/config/initializers/sentry_javascript.rb
new file mode 100644
index 00000000..6a941da7
--- /dev/null
+++ b/config/initializers/sentry_javascript.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class SentryJavascript
+ def self.active?
+ dsn.present? && %w[development test].exclude?(environment)
+ end
+
+ def self.dsn
+ ENV['SENTRY_JAVASCRIPT_DSN']
+ end
+
+ def self.release
+ Sentry.configuration.release
+ end
+
+ def self.environment
+ Sentry.configuration.environment
+ end
+end
diff --git a/docs/environment_variables.md b/docs/environment_variables.md
index 3a1166fe..b75965b5 100644
--- a/docs/environment_variables.md
+++ b/docs/environment_variables.md
@@ -2,14 +2,16 @@
The following environment variables are specifically support in CodeOcean and are used to configure the application in addition to the setting files under `config/`.
-| Environment Variable | Default | Description |
-|- |- |- |
-| `RAILS_ENV` | `development` | Specifies the Rails environment which can be configured using the files in `config/environments` |
-| `RAILS_RELATIVE_URL_ROOT` | `/` | Specifies the subpath of the application, used for links and assets |
-| `SENTRY_DSN` | `` | Specifies the Sentry error reporting endpoint for the Rails server |
-| `RAILS_LOG_TO_STDOUT` | `false` in `production` | Enables the server to print log output to the command line |
-| `RAILS_SERVE_STATIC_FILES` | `true` in `development` and `test`
`false` in `production` and `staging` | Specifies whether the Rails server should be able to handle requests for non-dynamic resources (e.g., assets) |
-| `BACKTRACE` | `false` | Enables more verbose log output from framework code during debugging |
-| `TRUSTED_IP` | ` ` in `development` | Enables `BetterErrors` for the given IP addresses during development |
-| `LISTEN_ADDRESS` | `127.0.0.1` in `development` | Specifies the IP address the server should attach to during development |
-| `HEADLESS_TEST` | `false` | Enables the test environment to work without a window manager for feature tests (e.g., using Vagrant) |
+| Environment Variable | Default | Description |
+|- |- |- |
+| `RAILS_ENV` | `development` | Specifies the Rails environment which can be configured using the files in `config/environments` |
+| `RAILS_RELATIVE_URL_ROOT` | `/` | Specifies the subpath of the application, used for links and assets |
+| `SENTRY_DSN` | ` ` | Specifies the [Sentry error reporting](https://sentry.io) endpoint for the Rails server |
+| `SENTRY_JAVASCRIPT_DSN` | ` ` | Specifies the [Sentry error reporting](https://sentry.io) endpoint for the frontend used by browsers |
+| `SENTRY_CURRENT_ENV` | ` ` | Specifies the [Sentry](https://sentry.io) environment used for error reporting |
+| `RAILS_LOG_TO_STDOUT` | `false` in `production` | Enables the server to print log output to the command line |
+| `RAILS_SERVE_STATIC_FILES` | `true` in `development` and `test`
`false` in `production` and `staging` | Specifies whether the Rails server should be able to handle requests for non-dynamic resources (e.g., assets) |
+| `BACKTRACE` | `false` | Enables more verbose log output from framework code during debugging |
+| `TRUSTED_IP` | ` ` in `development` | Enables `BetterErrors` for the given IP addresses during development |
+| `LISTEN_ADDRESS` | `127.0.0.1` in `development` | Specifies the IP address the Vagrant VM server should attach to during development |
+| `HEADLESS_TEST` | `false` | Enables the test environment to work without a window manager for feature tests (e.g., using Vagrant) |