Class: FastlaneCore::CrashReporting

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane_core/crash_reporting/crash_reporting.rb

Constant Summary collapse

URL =
'https://02c6a8be5bd4425389706655f3657f5c:[email protected]/55281'

Class Method Summary collapse

Class Method Details

.ask_during_setupObject

Ask the user politely if they want to send crash reports



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fastlane_core/crash_reporting/crash_reporting.rb', line 35

def ask_during_setup
  return if enabled?

  puts "-------------------------------------------------------------------------------------------".yellow
  puts "😃  Enable crash reporting when fastlane experiences a problem?".yellow
  puts "👍  This makes resolving issues much easier and helps improve fastlane.".yellow
  puts "🔒  The reports will be stored securely on getsentry.com".yellow
  puts "🙊  More information about privacy: https://github.com/fastlane/fastlane/releases/tag/1.33.3".yellow
  puts "🌴  You can always disable crash reports at anytime `fastlane disable_crash_reporting`".yellow
  puts "-------------------------------------------------------------------------------------------".yellow
  if agree("Do you want to enable crash reporting? (y/n) ", true)
    enable
  end
end

.disableObject



16
17
18
19
# File 'lib/fastlane_core/crash_reporting/crash_reporting.rb', line 16

def disable
  File.delete(file_path) if File.exist?(file_path)
  puts "Disabled crash reporting :("
end

.enableObject



9
10
11
12
13
14
# File 'lib/fastlane_core/crash_reporting/crash_reporting.rb', line 9

def enable
  File.write(file_path, "1")
  puts "Successfully enabled crash reporting.".green
  puts "This will only send a stack trace for installed gems to Sentry.".green
  puts "Thanks for improving fastlane!".green
end

.enabled?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/fastlane_core/crash_reporting/crash_reporting.rb', line 21

def enabled?
  File.exist?(file_path)
end

.file_pathObject



5
6
7
# File 'lib/fastlane_core/crash_reporting/crash_reporting.rb', line 5

def file_path
  File.expand_path(File.join('~/.fastlane_crash_reporting'))
end

.handle_crash(ex) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/fastlane_core/crash_reporting/crash_reporting.rb', line 50

def handle_crash(ex)
  unless enabled?
    show_message
    return
  end

  raise ex if Helper.test?
  send_crash(ex)
end

.send_crash(ex) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fastlane_core/crash_reporting/crash_reporting.rb', line 60

def send_crash(ex)
  # https://github.com/getsentry/raven-ruby/wiki/Advanced-Configuration
  require 'raven'
  require 'json'
  require 'fastlane_core/crash_reporting/clean_stack_trace'

  Raven.configure do |config|
    config.dsn = URL
    config.logger = Logger.new('/dev/null') # we couldn't care less
    config.sanitize_fields = %w(server_name)
    config.processors << Raven::Processor::CleanStackTrace
  end

  Raven::Context.clear! # we don't want to transfer things like the host name
  crash = Raven.capture_exception(ex)
  path = "/tmp/sentry_#{crash.id}.json"
  File.write(path, JSON.pretty_generate(crash.to_hash))
  puts "Successfully submitted a crash report. If this is a problem with one of the tools specifically,".yellow
  puts "please submit an issue on GitHub and attach the following number to it: '#{crash.id}'".yellow
  puts "The crash report has been stored locally '#{path}'".yellow
rescue => e
  Helper.log.debug e # We don't want crash reporting to cause crash
end

.show_messageObject



25
26
27
28
29
30
31
32
# File 'lib/fastlane_core/crash_reporting/crash_reporting.rb', line 25

def show_message
  puts "-------------------------------------------------------------------------------------------".yellow
  puts "😨  An error occured. Please enable crash reports using `fastlane enable_crash_reporting`.".yellow
  puts "👍  This makes resolving issues much easier and helps improve fastlane.".yellow
  puts "🔒  The reports will be stored securely on getsentry.com.".yellow
  puts "🙊  More information about privacy: https://github.com/fastlane/fastlane/releases/tag/1.33.3".yellow
  puts "-------------------------------------------------------------------------------------------".yellow
end