DEV: Add ENV variable for enabling MiniProfiler snapshots (#10690)

* DEV: Add ENV variable for enabling MiniProfiler snapshots

* MiniProfiler is not loaded in test env
This commit is contained in:
Osama Sayegh
2020-09-17 18:18:35 +03:00
committed by GitHub
parent 6e69c25134
commit a92d88747e
3 changed files with 14 additions and 5 deletions

View File

@ -31,6 +31,7 @@ class ApplicationController < ActionController::Base
before_action :check_readonly_mode
before_action :handle_theme
before_action :set_current_user_for_logs
before_action :set_mp_snapshot_fields
before_action :clear_notifications
around_action :with_resolved_locale
before_action :set_mobile_view
@ -295,6 +296,12 @@ class ApplicationController < ActionController::Base
response.headers["X-Discourse-Route"] = "#{controller_name}/#{action_name}"
end
def set_mp_snapshot_fields
if defined?(Rack::MiniProfiler)
Rack::MiniProfiler.add_snapshot_custom_field("application version", Discourse.git_version)
end
end
def clear_notifications
if current_user && !@readonly_mode