Sha256: 2590bda23e17fdd58c4f88379b59adb4b88166aacfa736f7e9fbd96a05b58caa

Contents?: true

Size: 1.55 KB

Versions: 16

Compression:

Stored size: 1.55 KB

Contents

module FastlaneCore
  class CrashReportGenerator
    class << self
      def generate(exception: nil, action: nil)
        message = format_crash_report_message(exception: exception)
        crash_report_payload(message: message, action: action)
      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")
        message = exception.respond_to?(:prefix) ? exception.prefix : '[EXCEPTION]'
        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: '', 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

16 entries across 16 versions & 1 rubygems

Version Path
fastlane-2.35.1 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.36.0.beta.20170526010038 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.36.0.beta.20170525010052 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.35.0 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.34.0 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.34.0.beta.20170524010028 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.33.0 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.33.0.beta.20170523010027 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.33.0.beta.20170522010027 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.33.0.beta.20170521010032 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.33.0.beta.20170520010019 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.32.1 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.33.0.beta.20170519010039 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.32.0 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.32.0.beta.20170518010031 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb
fastlane-2.31.0 fastlane_core/lib/fastlane_core/crash_reporter/crash_report_generator.rb