rails_error_dashboard 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 66993309911427e7fdbddadebfea4a8603fa851ce47c7d5ac6189510c741965b
|
|
4
|
+
data.tar.gz: 86d88a89e817adcb790a9b83791decfaa13ffeac4d1b744b846d072e6610ebb5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6581ea39ea6340b0df0dcb9835c597367f5c37459462f3ebe6f79315f99771ade90770fd04605477edef545b75aef32ae6d04acffe4caf896390b219ae11380e
|
|
7
|
+
data.tar.gz: 1dce7070b16addd615deb960d93e3226a448cb776526a17d1f353a1fdd8d25e90c8a2916bba21482b23637bcebf5a34c153b9227113ea6a23eeba79891f6acd7
|
|
@@ -518,7 +518,9 @@ module RailsErrorDashboard
|
|
|
518
518
|
|
|
519
519
|
# Turbo Stream broadcasting methods
|
|
520
520
|
def broadcast_new_error
|
|
521
|
+
# Skip broadcasting in API-only mode or if Turbo is not available
|
|
521
522
|
return unless defined?(Turbo)
|
|
523
|
+
return unless broadcast_available?
|
|
522
524
|
|
|
523
525
|
platforms = ErrorLog.distinct.pluck(:platform).compact
|
|
524
526
|
show_platform = platforms.size > 1
|
|
@@ -531,11 +533,14 @@ module RailsErrorDashboard
|
|
|
531
533
|
)
|
|
532
534
|
broadcast_replace_stats
|
|
533
535
|
rescue => e
|
|
534
|
-
Rails.logger.error("Failed to broadcast new error: #{e.message}")
|
|
536
|
+
Rails.logger.error("[RailsErrorDashboard] Failed to broadcast new error: #{e.class} - #{e.message}")
|
|
537
|
+
Rails.logger.debug("[RailsErrorDashboard] Backtrace: #{e.backtrace&.first(3)&.join("\n")}")
|
|
535
538
|
end
|
|
536
539
|
|
|
537
540
|
def broadcast_error_update
|
|
541
|
+
# Skip broadcasting in API-only mode or if Turbo is not available
|
|
538
542
|
return unless defined?(Turbo)
|
|
543
|
+
return unless broadcast_available?
|
|
539
544
|
|
|
540
545
|
platforms = ErrorLog.distinct.pluck(:platform).compact
|
|
541
546
|
show_platform = platforms.size > 1
|
|
@@ -548,13 +553,19 @@ module RailsErrorDashboard
|
|
|
548
553
|
)
|
|
549
554
|
broadcast_replace_stats
|
|
550
555
|
rescue => e
|
|
551
|
-
Rails.logger.error("Failed to broadcast error update: #{e.message}")
|
|
556
|
+
Rails.logger.error("[RailsErrorDashboard] Failed to broadcast error update: #{e.class} - #{e.message}")
|
|
557
|
+
Rails.logger.debug("[RailsErrorDashboard] Backtrace: #{e.backtrace&.first(3)&.join("\n")}")
|
|
552
558
|
end
|
|
553
559
|
|
|
554
560
|
def broadcast_replace_stats
|
|
561
|
+
# Skip broadcasting in API-only mode or if Turbo is not available
|
|
555
562
|
return unless defined?(Turbo)
|
|
563
|
+
return unless broadcast_available?
|
|
556
564
|
|
|
557
565
|
stats = Queries::DashboardStats.call
|
|
566
|
+
# Safety check: ensure stats is not nil before broadcasting
|
|
567
|
+
return unless stats.is_a?(Hash) && stats.present?
|
|
568
|
+
|
|
558
569
|
Turbo::StreamsChannel.broadcast_replace_to(
|
|
559
570
|
"error_list",
|
|
560
571
|
target: "dashboard_stats",
|
|
@@ -562,7 +573,26 @@ module RailsErrorDashboard
|
|
|
562
573
|
locals: { stats: stats }
|
|
563
574
|
)
|
|
564
575
|
rescue => e
|
|
565
|
-
Rails.logger.error("Failed to broadcast stats update: #{e.message}")
|
|
576
|
+
Rails.logger.error("[RailsErrorDashboard] Failed to broadcast stats update: #{e.class} - #{e.message}")
|
|
577
|
+
Rails.logger.debug("[RailsErrorDashboard] Backtrace: #{e.backtrace&.first(3)&.join("\n")}")
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
# Check if broadcast functionality is available and properly configured
|
|
581
|
+
# In API-only apps, ActionCable might not be configured or Rails.cache might not be available
|
|
582
|
+
def broadcast_available?
|
|
583
|
+
# Check if ActionCable is available (required for Turbo Streams)
|
|
584
|
+
return false unless defined?(ActionCable)
|
|
585
|
+
|
|
586
|
+
# Check if Rails.cache is configured and working
|
|
587
|
+
# This prevents errors when cache is not available in API-only mode
|
|
588
|
+
begin
|
|
589
|
+
Rails.cache.write("rails_error_dashboard_broadcast_test", true, expires_in: 1.second)
|
|
590
|
+
Rails.cache.delete("rails_error_dashboard_broadcast_test")
|
|
591
|
+
true
|
|
592
|
+
rescue => e
|
|
593
|
+
Rails.logger.debug("[RailsErrorDashboard] Broadcast not available: #{e.message}")
|
|
594
|
+
false
|
|
595
|
+
end
|
|
566
596
|
end
|
|
567
597
|
|
|
568
598
|
# Enhanced Metrics: Release/Version Tracking
|
|
@@ -12,28 +12,57 @@ module RailsErrorDashboard
|
|
|
12
12
|
def call
|
|
13
13
|
# Cache dashboard stats for 1 minute to reduce database load
|
|
14
14
|
# Dashboard is viewed frequently, so short cache prevents stale data
|
|
15
|
-
|
|
15
|
+
begin
|
|
16
|
+
Rails.cache.fetch(cache_key, expires_in: 1.minute) do
|
|
17
|
+
{
|
|
18
|
+
total_today: ErrorLog.where("occurred_at >= ?", Time.current.beginning_of_day).count,
|
|
19
|
+
total_week: ErrorLog.where("occurred_at >= ?", 7.days.ago).count,
|
|
20
|
+
total_month: ErrorLog.where("occurred_at >= ?", 30.days.ago).count,
|
|
21
|
+
unresolved: ErrorLog.unresolved.count,
|
|
22
|
+
resolved: ErrorLog.resolved.count,
|
|
23
|
+
by_platform: ErrorLog.group(:platform).count,
|
|
24
|
+
top_errors: top_errors,
|
|
25
|
+
# Trend visualizations
|
|
26
|
+
errors_trend_7d: errors_trend_7d,
|
|
27
|
+
errors_by_severity_7d: errors_by_severity_7d,
|
|
28
|
+
spike_detected: spike_detected?,
|
|
29
|
+
spike_info: spike_info,
|
|
30
|
+
# New metrics for Overview dashboard
|
|
31
|
+
error_rate: error_rate,
|
|
32
|
+
affected_users_today: affected_users_today,
|
|
33
|
+
affected_users_yesterday: affected_users_yesterday,
|
|
34
|
+
affected_users_change: affected_users_change,
|
|
35
|
+
trend_percentage: trend_percentage,
|
|
36
|
+
trend_direction: trend_direction,
|
|
37
|
+
top_errors_by_impact: top_errors_by_impact
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
rescue => e
|
|
41
|
+
# If Rails.cache or any stats query fails, return empty stats hash
|
|
42
|
+
# This prevents broadcast failures in API-only mode or when cache is unavailable
|
|
43
|
+
Rails.logger.error("[RailsErrorDashboard] DashboardStats failed: #{e.class} - #{e.message}")
|
|
44
|
+
Rails.logger.debug("[RailsErrorDashboard] Backtrace: #{e.backtrace&.first(3)&.join("\n")}")
|
|
45
|
+
|
|
46
|
+
# Return minimal stats hash to prevent nil errors in views
|
|
16
47
|
{
|
|
17
|
-
total_today:
|
|
18
|
-
total_week:
|
|
19
|
-
total_month:
|
|
20
|
-
unresolved:
|
|
21
|
-
resolved:
|
|
22
|
-
by_platform:
|
|
23
|
-
top_errors:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
trend_direction: trend_direction,
|
|
36
|
-
top_errors_by_impact: top_errors_by_impact
|
|
48
|
+
total_today: 0,
|
|
49
|
+
total_week: 0,
|
|
50
|
+
total_month: 0,
|
|
51
|
+
unresolved: 0,
|
|
52
|
+
resolved: 0,
|
|
53
|
+
by_platform: {},
|
|
54
|
+
top_errors: {},
|
|
55
|
+
errors_trend_7d: {},
|
|
56
|
+
errors_by_severity_7d: { critical: 0, high: 0, medium: 0, low: 0 },
|
|
57
|
+
spike_detected: false,
|
|
58
|
+
spike_info: nil,
|
|
59
|
+
error_rate: 0.0,
|
|
60
|
+
affected_users_today: 0,
|
|
61
|
+
affected_users_yesterday: 0,
|
|
62
|
+
affected_users_change: 0,
|
|
63
|
+
trend_percentage: 0.0,
|
|
64
|
+
trend_direction: :stable,
|
|
65
|
+
top_errors_by_impact: []
|
|
37
66
|
}
|
|
38
67
|
end
|
|
39
68
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_error_dashboard
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.17
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anjan Jagirdar
|
|
@@ -379,7 +379,7 @@ metadata:
|
|
|
379
379
|
source_code_uri: https://github.com/AnjanJ/rails_error_dashboard
|
|
380
380
|
changelog_uri: https://github.com/AnjanJ/rails_error_dashboard/blob/main/CHANGELOG.md
|
|
381
381
|
post_install_message: "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n
|
|
382
|
-
\ Rails Error Dashboard v0.1.
|
|
382
|
+
\ Rails Error Dashboard v0.1.17\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n\U0001F195
|
|
383
383
|
First time? Quick start:\n rails generate rails_error_dashboard:install\n rails
|
|
384
384
|
db:migrate\n # Add to config/routes.rb:\n mount RailsErrorDashboard::Engine
|
|
385
385
|
=> '/error_dashboard'\n\n\U0001F504 Upgrading from v0.1.x?\n rails db:migrate\n
|