Commit 826ee3403b46d2e015869d10c373241541e127ba

Authored by Harro
1 parent 6ce9ef1b
Exists in master and in 1 other branch production

can set minimum app version. api filters out errors with app-version less than t…

…his amount. filtering only happens if both min_app_version and app-version are set.
app/controllers/notices_controller.rb
... ... @@ -11,11 +11,17 @@ class NoticesController < ApplicationController
11 11 report = ErrorReport.new(notice_params)
12 12  
13 13 if report.valid?
14   - report.generate_notice!
15   - api_xml = report.notice.to_xml(:only => false, :methods => [:id]) do |xml|
16   - xml.url locate_url(report.notice.id, :host => Errbit::Config.host)
  14 +
  15 + if report.should_keep?
  16 + report.generate_notice!
  17 + api_xml = report.notice.to_xml(:only => false, :methods => [:id]) do |xml|
  18 + xml.url locate_url(report.notice.id, :host => Errbit::Config.host)
  19 + end
  20 + render :xml => api_xml
  21 + else
  22 + render :nothing => true
17 23 end
18   - render :xml => api_xml
  24 +
19 25 else
20 26 render :text => "Your API key is unknown", :status => 422
21 27 end
... ...
app/models/app.rb
... ... @@ -9,6 +9,7 @@ class App
9 9 field :bitbucket_repo
10 10 field :asset_host
11 11 field :repository_branch
  12 + field :min_app_version
12 13 field :resolve_errs_on_deploy, :type => Boolean, :default => false
13 14 field :notify_all_users, :type => Boolean, :default => false
14 15 field :notify_on_errs, :type => Boolean, :default => true
... ...
app/models/error_report.rb
... ... @@ -72,6 +72,30 @@ class ErrorReport
72 72 !!app
73 73 end
74 74  
  75 + def should_keep?
  76 +
  77 + app_version = server_environment['app-version'] || ''
  78 +
  79 + if self.app.min_app_version.present?
  80 +
  81 + if app_version.length > 0
  82 +
  83 + if Gem::Version.new(app_version) >= Gem::Version.new(self.app.min_app_version)
  84 + true
  85 + else
  86 + false
  87 + end
  88 +
  89 + else
  90 + true
  91 + end
  92 +
  93 + else
  94 + true
  95 + end
  96 +
  97 + end
  98 +
75 99 private
76 100  
77 101 def fingerprint
... ...
app/views/apps/_fields.html.haml
... ... @@ -22,7 +22,10 @@
22 22 = f.label :asset_host
23 23 %em Used to generate links for JavaScript errors
24 24 = f.text_field :asset_host, :placeholder => "e.g. https://assets.example.com"
25   -
  25 +%div
  26 + = f.label :min_app_version
  27 + %em Use with mobile apps to drop errors from old versions that have already been fixed
  28 + = f.text_field :min_app_version, :placeholder => "e.g. 2.0.1 from the Bundle Identifier on an iOS app"
26 29 %fieldset
27 30 %legend Notifications
28 31 %div.checkbox
... ...
app/views/apps/show.html.haml
... ... @@ -2,6 +2,9 @@
2 2 - content_for :head do
3 3 = 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)
4 4 - content_for :meta do
  5 + - if app.min_app_version.present?
  6 + %strong="Min App Version:"
  7 + = app.min_app_version
5 8 %strong=t('.errors_caught')
6 9 = app.problems.count
7 10 %strong=t('.deploy_count')
... ...