Created
May 22, 2019 15:38
-
-
Save kechol/5ff6c9fcc89597b6fbc848e7ab07399a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "net/http" | |
require "uri" | |
require "json" | |
ENDPOINT = 'https://sentry.io/api/0'.freeze | |
TOKEN = 'XXXXXXXXXX'.freeze | |
def sentry_api(url) | |
uri = URI.parse(url) | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true | |
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
request = Net::HTTP::Get.new(uri.request_uri) | |
request["Authorization"] = "bearer #{TOKEN}" | |
response = http.request(request) | |
return [] if response.code != "200" | |
return JSON.parse(response.body) | |
end | |
issues = sentry_api("#{ENDPOINT}/projects/ORG_NAME/PROJ_NAME/issues/") | |
puts "issues: #{issues.size}" | |
issues.each do |issue| | |
events = sentry_api("#{ENDPOINT}/issues/#{issue['id']}/events/") | |
puts "#{issue['id']} events: #{events.size}" | |
events.each do |event| | |
tags = event["tags"].map{|tag| [tag["key"], tag["value"]]}.to_h | |
sleep 2 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment