Class: RailsErrorDashboard::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RailsErrorDashboard::Generators::InstallGenerator
- Defined in:
- lib/generators/rails_error_dashboard/install/install_generator.rb
Instance Method Summary collapse
- #add_route ⇒ Object
- #copy_migrations ⇒ Object
- #create_initializer_file ⇒ Object
- #select_optional_features ⇒ Object
- #show_feature_summary ⇒ Object
- #show_readme ⇒ Object
- #welcome_message ⇒ Object
Instance Method Details
#add_route ⇒ Object
228 229 230 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 228 def add_route route "mount RailsErrorDashboard::Engine => '/error_dashboard'" end |
#copy_migrations ⇒ Object
224 225 226 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 224 def copy_migrations rails_command "rails_error_dashboard:install:migrations" end |
#create_initializer_file ⇒ Object
194 195 196 197 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 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 194 def create_initializer_file # Notifications @enable_slack = @selected_features&.dig(:slack) || [:slack] @enable_email = @selected_features&.dig(:email) || [:email] @enable_discord = @selected_features&.dig(:discord) || [:discord] @enable_pagerduty = @selected_features&.dig(:pagerduty) || [:pagerduty] @enable_webhooks = @selected_features&.dig(:webhooks) || [:webhooks] # Performance @enable_async_logging = @selected_features&.dig(:async_logging) || [:async_logging] @enable_error_sampling = @selected_features&.dig(:error_sampling) || [:error_sampling] @enable_separate_database = @selected_features&.dig(:separate_database) || [:separate_database] @database_name = [:database] # Advanced Analytics @enable_baseline_alerts = @selected_features&.dig(:baseline_alerts) || [:baseline_alerts] @enable_similar_errors = @selected_features&.dig(:similar_errors) || [:similar_errors] @enable_co_occurring_errors = @selected_features&.dig(:co_occurring_errors) || [:co_occurring_errors] @enable_error_cascades = @selected_features&.dig(:error_cascades) || [:error_cascades] @enable_error_correlation = @selected_features&.dig(:error_correlation) || [:error_correlation] @enable_platform_comparison = @selected_features&.dig(:platform_comparison) || [:platform_comparison] @enable_occurrence_patterns = @selected_features&.dig(:occurrence_patterns) || [:occurrence_patterns] # Developer Tools @enable_source_code_integration = @selected_features&.dig(:source_code_integration) || [:source_code_integration] @enable_git_blame = @selected_features&.dig(:git_blame) || [:git_blame] template "initializer.rb", "config/initializers/rails_error_dashboard.rb" end |
#select_optional_features ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 49 def select_optional_features return unless [:interactive] && behavior == :invoke return unless $stdin.tty? # Skip interactive mode if not running in a terminal say "Let's configure optional features...\n", :cyan say "(You can always enable/disable these later in the initializer)\n\n", :yellow @selected_features = {} # Feature definitions with descriptions - organized by category features = [ # === NOTIFICATIONS === { key: :slack, name: "Slack Notifications", description: "Send error alerts to Slack channels", category: "Notifications" }, { key: :email, name: "Email Notifications", description: "Send error alerts via email", category: "Notifications" }, { key: :discord, name: "Discord Notifications", description: "Send error alerts to Discord", category: "Notifications" }, { key: :pagerduty, name: "PagerDuty Integration", description: "Critical errors to PagerDuty", category: "Notifications" }, { key: :webhooks, name: "Generic Webhooks", description: "Send data to custom endpoints", category: "Notifications" }, # === PERFORMANCE & SCALABILITY === { key: :async_logging, name: "Async Error Logging", description: "Process errors in background jobs (faster responses)", category: "Performance" }, { key: :error_sampling, name: "Error Sampling", description: "Log only % of non-critical errors (reduce volume)", category: "Performance" }, { key: :separate_database, name: "Separate Error Database", description: "Store errors in dedicated database", category: "Performance" }, # === ADVANCED ANALYTICS === { key: :baseline_alerts, name: "Baseline Anomaly Alerts", description: "Auto-detect unusual error rate spikes", category: "Advanced Analytics" }, { key: :similar_errors, name: "Fuzzy Error Matching", description: "Find similar errors across different hashes", category: "Advanced Analytics" }, { key: :co_occurring_errors, name: "Co-occurring Errors", description: "Detect errors that happen together", category: "Advanced Analytics" }, { key: :error_cascades, name: "Error Cascade Detection", description: "Identify error chains (A causes B causes C)", category: "Advanced Analytics" }, { key: :error_correlation, name: "Error Correlation Analysis", description: "Correlate with versions, users, time", category: "Advanced Analytics" }, { key: :platform_comparison, name: "Platform Comparison", description: "Compare iOS vs Android vs Web health", category: "Advanced Analytics" }, { key: :occurrence_patterns, name: "Occurrence Pattern Detection", description: "Detect cyclical patterns and bursts", category: "Advanced Analytics" }, # === DEVELOPER TOOLS === { key: :source_code_integration, name: "Source Code Integration (NEW!)", description: "View source code directly in error details", category: "Developer Tools" }, { key: :git_blame, name: "Git Blame Integration (NEW!)", description: "Show git blame info (author, commit, timestamp)", category: "Developer Tools" } ] features.each_with_index do |feature, index| say "\n[#{index + 1}/#{features.length}] #{feature[:name]}", :cyan say " #{feature[:description]}", :white # Check if feature was passed via command line option if [feature[:key]] @selected_features[feature[:key]] = true say " ✓ Enabled (via --#{feature[:key]} flag)", :green else response = ask(" Enable? (y/N):", :yellow, limited_to: [ "y", "Y", "n", "N", "" ]) @selected_features[feature[:key]] = response.downcase == "y" if @selected_features[feature[:key]] say " ✓ Enabled", :green else say " ✗ Disabled", :white end end end say "\n" end |
#show_feature_summary ⇒ Object
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 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 232 def show_feature_summary return unless behavior == :invoke say "\n" say "=" * 70 say " ✓ Installation Complete!", :green say "=" * 70 say "\n" say "Core Features (Always ON):", :cyan say " ✓ Error Capture", :green say " ✓ Dashboard UI", :green say " ✓ Real-time Updates", :green say " ✓ Analytics", :green # Count optional features enabled enabled_count = 0 # Notifications notification_features = [] notification_features << "Slack" if @enable_slack notification_features << "Email" if @enable_email notification_features << "Discord" if @enable_discord notification_features << "PagerDuty" if @enable_pagerduty notification_features << "Webhooks" if @enable_webhooks if notification_features.any? say "\nNotifications:", :cyan say " ✓ #{notification_features.join(", ")}", :green enabled_count += notification_features.size end # Performance performance_features = [] performance_features << "Async Logging" if @enable_async_logging performance_features << "Error Sampling" if @enable_error_sampling performance_features << "Separate Database" if @enable_separate_database if performance_features.any? say "\nPerformance:", :cyan say " ✓ #{performance_features.join(", ")}", :green enabled_count += performance_features.size end # Advanced Analytics analytics_features = [] analytics_features << "Baseline Alerts" if @enable_baseline_alerts analytics_features << "Fuzzy Matching" if @enable_similar_errors analytics_features << "Co-occurring Errors" if @enable_co_occurring_errors analytics_features << "Error Cascades" if @enable_error_cascades analytics_features << "Error Correlation" if @enable_error_correlation analytics_features << "Platform Comparison" if @enable_platform_comparison analytics_features << "Pattern Detection" if @enable_occurrence_patterns if analytics_features.any? say "\nAdvanced Analytics:", :cyan say " ✓ #{analytics_features.join(", ")}", :green enabled_count += analytics_features.size end # Developer Tools developer_tools_features = [] developer_tools_features << "Source Code Integration" if @enable_source_code_integration developer_tools_features << "Git Blame" if @enable_git_blame if developer_tools_features.any? say "\nDeveloper Tools:", :cyan say " ✓ #{developer_tools_features.join(", ")}", :green enabled_count += developer_tools_features.size end say "\n" say "Configuration Required:", :yellow if enabled_count > 0 say " → Edit config/initializers/rails_error_dashboard.rb", :yellow if @enable_error_sampling say " → Set SLACK_WEBHOOK_URL in .env", :yellow if @enable_slack say " → Set ERROR_NOTIFICATION_EMAILS in .env", :yellow if @enable_email say " → Set DISCORD_WEBHOOK_URL in .env", :yellow if @enable_discord say " → Set PAGERDUTY_INTEGRATION_KEY in .env", :yellow if @enable_pagerduty say " → Set WEBHOOK_URLS in .env", :yellow if @enable_webhooks say " → Ensure Sidekiq/Solid Queue running", :yellow if @enable_async_logging if @enable_separate_database if @database_name say " → Configure '#{@database_name}' database in database.yml", :yellow else say " → Configure database in database.yml and set config.database", :yellow end say " See docs/guides/DATABASE_OPTIONS.md for details", :yellow end say "\n" say "Next Steps:", :cyan say " 1. Run: rails db:migrate" say " 2. Update credentials in config/initializers/rails_error_dashboard.rb" say " 3. Restart your Rails server" say " 4. Visit http://localhost:3000/error_dashboard" say "\n" say "📖 Documentation:", :white say " • Quick Start: docs/QUICKSTART.md", :white say " • Complete Feature Guide: docs/FEATURES.md", :white say " • All Docs: docs/README.md", :white say "\n" say "⚙️ To enable/disable features later:", :white say " Edit config/initializers/rails_error_dashboard.rb", :white say "\n" end |
#show_readme ⇒ Object
338 339 340 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 338 def show_readme # Skip the old README display since we have the new summary end |
#welcome_message ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 34 def say "\n" say "=" * 70 say " 📊 Rails Error Dashboard Installation", :cyan say "=" * 70 say "\n" say "Core features will be enabled automatically:", :green say " ✓ Error capture (controllers, jobs, middleware)" say " ✓ Dashboard UI at /error_dashboard" say " ✓ Real-time updates" say " ✓ Analytics & spike detection" say " ✓ 90-day error retention" say "\n" end |