Skip to content

Commit

Permalink
can set minimum app version. api filters out errors with app-version …
Browse files Browse the repository at this point in the history
…less than this amount. filtering only happens if both min_app_version and app-version are set.
  • Loading branch information
Harro committed Dec 6, 2013
1 parent 6ce9ef1 commit 826ee34
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
14 changes: 10 additions & 4 deletions app/controllers/notices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ def create
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
Expand Down
1 change: 1 addition & 0 deletions app/models/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions app/models/error_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,30 @@ def valid?
!!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
Expand Down
5 changes: 4 additions & 1 deletion app/views/apps/_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions app/views/apps/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 826ee34

Please sign in to comment.