Skip to content

armgit / maybe

Public Imported from GitHub
0

The personal finance app for everyone

Fix Sentry context for security details exception

Zach Gollwitzerf82f77466a97
diff --git a/app/jobs/fetch_security_info_job.rb b/app/jobs/fetch_security_info_job.rb
deleted file mode 100644
index e789222f..00000000
--- a/app/jobs/fetch_security_info_job.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-class FetchSecurityInfoJob < ApplicationJob
- queue_as :low_priority
-
- def perform(security_id)
- return unless Security.provider.present?
-
- security = Security.find(security_id)
-
- params = {
- ticker: security.ticker
- }
- params[:mic_code] = security.exchange_mic if security.exchange_mic.present?
- params[:operating_mic] = security.exchange_operating_mic if security.exchange_operating_mic.present?
-
- security_info_response = Security.provider.fetch_security_info(**params)
-
- security.update(
- name: security_info_response.info.dig("name")
- )
- end
-end
diff --git a/app/models/security/provided.rb b/app/models/security/provided.rb
index 221acde5..7927d6e6 100644
--- a/app/models/security/provided.rb
+++ b/app/models/security/provided.rb
@@ -75,7 +75,7 @@ module Security::Provided
Rails.logger.warn("Failed to fetch security info for #{ticker} from #{provider.class.name}: #{response.error.message}")
Sentry.capture_exception(SecurityInfoMissingError.new("Failed to get security info"), level: :warning) do |scope|
scope.set_tags(security_id: self.id)
- scope.set_context(provider_error: response.error.message)
+ scope.set_context("security", { id: self.id, provider_error: response.error.message })
end
end
end