src/platform/packages/shared/content-management/content_insights/README.mdx
The Content Insights is a set of Content Management services and components to provide insights on the content of Kibana. Currently, it allows to track the usage of your content and display the stats of it.
viewed// server side
import { registerContentInsights } from '@kbn/content-management-content-insights-server';
if (plugins.usageCollection) {
// Registers routes for tracking and fetching dashboard views
registerContentInsights(
{
usageCollection: plugins.usageCollection,
http: core.http,
getStartServices: () =>
core.getStartServices().then(([_, start]) => ({
usageCollection: start.usageCollection!,
})),
},
{
domainId: 'dashboard',
// makes sure that only users with read/all access to dashboard app can access the routes
routePrivileges: ['dashboardUsageStats'],
}
);
}
// client side
import { ContentInsightsClient } from '@kbn/content-management-content-insights-public';
const contentInsightsClient = new ContentInsightsClient(
{ http: params.coreStart.http },
{ domainId: 'dashboard' }
);
contentInsightsClient.track(dashboardId, 'viewed');
// wrap component in `ContentInsightsProvider` and use the hook to open an insights flyout
const openInsightsFlyout = useOpenInsightsFlyout();
openInsightsFlyout({ item });