Commit 826ee3403b46d2e015869d10c373241541e127ba
1 parent
6ce9ef1b
Exists in
master
and in
1 other branch
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.
Showing
5 changed files
with
42 additions
and
5 deletions
Show diff stats
app/controllers/notices_controller.rb
@@ -11,11 +11,17 @@ class NoticesController < ApplicationController | @@ -11,11 +11,17 @@ class NoticesController < ApplicationController | ||
11 | report = ErrorReport.new(notice_params) | 11 | report = ErrorReport.new(notice_params) |
12 | 12 | ||
13 | if report.valid? | 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 | end | 23 | end |
18 | - render :xml => api_xml | 24 | + |
19 | else | 25 | else |
20 | render :text => "Your API key is unknown", :status => 422 | 26 | render :text => "Your API key is unknown", :status => 422 |
21 | end | 27 | end |
app/models/app.rb
@@ -9,6 +9,7 @@ class App | @@ -9,6 +9,7 @@ class App | ||
9 | field :bitbucket_repo | 9 | field :bitbucket_repo |
10 | field :asset_host | 10 | field :asset_host |
11 | field :repository_branch | 11 | field :repository_branch |
12 | + field :min_app_version | ||
12 | field :resolve_errs_on_deploy, :type => Boolean, :default => false | 13 | field :resolve_errs_on_deploy, :type => Boolean, :default => false |
13 | field :notify_all_users, :type => Boolean, :default => false | 14 | field :notify_all_users, :type => Boolean, :default => false |
14 | field :notify_on_errs, :type => Boolean, :default => true | 15 | field :notify_on_errs, :type => Boolean, :default => true |
app/models/error_report.rb
@@ -72,6 +72,30 @@ class ErrorReport | @@ -72,6 +72,30 @@ class ErrorReport | ||
72 | !!app | 72 | !!app |
73 | end | 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 | private | 99 | private |
76 | 100 | ||
77 | def fingerprint | 101 | def fingerprint |
app/views/apps/_fields.html.haml
@@ -22,7 +22,10 @@ | @@ -22,7 +22,10 @@ | ||
22 | = f.label :asset_host | 22 | = f.label :asset_host |
23 | %em Used to generate links for JavaScript errors | 23 | %em Used to generate links for JavaScript errors |
24 | = f.text_field :asset_host, :placeholder => "e.g. https://assets.example.com" | 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 | %fieldset | 29 | %fieldset |
27 | %legend Notifications | 30 | %legend Notifications |
28 | %div.checkbox | 31 | %div.checkbox |
app/views/apps/show.html.haml
@@ -2,6 +2,9 @@ | @@ -2,6 +2,9 @@ | ||
2 | - content_for :head do | 2 | - content_for :head do |
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) | 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 | - content_for :meta do | 4 | - content_for :meta do |
5 | + - if app.min_app_version.present? | ||
6 | + %strong="Min App Version:" | ||
7 | + = app.min_app_version | ||
5 | %strong=t('.errors_caught') | 8 | %strong=t('.errors_caught') |
6 | = app.problems.count | 9 | = app.problems.count |
7 | %strong=t('.deploy_count') | 10 | %strong=t('.deploy_count') |