Class: RailsNexus::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_nexus/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

Returns a new instance of Configuration.



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/rails_nexus/configuration.rb', line 198

def initialize
  @application_name = nil
  @auth_block = nil
  @exception_data = nil
  @after_create = nil
  @per_page = 30
  @enabled = true

  # Notifications
  @webhooks = []
  @webhook_timeout = 5
  @webhook_headers = {}
  @webhook_allowed_hosts = []
  @webhook_denied_hosts = []
  @webhook_allow_http_in_development = false

  # Logging
  @logging_enabled = true
  @log_level = :info
  @log_file = nil
  @log_backtrace = true
  @log_params = true
  @log_user_info = true
  @log_backtrace_limit = 20
  @deduplication_enabled = false
  @deduplication_window = 300

  # Cleanup
  @retention_days = nil

  # Appearance
  @theme = "auto"
  @use_host_layout = false
  @body_class = ""

  # Sidebar
  @sidebar_links = []

  # Advanced UI
  @show_stats = true
  @keyboard_shortcuts = true
  @group_exceptions = false
  @show_metadata = true
  @show_environment = false
  @show_request = true
  @backtrace_limit = 30
  @enable_navigation = true
  @table_columns = %i[class controller action message time].freeze
  @date_format = nil
  @page_size_options = [25, 50, 100].freeze

  # Server Statistics
  @show_server_stats = true
  @show_sidekiq_stats = true
  @show_process_info = true
  @stats_refresh_interval = 30

  # Cron Job Monitoring
  @cron_job_tracking = true
  @cron_job_retention_days = 30

  # Webhook Delivery Logging
  @log_webhook_deliveries = true
  @webhook_delivery_retention_days = 30

  # Breadcrumbs (activity trail) — needed for N+1 detection and breadcrumb tab
  @breadcrumbs_enabled = true

  # Storm Protection (circuit breaker)
  @storm_protection_enabled = true
  @storm_threshold_per_second = 50
  @storm_cooldown_seconds = 60

  # User Impact
  @user_impact_tracking = true

  # Source Code Viewing
  @source_code_viewing = true
  # Database
  @database_url = nil
  @database_name = nil
  @database_yml = nil
  @table_prefix = "rails_nexus_"
end

Instance Attribute Details

#after_create ⇒ Object

Proc called with the LoggedException record after creation. Use for Telegram, Slack, email, or custom notifications. Example:

config.after_create = ->(exception) { MyNotifier.alert(exception) }


37
38
39
# File 'lib/rails_nexus/configuration.rb', line 37

def after_create
  @after_create
end

#application_name ⇒ Object

Dashboard title shown in the header. Set to nil to use "RailsNexus".



8
9
10
# File 'lib/rails_nexus/configuration.rb', line 8

def application_name
  @application_name
end

#auth_block ⇒ Object

Proc called with the controller instance before each request. Return false/nil to deny access; return true to allow. Example:

config.auth_block = ->(controller) { controller.current_user&.admin? }


22
23
24
# File 'lib/rails_nexus/configuration.rb', line 22

def auth_block
  @auth_block
end

#backtrace_limit ⇒ Object

Maximum number of backtrace frames to show before collapsing (default: 30).



144
145
146
# File 'lib/rails_nexus/configuration.rb', line 144

def backtrace_limit
  @backtrace_limit
end

#body_class ⇒ Object

CSS class added to the dashboard body element.



110
111
112
# File 'lib/rails_nexus/configuration.rb', line 110

def body_class
  @body_class
end

Breadcrumbs



174
175
176
# File 'lib/rails_nexus/configuration.rb', line 174

def breadcrumbs_enabled
  @breadcrumbs_enabled
end

#cron_job_retention_days ⇒ Object

Returns the value of attribute cron_job_retention_days.



167
168
169
# File 'lib/rails_nexus/configuration.rb', line 167

def cron_job_retention_days
  @cron_job_retention_days
end

#cron_job_tracking ⇒ Object

Cron Job Monitoring



166
167
168
# File 'lib/rails_nexus/configuration.rb', line 166

def cron_job_tracking
  @cron_job_tracking
end

#database_name ⇒ Object

Returns the value of attribute database_name.



194
195
196
# File 'lib/rails_nexus/configuration.rb', line 194

def database_name
  @database_name
end

#database_url ⇒ Object

─── Database ─────────────────────────────────────────────── Use a separate database for RailsNexus tables. Options:

config.database_url = "mysql2://user:pass@localhost/rails_nexus"
config.database_name = "rails_nexus"  # uses config/database.yml entry
config.database_yml  = "config/rails_nexus_database.yml"
config.table_prefix  = "rails_nexus_"


193
194
195
# File 'lib/rails_nexus/configuration.rb', line 193

def database_url
  @database_url
end

#database_yml ⇒ Object

Returns the value of attribute database_yml.



195
196
197
# File 'lib/rails_nexus/configuration.rb', line 195

def database_yml
  @database_yml
end

#date_format ⇒ Object

Date format for display (default: nil = auto relative).



154
155
156
# File 'lib/rails_nexus/configuration.rb', line 154

def date_format
  @date_format
end

#deduplication_enabled ⇒ Object

Enable exception deduplication (default: false). When enabled, only logs unique exception class + controller combinations within a time window.



88
89
90
# File 'lib/rails_nexus/configuration.rb', line 88

def deduplication_enabled
  @deduplication_enabled
end

#deduplication_window ⇒ Object

Deduplication time window in seconds (default: 300 = 5 minutes).



91
92
93
# File 'lib/rails_nexus/configuration.rb', line 91

def deduplication_window
  @deduplication_window
end

#enable_navigation ⇒ Object

Enable prev/next navigation in detail view (default: true).



147
148
149
# File 'lib/rails_nexus/configuration.rb', line 147

def enable_navigation
  @enable_navigation
end

#enabled ⇒ Object

Enable/disable the dashboard entirely (default: true).



11
12
13
# File 'lib/rails_nexus/configuration.rb', line 11

def enabled
  @enabled
end

#exception_data ⇒ Object

Proc called with the controller to attach extra data to each exception record. Example:

config.exception_data = ->(controller) { { user_id: controller.current_user&.id } }


29
30
31
# File 'lib/rails_nexus/configuration.rb', line 29

def exception_data
  @exception_data
end

#group_exceptions ⇒ Object

Enable exception grouping in the list (default: false). Groups exceptions by class + controller.



132
133
134
# File 'lib/rails_nexus/configuration.rb', line 132

def group_exceptions
  @group_exceptions
end

#keyboard_shortcuts ⇒ Object

Enable keyboard shortcuts in the dashboard (default: true).



128
129
130
# File 'lib/rails_nexus/configuration.rb', line 128

def keyboard_shortcuts
  @keyboard_shortcuts
end

#log_backtrace ⇒ Object

Include backtrace in logs (default: true).



74
75
76
# File 'lib/rails_nexus/configuration.rb', line 74

def log_backtrace
  @log_backtrace
end

#log_backtrace_limit ⇒ Object

Maximum backtrace lines to include (default: 20).



83
84
85
# File 'lib/rails_nexus/configuration.rb', line 83

def log_backtrace_limit
  @log_backtrace_limit
end

#log_file ⇒ Object

Write logs to a JSON file (path or nil). Example:

config.log_file = "log/rails_nexus.log"


71
72
73
# File 'lib/rails_nexus/configuration.rb', line 71

def log_file
  @log_file
end

#log_level ⇒ Object

Log level for rails_nexus logger (default: :info). Options: :debug, :info, :warn, :error, :fatal



66
67
68
# File 'lib/rails_nexus/configuration.rb', line 66

def log_level
  @log_level
end

#log_params ⇒ Object

Include request params in logs (default: true).



77
78
79
# File 'lib/rails_nexus/configuration.rb', line 77

def log_params
  @log_params
end

#log_user_info ⇒ Object

Include user info in logs (default: true).



80
81
82
# File 'lib/rails_nexus/configuration.rb', line 80

def 
  @log_user_info
end

#log_webhook_deliveries ⇒ Object

Webhook Delivery Logging



170
171
172
# File 'lib/rails_nexus/configuration.rb', line 170

def log_webhook_deliveries
  @log_webhook_deliveries
end

#logging_enabled ⇒ Object

Enable structured logging (default: true).



62
63
64
# File 'lib/rails_nexus/configuration.rb', line 62

def logging_enabled
  @logging_enabled
end

#page_size_options ⇒ Object

Rows per page options for the page size selector (default: [25, 50, 100]).



157
158
159
# File 'lib/rails_nexus/configuration.rb', line 157

def page_size_options
  @page_size_options
end

#per_page ⇒ Object

Number of exceptions per page (default: 30).



14
15
16
# File 'lib/rails_nexus/configuration.rb', line 14

def per_page
  @per_page
end

#retention_days ⇒ Object

Automatically delete exceptions older than N days. Set to nil to disable (default: nil).



97
98
99
# File 'lib/rails_nexus/configuration.rb', line 97

def retention_days
  @retention_days
end

#show_environment ⇒ Object

Show environment variables in detail view (default: false).



138
139
140
# File 'lib/rails_nexus/configuration.rb', line 138

def show_environment
  @show_environment
end

#show_metadata ⇒ Object

Show metadata grid in detail view (default: true).



135
136
137
# File 'lib/rails_nexus/configuration.rb', line 135

def 
  @show_metadata
end

#show_process_info ⇒ Object

Returns the value of attribute show_process_info.



162
163
164
# File 'lib/rails_nexus/configuration.rb', line 162

def show_process_info
  @show_process_info
end

#show_request ⇒ Object

Show request params in detail view (default: true).



141
142
143
# File 'lib/rails_nexus/configuration.rb', line 141

def show_request
  @show_request
end

#show_server_stats ⇒ Object

Server Statistics



160
161
162
# File 'lib/rails_nexus/configuration.rb', line 160

def show_server_stats
  @show_server_stats
end

#show_sidekiq_stats ⇒ Object

Returns the value of attribute show_sidekiq_stats.



161
162
163
# File 'lib/rails_nexus/configuration.rb', line 161

def show_sidekiq_stats
  @show_sidekiq_stats
end

#show_stats ⇒ Object

Show stats overview cards on index page (default: true).



125
126
127
# File 'lib/rails_nexus/configuration.rb', line 125

def show_stats
  @show_stats
end

Custom links shown in the dashboard sidebar. Example:

config.sidebar_links = [
{ label: "GitHub", url: "https://github.com/myorg/myapp", icon: "code" },
{ label: "Docs", url: "/docs", icon: "book" }
]


120
121
122
# File 'lib/rails_nexus/configuration.rb', line 120

def sidebar_links
  @sidebar_links
end

#source_code_viewing ⇒ Object

Source Code Viewing



185
186
187
# File 'lib/rails_nexus/configuration.rb', line 185

def source_code_viewing
  @source_code_viewing
end

#stats_refresh_interval ⇒ Object

Returns the value of attribute stats_refresh_interval.



163
164
165
# File 'lib/rails_nexus/configuration.rb', line 163

def stats_refresh_interval
  @stats_refresh_interval
end

#storm_cooldown_seconds ⇒ Object

Returns the value of attribute storm_cooldown_seconds.



179
180
181
# File 'lib/rails_nexus/configuration.rb', line 179

def storm_cooldown_seconds
  @storm_cooldown_seconds
end

#storm_protection_enabled ⇒ Object

Storm Protection



177
178
179
# File 'lib/rails_nexus/configuration.rb', line 177

def storm_protection_enabled
  @storm_protection_enabled
end

#storm_threshold_per_second ⇒ Object

Returns the value of attribute storm_threshold_per_second.



178
179
180
# File 'lib/rails_nexus/configuration.rb', line 178

def storm_threshold_per_second
  @storm_threshold_per_second
end

#table_columns ⇒ Object

Columns to show in the exception table. Default: [:class, :controller, :action, :message, :time]



151
152
153
# File 'lib/rails_nexus/configuration.rb', line 151

def table_columns
  @table_columns
end

#table_prefix ⇒ Object

Returns the value of attribute table_prefix.



196
197
198
# File 'lib/rails_nexus/configuration.rb', line 196

def table_prefix
  @table_prefix
end

#theme ⇒ Object

Dashboard theme: "light", "dark", or "auto" (default: "auto").



102
103
104
# File 'lib/rails_nexus/configuration.rb', line 102

def theme
  @theme
end

#use_host_layout ⇒ Object

Use the host app's layout instead of rails_nexus's built-in layout. Set to true to render inside the host app's sidebar/nav. Set to false (default) for a standalone dashboard.



107
108
109
# File 'lib/rails_nexus/configuration.rb', line 107

def use_host_layout
  @use_host_layout
end

#user_impact_tracking ⇒ Object

User Impact



182
183
184
# File 'lib/rails_nexus/configuration.rb', line 182

def user_impact_tracking
  @user_impact_tracking
end

#webhook_allow_http_in_development ⇒ Object

HTTP remains disabled except when this is true and Rails.env is development.



57
58
59
# File 'lib/rails_nexus/configuration.rb', line 57

def webhook_allow_http_in_development
  @webhook_allow_http_in_development
end

#webhook_allowed_hosts ⇒ Object

Host allow/deny policies. Wildcards such as "*.example.com" are accepted.



53
54
55
# File 'lib/rails_nexus/configuration.rb', line 53

def webhook_allowed_hosts
  @webhook_allowed_hosts
end

#webhook_delivery_retention_days ⇒ Object

Returns the value of attribute webhook_delivery_retention_days.



171
172
173
# File 'lib/rails_nexus/configuration.rb', line 171

def webhook_delivery_retention_days
  @webhook_delivery_retention_days
end

#webhook_denied_hosts ⇒ Object

Returns the value of attribute webhook_denied_hosts.



54
55
56
# File 'lib/rails_nexus/configuration.rb', line 54

def webhook_denied_hosts
  @webhook_denied_hosts
end

#webhook_headers ⇒ Object

Custom headers sent with webhook requests. Example:

config.webhook_headers = { "Authorization" => "Bearer token123" }


50
51
52
# File 'lib/rails_nexus/configuration.rb', line 50

def webhook_headers
  @webhook_headers
end

#webhook_timeout ⇒ Object

Webhook timeout in seconds (default: 5).



45
46
47
# File 'lib/rails_nexus/configuration.rb', line 45

def webhook_timeout
  @webhook_timeout
end

#webhooks ⇒ Object

Webhook URLs called on each new exception (POST with JSON body). Example:

config.webhooks = ["https://hooks.slack.com/services/xxx"]


42
43
44
# File 'lib/rails_nexus/configuration.rb', line 42

def webhooks
  @webhooks
end