Skip to content

Commit

Permalink
Merge pull request #116 from OpenSourceActivismTech/upgrade/sentry-sdk
Browse files Browse the repository at this point in the history
Upgrade Sentry sdk
  • Loading branch information
jlev committed Oct 28, 2020
2 parents 3ed2f3b + d50e7fd commit 39f5fcb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions call_server/api/views.py
Expand Up @@ -490,9 +490,9 @@ def call_info(sid):
@cache.cached(timeout=600)
def campaign_embed_js(campaign_id):
campaign = Campaign.query.filter_by(id=campaign_id).first_or_404()
dsn_public = current_app.config.get('SENTRY_DSN_PUBLIC', '')
dsn_public_key = current_app.config.get('SENTRY_DSN_PUBLIC_KEY', '')
return Response(render_template('api/embed.js',
campaign=campaign, DSN_PUBLIC=dsn_public
campaign=campaign, DSN_PUBLIC_KEY=dsn_public_key
), content_type='application/javascript')


Expand Down
21 changes: 12 additions & 9 deletions call_server/app.py
Expand Up @@ -54,17 +54,20 @@ def create_app(configuration=None, app_name=None, blueprints=None):
configure_app(app, configuration)

if app.config.get('SENTRY_DSN'):
from raven.contrib.flask import Sentry
sentry = Sentry()
sentry.init_app(app, dsn=app.config['SENTRY_DSN'])
sentry_report_uri = 'https://sentry.io/api/%s/csp-report/?sentry_key=%s' % (
sentry.client.remote.project, sentry.client.remote.public_key
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration

sentry = sentry_sdk.init(app.config['SENTRY_DSN'],
integrations=[FlaskIntegration()],
_experiments={"auto_enabling_integrations": True},
traces_sample_rate=0.1
)
talisman.content_security_policy_report_uri = sentry_report_uri
sentry_public_dsn = 'https://%s@sentry.io/%s' % (
sentry.client.remote.public_key, sentry.client.remote.project
sentry_dsn = sentry._client.transport.parsed_dsn
sentry_report_uri = 'https://sentry.io/api/%s/security/?sentry_key=%s' % (
sentry_dsn.project_id, sentry_dsn.public_key
)
app.config['SENTRY_DSN_PUBLIC'] = sentry_public_dsn
talisman.content_security_policy_report_uri = sentry_report_uri
app.config['SENTRY_DSN_PUBLIC_KEY'] = sentry_dsn.public_key

# init extensions once we have app context
init_extensions(app)
Expand Down
2 changes: 1 addition & 1 deletion call_server/templates/api/embed.js
Expand Up @@ -83,7 +83,7 @@ if (typeof window.jQuery === 'undefined') {

// load sentry for frontend error tracking
if (window.CallPowerOptions.errorTracking) {
getScript('https://js.sentry-cdn.com/{{DSN_PUBLIC}}.min.js',
getScript('https://js.sentry-cdn.com/{{DSN_PUBLIC_KEY}}.min.js',
function() {},
'anonymous')
}
2 changes: 1 addition & 1 deletion requirements/heroku.txt
@@ -1,3 +1,3 @@
-r production.txt
newrelic==4.16.0.116
raven==6.10.0
sentry-sdk==0.19.1

0 comments on commit 39f5fcb

Please sign in to comment.