<commit_before>class TrackEngagement
  include Sidekiq::Worker
  sidekiq_options queue: 'analytics'

  EVENT_NAME = 'influenced'

  def perform(user_id, timestamp, verb, verb_subject, product_id)
    user = User.find(user_id)

    props = {
      verb: verb,
      verb_subject: verb_subject,
      verb_and_subject: "#{verb}.#{verb_subject}",
    }

    if product_id
      product = Product.find(product_id)
      props[:product_id] = product.id
      props[:product_slug] = product.slug
    end

    Analytics.track(
      user_id: user.id,
      event: EVENT_NAME,
      timestamp: Time.at(timestamp),
      properties: props
    )
  end
end
<commit_msg>make engagement metric overrideable<commit_after>class TrackEngagement
  include Sidekiq::Worker
  sidekiq_options queue: 'analytics'

  EVENT_NAME = (ENV['ENGAGEMENT_METRIC'] || 'influenced')

  def perform(user_id, timestamp, verb, verb_subject, product_id)
    user = User.find(user_id)

    props = {
      verb: verb,
      verb_subject: verb_subject,
      verb_and_subject: "#{verb}.#{verb_subject}",
    }

    if product_id
      product = Product.find(product_id)
      props[:product_id] = product.id
      props[:product_slug] = product.slug
    end

    Analytics.track(
      user_id: user.id,
      event: EVENT_NAME,
      timestamp: Time.at(timestamp),
      properties: props
    )
  end
end

{'fraction_non_alphanumeric': 0.10380116959064327, 'fraction_numerical': 0.0, 'mean_word_length': 3.0988023952095807, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6863946', 'n_tokens_mistral': 452, 'n_tokens_neox': 446, 'n_words': 92}