diff --git a/src/plugins/home/public/application/components/__snapshots__/home.test.js.snap b/src/plugins/home/public/application/components/__snapshots__/home.test.js.snap index e9b0494105e12..b949fa7995d30 100644 --- a/src/plugins/home/public/application/components/__snapshots__/home.test.js.snap +++ b/src/plugins/home/public/application/components/__snapshots__/home.test.js.snap @@ -44,6 +44,8 @@ exports[`home change home route should render a link to change the default route /> @@ -94,6 +96,8 @@ exports[`home directories should not render directory entry when showOnHomePage /> @@ -156,6 +160,8 @@ exports[`home directories should render ADMIN directory entry in "Manage your da /> @@ -218,6 +224,8 @@ exports[`home directories should render DATA directory entry in "Ingest your dat /> @@ -320,6 +328,8 @@ exports[`home directories should render solutions in the "solution section" 1`] /> @@ -370,6 +380,8 @@ exports[`home header render 1`] = ` /> @@ -432,6 +444,8 @@ exports[`home header should show "Dev tools" link if console is available 1`] = /> @@ -482,6 +496,8 @@ exports[`home header should show "Manage" link if stack management is available /> @@ -532,6 +548,8 @@ exports[`home isNewKibanaInstance should safely handle execeptions 1`] = ` /> @@ -582,6 +600,8 @@ exports[`home isNewKibanaInstance should set isNewKibanaInstance to false when t /> @@ -632,6 +652,8 @@ exports[`home isNewKibanaInstance should set isNewKibanaInstance to true when th /> @@ -682,6 +704,8 @@ exports[`home should render home component 1`] = ` /> @@ -732,6 +756,8 @@ exports[`home welcome should show the normal home page if loading fails 1`] = ` /> @@ -782,6 +808,8 @@ exports[`home welcome should show the normal home page if welcome screen is disa /> @@ -839,6 +867,8 @@ exports[`home welcome stores skip welcome setting if skipped 1`] = ` /> diff --git a/src/plugins/home/public/application/components/add_data/add_data.test.tsx b/src/plugins/home/public/application/components/add_data/add_data.test.tsx index b6d97db7388cc..9ba554dd2c222 100644 --- a/src/plugins/home/public/application/components/add_data/add_data.test.tsx +++ b/src/plugins/home/public/application/components/add_data/add_data.test.tsx @@ -27,6 +27,12 @@ jest.mock('../app_navigation_handler', () => { }; }); +jest.mock('../../kibana_services', () => ({ + getServices: () => ({ + trackUiMetric: jest.fn(), + }), +})); + beforeEach(() => { jest.clearAllMocks(); }); diff --git a/src/plugins/home/public/application/components/add_data/add_data.tsx b/src/plugins/home/public/application/components/add_data/add_data.tsx index 0311c1fc5e5c6..eb710f0fcc168 100644 --- a/src/plugins/home/public/application/components/add_data/add_data.tsx +++ b/src/plugins/home/public/application/components/add_data/add_data.tsx @@ -17,69 +17,78 @@ * under the License. */ -import React, { FC } from 'react'; +import React, { FC, MouseEvent } from 'react'; import PropTypes from 'prop-types'; import { EuiButtonEmpty, EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiTitle } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n/react'; +import { METRIC_TYPE } from '@kbn/analytics'; // @ts-expect-error untyped service import { FeatureCatalogueEntry } from '../../services'; import { createAppNavigationHandler } from '../app_navigation_handler'; // @ts-expect-error untyped component import { Synopsis } from '../synopsis'; +import { getServices } from '../../kibana_services'; interface Props { addBasePath: (path: string) => string; features: FeatureCatalogueEntry[]; } -export const AddData: FC = ({ addBasePath, features }) => ( -
- - - -

- -

-
-
+export const AddData: FC = ({ addBasePath, features }) => { + const { trackUiMetric } = getServices(); - -
- - - -
-
-
- - + return ( +
+ + + +

+ +

+
+
- - {features.map((feature) => ( - - + +
+ + + +
- ))} -
-
-); + + + + + + {features.map((feature) => ( + + { + trackUiMetric(METRIC_TYPE.CLICK, `ingest_data_card_${feature.id}`); + createAppNavigationHandler(feature.path)(event); + }} + description={feature.description} + iconType={feature.icon} + title={feature.title} + url={addBasePath(feature.path)} + wrapInPanel + /> + + ))} + +
+ ); +}; AddData.propTypes = { addBasePath: PropTypes.func.isRequired, diff --git a/src/plugins/home/public/application/components/home.js b/src/plugins/home/public/application/components/home.js index 054f5a5344df4..a990beaa6a442 100644 --- a/src/plugins/home/public/application/components/home.js +++ b/src/plugins/home/public/application/components/home.js @@ -21,6 +21,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule } from '@elastic/eui'; +import { METRIC_TYPE } from '@kbn/analytics'; import { i18n } from '@kbn/i18n'; import { OverviewPageFooter, @@ -120,7 +121,7 @@ export class Home extends Component { renderNormal() { const { addBasePath, solutions, directories } = this.props; - + const { trackUiMetric } = getServices(); const devTools = this.findDirectoryById('console'); const addDataFeatures = this.getFeaturesByCategory(FeatureCatalogueCategory.DATA); const manageDataFeatures = this.getFeaturesByCategory(FeatureCatalogueCategory.ADMIN); @@ -171,7 +172,16 @@ export class Home extends Component {