add sentry js back in
This commit is contained in:
parent
6696188601
commit
e6ddf2f120
3
app.py
3
app.py
|
@ -81,13 +81,14 @@ def install_security_headers(resp):
|
|||
csp = ("default-src 'none';"
|
||||
"img-src 'self' https:;"
|
||||
"style-src 'self' 'unsafe-inline';"
|
||||
"connect-src 'self';"
|
||||
"frame-ancestors 'none';"
|
||||
)
|
||||
if 'SENTRY_DSN' in app.config:
|
||||
csp += "script-src 'self' https://cdn.ravenjs.com/;"
|
||||
csp += "connect-src 'self' https://sentry.io/;"
|
||||
else:
|
||||
csp += "script-src 'self';"
|
||||
csp += "connect-src 'self';"
|
||||
|
||||
if 'CSP_REPORT_URI' in app.config:
|
||||
csp += "report-uri " + app.config.get('CSP_REPORT_URI')
|
||||
|
|
15
routes.py
15
routes.py
|
@ -40,10 +40,7 @@ def inject_version():
|
|||
@app.context_processor
|
||||
def inject_sentry():
|
||||
if sentry:
|
||||
client_dsn = app.config.get('SENTRY_DSN').split('@')
|
||||
client_dsn[:1] = client_dsn[0].split(':')
|
||||
client_dsn = ':'.join(client_dsn[0:2]) + '@' + client_dsn[3]
|
||||
return dict(sentry_dsn=client_dsn)
|
||||
return dict(sentry=True)
|
||||
return dict()
|
||||
|
||||
|
||||
|
@ -338,3 +335,13 @@ def mastodon_login_step2(instance_url):
|
|||
|
||||
g.viewer = sess
|
||||
return redirect(url_for('index'))
|
||||
|
||||
@app.route('/sentry/setup.js')
|
||||
def sentry_setup():
|
||||
client_dsn = app.config.get('SENTRY_DSN').split('@')
|
||||
client_dsn[:1] = client_dsn[0].split(':')
|
||||
client_dsn = ':'.join(client_dsn[0:2]) + '@' + client_dsn[3]
|
||||
resp = make_response(render_template(
|
||||
'sentry.js', sentry_dsn = client_dsn))
|
||||
resp.headers.set('content-type', 'text/javascript')
|
||||
return resp
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
<meta name='twitter:card' content='summary' />
|
||||
<meta name='twitter:site:id' content='808418'/>
|
||||
|
||||
{% if sentry_dsn -%}
|
||||
<script defer src="https://cdn.ravenjs.com/3.17.0/raven.min.js" crossorigin="anonymous"
|
||||
onload="Raven.config('{{sentry_dsn}}').install()"></script>
|
||||
{% if sentry -%}
|
||||
<script defer src="https://cdn.ravenjs.com/3.17.0/raven.min.js" crossorigin="anonymous"></script>
|
||||
<script defer src="{{ url_for('sentry_setup') }}"></script>
|
||||
{% endif -%}
|
||||
{% block scripts %}{% endblock %}
|
||||
</head>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Raven.config('{{sentry_dsn}}').install()
|
Loading…
Reference in New Issue