From 826ee3403b46d2e015869d10c373241541e127ba Mon Sep 17 00:00:00 2001 From: Harro Date: Fri, 6 Dec 2013 13:52:59 -0500 Subject: [PATCH] can set minimum app version. api filters out errors with app-version less than this amount. filtering only happens if both min_app_version and app-version are set. --- app/controllers/notices_controller.rb | 14 ++++++++++---- app/models/app.rb | 1 + app/models/error_report.rb | 24 ++++++++++++++++++++++++ app/views/apps/_fields.html.haml | 5 ++++- app/views/apps/show.html.haml | 3 +++ 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/app/controllers/notices_controller.rb b/app/controllers/notices_controller.rb index 93acb42..f1c0226 100644 --- a/app/controllers/notices_controller.rb +++ b/app/controllers/notices_controller.rb @@ -11,11 +11,17 @@ class NoticesController < ApplicationController report = ErrorReport.new(notice_params) if report.valid? - report.generate_notice! - api_xml = report.notice.to_xml(:only => false, :methods => [:id]) do |xml| - xml.url locate_url(report.notice.id, :host => Errbit::Config.host) + + if report.should_keep? + report.generate_notice! + api_xml = report.notice.to_xml(:only => false, :methods => [:id]) do |xml| + xml.url locate_url(report.notice.id, :host => Errbit::Config.host) + end + render :xml => api_xml + else + render :nothing => true end - render :xml => api_xml + else render :text => "Your API key is unknown", :status => 422 end diff --git a/app/models/app.rb b/app/models/app.rb index 043fcff..0e5de99 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -9,6 +9,7 @@ class App field :bitbucket_repo field :asset_host field :repository_branch + field :min_app_version field :resolve_errs_on_deploy, :type => Boolean, :default => false field :notify_all_users, :type => Boolean, :default => false field :notify_on_errs, :type => Boolean, :default => true diff --git a/app/models/error_report.rb b/app/models/error_report.rb index b00b5df..40b50d8 100644 --- a/app/models/error_report.rb +++ b/app/models/error_report.rb @@ -72,6 +72,30 @@ class ErrorReport !!app end + def should_keep? + + app_version = server_environment['app-version'] || '' + + if self.app.min_app_version.present? + + if app_version.length > 0 + + if Gem::Version.new(app_version) >= Gem::Version.new(self.app.min_app_version) + true + else + false + end + + else + true + end + + else + true + end + + end + private def fingerprint diff --git a/app/views/apps/_fields.html.haml b/app/views/apps/_fields.html.haml index ca9bbab..e63262b 100644 --- a/app/views/apps/_fields.html.haml +++ b/app/views/apps/_fields.html.haml @@ -22,7 +22,10 @@ = f.label :asset_host %em Used to generate links for JavaScript errors = f.text_field :asset_host, :placeholder => "e.g. https://assets.example.com" - +%div + = f.label :min_app_version + %em Use with mobile apps to drop errors from old versions that have already been fixed + = f.text_field :min_app_version, :placeholder => "e.g. 2.0.1 from the Bundle Identifier on an iOS app" %fieldset %legend Notifications %div.checkbox diff --git a/app/views/apps/show.html.haml b/app/views/apps/show.html.haml index f44216a..034e557 100644 --- a/app/views/apps/show.html.haml +++ b/app/views/apps/show.html.haml @@ -2,6 +2,9 @@ - content_for :head do = auto_discovery_link_tag :atom, app_path(app, User.token_authentication_key => current_user.authentication_token, :format => "atom"), :title => t('.atom_title', :name => app.name, :host => request.host) - content_for :meta do + - if app.min_app_version.present? + %strong="Min App Version:" + = app.min_app_version %strong=t('.errors_caught') = app.problems.count %strong=t('.deploy_count') -- libgit2 0.21.2