These docs are a work-in-progress and are currently undergoing a major rewrite!
Forge Pro

Sentry

Sentry is an error monitoring service that we think has a great Django integration. It allows you to debug production errors and also has some performance monitoring features that can be enabled.

Installation

# settings.py
INSTALLED_APPS = INSTALLED_APPS + [
  "forgepro.sentry",
]

# Enable the error page feedback widget
MIDDLEWARE = MIDDLEWARE + [
  "forgepro.sentry.SentryFeedbackMiddleware",
]

In your base.html, load sentry and include the sentry_js tag:

<!-- base.html -->
{% load sentry %}
<!doctype html>
<html lang="en">
  <head>
      ...
      {% sentry_js %}
  </head>
  <body>
      ...
  </body>
</html>

To enable Sentry in production, add the SENTRY_DSN to your Heroku app:

heroku config:set SENTRY_DSN=<your-DSN>

Configuration

By default, you'll get both Python (backend) and JavaScript (frontend) error reporting that includes PII (user ID, username, and email). You can further tweak the Sentry settings with these environment variables:

  • SENTRY_RELEASE - the commit sha by default
  • SENTRY_ENVIRONMENT - "production" by default
  • SENTRY_PII_ENABLED - true by default, set to false to disable sending PII
  • SENTRY_JS_ENABLED - true by default, set to false to disable JS error reporting
Name Default Environment Description
SENTRY_DSN Any Sentry DSN
SENTRY_RELEASE HEROKU_SLUG_COMMIT Any Sentry release tag
SENTRY_ENVIRONMENT production Any Sentry environment tag
SENTRY_PII_ENABLED true Any Send username/email with Sentry errors
SENTRY_JS_ENABLED true Any Enables JS error monitoring (requiers {% sentry_js %} tag too)

Error page feedback widget

By adding the SentryFeedbackMiddleware to your MIDDLEWARE, your 500.html server error page will include the Sentry feedback widget: