Sha256: 11117c3dc78bf5880cb5897222219bad99f40f98c578d8d1b621349049cd445a

Contents?: true

Size: 1.68 KB

Versions: 73

Compression:

Stored size: 1.68 KB

Contents

require_relative 'crash_report_sanitizer'

module FastlaneCore
  class CrashReportGenerator
    class << self
      def generate(exception: nil)
        message = format_crash_report_message(exception: exception)
        crash_report_payload(message: message)
      end

      private

      def format_crash_report_message(exception: nil)
        return if exception.nil?
        backtrace = exception.respond_to?(:trimmed_backtrace) ? exception.trimmed_backtrace : exception.backtrace
        backtrace = FastlaneCore::CrashReportSanitizer.sanitize_backtrace(backtrace: backtrace).join("\n")

        if exception.fastlane_crash_came_from_plugin?
          message = '[PLUGIN_CRASH]'
        elsif exception.respond_to?(:prefix)
          message = exception.prefix
        else
          message = '[EXCEPTION]'
        end

        message += ': '

        if exception.respond_to?(:crash_report_message)
          exception_message = FastlaneCore::CrashReportSanitizer.sanitize_string(string: exception.crash_report_message)
        else
          exception_message = "#{exception.class.name}: #{FastlaneCore::CrashReportSanitizer.sanitize_string(string: exception.message)}"
        end

        message += exception_message
        message = message[0..100]
        message += "\n" unless exception.respond_to?(:could_contain_pii?) && exception.could_contain_pii?
        message + backtrace
      end

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

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
fastlane-2.85.0.beta.20180305050037 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.85.0.beta.20180304050031 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.85.0.beta.20180303050048 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.85.0.beta.20180302050035 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.84.0 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.84.0.beta.20180301050048 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.84.0.beta.20180228050122 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.84.0.beta.20180227050054 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.83.0 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.83.0.beta.20180226050016 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.83.0.beta.20180225050035 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.83.0.beta.20180224050047 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.82.0 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.82.0.beta.20180223010003 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.82.0.beta.20180222010003 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.82.0.beta.20180221010003 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.82.0.beta.20180220010002 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.82.0.beta.20180219010003 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.82.0.beta.20180218010003 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.82.0.beta.20180217010002 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb