Skip to main content
The useAggregateEvents hook provides access to usage analytics and reporting data. It fetches data from the /events/aggregate endpoint, that can be displayed in a chart (typically via a library like Recharts).
Learn how to setup Autumn hooks in the Getting Started guide.

Parameters

featureId
string | string[]
required
The feature ID or array of feature IDs to query usage data for.
groupBy
string
Aggregate data by an event properties paramater. This property is metadata passed in the event endpoint. Should be formatted as properties.<event_property>
range
string
Time range for the analytics query. Available options: “24h”, “7d”, “30d”, “90d”, “last_cycle”, “1bc”, “3bc”. “bc” refers to billing cycle. Defaults to “30d” if not provided.
binSize
string
Granularity of the time bins for the data points. Available options: “day”, “hour”. Defaults to “day”.
customRange
object
Custom date range for the query. When provided, overrides the range parameter.
swrConfig
SWRConfiguration
Optional SWR configuration object to customize caching and revalidation behavior. Accepts a refreshInterval in milliseconds.

Returns

list

Array of aggregated event data points for each time period. Each AggregatedEventRow includes:
  • period: Unix timestamp in milliseconds representing the start of the time period
  • Dynamic properties for each queried featureId with their usage amounts

total

Aggregate totals for the entire time range. Returns a record with each feature ID as the key and an object containing:
  • count: Total number of events
  • sum: Total sum of all event values

isLoading

Boolean indicating whether the event data is currently being fetched.

error

Any AutumnError that occurred while fetching event data.

refetch()

Function to manually refetch the event data.