Behaviour for a single analysis capability (frequency, aggregate, time_bucket, percentile, histogram, ...).
AshDyan's analysis types were previously a closed sum type scattered across
parallel case/when clauses in AshDyan.Request, AshDyan.Engine,
AshDyan.Engine.Formatter, and AshDyan.Charts. Implementing this behaviour
and registering the module under config :ash_dyan, :analysis_types lets a
downstream app add a new analysis type (e.g. :funnel, :cohort) without
forking AshDyan.
Example
defmodule MyApp.AshDyan.Funnel do
@behaviour AshDyan.Analysis
# ... implement the four callbacks ...
end
# config/config.exs
config :ash_dyan, :analysis_types, %{funnel: MyApp.AshDyan.Funnel}The request's :type is the registry key.
Summary
Callbacks
@callback format(AshDyan.Request.t(), [Ash.Resource.Record.t()]) :: {:ok, AshDyan.Result.t()} | {:error, term()}
@callback recommend_chart(AshDyan.Result.t()) :: AshDyan.Charts.chart_type()
@callback select_fields(AshDyan.Request.t()) :: [atom()]
@callback validate(AshDyan.Request.t()) :: :ok | {:error, AshDyan.Error.t()}