Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions contentcuration/contentcuration/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def site_variables(request):
"DEBUG": settings.DEBUG,
"LANG_INFO": json_for_parse_from_data(language_globals()),
"LOGGED_IN": not request.user.is_anonymous,
"SENTRY_DSN": settings.SENTRY_DSN,
"SENTRY_ENVIRONMENT": settings.SENTRY_ENVIRONMENT,
"SENTRY_RELEASE": settings.SENTRY_RELEASE,
"SENTRY_ACTIVE": settings.SENTRY_ACTIVE,
}


Expand Down
6 changes: 4 additions & 2 deletions contentcuration/contentcuration/frontend/shared/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ import { Session, injectVuexStore } from 'shared/data/resources';
// just say yes to devtools (in debug mode)
if (process.env.NODE_ENV !== 'production') {
Vue.config.devtools = true;
} else {
} else if (window.sentryActive) {
Sentry.init({
Vue,
dsn: 'https://e4b21baeb7a044b885464d2af687fb73@sentry.io/1252819',
dsn: window.sentryDSN,
environment: window.sentryEnvironment,
release: window.sentryRelease,
initialScope: {
user: window.user ? { id: window.user.id, email: window.user.email } : null,
},
Expand Down
15 changes: 10 additions & 5 deletions contentcuration/contentcuration/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,18 +413,23 @@ def gettext(s):
key = get_secret("SENTRY_DSN_KEY")
if key:
key = key.strip() # strip any possible whitespace or trailing newline
release_commit = get_secret("RELEASE_COMMIT_SHA")
if key and len(key) > 0 and release_commit:

SENTRY_DSN = 'https://{secret}@sentry.io/1252819'.format(secret=key) if key else None
SENTRY_ENVIRONMENT = get_secret("BRANCH_ENVIRONMENT")
SENTRY_RELEASE = get_secret("RELEASE_COMMIT_SHA")
SENTRY_ACTIVE = False

if SENTRY_DSN and SENTRY_RELEASE and SENTRY_ENVIRONMENT:
import sentry_sdk
# TODO: there are also Celery and Redis integrations, but since they are new
# I left them as a separate task so we can spend more time on testing.
from sentry_sdk.integrations.django import DjangoIntegration

sentry_sdk.init(
dsn='https://{secret}@sentry.io/1252819'.format(secret=key),
dsn=SENTRY_DSN,
integrations=[DjangoIntegration()],
release=release_commit,
environment=get_secret("BRANCH_ENVIRONMENT"),
release=SENTRY_RELEASE,
environment=SENTRY_ENVIRONMENT,
send_default_pii=True,
)

Expand Down
6 changes: 6 additions & 0 deletions contentcuration/contentcuration/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@
var csrftoken = '{{ csrf_token }}';
var betaMode = "{{ BETA_MODE }}" === "True";
var storageBaseUrl = "{{ STORAGE_HOST }}/{{ STORAGE_BASE_URL }}";
{% if SENTRY_ACTIVE %}
var sentryActive = true;
var sentryDSN = "{{ SENTRY_DSN }}";
var sentryEnvironment = "{{ SENTRY_ENVIRONMENT }}";
var sentryRelease = "{{ SENTRY_RELEASE }}";
{% endif %}
{% if not debug %}
if (user && user.id && window.Sentry) {
Sentry.setUser({ id: user.id, email: user.email });
Expand Down