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
205 206 207 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 205 def add_route route "mount RailsErrorDashboard::Engine => '/error_dashboard'" end |
#copy_migrations ⇒ Object
201 202 203 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 201 def copy_migrations rake "rails_error_dashboard:install:migrations" end |
#create_initializer_file ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 176 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] # 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] template "initializer.rb", "config/initializers/rails_error_dashboard.rb" end |
#select_optional_features ⇒ Object
45 46 47 48 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 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 45 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" } ] features.each_with_index do |feature, index| say "\n[#{index + 1}/#{features.length}] #{feature[:name]}", :cyan say " #{feature[:description]}", :light_black # 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", :light_black end end end say "\n" end |
#show_feature_summary ⇒ Object
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 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 209 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 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 say " → Configure database.yml (docs/guides/DATABASE_OPTIONS.md)", :yellow if @enable_separate_database 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:", :light_black say " • Quick Start: docs/QUICKSTART.md", :light_black say " • Complete Feature Guide: docs/FEATURES.md", :light_black say " • All Docs: docs/README.md", :light_black say "\n" say "⚙️ To enable/disable features later:", :light_black say " Edit config/initializers/rails_error_dashboard.rb", :light_black say "\n" end |
#show_readme ⇒ Object
297 298 299 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 297 def show_readme # Skip the old README display since we have the new summary end |
#welcome_message ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/generators/rails_error_dashboard/install/install_generator.rb', line 30 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 |