Sha256: 42a9608fcd4ecfbd75857e83e1ebc05fdc0ad8db39363062c35ae15d6bbd6cfa

Contents?: true

Size: 539 Bytes

Versions: 2

Compression:

Stored size: 539 Bytes

Contents

module Ahoy
  class EventsController < Ahoy::BaseController

    def create
      events = params[:name] ? [params] : ActiveSupport::JSON.decode(request.body.read)
      events.each do |event|
        time = Time.zone.parse(event["time"]) rescue nil

        # timestamp is deprecated
        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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ahoy_matey-1.0.1 app/controllers/ahoy/events_controller.rb
ahoy_matey-1.0.0 app/controllers/ahoy/events_controller.rb