rails_event_viewer 0.4.1 → 0.5.0

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: d23e7d737a8e9d46d9ccbc7b5eafca59dbff648f3fd8deef10576d45555fbe3a
4
- data.tar.gz: 9931baf5951842895eeacb45a87d56e50f2294dbbb0b105972995bdcfd7becf9
3
+ metadata.gz: 375560c35f98c2ac5f6962d8cfe010a3303a2d6dc1c1be571d2f460d53321aee
4
+ data.tar.gz: 9d7cc22776fd8bcd0b0c7b683f9e67b61e684cb8d5f6977f9443d6f97501f59a
5
5
  SHA512:
6
- metadata.gz: ca612bc3fc3a3f16fa398cac9179a5dd23adc54021384693f552abc6333789ed6c8b0fb9904c3b7ca5a57bdfb90e60857292be0bd395beb82f99cbd05118f016
7
- data.tar.gz: 89c8fe09a4ca8a901b2737b013280cbea230ca8a7ab9c10ffd5656a0e2e5214f30667e11e9f8a23e5c6db49575e9cda27851f060336ece2f08b985aa52e2015f
6
+ metadata.gz: e3ff263712f32e6ae3ebe6021048efdf72f2cf008431fc7751c52897e7a8985a35410c26195ae7cd5b4c8cc6c409fd79ce5aee99bff6aa67f5ea1fbbbbdc06e5
7
+ data.tar.gz: '08d8c02f0cd633bcd6bf1e6104cdf7506f342d37611e363eff37377a29e18f5c1bab098e0d5146cc3055926e1dc09d7fbc37d919e8c520349ae0cad8029ac74b'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0 (2026-10-05)
4
+
5
+ Breaking:
6
+
7
+ - The ActiveRecord adapter returns events as hashes with symbol keys, like the Memory and Redis adapters. Call `event[:name]`, not `event.name`, and `event[:payload][:order_id]`, not `event.payload["order_id"]`.
8
+
9
+ ## 0.4.2 (2026-10-04)
10
+
11
+ Changed:
12
+
13
+ - Group durations are rounded and show only the two largest units.
14
+ - Source paths on the event page are shortened. Hover shows the full path.
15
+ - The event count has thousands separators.
16
+ - The events-by-type chart uses ten distinct colours.
17
+ - Timeline offsets step through minutes, hours and days.
18
+ - The 24-hour chart starts on a whole hour.
19
+
3
20
  ## 0.4.1 (2026-10-03)
4
21
 
5
22
  Added:
data/README.md CHANGED
@@ -42,9 +42,11 @@ RailsEventViewer.events
42
42
  .with_tag(:priority, "high")
43
43
  .since(1.day.ago)
44
44
  .limit(50)
45
- .to_a
45
+ .map { |event| event[:payload][:order_id] }
46
46
  ```
47
47
 
48
+ Each event is a hash with symbol keys, whichever adapter stores it.
49
+
48
50
  Other filters: `with_context`, `search`, `until`, `offset`, and `count`.
49
51
  Without `limit`, a query returns `config.per_page` events, 25 by default.
50
52
 
@@ -8,7 +8,7 @@ module RailsEventViewer
8
8
 
9
9
  if analytics_supported?
10
10
  @events_by_type = current_adapter.counts_by_name(limit: 10)
11
- @events_over_time = current_adapter.events_over_time(range: 24.hours.ago.., interval: :hour)
11
+ @events_over_time = current_adapter.events_over_time(range: 24.hours.ago.beginning_of_hour.., interval: :hour)
12
12
  else
13
13
  @events_by_type = {}
14
14
  @events_over_time = {}
@@ -42,7 +42,7 @@ module RailsEventViewer
42
42
  context = event[:context]
43
43
  return [] unless context.present?
44
44
 
45
- request_id = context["request_id"] || context[:request_id]
45
+ request_id = context[:request_id]
46
46
  occurred_at = event[:occurred_at]
47
47
  return [] unless request_id && occurred_at
48
48
 
@@ -58,12 +58,12 @@ module RailsEventViewer
58
58
  def format_duration(seconds)
59
59
  return "-" unless seconds
60
60
 
61
- duration = ActiveSupport::Duration.build(seconds)
61
+ duration = ActiveSupport::Duration.build(seconds.round)
62
62
  parts = duration.parts
63
63
 
64
64
  return "0 seconds" if parts.empty? || parts == { seconds: 0 }
65
65
 
66
- parts.map { |unit, value|
66
+ parts.first(2).map { |unit, value|
67
67
  unit_name = value == 1 ? unit.to_s.singularize : unit.to_s
68
68
  "#{value} #{unit_name}"
69
69
  }.to_sentence
@@ -55,7 +55,7 @@
55
55
  html: '<div id="%{id}" class="h-full w-full">%{loading}</div>',
56
56
  content_for: nil,
57
57
  donut: true,
58
- colors: ["#4F46E5", "#10B981", "#F59E0B", "#EF4444", "#8B5CF6", "#EC4899", "#06B6D4", "#84CC16"] %>
58
+ colors: ["#4F46E5", "#10B981", "#F59E0B", "#EF4444", "#8B5CF6", "#EC4899", "#06B6D4", "#84CC16", "#64748B", "#92400E"] %>
59
59
  <% else %>
60
60
  <div class="flex items-center justify-center h-full text-gray-500">
61
61
  No events to display
@@ -11,7 +11,7 @@
11
11
  <% end %>
12
12
  </h1>
13
13
  <div class="text-sm text-gray-500">
14
- <%= @pagination.count %> events
14
+ <%= number_with_delimiter(@pagination.count) %> events
15
15
  </div>
16
16
  </div>
17
17
 
@@ -84,11 +84,11 @@
84
84
  <%= format_event_time(@event) %>
85
85
  </dd>
86
86
  </div>
87
- <% if @event.respond_to?(:created_at) && @event.created_at %>
87
+ <% if @event[:created_at] %>
88
88
  <div class="px-6 py-4">
89
89
  <dt class="text-sm font-medium text-gray-500">Created At</dt>
90
90
  <dd class="mt-1 text-sm text-gray-900">
91
- <%= @event.created_at.strftime("%Y-%m-%d %H:%M:%S %Z") %>
91
+ <%= @event[:created_at].strftime("%Y-%m-%d %H:%M:%S %Z") %>
92
92
  </dd>
93
93
  </div>
94
94
  <% end %>
@@ -97,8 +97,8 @@
97
97
  <div class="px-6 py-4">
98
98
  <dt class="text-sm font-medium text-gray-500">Source Location</dt>
99
99
  <dd class="mt-1 text-sm text-gray-900">
100
- <code class="bg-gray-100 px-2 py-1 rounded text-xs break-all">
101
- <%= filepath %>:<%= @event[:source_line] %>
100
+ <code class="bg-gray-100 px-2 py-1 rounded text-xs break-all" title="<%= filepath %>">
101
+ <%= event_short_filepath(@event) %>:<%= @event[:source_line] %>
102
102
  </code>
103
103
  <% label = @event[:source_label] %>
104
104
  <% if label.present? %>
@@ -64,8 +64,12 @@
64
64
  +<%= (offset * 1000).round %>ms
65
65
  <% elsif offset < 60 %>
66
66
  +<%= offset.round(1) %>s
67
+ <% elsif offset < 1.hour %>
68
+ +<%= (offset / 1.minute).round %>m
69
+ <% elsif offset < 1.day %>
70
+ +<%= (offset / 1.hour).round %>h
67
71
  <% else %>
68
- +<%= (offset / 60).round %>m
72
+ +<%= (offset / 1.day).round %>d
69
73
  <% end %>
70
74
  </span>
71
75
  </div>
@@ -36,6 +36,7 @@ module RailsEventViewer
36
36
  build_scope(relation)
37
37
  .offset(relation.offset_value)
38
38
  .limit(relation.limit_value)
39
+ .map { |entry| to_event(entry) }
39
40
  end
40
41
 
41
42
  def count_events(relation)
@@ -47,7 +48,8 @@ module RailsEventViewer
47
48
  end
48
49
 
49
50
  def find_event(id)
50
- Entry.find_by(id: id)
51
+ entry = Entry.find_by(id: id)
52
+ to_event(entry) if entry
51
53
  end
52
54
 
53
55
  def delete_before(timestamp)
@@ -111,7 +113,8 @@ module RailsEventViewer
111
113
  end
112
114
 
113
115
  def fetch_last(relation)
114
- build_scope(relation).reorder(occurred_at: :asc, id: :asc).first
116
+ entry = build_scope(relation).reorder(occurred_at: :asc, id: :asc).first
117
+ to_event(entry) if entry
115
118
  end
116
119
 
117
120
  def event_time_span(relation)
@@ -125,6 +128,10 @@ module RailsEventViewer
125
128
 
126
129
  private
127
130
 
131
+ def to_event(entry)
132
+ entry.attributes.deep_symbolize_keys
133
+ end
134
+
128
135
  def parse_timestamp(value)
129
136
  return nil if value.nil?
130
137
  return value if value.is_a?(Time)
@@ -1,3 +1,3 @@
1
1
  module RailsEventViewer
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_event_viewer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keshav Biswa