Class: Fastlane::Helper::SentryApiHelper
- Inherits:
-
Object
- Object
- Fastlane::Helper::SentryApiHelper
- Defined in:
- lib/fastlane/plugin/sentry_api/helper/sentry_api_helper.rb
Constant Summary collapse
- BASE_URL =
"https://sentry.io/api/0"
Class Method Summary collapse
-
.api_request(auth_token:, path:, params: {}, base_url: BASE_URL) ⇒ Hash
Make a GET request to the Sentry REST API.
-
.get_events(auth_token:, org_slug:, params: {}) ⇒ Object
GET /api/0/organizations/org/events/ Used for Discover queries (TTID percentiles, performance metrics).
-
.get_issues(auth_token:, org_slug:, project_slug:, params: {}) ⇒ Object
GET /api/0/projects/org/project/issues/ Used for listing project issues filtered by release, query, etc.
-
.get_sessions(auth_token:, org_slug:, params: {}) ⇒ Object
GET /api/0/organizations/org/sessions/ Used for crash-free rates, session counts, user counts.
Class Method Details
.api_request(auth_token:, path:, params: {}, base_url: BASE_URL) ⇒ Hash
Make a GET request to the Sentry REST API.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fastlane/plugin/sentry_api/helper/sentry_api_helper.rb', line 21 def api_request(auth_token:, path:, params: {}, base_url: BASE_URL) url = "#{base_url}#{path}" uri = URI(url) uri.query = build_query_string(params) unless params.nil? || params.empty? UI.verbose("Sentry API GET: #{uri}") req = Net::HTTP::Get.new(uri) req['Authorization'] = "Bearer #{auth_token}" req['Content-Type'] = 'application/json' http = Net::HTTP.new(uri.hostname, uri.port) if uri.scheme == 'https' http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER # Disable CRL checking to avoid "unable to get certificate CRL" errors cert_store = OpenSSL::X509::Store.new cert_store.set_default_paths http.cert_store = cert_store end http.open_timeout = 30 http.read_timeout = 60 response = http.request(req) status_code = response.code.to_i body = response.body.to_s json = parse_json(body) { status: status_code, body: body, json: json } end |
.get_events(auth_token:, org_slug:, params: {}) ⇒ Object
GET /api/0/organizations/org/events/ Used for Discover queries (TTID percentiles, performance metrics).
66 67 68 69 70 71 72 |
# File 'lib/fastlane/plugin/sentry_api/helper/sentry_api_helper.rb', line 66 def get_events(auth_token:, org_slug:, params: {}) api_request( auth_token: auth_token, path: "/organizations/#{org_slug}/events/", params: params ) end |
.get_issues(auth_token:, org_slug:, project_slug:, params: {}) ⇒ Object
GET /api/0/projects/org/project/issues/ Used for listing project issues filtered by release, query, etc.
76 77 78 79 80 81 82 |
# File 'lib/fastlane/plugin/sentry_api/helper/sentry_api_helper.rb', line 76 def get_issues(auth_token:, org_slug:, project_slug:, params: {}) api_request( auth_token: auth_token, path: "/projects/#{org_slug}/#{project_slug}/issues/", params: params ) end |
.get_sessions(auth_token:, org_slug:, params: {}) ⇒ Object
GET /api/0/organizations/org/sessions/ Used for crash-free rates, session counts, user counts.
56 57 58 59 60 61 62 |
# File 'lib/fastlane/plugin/sentry_api/helper/sentry_api_helper.rb', line 56 def get_sessions(auth_token:, org_slug:, params: {}) api_request( auth_token: auth_token, path: "/organizations/#{org_slug}/sessions/", params: params ) end |