MixTape
The Problem
Littering controllers with MixPanel events with large param payloads isn't a nice thing to do.
MixTape tries to help by creating a DSL for specifying your events in advance, and keeping them in a single file.
Defining your Events
MixTape::Builder.definition do
"Log number of times user clicks button" do |user, |
{
user_name: user.username,
distinct_id: user.id,
button_id: .id,
button_page: .page
}
end
checks_mail "User just checked their mail" do |user, inbox|
{
distinct_id: user.id,
user_name: user.username,
user_id: user.id,
unread_count: inbox.count
}
end
user_invites_friend "User has invited a friend" do |user, friend|
{
distinct_id: user.id,
user_name: user.username,
user_id: user.id,
friend_name: friend.name
}
end
end
To track a defined event:
MixTape.track_user_invites_friend(user, friend)
To update an existing event object:
MixTape.set_user_invites_friend(user, friend)
Available Events
To view defined events:
rake mix_tape:events
Installation
Add this line to your application's Gemfile:
gem 'mix_tape'
Don't forget to set your MixPanel API token:
MixTape.config do |config|
config.token = '12345'
end
And then execute:
$ bundle
Or install it yourself as:
$ gem install mix_tape
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request