notable 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b698c7c6e4b8d027912deb4740e3713b61acac0eb56130d4e917bd55752b12b8
4
- data.tar.gz: 66dd7ddb28daf9422772e23db13acf401c53b33a7acdb017909e66df3aa6db8d
3
+ metadata.gz: f7ba556539ddc3c2c67a5fc37623c138c15432f32e962ff60118863ecd5ff3b7
4
+ data.tar.gz: a301a3c1a1f84c0bce4dd83e1a965210d6ccb08586c9b2bb6f51fb10676d3f8c
5
5
  SHA512:
6
- metadata.gz: 7f3c6625ffe35bf197a0110071bda6d76c0f00c4de99921e39d8e24dacf940015a597c1437b4ac8100ef744b3af343f7fef9c84c3783969a666389f642efc39b
7
- data.tar.gz: d67e694ebb51daae26242fe59e7a3b43178b44f33b77e6d0dbbd639106cc4a6b20d4bcc8f7a6b068338f01b3c0c4cd2df9e22f7c19fe703e57f2197c72af97ad
6
+ metadata.gz: 9f7cb09c2f95526ebd6862199fcbe8889a50919c93e63293a5142efd5346998b7d9c803c358c0e283db43967e7f7303e22409b3afbc5206ea78939de7846ab84
7
+ data.tar.gz: c7612312bafaefbe1cee0f3b70f1bb0dff3bc0963e8116f1c110452d2b6634a8f3df1c7455dce10a058c934a2da71edb5569396d020292c15a075bdfa63e48f7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## 0.4.0 (2022-01-10)
2
+
3
+ - Dropped support for Ruby < 2.6 and Rails < 5.2
4
+
5
+ ## 0.3.4 (2020-09-07)
6
+
7
+ - Use `datetime` type in migration
8
+
9
+ ## 0.3.3 (2020-07-26)
10
+
11
+ - Added support for `queued_time` for Active Job 6
12
+
13
+ ## 0.3.2 (2020-07-24)
14
+
15
+ - Added support for Rails API
16
+ - Fixed blocked requests with Rack::Attack
17
+
1
18
  ## 0.3.1 (2020-05-20)
2
19
 
3
20
  - Fixed deprecation warning in Ruby 2.7
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2019 Andrew Kane
1
+ Copyright (c) 2014-2022 Andrew Kane
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,12 +1,8 @@
1
1
  # Notable
2
2
 
3
- :star2: Extraordinary insight into your users and background jobs
3
+ :star2: :star2: :star2:
4
4
 
5
- Wouldn’t it be great to see when one of your users encounters an error, timeout, or validation failure? Now you can - directly in your admin pages.
6
-
7
- #### Introducing Notable
8
-
9
- Notable tracks notable requests and background jobs and stores them in your database. What makes a request or job notable? There are a number of default situations, but ultimately you decide what interests you.
5
+ Notable tracks notable requests and background jobs and stores them in your database. What makes a request or job notable? There are a number of default situations, but ultimately you decide what interests you.
10
6
 
11
7
  By default, Notable tracks:
12
8
 
@@ -23,12 +19,14 @@ You can track custom notes as well.
23
19
 
24
20
  :tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)
25
21
 
22
+ [![Build Status](https://github.com/ankane/notable/workflows/build/badge.svg?branch=master)](https://github.com/ankane/notable/actions)
23
+
26
24
  ## Installation
27
25
 
28
26
  Add this line to your application’s Gemfile:
29
27
 
30
28
  ```ruby
31
- gem 'notable'
29
+ gem "notable"
32
30
  ```
33
31
 
34
32
  And run:
@@ -41,26 +39,18 @@ rails db:migrate
41
39
 
42
40
  To explore the data, check out [Blazer](https://github.com/ankane/blazer).
43
41
 
44
- ## Requests
42
+ ## How It Works
45
43
 
46
44
  A `Notable::Request` is created for:
47
45
 
48
46
  - errors
49
47
  - 404s
50
48
  - slow requests
51
- - timeouts
49
+ - timeouts from [Slowpoke](https://github.com/ankane/slowpoke)
52
50
  - validation failures
53
51
  - [CSRF failures](https://guides.rubyonrails.org/security.html#cross-site-request-forgery-csrf)
54
52
  - unpermitted parameters
55
- - blocked and throttled requests
56
-
57
- For timeouts, use [Slowpoke](https://github.com/ankane/slowpoke).
58
-
59
- For blocked and throttled requests, use [Rack Attack](https://github.com/kickstarter/rack-attack).
60
-
61
- ## Jobs
62
-
63
- Wouldn’t it be great to have a record of exact jobs that fail?
53
+ - blocked and throttled requests from [Rack Attack](https://github.com/kickstarter/rack-attack)
64
54
 
65
55
  A `Notable::Job` is created for:
66
56
 
@@ -68,19 +58,13 @@ A `Notable::Job` is created for:
68
58
  - slow jobs
69
59
  - validation failures
70
60
 
71
- ## Manual Tracking
61
+ Create a custom note inside a request or job with:
72
62
 
73
63
  ```ruby
74
- Notable.track(note_type, note)
64
+ Notable.track("Note Type", "Optional extra info")
75
65
  ```
76
66
 
77
- Like
78
-
79
- ```ruby
80
- Notable.track("Auth Event", "Signed In")
81
- ```
82
-
83
- ## Customize
67
+ ## Customization
84
68
 
85
69
  Disable tracking in certain environments
86
70
 
@@ -150,6 +134,10 @@ Notable.track_job_method = lambda do |data|
150
134
  end
151
135
  ```
152
136
 
137
+ ## History
138
+
139
+ View the [changelog](https://github.com/ankane/notable/blob/master/CHANGELOG.md)
140
+
153
141
  ## Contributing
154
142
 
155
143
  Everyone is encouraged to help improve this project. Here are a few ways you can help:
@@ -165,4 +153,5 @@ To get started with development:
165
153
  git clone https://github.com/ankane/notable.git
166
154
  cd notable
167
155
  bundle install
156
+ bundle exec rake test
168
157
  ```
@@ -8,7 +8,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
8
8
  t.string :queue
9
9
  t.float :runtime
10
10
  t.float :queued_time
11
- t.timestamp :created_at
11
+ t.datetime :created_at
12
12
  end
13
13
  end
14
14
  end
@@ -3,8 +3,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
3
3
  create_table :notable_requests do |t|
4
4
  t.string :note_type
5
5
  t.text :note
6
- t.integer :user_id
7
- t.string :user_type
6
+ t.references :user, polymorphic: true
8
7
  t.text :action
9
8
  t.integer :status
10
9
  t.text :url
@@ -14,9 +13,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version
14
13
  t.text :referrer
15
14
  t.text :params
16
15
  t.float :request_time
17
- t.timestamp :created_at
16
+ t.datetime :created_at
18
17
  end
19
-
20
- add_index :notable_requests, [:user_id, :user_type]
21
18
  end
22
19
  end
@@ -4,8 +4,8 @@ module Notable
4
4
 
5
5
  included do
6
6
  around_perform do |job, block|
7
- # no way to get queued_at time :(
8
- Notable.track_job(job.class.name, job.job_id, job.queue_name, nil, try(:notable_slow_job_threshold)) do
7
+ # enqueued_at is only available in Active Job 6+
8
+ Notable.track_job(job.class.name, job.job_id, job.queue_name, job.try(:enqueued_at), try(:notable_slow_job_threshold)) do
9
9
  block.call
10
10
  end
11
11
  end
@@ -1,7 +1,7 @@
1
1
  ActiveSupport::Notifications.subscribe "rack.attack" do |_name, _start, _finish, _request_id, req|
2
2
  request = req.is_a?(Hash) ? req[:request] : req
3
3
 
4
- if [:blacklist, :throttle].include?(request.env["rack.attack.match_type"])
4
+ if [:blacklist, :blocklist, :throttle].include?(request.env["rack.attack.match_type"])
5
5
  Notable.track "Throttle", request.env["rack.attack.matched"]
6
6
  end
7
7
  end
@@ -7,7 +7,7 @@ module Notable
7
7
  end
8
8
 
9
9
  def track_unverified_request
10
- if !verified_request?
10
+ if respond_to?(:verified_request?, true) && !verified_request?
11
11
  expected = form_authenticity_token
12
12
  actual = form_authenticity_param || request.headers["X-CSRF-Token"]
13
13
  Notable.track "Unverified Request", "#{actual || "nil"} != #{expected}"
@@ -1,3 +1,3 @@
1
1
  module Notable
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/notable.rb CHANGED
@@ -70,6 +70,7 @@ module Notable
70
70
  exception = nil
71
71
  notes = nil
72
72
  start_time = Time.now
73
+ created_at = Time.parse(created_at) if created_at.is_a?(String)
73
74
  queued_time = created_at ? start_time - created_at : nil
74
75
  begin
75
76
  yield
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-20 00:00:00.000000000 Z
11
+ date: 2022-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
19
+ version: '5.2'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5'
26
+ version: '5.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: safely_block
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,36 +38,8 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.1.1
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- description:
70
- email: andrew@chartkick.com
41
+ description:
42
+ email: andrew@ankane.org
71
43
  executables: []
72
44
  extensions: []
73
45
  extra_rdoc_files: []
@@ -95,7 +67,7 @@ homepage: https://github.com/ankane/notable
95
67
  licenses:
96
68
  - MIT
97
69
  metadata: {}
98
- post_install_message:
70
+ post_install_message:
99
71
  rdoc_options: []
100
72
  require_paths:
101
73
  - lib
@@ -103,15 +75,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
75
  requirements:
104
76
  - - ">="
105
77
  - !ruby/object:Gem::Version
106
- version: '2.4'
78
+ version: '2.6'
107
79
  required_rubygems_version: !ruby/object:Gem::Requirement
108
80
  requirements:
109
81
  - - ">="
110
82
  - !ruby/object:Gem::Version
111
83
  version: '0'
112
84
  requirements: []
113
- rubygems_version: 3.1.2
114
- signing_key:
85
+ rubygems_version: 3.3.3
86
+ signing_key:
115
87
  specification_version: 4
116
88
  summary: Track notable requests and background jobs
117
89
  test_files: []