Sha256: a4ca2a68b34d9e16371d3362a888ac36968c7c8531b1609afc793afc225c5002

Contents?: true

Size: 1.6 KB

Versions: 8

Compression:

Stored size: 1.6 KB

Contents

module FastlaneCore
  class CrashReportGenerator
    class << self
      def types
        {
          user_error: '[USER_ERROR]',
          crash: '[FASTLANE_CRASH]',
          exception: '[EXCEPTION]',
          connection_failure: '[CONNECTION_FAILURE]',
          system: '[SYSTEM_ERROR]',
          option_parser: '[OPTION_PARSER]',
          invalid_command: '[INVALID_COMMAND]',
          unknown: '[UNKNOWN]'
        }
      end

      def generate(type: :unknown, exception: nil, action: nil)
        message = crash_report_message(type: type, exception: exception)
        crash_report_payload(message: message, action: action)
      end

      private

      def crash_report_message(type: :unknown, exception: nil)
        return if exception.nil?
        backtrace = FastlaneCore::CrashReportSanitizer.sanitize_backtrace(type: type, backtrace: exception.backtrace).join("\n")
        message = types[type]
        sanitized_exception_message = FastlaneCore::CrashReportSanitizer.sanitize_string(string: exception.message)
        if type == :user_error
          message += ': '
        else
          message += ": #{sanitized_exception_message}"
        end
        message = message[0..100]
        message += "\n" unless type == :user_error
        message + backtrace
      end

      def crash_report_payload(message: '', action: nil)
        {
          'eventTime' => Time.now.utc.to_datetime.rfc3339,
          'serviceContext' => {
            'service' => action || 'fastlane',
            'version' => Fastlane::VERSION
          },
          'message' => message
        }.to_json
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fastlane-2.31.0.beta.20170517010031 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.31.0.beta.20170516010048 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.31.0.beta.20170515010044 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.31.0.beta.20170514010036 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.31.0.beta.20170513010043 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.30.2 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.31.0.beta.20170512010054 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.30.1 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb