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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52d35afe044f5b6eca4a568544c39a03e54cee75
4
- data.tar.gz: d6d2ca20fac97e5263e7ec3b99ce752601d649a2
3
+ metadata.gz: ef01f6926c48b576ee5d92121df6d24c195048a5
4
+ data.tar.gz: 77d0e02a19091ca197c61f0cd139a3fd9efee677
5
5
  SHA512:
6
- metadata.gz: 8dfb7fc4a3772cbbb1cd0e776155be6bc3c81d179e396ddeba44093053b35eba7f9c4d5e2c9698d4d5b3f813ae7203d4c032882432fe334053535bcba42591b6
7
- data.tar.gz: 609e3fcddb54771279eeabb0994e9934eed3bc8bd110f930baf68886f931f830096211e197757201605501bd8988a0fefe51c954bafce1e09b3c062129588fdb
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
- StdoutPrinter.write "Invalid Bugsnag error URL. Example: https://bugsnag.com/<organization>/<project_name>/errors/<error_id>"
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
- StdoutPrinter.write "Fetching user names from error id: #{error_id}. (Each '.' is an event page fetched): "
21
+ puts "Fetching user names from error id: #{error_id}. (Each '.' is an event page fetched): "
26
22
  events = fetch_events(error_id)
27
- print "\n"
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: 100)
41
- return events if results_size < 100
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 < 100
44
- events_new, results_size = fetch_events_page(error_id, per_page: 100, offset: events.last[:id])
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); StdoutPrinter.write '.'
48
+ events = Bugsnag::Api.error_events(error_id, options); print '.'
53
49
  [events, events.size]
54
50
  end
55
51
 
@@ -1,3 +1,3 @@
1
1
  module BugsnagErrorUsers
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
- abort unless bugsnag_token_present?
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
- if Bugsnag::Api.configuration.auth_token.present?
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag-error-users
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Butcher