benecaster_analytics_tier_breakdown
Filters the tier breakdown for GET benecaster-analytics/v1/analytics/tier-breakdown: per tier and in total, a current and a prior period (the same number of days, ending the day before date_from), each one growth point over the whole period plus its opening_active, and a change of {active, active_pct}. active_pct is already a percentage, rounded to one decimal, and null when the prior count is 0 or unknown. It does not pass through benecaster_analytics_growth_series.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$data |
array |
— | The breakdown the route answers |
$args |
array |
— | The query: show_ids (only shows where the add-on is active), date_from and date_to (inclusive UTC Y-m-d), tier_slug |
Returns:
array
Example
add_filter( 'benecaster_analytics_tier_breakdown', function ( array $data, array $args ): array {
$data['total']['change']['label'] = sprintf( '%+d', (int) $data['total']['change']['active'] );
return $data;
}, 10, 2 );
Notes
Anything that is not an array is ignored and the unfiltered data is used. Guard with benecaster_addon_is_active( 'analytics-dashboard', $show_id ) for each show you act on. Walkthrough: Read the Analytics Dashboard tier breakdown and tier movement.
Need this built rather than just documented? See our services →