3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/ahoy/events_controller.rb', line 3
def create
events =
if params[:name]
[request.params]
elsif params[:events]
request.params[:events]
else
begin
ActiveSupport::JSON.decode(request.body.read)
rescue ActiveSupport::JSON.parse_error
[]
end
end
events.first(Ahoy.max_events_per_request).each do |event|
time = Time.zone.parse(event["time"]) rescue nil
time ||= Time.zone.at(event["time"].to_f) rescue nil
options = {
id: event["id"],
time: time
}
ahoy.track event["name"], event["properties"], options
end
render json: {}
end
|