defmodule Aprsme.ApiMetrics do
  @moduledoc """
  Emits telemetry events for API and WebSocket usage, consumed by PromEx for
  Prometheus metrics.

  Designed to be called from the same code paths as `PlausibleAnalytics.track/3`
  so that both analytics (Plausible) and monitoring (Prometheus) receive the same
  data.
  """

  @doc """
  Emits an `[:aprsme, :api, :request]` telemetry event with the event name
  and HTTP/WS metadata.
  """
  @spec track(map(), String.t()) :: :ok
  def track(_metadata, event_name) do
    :telemetry.execute([:aprsme, :api, :request], %{count: 1}, %{event: event_name})
  end
end
