Skip to content

Commit

Permalink
Add a metric to track users joining / leaving the beta group
Browse files Browse the repository at this point in the history
Co-authored-by: Saray Cabrera Padrón <scabrerapadron@suse.de>
  • Loading branch information
bgeuken and saraycp committed Aug 24, 2018
1 parent 751521c commit 5d9a832
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/api/app/models/user.rb
Expand Up @@ -100,6 +100,7 @@ class User < ApplicationRecord
validates :password, confirmation: true, allow_blank: true

after_create :create_home_project, :track_create
before_save :send_metric_for_beta_change, if: :in_beta_changed?

def track_create
RabbitmqBus.send_to_bus('metrics', "user.create id=#{id}")
Expand Down Expand Up @@ -840,6 +841,11 @@ def mark_login!
update_attributes(last_logged_in_at: Time.now, login_failure_count: 0)
end

def send_metric_for_beta_change
channel = (in_beta? ? 'joined_beta' : 'left_beta')
RabbitmqBus.send_to_bus('metrics', "user.#{channel} value=1")
end

private

def password_validation
Expand Down

0 comments on commit 5d9a832

Please sign in to comment.