class Crep::HockeyAppCrashSource
The HockeyApp Crash
Source
Public Instance Methods
configure(bundle_identifier)
click to toggle source
# File lib/crep/model/crash_sources/hockeyapp_crash_source.rb, line 12 def configure(bundle_identifier) HockeyApp::Config.configure do |config| raise 'Missing API token (CREP_HOCKEY_API_TOKEN)' unless ENV['CREP_HOCKEY_API_TOKEN'] config.token = ENV['CREP_HOCKEY_API_TOKEN'] end @client = HockeyApp.build_client @hockeyapp_app = hockeyapp(bundle_identifier, @client) @app = App.new(@hockeyapp_app.title, bundle_identifier) end
crash_count(version:, build:)
click to toggle source
# File lib/crep/model/crash_sources/hockeyapp_crash_source.rb, line 28 def crash_count(version:, build:) statistics = @client.get_statistics @hockeyapp_app statistics_filtered_by_version = statistics.select do |statistic| statistic.shortversion == version && statistic.version == build end statistics_filtered_by_version.first.crashes end
crash_from_reason(reason, version)
click to toggle source
# File lib/crep/model/crash_sources/hockeyapp_crash_source.rb, line 48 def crash_from_reason(reason, version) Crash.new(file_line: "#{reason.file}:#{reason.line}", occurrences: reason.number_of_crashes, reason: reason.reason, crash_class: reason.crash_class, registered_at: Date.parse(reason.created_at), deep_link: deep_link(app_id: reason.app.public_identifier, reason_id: reason.id), url: url(app_id: reason.app.public_identifier, version_id: version.id, reason_id: reason.id)) end
crash_groups(version, show_only_unresolved)
click to toggle source
# File lib/crep/model/crash_sources/hockeyapp_crash_source.rb, line 36 def crash_groups(version, show_only_unresolved) reasons = version.crash_reasons('sort' => 'number_of_crashes', 'order' => 'desc') unresolved_reasons = show_only_unresolved ? unresolved_reasons(reasons) : reasons crashes_from_reasons(unresolved_reasons, version) end
crashes(top, version, build, show_only_unresolved)
click to toggle source
# File lib/crep/model/crash_sources/hockeyapp_crash_source.rb, line 23 def crashes(top, version, build, show_only_unresolved) version = version(version: version, build: build) crash_groups(version, show_only_unresolved).take(top.to_i) end
crashes_from_reasons(unresolved_reasons, version)
click to toggle source
# File lib/crep/model/crash_sources/hockeyapp_crash_source.rb, line 42 def crashes_from_reasons(unresolved_reasons, version) unresolved_reasons.map do |reason| crash_from_reason(reason, version) end end
deep_link(app_id:, reason_id:)
click to toggle source
# File lib/crep/model/crash_sources/hockeyapp_crash_source.rb, line 62 def deep_link(app_id:, reason_id:) "hockeyapp-coach://view-crash/#{app_id}/#{reason_id}/latest" end
filtered_versions_by_version_and_build(versions, version_filter, build_filter)
click to toggle source
# File lib/crep/model/crash_sources/hockeyapp_crash_source.rb, line 97 def filtered_versions_by_version_and_build(versions, version_filter, build_filter) versions.select do |version| (version.shortversion == version_filter) && (version.version == build_filter) end end
hockeyapp(bundle_identifier, client)
click to toggle source
# File lib/crep/model/crash_sources/hockeyapp_crash_source.rb, line 85 def hockeyapp(bundle_identifier, client) all_apps = client.get_apps apps = all_apps.select do |app| app.bundle_identifier == bundle_identifier end unless apps.first CrepLogger.error("No app with the give bundle identifier (#{bundle_identifier}) was found.") raise end apps.first end
unresolved_reasons(reasons)
click to toggle source
# File lib/crep/model/crash_sources/hockeyapp_crash_source.rb, line 81 def unresolved_reasons(reasons) reasons.reject(&:fixed) end
url(app_id:, version_id:, reason_id:)
click to toggle source
# File lib/crep/model/crash_sources/hockeyapp_crash_source.rb, line 58 def url(app_id:, version_id:, reason_id:) "https://rink.hockeyapp.net/manage/apps/#{app_id}/app_versions/#{version_id}/crash_reasons/#{reason_id}" end
version(version:, build:)
click to toggle source
# File lib/crep/model/crash_sources/hockeyapp_crash_source.rb, line 66 def version(version:, build:) filtered_versions = filtered_versions_by_version_and_build(@hockeyapp_app.versions, version, build) if filtered_versions.count <= 0 CrepLogger.error("No version was found for #{version})#{build})") raise end report_version = filtered_versions.first CrepLogger.warn("Multiple results for #{version}/#{build} were found, using the first (with ID #{report_version.id}) one that was found") unless filtered_versions.count <= 1 report_version end