Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def write(type, attributes, plan)
- geo = resolve_geo(attributes[:remote_addr])
- listener =
- if attributes[:anonymous] == true
- -1
- else
- ( attributes[:user_id].to_i == 0 ? nil : attributes[:user_id].to_i )
- end
- event = {
- :type => type,
- :id => attributes[:id].to_i,
- :created_at => DateTime.parse(attributes[:created_at].to_s),
- :track => attributes[:track_id].to_i,
- :listener => listener,
- :owner => attributes[:owner_id].to_i,
- :country => geo[:country_code],
- :region => geo[:region],
- :app => attributes[:app],
- :referrer => attributes[:referrer],
- }.reject { |k,v| v.nil? }
- Stats::MongoStore.store(plan).write(event)
- end
Add Comment
Please, Sign In to add comment