Communicates with a business intelegance tool Mixpanel. We use this for internal reporting and anlytics. This is a wapper class around Mixpanel::Tracker.
Constants
| CAPTCHA_MEMBER | = | OpenStruct.new(id: 1) |
Note: We are adding the +Solved Captcha+ event to the 1st user in |
||
| EVENTS | = | { accepted_billing: "Accepted Billing", canceled_plan: "Canceled Plan", connected_billing: "Connected Billing", connected_stripe: "Connected Stripe", created_account: "Created Account", created_organization: "Created Organization", created_plan: "Created Plan", created_site: "Created Site", installed_javascript: "Installed JavaScript", invited_admin: "Invited Admin", joined_plan: "Joined Plan", paid_subscription: "Paid Subscription", received_payment: "Received Payment", record_payment: "Record Payment", solved_captcha: "Solved Captcha" } |
Class Public methods
track(event, args) Link
Generates an event in Mixpanel. Based on the event type we provide specific properties that correspond with that event.
Attributes
-
event- a valid event from theEVENTSconstant -
args- aHashof objects from where property values are accessed
An EventNotFound will be raised if the event supplied is not listed in the EVENTS constant.
Special Side Affects
Calling track(:created_site, member: member, site: site) will also execute a corresponding call to update_profile(site: site).
Example
member = DB::Member.first
Service::Mixpanel.track(:created_organization, member: member)
Source: show
# File app/services/service/mixpanel.rb, line 82 def track(event, args) raise EventNotFound, "#{event} is not a valid event" unless EVENTS[event] new.send("track_#{event}", **args) end
update_profile(site: nil, member: nil) Link
Updates or creates a new profile in an event in Mixpanel. Based on the group key we provide specific properties that correspond with that profile.
Hash
-
site- object -
member- object
An ArgumentError will be raised if the anything other than site or member keys are supplied.
Example
# Update both a site and a member profile.
member = DB::Member.first
site = DB::Site.first
Service::Mixpanel.update_profile(site: site, member: member)
Source: show
# File app/services/service/mixpanel.rb, line 107 def update_profile(site: nil, member: nil) new.send(:update_site_profile, site) if site new.send(:update_member_profile, member) if member end