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).
Parameters
The feature ID or array of feature IDs to query usage data for.
Aggregate data by an event properties paramater. This property is metadata passed in the event endpoint. Should be formatted as
properties.<event_property>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.
Granularity of the time bins for the data points. Available options: “day”, “hour”. Defaults to “day”.
Custom date range for the query. When provided, overrides the
range parameter.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
featureIdwith 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 eventssum: 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.

