diff --git a/app/models/plaid_account.rb b/app/models/plaid_account.rb index 2c1d0a30..240b7c18 100644 --- a/app/models/plaid_account.rb +++ b/app/models/plaid_account.rb @@ -158,19 +158,21 @@ class PlaidAccount < ApplicationRecord end def get_security(plaid_security, securities) - security = nil + return nil if plaid_security.nil? - if plaid_security.ticker_symbol.present? - security = plaid_security + security = if plaid_security.ticker_symbol.present? + plaid_security else - security = securities.find { |s| s.security_id == plaid_security.proxy_security_id } + securities.find { |s| s.security_id == plaid_security.proxy_security_id } end + return nil if security.nil? || security.ticker_symbol.blank? + Security.find_or_create_by!( ticker: security.ticker_symbol, exchange_mic: security.market_identifier_code || "XNAS", country_code: "US" - ) if security.present? + ) end def transfer?(plaid_txn) diff --git a/app/models/sync.rb b/app/models/sync.rb index 84e078da..e818b486 100644 --- a/app/models/sync.rb +++ b/app/models/sync.rb @@ -29,6 +29,7 @@ class Sync < ApplicationRecord end def fail!(error) + Sentry.capture_exception(error) update! status: :failed, error: error.message, last_ran_at: Time.current end end diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb index 56e6b4fc..e4ce7417 100644 --- a/config/initializers/sentry.rb +++ b/config/initializers/sentry.rb @@ -1,8 +1,9 @@ if ENV["SENTRY_DSN"].present? Sentry.init do |config| config.dsn = ENV["SENTRY_DSN"] + config.environment = ENV["RAILS_ENV"] config.breadcrumbs_logger = [ :active_support_logger, :http_logger ] - config.enabled_environments = %w[production] + config.enabled_environments = %w[development production] # Set traces_sample_rate to 1.0 to capture 100% # of transactions for performance monitoring.