Skip to main content

Draw the Analytics Screen from the Analytics Dashboard Add-on

Free Advanced

Benecaster owns the Analytics menu item and the #/analytics route. The Analytics Dashboard add-on fills one slot, BenecasterAnalyticsScreen, and Benecaster decides, show by show, whether to render it.

The fill receives { showId, path, navigate, setDirty }. path is the rest of the address after /analytics/, so one fill can serve sub-screens such as #/analytics/settings, and navigate( 'settings' ) moves there.

Code

const AnalyticsScreen = ( { showId, path } ) => {
    if ( path === 'settings' ) {
        return <AnalyticsSettings showId={ showId } />;
    }
    return <AnalyticsOverview showId={ showId } />;
};

window.BenecasterExtensions?.registerFill( 'BenecasterAnalyticsScreen', AnalyticsScreen );

View on GitHub →

Need this built rather than just documented? See our services →