From bafcee8593461e0b02dc0f8dd7363bd0853b5e41 Mon Sep 17 00:00:00 2001 From: henteko Date: Tue, 15 Jan 2019 14:53:30 +0900 Subject: [PATCH 1/5] remove send error to github issue --- deploygate.gemspec | 1 - lib/deploygate.rb | 1 - lib/deploygate/command_builder.rb | 48 +------------------------------ 3 files changed, 1 insertion(+), 49 deletions(-) diff --git a/deploygate.gemspec b/deploygate.gemspec index 731d528..15049d7 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' diff --git a/lib/deploygate.rb b/lib/deploygate.rb index 4c0ec16..54aca8b 100644 --- a/lib/deploygate.rb +++ b/lib/deploygate.rb @@ -6,7 +6,6 @@ require "openssl" require "plist" require "find" -require "github_issue_request" require "highline" require "uuid" require "gem_update_checker" diff --git a/lib/deploygate/command_builder.rb b/lib/deploygate/command_builder.rb index 811bf6f..a9db065 100644 --- a/lib/deploygate/command_builder.rb +++ b/lib/deploygate/command_builder.rb @@ -27,8 +27,6 @@ def setup exit end - # check update - GithubIssueRequest::Url.config('deploygate', 'deploygate-cli') check_update() end @@ -128,48 +126,6 @@ def run run! end - # @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 - # @param [Symbol] command # @param [Exception] error def error_handling(command, error) @@ -179,9 +135,7 @@ def error_handling(command, error) 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? + # TODO: send error to sentry end puts '' end From 2fe84a346ae3fbfd3ba9878b7c68c0b957d33c4b Mon Sep 17 00:00:00 2001 From: henteko Date: Tue, 15 Jan 2019 16:08:43 +0900 Subject: [PATCH 2/5] setup sentry --- config/locales/en.yml | 2 -- deploygate.gemspec | 1 + lib/deploygate.rb | 2 ++ lib/deploygate/command_builder.rb | 31 ++++++++++++++++++++----------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index a162e5a..601e399 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -41,8 +41,6 @@ en: 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}' show_update_message: | ################################################################# # %{gem_name} %{latest_version} is available. You are on %{current_version}. diff --git a/deploygate.gemspec b/deploygate.gemspec index 15049d7..8dc7b1a 100644 --- a/deploygate.gemspec +++ b/deploygate.gemspec @@ -35,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 54aca8b..53b3c8b 100644 --- a/lib/deploygate.rb +++ b/lib/deploygate.rb @@ -10,6 +10,7 @@ require "uuid" require "gem_update_checker" require "active_support/core_ext/time" +require "active_support/core_ext/hash" require "locale" require "tempfile" require "open3" @@ -20,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')] diff --git a/lib/deploygate/command_builder.rb b/lib/deploygate/command_builder.rb index a9db065..1f963a0 100644 --- a/lib/deploygate/command_builder.rb +++ b/lib/deploygate/command_builder.rb @@ -15,6 +15,12 @@ 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 + end + # set Ctrl-C trap Signal.trap(:INT){ puts '' @@ -47,7 +53,7 @@ def run Commands::Login.run(args, options) rescue => e error_handling(LOGIN, e) - raise e + exit 1 end end end @@ -68,7 +74,7 @@ def run Commands::Deploy.run(args, options) rescue => e error_handling(DEPLOY, e) - raise e + exit 1 end end end @@ -89,7 +95,7 @@ def run Commands::AddDevices.run(args, options) rescue => e error_handling(ADD_DEVICES, e) - raise e + exit 1 end end end @@ -102,7 +108,7 @@ def run Commands::Logout.run rescue => e error_handling(LOGOUT, e) - raise e + exit 1 end end end @@ -118,7 +124,7 @@ def run Commands::Config.run(args, options) rescue => e error_handling(CONFIG, e) - raise e + exit 1 end end end @@ -126,18 +132,21 @@ def run run! end - # @param [Symbol] command + # @param [String] 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) 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"} - # TODO: send error to sentry - end - puts '' + tags = { + command: command, + dg_version: DeployGate::VERSION + } + version = Gym::Xcode.xcode_version + tags[:xcode_version] = version if version.present? + + Raven.capture_exception(error, tags: tags) end # @return [void] From cf1be7501a60244efcfd87598b6c39f1404fce6b Mon Sep 17 00:00:00 2001 From: henteko Date: Tue, 15 Jan 2019 16:24:40 +0900 Subject: [PATCH 3/5] rename RavenIgnoreException --- lib/deploygate.rb | 3 ++- lib/deploygate/command_builder.rb | 6 +++--- lib/deploygate/deploy.rb | 6 +++--- lib/deploygate/not_issue_error.rb | 4 ---- lib/deploygate/raven_ignore_exception.rb | 4 ++++ lib/deploygate/session.rb | 2 +- lib/deploygate/xcode/analyze.rb | 2 +- lib/deploygate/xcode/ios.rb | 2 +- lib/deploygate/xcode/member_centers/provisioning_profile.rb | 4 ++-- 9 files changed, 17 insertions(+), 16 deletions(-) delete mode 100644 lib/deploygate/not_issue_error.rb create mode 100644 lib/deploygate/raven_ignore_exception.rb diff --git a/lib/deploygate.rb b/lib/deploygate.rb index 53b3c8b..1bdc4db 100644 --- a/lib/deploygate.rb +++ b/lib/deploygate.rb @@ -35,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" @@ -56,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 1f963a0..65cda34 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' @@ -19,6 +19,7 @@ def setup 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 @@ -137,8 +138,7 @@ def run def error_handling(command, error) STDERR.puts HighLine.color(I18n.t('command_builder.error_handling.message', message: error.message), HighLine::RED) - return if ENV['CI'] # When run ci server - return if error.kind_of?(DeployGate::NotIssueError) + return if error.kind_of?(DeployGate::RavenIgnoreException) tags = { command: command, dg_version: DeployGate::VERSION diff --git a/lib/deploygate/deploy.rb b/lib/deploygate/deploy.rb index c60cdd4..a1b2024 100644 --- a/lib/deploygate/deploy.rb +++ b/lib/deploygate/deploy.rb @@ -1,10 +1,10 @@ module DeployGate class Deploy - class NotLoginError < DeployGate::NotIssueError + class NotLoginError < DeployGate::RavenIgnoreException end - class NotFileExistError < DeployGate::NotIssueError + class NotFileExistError < DeployGate::RavenIgnoreException end - class UploadError < DeployGate::NotIssueError + class UploadError < DeployGate::RavenIgnoreException end class << self diff --git a/lib/deploygate/not_issue_error.rb b/lib/deploygate/not_issue_error.rb deleted file mode 100644 index cb3cde7..0000000 --- a/lib/deploygate/not_issue_error.rb +++ /dev/null @@ -1,4 +0,0 @@ -module DeployGate - class NotIssueError < StandardError - end -end diff --git a/lib/deploygate/raven_ignore_exception.rb b/lib/deploygate/raven_ignore_exception.rb new file mode 100644 index 0000000..3f51c34 --- /dev/null +++ b/lib/deploygate/raven_ignore_exception.rb @@ -0,0 +1,4 @@ +module DeployGate + class RavenIgnoreException < StandardError + end +end diff --git a/lib/deploygate/session.rb b/lib/deploygate/session.rb index c394139..8e6c5f9 100644 --- a/lib/deploygate/session.rb +++ b/lib/deploygate/session.rb @@ -1,6 +1,6 @@ module DeployGate class Session - class LoginError < DeployGate::NotIssueError + class LoginError < DeployGate::RavenIgnoreException end attr_reader :name, :token diff --git a/lib/deploygate/xcode/analyze.rb b/lib/deploygate/xcode/analyze.rb index eec5b96..59654ba 100644 --- a/lib/deploygate/xcode/analyze.rb +++ b/lib/deploygate/xcode/analyze.rb @@ -9,7 +9,7 @@ class Analyze PROVISIONING_STYLE_AUTOMATIC = 'Automatic' PROVISIONING_STYLE_MANUAL = 'Manual' - class BundleIdentifierDifferentError < DeployGate::NotIssueError + class BundleIdentifierDifferentError < DeployGate::RavenIgnoreException end # @param [Array] workspaces diff --git a/lib/deploygate/xcode/ios.rb b/lib/deploygate/xcode/ios.rb index 4390360..209ffb4 100644 --- a/lib/deploygate/xcode/ios.rb +++ b/lib/deploygate/xcode/ios.rb @@ -5,7 +5,7 @@ module Ios PROJECT_DIR_EXTNAME = '.xcodeproj' IGNORE_DIRS = [ '.git', 'Carthage' ] - class NotSupportExportMethodError < DeployGate::NotIssueError + class NotSupportExportMethodError < DeployGate::RavenIgnoreException end class << self diff --git a/lib/deploygate/xcode/member_centers/provisioning_profile.rb b/lib/deploygate/xcode/member_centers/provisioning_profile.rb index d00720b..058ea6b 100644 --- a/lib/deploygate/xcode/member_centers/provisioning_profile.rb +++ b/lib/deploygate/xcode/member_centers/provisioning_profile.rb @@ -4,9 +4,9 @@ module MemberCenters class ProvisioningProfile attr_reader :member_center, :app_identifier - class NotInstalledCertificateError < DeployGate::NotIssueError + class NotInstalledCertificateError < DeployGate::RavenIgnoreException end - class NotExistUUIDProvisioningProfileError < DeployGate::NotIssueError + class NotExistUUIDProvisioningProfileError < DeployGate::RavenIgnoreException end OUTPUT_PATH = '/tmp/dg/provisioning_profile/' From 4a2fbadc3559bc5a39c1f7795e49664b52e06d4e Mon Sep 17 00:00:00 2001 From: henteko Date: Tue, 15 Jan 2019 17:14:05 +0900 Subject: [PATCH 4/5] remove error message --- config/locales/en.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 601e399..31ad452 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,13 +29,11 @@ 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}' show_update_message: | From b9084e485038033e14906a719df4bd7b5e1c0ce2 Mon Sep 17 00:00:00 2001 From: henteko Date: Wed, 16 Jan 2019 14:50:02 +0900 Subject: [PATCH 5/5] add error report --- config/locales/en.yml | 2 ++ lib/deploygate/command_builder.rb | 40 ++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 31ad452..67a3d59 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -36,6 +36,8 @@ en: token: 'DeployGate API token' error_handling: message: 'Error: %{message}' + 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/lib/deploygate/command_builder.rb b/lib/deploygate/command_builder.rb index 65cda34..544ffd6 100644 --- a/lib/deploygate/command_builder.rb +++ b/lib/deploygate/command_builder.rb @@ -137,16 +137,50 @@ def run # @param [Exception] error def error_handling(command, error) STDERR.puts HighLine.color(I18n.t('command_builder.error_handling.message', message: error.message), HighLine::RED) - + return if ENV['CI'] # When run ci server return if error.kind_of?(DeployGate::RavenIgnoreException) + + dg_version = DeployGate::VERSION tags = { command: command, - dg_version: DeployGate::VERSION + dg_version: dg_version } version = Gym::Xcode.xcode_version tags[:xcode_version] = version if version.present? - Raven.capture_exception(error, tags: tags) + puts '' + puts error_report(error, version, dg_version) + if HighLine.agree(I18n.t('command_builder.error_handling.agree')) {|q| q.default = "y"} + tags = { + command: command, + dg_version: DeployGate::VERSION + } + version = Gym::Xcode.xcode_version + tags[:xcode_version] = version if version.present? + + Raven.capture_exception(error, tags: tags) + puts HighLine.color(I18n.t('command_builder.error_handling.thanks'), HighLine::GREEN) + end + 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? + + backtrace = error.backtrace.take(5).join("\n") + backtrace += "\nand more ..." if error.backtrace.count > 5 + + <