Class: BugsnagErrorUsers::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/bugsnag-error-users/fetcher.rb

Constant Summary collapse

PAGE_SIZE =
100

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_url) ⇒ Fetcher

Returns a new instance of Fetcher.



9
10
11
# File 'lib/bugsnag-error-users/fetcher.rb', line 9

def initialize(error_url)
  @error_url = error_url
end

Instance Attribute Details

#error_urlObject (readonly)

Returns the value of attribute error_url.



7
8
9
# File 'lib/bugsnag-error-users/fetcher.rb', line 7

def error_url
  @error_url
end

Instance Method Details

#fetchObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bugsnag-error-users/fetcher.rb', line 13

def fetch
  error_id = error_id_from_url(error_url)

  if error_id.nil?
    puts "Invalid Bugsnag error URL. Example: https://bugsnag.com/<organization>/<project_name>/errors/<error_id>"
    return []
  end

  print "Fetching user names from error id: #{error_id}. (Each '.' is an event page fetched): "
  events = fetch_events(error_id)
  puts "\n"
  extract_usernames(events)
end