diff --git a/config/locales/en.yml b/config/locales/en.yml index a162e5a..67a3d59 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -6,7 +6,6 @@ en: login: description: 'Log in to DeployGate' terminal: 'Login in terminal' - error: 'Commands::Login Error: %{e}' deploy: description: 'Build and upload a new build' message: 'Build description message' @@ -16,14 +15,12 @@ en: scheme: 'Set Xcode build scheme (iOS app only)' open: 'Open a browser after the build uploaded (OS X only)' disable_notify: 'Disable email notification (iOS app only)' - error: 'Commands::Deploy Error: %{e}' add_devices: description: 'Register devices to your Apple Developer account and refresh your provisioning profile. (iOS only) By default, it automatically finds new devices added to your application on DeployGate and ask you which device to register. You can also specify which device to register via command line options.' user: 'Owner user or organization name' udid: 'UDID to be registered' device_name: 'Device name to be registered' distribution_key: 'If you also want to update distribution page, set the last part of the URL of the page' - error: 'Commands::AddDevices Error: %{e}' server: description: 'Start the add-devices server. When added new device automatically run add-devices command.' connecting: 'Connecting...' @@ -32,17 +29,15 @@ en: finish_build: 'add-devices completed successfully.' logout: description: 'Log out current session' - error: 'Commands::Logout Error: %{e}' config: description: "Configure login session of `dg` command. Usually, the session automatically created on the installation process so you don't need to use this command." json: 'Set output format to JSON' name: 'DeployGate user name' token: 'DeployGate API token' - error: 'Commands::Config Error: %{e}' error_handling: message: 'Error: %{message}' - agree: 'Do you want to report this issue on GitHub? (y/n) ' - please_open: 'Please open GitHub issue: %{url}' + agree: 'Do you want to this error report to DeployGate? (y/n) ' + thanks: 'Thank you feedback! We will improve based on it.' show_update_message: | ################################################################# # %{gem_name} %{latest_version} is available. You are on %{current_version}. diff --git a/deploygate.gemspec b/deploygate.gemspec index 731d528..8dc7b1a 100644 --- a/deploygate.gemspec +++ b/deploygate.gemspec @@ -25,7 +25,6 @@ POST_INSTALL_MESSAGE spec.add_runtime_dependency 'commander', '~> 4.4' spec.add_runtime_dependency 'plist', '~> 3.1' spec.add_runtime_dependency 'xcodeproj', '~> 1.7' - spec.add_runtime_dependency 'github_issue_request', '~> 0.1' spec.add_runtime_dependency 'highline', '~> 1.7' spec.add_runtime_dependency 'uuid', '~> 2.3' spec.add_runtime_dependency 'gem_update_checker', '~> 0.2' @@ -36,6 +35,7 @@ POST_INSTALL_MESSAGE spec.add_runtime_dependency 'net-ping', '~> 2.0' spec.add_runtime_dependency 'socket.io-client-simple', '~> 1.2' spec.add_runtime_dependency 'workers', '~> 0.6' + spec.add_runtime_dependency 'sentry-raven', '~> 2.8' # ios build spec.add_runtime_dependency 'fastlane', '~> 2.57.2' diff --git a/lib/deploygate.rb b/lib/deploygate.rb index 4c0ec16..1bdc4db 100644 --- a/lib/deploygate.rb +++ b/lib/deploygate.rb @@ -6,11 +6,11 @@ require "openssl" require "plist" require "find" -require "github_issue_request" require "highline" require "uuid" require "gem_update_checker" require "active_support/core_ext/time" +require "active_support/core_ext/hash" require "locale" require "tempfile" require "open3" @@ -21,6 +21,7 @@ require "net/ping" require "socket.io-client-simple" require "workers" +require "sentry-raven" require "i18n" I18n.load_path = Dir[File.join(File.dirname(__FILE__), '../config/locales/*.yml')] @@ -34,7 +35,7 @@ module DeployGate end -require "deploygate/not_issue_error" +require "deploygate/raven_ignore_exception" require "deploygate/api/v1/base" require "deploygate/api/v1/session" require "deploygate/api/v1/push" @@ -55,6 +56,7 @@ module DeployGate require "deploygate/session" require "deploygate/deploy" require "deploygate/project" +require "deploygate/raven_ignore_exception" require "deploygate/user" require "deploygate/browser_login" require "deploygate/add_devices_server" diff --git a/lib/deploygate/command_builder.rb b/lib/deploygate/command_builder.rb index 811bf6f..544ffd6 100644 --- a/lib/deploygate/command_builder.rb +++ b/lib/deploygate/command_builder.rb @@ -3,7 +3,7 @@ class CommandBuilder include Commander::Methods attr_reader :arguments - class NotInternetConnectionError < DeployGate::NotIssueError + class NotInternetConnectionError < DeployGate::RavenIgnoreException end PING_URL = 'https://deploygate.com' @@ -15,6 +15,13 @@ class NotInternetConnectionError < DeployGate::NotIssueError CONFIG = 'config' def setup + # sentry config + Raven.configure do |config| + config.dsn = 'https://e0b4dda8fe2049a7b0d98c6d2759e067@sentry.io/1371610' + config.logger = Raven::Logger.new('/dev/null') # hide sentry log + config.excluded_exceptions = Raven::Configuration::IGNORE_DEFAULT + [DeployGate::RavenIgnoreException.name] + end + # set Ctrl-C trap Signal.trap(:INT){ puts '' @@ -27,8 +34,6 @@ def setup exit end - # check update - GithubIssueRequest::Url.config('deploygate', 'deploygate-cli') check_update() end @@ -49,7 +54,7 @@ def run Commands::Login.run(args, options) rescue => e error_handling(LOGIN, e) - raise e + exit 1 end end end @@ -70,7 +75,7 @@ def run Commands::Deploy.run(args, options) rescue => e error_handling(DEPLOY, e) - raise e + exit 1 end end end @@ -91,7 +96,7 @@ def run Commands::AddDevices.run(args, options) rescue => e error_handling(ADD_DEVICES, e) - raise e + exit 1 end end end @@ -104,7 +109,7 @@ def run Commands::Logout.run rescue => e error_handling(LOGOUT, e) - raise e + exit 1 end end end @@ -120,7 +125,7 @@ def run Commands::Config.run(args, options) rescue => e error_handling(CONFIG, e) - raise e + exit 1 end end end @@ -128,62 +133,54 @@ def run run! end + # @param [String] command # @param [Exception] error - # @return [String] - def create_error_issue_body(error) - return < title, - :body => create_error_issue_body(error), - } - GithubIssueRequest::Url.new(options).to_s - end + def error_report(error, dg_version, xcode_version) + meta_info = "dg version: #{dg_version}" + meta_info += "\nXcode version: #{xcode_version}" if xcode_version.present? - # @param [Symbol] command - # @param [Exception] error - def error_handling(command, error) - STDERR.puts HighLine.color(I18n.t('command_builder.error_handling.message', message: error.message), HighLine::RED) + backtrace = error.backtrace.take(5).join("\n") + backtrace += "\nand more ..." if error.backtrace.count > 5 - return if ENV['CI'] # When run ci server - return if error.kind_of?(DeployGate::NotIssueError) - puts '' - if HighLine.agree(I18n.t('command_builder.error_handling.agree')) {|q| q.default = "n"} - url = create_issue_url(command, error) - puts I18n.t('command_builder.error_handling.please_open', url: url) - system('open', url) if Commands::Deploy::Push.openable? - end - puts '' + <