bugsnag-error-users 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bugsnag-error-users/fetcher.rb +10 -14
- data/lib/bugsnag-error-users/version.rb +1 -1
- data/lib/tasks/bugsnag-error-users.rake +6 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef01f6926c48b576ee5d92121df6d24c195048a5
|
4
|
+
data.tar.gz: 77d0e02a19091ca197c61f0cd139a3fd9efee677
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b097dfa0c1945f38166e55e7ef2a4f2a9de1403c3ce705721b634e9f54bfd1ccaf5a24469ed9f674ec22c86d9456a377107cd2e0570d8b7ad1bf81d2c5429e2d
|
7
|
+
data.tar.gz: 8b169b407aa9af084b2a005211c39bc185e9498be1dc51fc9d083c35af7032914066f2e368f58a82d433bde4e28813b6858e1cc19cda16b765a5834e8eea4b1d
|
@@ -1,13 +1,9 @@
|
|
1
1
|
require 'bugsnag/api'
|
2
2
|
|
3
3
|
module BugsnagErrorUsers
|
4
|
-
class StdoutPrinter
|
5
|
-
def self.write(str)
|
6
|
-
print(str)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
4
|
class Fetcher
|
5
|
+
PAGE_SIZE = 100
|
6
|
+
|
11
7
|
attr_reader :error_url
|
12
8
|
|
13
9
|
def initialize(error_url)
|
@@ -18,13 +14,13 @@ module BugsnagErrorUsers
|
|
18
14
|
error_id = error_id_from_url(error_url)
|
19
15
|
|
20
16
|
if error_id.nil?
|
21
|
-
|
17
|
+
puts "Invalid Bugsnag error URL. Example: https://bugsnag.com/<organization>/<project_name>/errors/<error_id>"
|
22
18
|
return []
|
23
19
|
end
|
24
20
|
|
25
|
-
|
21
|
+
puts "Fetching user names from error id: #{error_id}. (Each '.' is an event page fetched): "
|
26
22
|
events = fetch_events(error_id)
|
27
|
-
|
23
|
+
puts "\n"
|
28
24
|
extract_usernames(events)
|
29
25
|
end
|
30
26
|
|
@@ -37,11 +33,11 @@ module BugsnagErrorUsers
|
|
37
33
|
end
|
38
34
|
|
39
35
|
def fetch_events(error_id)
|
40
|
-
events, results_size = fetch_events_page(error_id, per_page:
|
41
|
-
return events if results_size <
|
36
|
+
events, results_size = fetch_events_page(error_id, per_page: PAGE_SIZE)
|
37
|
+
return events if results_size < PAGE_SIZE
|
42
38
|
|
43
|
-
until results_size <
|
44
|
-
events_new, results_size = fetch_events_page(error_id, per_page:
|
39
|
+
until results_size < PAGE_SIZE
|
40
|
+
events_new, results_size = fetch_events_page(error_id, per_page: PAGE_SIZE, offset: events.last[:id])
|
45
41
|
events.concat(events_new)
|
46
42
|
end
|
47
43
|
|
@@ -49,7 +45,7 @@ module BugsnagErrorUsers
|
|
49
45
|
end
|
50
46
|
|
51
47
|
def fetch_events_page(error_id, options={})
|
52
|
-
events = Bugsnag::Api.error_events(error_id, options);
|
48
|
+
events = Bugsnag::Api.error_events(error_id, options); print '.'
|
53
49
|
[events, events.size]
|
54
50
|
end
|
55
51
|
|
@@ -1,7 +1,10 @@
|
|
1
1
|
namespace :bugsnag do
|
2
2
|
desc "Extract exception event user names from bugsnag error url"
|
3
3
|
task :error_users, [:error_url] => :environment do |t, args|
|
4
|
-
|
4
|
+
unless bugsnag_token_present?
|
5
|
+
puts "Aborting! Bugsnag::Api.configuration.auth_token must be set. See the bugsnag-error-users README."
|
6
|
+
abort
|
7
|
+
end
|
5
8
|
|
6
9
|
fetcher = BugsnagErrorUsers::Fetcher.new(args.error_url)
|
7
10
|
user_names = fetcher.fetch
|
@@ -9,16 +12,12 @@ namespace :bugsnag do
|
|
9
12
|
user_names.each do |user_name|
|
10
13
|
puts user_name
|
11
14
|
end
|
15
|
+
puts "\nFetched #{user_names.size} results"
|
12
16
|
end
|
13
17
|
|
14
18
|
private
|
15
19
|
|
16
20
|
def bugsnag_token_present?
|
17
|
-
|
18
|
-
true
|
19
|
-
else
|
20
|
-
puts "Aborting! Bugsnag::Api.configuration.auth_token must be set. See the bugsnag-error-users README."
|
21
|
-
false
|
22
|
-
end
|
21
|
+
Bugsnag::Api.configuration.auth_token.present?
|
23
22
|
end
|
24
23
|
end
|