debugbar 0.3.0 → 0.3.2

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: 21eb9bf1086b2890a2b6d0ecdcc04e901ef902b5de0593630320ee107ab8ea2a
4
- data.tar.gz: 94e7e6f98f27b86ff2f28bbc915b20086ac5350b349c138d796fe051323141a1
3
+ metadata.gz: 5fb345ca3b935b2a6baee536310271a5cda8e15132e7a79413fb661e44c0dbef
4
+ data.tar.gz: 292867bd66a2a1e7348fca7451ef85e2bd756d187cefff23065c349fd90186f7
5
5
  SHA512:
6
- metadata.gz: c352157d378dae219d2a84f2482ebb102f552891af731f44d44357514cee04b5fd2d83ad766e21b5dfd5b9d7abe47b16250ea964e19c7fe1b89e85e005fa7bcd
7
- data.tar.gz: 5be2a2ff6dd67a5aa27d7daf00cebd0cc161d956235192b1f4a10691e6437fd5828006d996ea11627e6eb56e5da4354c3ea4fb95a7de3f88c24abb0c9ea1e095
6
+ metadata.gz: 6f0b963c955ca99ff48e9a281a43d3de900b552ed4b16de947529e106c00b5f65ff4cca955b62a521be56a9e1668ce9e6081ce364e57a8137a4dd466dfe087d2
7
+ data.tar.gz: 609c0a2137bf2f0517e362cbe8771ac4c7f4fef211b200c51621b7af2555a67b71e76967b1c45bf59c3c6c8639b6f255d13cfff341cbb048e83d885d7a8cecca
data/CHANGELOG.md CHANGED
@@ -1,11 +1,46 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.3.2 - 2024-05-04
4
+
5
+ * Improved Debug panel (to be in par with Queries panel) - See [#36](https://github.com/julienbourdeau/debugbar/pull/36)
6
+ * Better SQL dialect detection - See [c40e2405](https://github.com/julienbourdeau/debugbar/commit/c40e240524308c7ecf09fecbb548e97c2ef4e8b7)
7
+ * Add timings to SQL queries 🎨 - See [ebf8edcd](https://github.com/julienbourdeau/debugbar/commit/ebf8edcd8598a4a7b490a774a7374d51a3efc6b8)
8
+
9
+ ## v0.3.1 - 2024-05-01
10
+
11
+ * Add `active_record.adapter` config to help frontend format SQL queries - See [#35](https://github.com/julienbourdeau/debugbar/pull/35)
12
+ * Add `minimized` config key to start the debugbar minimized - See [2046b054](https://github.com/julienbourdeau/debugbar/commit/0178443d268d2a740a0d73b4039a03dd)
13
+ * Use `:null_session` to disable forgery protection when using polling - See [#27](https://github.com/julienbourdeau/debugbar/pull/27)
14
+
3
15
  ## v0.3.0 - 2024-03-31
4
16
 
5
17
  * Add support for Turbo Drive - See [#25](https://github.com/julienbourdeau/debugbar/pull/25) and [#26](https://github.com/julienbourdeau/debugbar/pull/26)
6
18
  * Fix error "undefined method `adapter_name' for ActiveJob:Module" for Rails < 7.1 - See [#24](https://github.com/julienbourdeau/debugbar/pull/24)
7
19
  * Limit the number of request to 25, configurable with `maxRequests` option - See [664f2c11](https://github.com/julienbourdeau/debugbar/commit/664f2c11e56f18a7c3e4a9fb83ba5b7e19fbb9a9)
8
20
 
21
+ ### Breaking changes
22
+
23
+ In order to support Turbo Drive, I had to split the helper into two parts. Before the JavaScript file was loaded,
24
+ directly in the body, but it has to be loaded in the head now.
25
+
26
+ If you were passing configuation t `debugbar_javascript`, you must now pass it to `debugbar_body`.
27
+
28
+ ```diff
29
+ <!DOCTYPE html>
30
+ <html>
31
+ <head>
32
+ ...
33
+ + <%= debugbar_head %>
34
+ </head>
35
+
36
+ <body>
37
+ ...
38
+ - <%= debugbar_javascript %>
39
+ + <%= debugbar_body %>
40
+ </body>
41
+ </html>
42
+ ```
43
+
9
44
  ## v0.2.0 - 2024-02-28
10
45
 
11
46
  * Introduce polling in case someone cannot use ActiveCable - See [8b262be7](https://github.com/julienbourdeau/debugbar/commit/8b262be7b644c7b587a6c3348bb02076053a344f)
@@ -1,6 +1,6 @@
1
1
  module Debugbar
2
2
  class PollingController < ApplicationController
3
- skip_before_action :verify_authenticity_token, only: [:confirm]
3
+ protect_from_forgery with: :null_session
4
4
  before_action :cors_set_access_control_headers
5
5
 
6
6
  def poll
@@ -13,6 +13,10 @@ module Debugbar::TagHelpers
13
13
  opt[:mode] = 'poll'
14
14
  end
15
15
 
16
+ if opt[:active_record].nil?
17
+ opt[:active_record] = { adapter: db_adapter }
18
+ end
19
+
16
20
  html = <<-HTML
17
21
  <div id="__debugbar" data-turbo-permanent></div>
18
22
  HTML
@@ -35,4 +39,10 @@ module Debugbar::TagHelpers
35
39
  errors << ""
36
40
  raise errors.join("\n")
37
41
  end
42
+
43
+ private
44
+
45
+ def db_adapter
46
+ ActiveRecord::Base.connection.adapter_name.downcase
47
+ end
38
48
  end
@@ -40,8 +40,8 @@ module Debugbar
40
40
  @jobs << job
41
41
  end
42
42
 
43
- def add_msg(msg, extra)
44
- @messages << {msg: msg, extra: extra}
43
+ def add_msg(msg, extra, source)
44
+ @messages << {id: SecureRandom.hex(8), msg: msg, extra: extra, source: source}
45
45
  end
46
46
 
47
47
  def add_cache(c)
@@ -36,12 +36,13 @@ module Debugbar
36
36
  duration: event.duration.round(1),
37
37
  lock_wait: payload[:lock_wait]&.round(1),
38
38
  binds: binds,
39
- source: query_source_location&.split(":in"),
39
+ source: query_source_location
40
40
  })
41
41
  end
42
42
 
43
43
  def query_source_location
44
- backtrace_cleaner.clean(caller(3))[0]
44
+ str = backtrace_cleaner.clean(caller(3))[0]
45
+ str&.split(":in")&.map { |s| s.delete_prefix("#{Rails.root}/").strip.tr("`'", '' ) } # Duplicated in Debugbar.msg
45
46
  end
46
47
  end
47
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Debugbar
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.2"
5
5
  end
data/lib/debugbar.rb CHANGED
@@ -47,12 +47,12 @@ module Debugbar
47
47
  end
48
48
  end
49
49
 
50
- def msg(msg, *extra)
50
+ def msg(msg, extra, source)
51
51
  if Current.request.nil?
52
52
  puts "The current request is not set yet. Printing to STDOUT instead."
53
- puts msg, extra
53
+ puts msg, extra, source
54
54
  else
55
- Current.request.add_msg(msg, extra)
55
+ Current.request.add_msg(msg, extra, source)
56
56
  end
57
57
  end
58
58
  end
@@ -82,7 +82,8 @@ module Debugbar
82
82
  end
83
83
 
84
84
  def msg(msg, *extra)
85
- Tracker.msg(msg, *extra)
85
+ source = caller.first&.split(":in")&.map { |s| s.delete_prefix("#{Rails.root}/").strip.tr("`'", '' ) }
86
+ Tracker.msg(msg, extra, source)
86
87
  end
87
88
  end
88
89
  end