bugsnag-error-users 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +47 -0
- data/Rakefile +10 -0
- data/bin/console +13 -0
- data/bin/setup +7 -0
- data/bugsnag-error-users.gemspec +27 -0
- data/lib/bugsnag-error-users/fetcher.rb +62 -0
- data/lib/bugsnag-error-users/railtie.rb +9 -0
- data/lib/bugsnag-error-users/version.rb +3 -0
- data/lib/bugsnag-error-users.rb +3 -0
- data/lib/tasks/bugsnag-error-users.rake +24 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 52d35afe044f5b6eca4a568544c39a03e54cee75
|
4
|
+
data.tar.gz: d6d2ca20fac97e5263e7ec3b99ce752601d649a2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8dfb7fc4a3772cbbb1cd0e776155be6bc3c81d179e396ddeba44093053b35eba7f9c4d5e2c9698d4d5b3f813ae7203d4c032882432fe334053535bcba42591b6
|
7
|
+
data.tar.gz: 609e3fcddb54771279eeabb0994e9934eed3bc8bd110f930baf68886f931f830096211e197757201605501bd8988a0fefe51c954bafce1e09b3c062129588fdb
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Christopher Butcher
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Bugsnag Error Users (a Rake task)
|
2
|
+
[![Build Status](https://api.travis-ci.org/repositories/chrisbutcher/bugsnag-error-users.svg)](https://travis-ci.org/chrisbutcher/bugsnag-error-users)
|
3
|
+
|
4
|
+
Fetch usernames from Bugsnag error URLs. Something I'd like to see Bugsnag support via their API. Consider this gem a temporary solution.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'bugsnag-error-users'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install bugsnag-error-users
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Once installed, set your Bugsnag API auth token, via an initializer:
|
25
|
+
```ruby
|
26
|
+
# config/initializers/bugsnag-api.rb
|
27
|
+
Bugsnag::Api.configure do |config|
|
28
|
+
config.auth_token = "API_TOKEN"
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
Then, you can run the rake task, passing in a Bugsnag error URL as a parameter:
|
33
|
+
```bash
|
34
|
+
$ rake bugsnag:error_users[https://bugsnag.com/<organization>/<project>/errors/<error_id>]
|
35
|
+
```
|
36
|
+
|
37
|
+
A unique list of user names and ids of affected users will be printed to your terminal.
|
38
|
+
Note: query params will be ignored, so you can just paste the error URL directly from your browser.
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/chrisbutcher/bugsnag-error-users. Contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
43
|
+
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
|
5
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
6
|
+
# with your gem easier. You can also use a different console, if you like.
|
7
|
+
|
8
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
9
|
+
# require "pry"
|
10
|
+
# Pry.start
|
11
|
+
|
12
|
+
require "irb"
|
13
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bugsnag-error-users/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "bugsnag-error-users"
|
8
|
+
spec.version = BugsnagErrorUsers::VERSION
|
9
|
+
spec.authors = ["Christopher Butcher"]
|
10
|
+
spec.email = ["christopher.butcher@shopify.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Fetch usernames from Bugsnag error urls.}
|
13
|
+
spec.description = %q{Fetch usernames from Bugsnag error urls.}
|
14
|
+
spec.homepage = "https://github.com/chrisbutcher/bugsnag-error-users"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "minitest"
|
25
|
+
spec.add_development_dependency "mocha"
|
26
|
+
spec.add_runtime_dependency "bugsnag-api"
|
27
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'bugsnag/api'
|
2
|
+
|
3
|
+
module BugsnagErrorUsers
|
4
|
+
class StdoutPrinter
|
5
|
+
def self.write(str)
|
6
|
+
print(str)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Fetcher
|
11
|
+
attr_reader :error_url
|
12
|
+
|
13
|
+
def initialize(error_url)
|
14
|
+
@error_url = error_url
|
15
|
+
end
|
16
|
+
|
17
|
+
def fetch
|
18
|
+
error_id = error_id_from_url(error_url)
|
19
|
+
|
20
|
+
if error_id.nil?
|
21
|
+
StdoutPrinter.write "Invalid Bugsnag error URL. Example: https://bugsnag.com/<organization>/<project_name>/errors/<error_id>"
|
22
|
+
return []
|
23
|
+
end
|
24
|
+
|
25
|
+
StdoutPrinter.write "Fetching user names from error id: #{error_id}. (Each '.' is an event page fetched): "
|
26
|
+
events = fetch_events(error_id)
|
27
|
+
print "\n"
|
28
|
+
extract_usernames(events)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def error_id_from_url(raw_url)
|
34
|
+
parsed_url = URI.parse(raw_url)
|
35
|
+
match = /errors\/([a-f0-9]+)/.match(parsed_url.path)
|
36
|
+
match[1] if match && match[1]
|
37
|
+
end
|
38
|
+
|
39
|
+
def fetch_events(error_id)
|
40
|
+
events, results_size = fetch_events_page(error_id, per_page: 100)
|
41
|
+
return events if results_size < 100
|
42
|
+
|
43
|
+
until results_size < 100
|
44
|
+
events_new, results_size = fetch_events_page(error_id, per_page: 100, offset: events.last[:id])
|
45
|
+
events.concat(events_new)
|
46
|
+
end
|
47
|
+
|
48
|
+
events
|
49
|
+
end
|
50
|
+
|
51
|
+
def fetch_events_page(error_id, options={})
|
52
|
+
events = Bugsnag::Api.error_events(error_id, options); StdoutPrinter.write '.'
|
53
|
+
[events, events.size]
|
54
|
+
end
|
55
|
+
|
56
|
+
def extract_usernames(events)
|
57
|
+
events.map do |event|
|
58
|
+
"#{event[:meta_data][:User][:name]}, ##{event[:meta_data][:User][:id]}"
|
59
|
+
end.compact.uniq.sort
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
namespace :bugsnag do
|
2
|
+
desc "Extract exception event user names from bugsnag error url"
|
3
|
+
task :error_users, [:error_url] => :environment do |t, args|
|
4
|
+
abort unless bugsnag_token_present?
|
5
|
+
|
6
|
+
fetcher = BugsnagErrorUsers::Fetcher.new(args.error_url)
|
7
|
+
user_names = fetcher.fetch
|
8
|
+
|
9
|
+
user_names.each do |user_name|
|
10
|
+
puts user_name
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
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
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bugsnag-error-users
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christopher Butcher
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
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: mocha
|
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
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bugsnag-api
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Fetch usernames from Bugsnag error urls.
|
84
|
+
email:
|
85
|
+
- christopher.butcher@shopify.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".travis.yml"
|
92
|
+
- CODE_OF_CONDUCT.md
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- bugsnag-error-users.gemspec
|
100
|
+
- lib/bugsnag-error-users.rb
|
101
|
+
- lib/bugsnag-error-users/fetcher.rb
|
102
|
+
- lib/bugsnag-error-users/railtie.rb
|
103
|
+
- lib/bugsnag-error-users/version.rb
|
104
|
+
- lib/tasks/bugsnag-error-users.rake
|
105
|
+
homepage: https://github.com/chrisbutcher/bugsnag-error-users
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.4.5
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Fetch usernames from Bugsnag error urls.
|
129
|
+
test_files: []
|