Skip to content

Instantly share code, notes, and snippets.

@CGA1123
Created June 2, 2019 08:20
Show Gist options
  • Save CGA1123/ca3f7ba2356ee26572b2e617760dd3ea to your computer and use it in GitHub Desktop.
Save CGA1123/ca3f7ba2356ee26572b2e617760dd3ea to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'bugsnag/api'
BUGSNAG_PERSONAL_TOKEN = ENV.fetch('BUGSNAG_PERSONAL_TOKEN')
URL_REGEX = /https:\/\/app.bugsnag.com\/carwow\/(?<project_slug>.*)\/errors\/(?<error_id>[a-zA-Z0-9]+)(\?.*)?/
PROJECTS = {
'project_slug' => 'bugsnag_project_id'
}
matches = ARGV.first.match(URL_REGEX)
client = Bugsnag::Api::Client.new(auth_token: BUGSNAG_PERSONAL_TOKEN)
project_id = PROJECTS.fetch(matches[:project_slug])
project_name = matches[:project_slug].split('-').map(&:capitalize).join(' ')
error = client.error(project_id, matches[:error_id])
puts <<Slackify
:cloud: [#{project_name}] #{error[:context]}
:bug: `[#{error[:error_class]}] #{error[:message].gsub('`', "'")}`
:memo: `#{error[:grouping_fields][:file]}:#{error[:grouping_fields][:lineNumber]}`
:link: #{ARGV.first.split('?').first}
Slackify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment