Enable Sentry browser profiling

This commit is contained in:
Sebastian Serth
2023-08-18 09:52:52 +02:00
parent 36f0e5cc24
commit 4fc38c7208
3 changed files with 9 additions and 1 deletions

View File

@ -57,6 +57,7 @@ $(document).on('turbolinks:load', function() {
replaysSessionSampleRate: 0.0, replaysSessionSampleRate: 0.0,
replaysOnErrorSampleRate: 1.0, replaysOnErrorSampleRate: 1.0,
integrations: window.SentryIntegrations(), integrations: window.SentryIntegrations(),
profilesSampleRate: 1.0,
initialScope: scope =>{ initialScope: scope =>{
const user = $('meta[name="current-user"]').attr('content'); const user = $('meta[name="current-user"]').attr('content');

View File

@ -13,7 +13,7 @@ class ApplicationController < ActionController::Base
after_action :verify_authorized, except: %i[welcome] after_action :verify_authorized, except: %i[welcome]
around_action :mnemosyne_trace around_action :mnemosyne_trace
around_action :switch_locale around_action :switch_locale
before_action :set_sentry_context, :load_embed_options before_action :set_sentry_context, :load_embed_options, :set_document_policy
protect_from_forgery(with: :exception, prepend: true) protect_from_forgery(with: :exception, prepend: true)
rescue_from Pundit::NotAuthorizedError, with: :render_not_authorized rescue_from Pundit::NotAuthorizedError, with: :render_not_authorized
rescue_from ActiveRecord::RecordNotFound, with: :render_not_found rescue_from ActiveRecord::RecordNotFound, with: :render_not_found
@ -72,6 +72,12 @@ class ApplicationController < ActionController::Base
end end
end end
def set_document_policy
# Instruct browsers to capture profiling data
response.set_header('Document-Policy', 'js-profiling')
end
private :set_document_policy
def set_sentry_context def set_sentry_context
return if current_user.blank? return if current_user.blank?

View File

@ -29,6 +29,7 @@ window.SentryIntegrations = function() { // Publish sentry integration in global
new SentryIntegration.ReportingObserver(), new SentryIntegration.ReportingObserver(),
new SentryIntegration.ExtraErrorData(), new SentryIntegration.ExtraErrorData(),
new SentryIntegration.HttpClient(), new SentryIntegration.HttpClient(),
new Sentry.BrowserProfilingIntegration(),
new Sentry.BrowserTracing(), new Sentry.BrowserTracing(),
new Sentry.Replay(), new Sentry.Replay(),
] ]