<commit_before>require 'stripe_event/base'

module StripeEvent
  module Customer
    module Source
      class Created < Base

        def call(event)
          card = event.data.object
          user = User.where(stripe_id: card.customer).first!
          membership = Membership.where(user: user).first!
          membership.update!(card_brand: card.brand, card_last4: card.last4)
        rescue ActiveRecord::RecordNotFound => e
          # Stripe is trying to tell us about a user we don't have :(
          Rollbar.error(e)
        end

      end
    end
  end
end<commit_msg>don't report opencollective users to rollbar<commit_after>require 'stripe_event/base'

module StripeEvent
  module Customer
    module Source
      class Created < Base

        def call(event)
          card = event.data.object

          # OpenCollective contributors don't have users
          user = User.where(stripe_id: card.customer).first
          return unless user

          membership = Membership.where(user: user).first!
          membership.update!(card_brand: card.brand, card_last4: card.last4)
        rescue ActiveRecord::RecordNotFound => e
          # Stripe is trying to tell us about a user we don't have :(
          Rollbar.error(e)
        end

      end
    end
  end
end
{'fraction_non_alphanumeric': 0.075, 'fraction_numerical': 0.003125, 'mean_word_length': 2.310077519379845, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '813895', 'n_tokens_mistral': 367, 'n_tokens_neox': 354, 'n_words': 104}