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

#initializeConfiguration

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_createObject

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_nameObject

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_blockObject

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_limitObject

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_classObject

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_daysObject

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_trackingObject

Cron Job Monitoring



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

def cron_job_tracking
  @cron_job_tracking
end

#database_nameObject

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_urlObject

─── 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_ymlObject

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_formatObject

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_enabledObject

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_windowObject

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_navigationObject

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

#enabledObject

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



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

def enabled
  @enabled
end

#exception_dataObject

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_exceptionsObject

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_shortcutsObject

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_backtraceObject

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_limitObject

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_fileObject

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_levelObject

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_paramsObject

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_infoObject

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_deliveriesObject

Webhook Delivery Logging



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

def log_webhook_deliveries
  @log_webhook_deliveries
end

#logging_enabledObject

Enable structured logging (default: true).



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

def logging_enabled
  @logging_enabled
end

#page_size_optionsObject

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_pageObject

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_daysObject

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_environmentObject

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_metadataObject

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_infoObject

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_requestObject

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_statsObject

Server Statistics



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

def show_server_stats
  @show_server_stats
end

#show_sidekiq_statsObject

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_statsObject

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_viewingObject

Source Code Viewing



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

def source_code_viewing
  @source_code_viewing
end

#stats_refresh_intervalObject

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_secondsObject

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_enabledObject

Storm Protection



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

def storm_protection_enabled
  @storm_protection_enabled
end

#storm_threshold_per_secondObject

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_columnsObject

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_prefixObject

Returns the value of attribute table_prefix.



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

def table_prefix
  @table_prefix
end

#themeObject

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_layoutObject

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_trackingObject

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_developmentObject

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_hostsObject

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_daysObject

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_hostsObject

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_headersObject

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_timeoutObject

Webhook timeout in seconds (default: 5).



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

def webhook_timeout
  @webhook_timeout
end

#webhooksObject

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