Created
February 20, 2012 12:42
-
-
Save kirs/1869045 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Modules | |
module FnordmetricEvent | |
class << self | |
def create(*options) | |
define_api | |
event_key = options[0] | |
raise "Pass the event key" unless event_key.present? | |
params = options[1] | |
if params | |
user_id = params.delete(:user).id if params[:user] | |
user_id = params.delete(:user_id) if params[:user_id] | |
end | |
params[:_type] = event_key.to_s | |
params[:_session] = "userid_#{user_id}" if user_id | |
@_api.event params | |
end | |
def write_user(user) | |
define_api | |
@_api.event({ _type: "_set_name", name: user.name, _session: "userid_#{user.id}" }) | |
end | |
private | |
def define_api | |
@_api ||= FnordMetric::API.new({}) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment