Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class ApplicationController < ActionController::Base
after_action :track_event
private
def track_event
mixpanel.track(event_user, event_name)
end
def event_user
current_user.try(:id).to_s
end
def event_name
controller_action = "#{params[:controller]}##{params[:action]}"
EVENT_TRANSLATIONS[controller_action] || controller_action
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment