Add your add-on’s panel to the Analytics screen
When Analytics Dashboard is running on a show, its Analytics screen draws every panel in window.BenecasterExtensions.analyticsPanels after all of its own panels, with the screen’s current filters. Push your panel from your admin script; use ??= so it works whether your script or Analytics Dashboard’s loads first, and never assign the list.
props:showId(the show in Benecaster’s show switcher),scope('show', or'all'for every show where Analytics Dashboard is active; your route must apply the same per-show check),dateFrom/dateTo(UTCY-m-d, inclusive),tierSlug(nullfor every tier; apply it only if it means something to your data).orderis optional, default 100, lower first; panels with the sameordersort byid.renderruns as its own React component, so it may use hooks; fetch your own data there, sendingX-WP-Nonce: window.benecasterAdmin.nonce.- The box and the heading (
title) are drawn for you; return the body only. - An entry without a string
id, a stringtitleand arenderfunction, or reusing anid, is skipped with a console warning. A panel that throws shows This panel could not be drawn. in its own box and leaves the screen working. - Nothing is drawn where Analytics Dashboard is not running on the show: Benecaster draws its own card there. To show your data without Analytics Dashboard, keep your own screen.
Code
const { React, i18n } = window.BenecasterExtensions; // Benecaster's shared runtime: never bundle your own React
const ext = ( window.BenecasterExtensions ??= {} );
( ext.analyticsPanels ??= [] ).push( {
id: 'outlinks-clicks', // unique: prefix with your add-on
title: i18n.__( 'Link clicks', 'benecaster-outlinks' ),
order: 50, // optional, default 100; lower first
render: ( { showId, scope, dateFrom, dateTo, tierSlug } ) =>
React.createElement( LinkClicks, { showId, scope, dateFrom, dateTo } ),
} );
Need this built rather than just documented? See our services →