# frozen_string_literal: true module Analytics class SnapshotsController < ActionController::API def create result = Analytics::SnapshotIngest.new( path: params[:path] || params[:page_path], device: params[:device], width: params[:width], height: params[:height], image: params[:image], remote_ip: request.remote_ip ).call return head :too_many_requests if result.rate_limited return render json: { ok: false, error: result.error }, status: :unprocessable_content unless result.ok render json: { ok: true, skipped: result.skipped }, status: :accepted end end end