Skip to content

Commit

Permalink
[Cloud Posture] track application views (#144665)
Browse files Browse the repository at this point in the history
  • Loading branch information
orouz authored Nov 7, 2022
1 parent f29982c commit abf0d0f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/cloud_security_posture/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"cloud",
"licensing"
],
"requiredBundles": ["kibanaReact"],
"requiredBundles": ["kibanaReact", "usageCollection"],
"optionalPlugins": ["usageCollection"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import React from 'react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { Redirect, Route, RouteComponentProps, type RouteProps, Switch } from 'react-router-dom';
import { TrackApplicationView } from '@kbn/usage-collection-plugin/public';
import { CLOUD_SECURITY_POSTURE_BASE_PATH, type CspSecuritySolutionContext } from '..';
import { cloudPosturePages } from '../common/navigation/constants';
import type { CloudSecurityPosturePageId, CspPageNavigationItem } from '../common/navigation/types';
Expand Down Expand Up @@ -50,7 +51,9 @@ export const addSpyRouteComponentToRoute = (
render: (props: RouteComponentProps) => (
<>
<SpyRoute pageName={route.id} />
<Component {...props} />
<TrackApplicationView viewId={route.id}>
<Component {...props} />
</TrackApplicationView>
</>
),
};
Expand Down
6 changes: 6 additions & 0 deletions x-pack/plugins/cloud_security_posture/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import type { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plu
import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
import type { DiscoverStart } from '@kbn/discover-plugin/public';
import type { FleetSetup, FleetStart } from '@kbn/fleet-plugin/public';
import type {
UsageCollectionSetup,
UsageCollectionStart,
} from '@kbn/usage-collection-plugin/public';
import type { CspRouterProps } from './application/csp_router';
import type { BreadcrumbEntry, CloudSecurityPosturePageId } from './common/navigation/types';

Expand All @@ -36,6 +40,7 @@ export interface CspClientPluginSetupDeps {
fleet: FleetSetup;
cloud: CloudSetup;
// optional
usageCollection?: UsageCollectionSetup;
}

export interface CspClientPluginStartDeps {
Expand All @@ -47,6 +52,7 @@ export interface CspClientPluginStartDeps {
fleet: FleetStart;
licensing: LicensingPluginStart;
// optional
usageCollection?: UsageCollectionStart;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const CloudSecurityPosture = memo(() => {
};

return (
// TODO: Finer granularity of this needs to be implemented in the cloud security posture plugin
<PluginTemplateWrapper>
<TrackApplicationView viewId="cloud_security_posture">
<SecuritySolutionPageWrapper noPadding noTimeline>
Expand Down

0 comments on commit abf0d0f

Please sign in to comment.