Skip to content

Commit b600085

Browse files
polypixeldevdavidcornuLuke-Oldenburggaryhtou
authored
Migrate all Airbrake usage to Appsignal (#10801)
## Summary of the problem <!-- Why these changes are being made? What problem does it solve? Link any related issues to provide more details. --> There's only room for one error reporter in this codebase... and Appsignal gives us better reports! ## Describe your changes <!-- Explain your thought process to the solution and provide a quick summary of the changes. --> Changed all `Airbrake.notify` and `notify_airbrake` statements to use the Rails error reporter, which is handled by Appsignal. Also changed the frontend error reporting to use Appsignal, and updated docs. Before deploying, make sure to set the `APPSIGNAL_API_KEY` environment variable to the appropriate key from Appsignal - https://docs.appsignal.com/front-end/installation.html#creating-a-push-api-key --------- Co-authored-by: David Cornu <[email protected]> Co-authored-by: Luke Oldenburg <[email protected]> Co-authored-by: Gary Tou <[email protected]>
1 parent aacdaba commit b600085

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+113
-333
lines changed

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ gem "diffy" # rendering diffs (comments)
113113
gem "webauthn", "~> 3.2"
114114

115115
gem "ahoy_matey" # analytics
116-
gem "airbrake" # exception tracking
117116
gem "blazer" # business intelligence tool/dashboard
118117

119118
gem "geo_pattern" # create procedurally generated patterns for Cards

Gemfile.lock

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ GEM
127127
activesupport (>= 7)
128128
device_detector (>= 1)
129129
safely_block (>= 0.4)
130-
airbrake (13.0.5)
131-
airbrake-ruby (~> 6.0)
132-
airbrake-ruby (6.2.2)
133-
rbtree3 (~> 0.6)
134130
airrecord (1.0.12)
135131
faraday (>= 1.0, < 3.0)
136132
faraday-net_http_persistent
@@ -657,7 +653,6 @@ GEM
657653
ffi (~> 1.0)
658654
rbs (3.9.2)
659655
logger
660-
rbtree3 (0.7.1)
661656
rdoc (6.14.0)
662657
erb
663658
psych (>= 4.0.0)
@@ -881,7 +876,6 @@ DEPENDENCIES
881876
actual_db_schema
882877
ahoy_email (~> 2.4)
883878
ahoy_matey
884-
airbrake
885879
airrecord (~> 1.0)
886880
annotaterb
887881
api-pagination

app/controllers/api/v4/stripe_cards_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def create
6868
render :show
6969

7070
rescue => e
71-
notify_airbrake(e)
71+
Rails.error.report e
7272
render json: { error: "internal_server_error" }, status: :internal_server_error
7373
end
7474

app/controllers/errors_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def timeout
2222

2323
def error
2424
@code = params[:code]
25-
Airbrake.notify("/#{@code} rendered.")
25+
Rails.error.unexpected "/#{@code} rendered."
2626
render status: params[:code], layout: "application"
2727
end
2828

app/controllers/stripe_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def handle_charge_dispute_funds_withdrawn(event)
169169

170170
donation = Donation.find_by(stripe_payment_intent_id: dispute[:payment_intent])
171171

172-
return notify_airbrake("Received charge dispute on nonexistent donation") if donation.nil?
172+
return Rails.error.unexpected("Received charge dispute on nonexistent donation") if donation.nil?
173173

174174
# Let's un-front the transaction.
175175
donation.canonical_pending_transactions.update_all(fronted: false)
@@ -178,7 +178,7 @@ def handle_charge_dispute_funds_withdrawn(event)
178178

179179
invoice = Invoice.find_by(stripe_charge_id: dispute[:charge])
180180

181-
return notify_airbrake("Received charge dispute on nonexistent invoice") if invoice.nil?
181+
return Rails.error.unexpected("Received charge dispute on nonexistent invoice") if invoice.nil?
182182

183183
invoice.canonical_pending_transactions.update_all(fronted: false)
184184
end
@@ -306,14 +306,14 @@ def handle_issuing_dispute_funds_reinstated(event)
306306
}
307307
)
308308
elsif dispute["status"] != "won"
309-
Airbrake.notify("Dispute with funds reinstated but without a win: #{dispute["id"]}")
309+
Rails.error.unexpected "Dispute with funds reinstated but without a win: #{dispute["id"]}"
310310
elsif dispute["currency"] != "usd"
311-
Airbrake.notify("Dispute with funds reinstated but non-USD currency. Must be manually handled.")
311+
Rails.error.unexpected "Dispute with funds reinstated but non-USD currency. Must be manually handled."
312312
end
313313
end
314314

315315
def handle_refund_failed(event)
316-
Airbrake.notify("Refund failed on Stripe: #{event}.")
316+
Rails.error.unexpected "Refund failed on Stripe: #{event}."
317317
end
318318

319319
end

app/controllers/webauthn_credentials_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def create
4343

4444
redirect_back fallback_location: edit_user_path(user), flash: { success: "Registered security key!" }
4545
rescue WebAuthn::Error => e
46-
Airbrake.notify(e)
46+
Rails.error.report e
4747
redirect_back fallback_location: edit_user_path(user), flash: { error: "Something went wrong registering a security key." }
4848
end
4949
end

app/helpers/application_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def help_phone
226226

227227
def format_date(date)
228228
if date.nil?
229-
Airbrake.notify("Hey! date is nil here")
229+
Rails.error.unexpected "Hey! date is nil here"
230230
return nil
231231
end
232232

app/javascript/airbrake.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

app/javascript/appsignal.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* global APPSIGNAL_FRONTEND */
2+
3+
import Appsignal from '@appsignal/javascript'
4+
5+
export const appsignal = new Appsignal({
6+
key: APPSIGNAL_FRONTEND,
7+
})

app/javascript/controllers/file_drop_controller.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Controller } from '@hotwired/stimulus'
22
import submitForm from '../common/submitForm'
3-
import airbrake from '../airbrake'
3+
import { appsignal } from '../appsignal'
44

55
let dropzone
66

@@ -17,7 +17,6 @@ function extractId(dataTransfer) {
1717
receiptId = imgTag.getAttribute('data-receipt-id')
1818
} catch (err) {
1919
console.error(err)
20-
// airbrake?.notify(err)
2120
}
2221

2322
if (!receiptId) {
@@ -33,7 +32,7 @@ function extractId(dataTransfer) {
3332
receiptId = imageElement.getAttribute('data-receipt-id')
3433
} catch (err) {
3534
console.error(err)
36-
airbrake?.notify(err)
35+
appsignal.sendError(err)
3736
}
3837
}
3938

0 commit comments

Comments
 (0)