Module: Statsman::Accountable
- Defined in:
- lib/statsman/accountable.rb
Overview
Include this module into your ActiveRecord models to get some convenience methods for sending stats
Instance Method Summary collapse
-
#statsman_change(change_type, mrr_difference, meta = {}) ⇒ Object
change_type can be anything you want, as it’s just used as a part of the stat key name.
- #statsman_counter(key, value, meta = {}) ⇒ Object
- #statsman_payment(successful_payment, amount, meta = {}) ⇒ Object
- #statsman_value(key, value, meta = {}) ⇒ Object
Instance Method Details
#statsman_change(change_type, mrr_difference, meta = {}) ⇒ Object
change_type can be anything you want, as it’s just used as a part of the stat key name. Some common types could be:
referral, upgrade, downgrade, signup,
conversion, cancel, lapse, unlapse
mrr_difference: in cents meta: optional hash of other data
25 26 27 28 29 30 31 |
# File 'lib/statsman/accountable.rb', line 25 def statsman_change(change_type, mrr_difference, = {}) class_name = self.class.name.downcase Statsman.send_value "#{class_name}_change_#{change_type}", mrr_difference, set_class_id() end |
#statsman_counter(key, value, meta = {}) ⇒ Object
9 10 11 |
# File 'lib/statsman/accountable.rb', line 9 def statsman_counter(key, value, = {}) Statsman.send_counter key, value, set_class_id() end |
#statsman_payment(successful_payment, amount, meta = {}) ⇒ Object
33 34 35 36 37 |
# File 'lib/statsman/accountable.rb', line 33 def statsman_payment(successful_payment, amount, = {}) Statsman.send_value "payment_#{successful_payment ? "success" : "failed"}", amount, set_class_id() end |
#statsman_value(key, value, meta = {}) ⇒ Object
13 14 15 |
# File 'lib/statsman/accountable.rb', line 13 def statsman_value(key, value, = {}) Statsman.send_value key, value, set_class_id() end |