View Source Plausible.Stats.Goal.Revenue (Plausible v0.0.1)

Revenue specific functions for the stats scope

Summary

Functions

Link to this function

format_revenue_metric(value, query, dimension_values)

View Source
Link to this function

preload_revenue_currencies(site, goals, metrics, dimensions)

View Source

Preloads revenue currencies for a query.

Assumptions and business logic:

  1. Goals are already filtered according to query filters and dimensions
  2. If there's a single currency involved, return map containing the default
  3. If there's a breakdown by event:goal we return all the relevant currencies as a map
  4. If filtering by multiple different currencies without event:goal breakdown empty map is returned
  5. If user has no access or preloading is not needed, empty map is returned

The resulting data structure is attached to a Query and used below in format_revenue_metric/3.