Class: Skadi::TrackingController

Inherits:
ActionController::API
  • Object
show all
Includes:
ActionController::Cookies
Defined in:
app/controllers/skadi/tracking_controller.rb

Instance Method Summary collapse

Instance Method Details

#limit_payload_size!Object



100
101
102
103
104
# File 'app/controllers/skadi/tracking_controller.rb', line 100

def limit_payload_size!
  if request.content_length && request.content_length > Skadi.configuration.max_tracking_payload_size
    render json: { error: "Payload too large" }, status: :content_too_large
  end
end

#trackObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/skadi/tracking_controller.rb', line 15

def track
  if @params["exit_page"].present? && @params["exit_page"].is_a?(String)
    @view.exit_page = Skadi::Url.redact_and_normalise_url(@params["exit_page"])
  end

  handle_consent @params["consent"]

  if @params["events"].present? && @params["events"].is_a?(Array)
    handle_events @params["events"]
  end

  if @params["demographics"].present? && @params["demographics"].is_a?(Array)
    handle_demographics @params["demographics"]
  end

  @view.verified = true
  @view.visit.verified = true if @view.visit

  skadi._persist

  head :no_content
end