[Unified observability] Track disabled features when loading overview page (#130230)

This commit is contained in:
Alejandro Fernández Gómez 2022-04-14 13:04:56 +02:00 committed by GitHub
parent 37ebf93c02
commit 6dbe26f2f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,7 +19,7 @@ import {
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import React, { useMemo, useRef, useCallback, useState } from 'react';
import React, { useMemo, useRef, useCallback, useState, useEffect } from 'react';
import { observabilityFeatureId } from '../../../common';
import { useKibana } from '../../../../../../src/plugins/kibana_react/public';
import { useTrackPageview, useUiTracker } from '../..';
@ -52,6 +52,9 @@ interface Props {
routeParams: RouteParams<'/overview'>;
}
export type BucketSize = ReturnType<typeof calculateBucketSize>;
const CAPABILITIES_KEYS = ['logs', 'infrastructure', 'apm', 'uptime'];
function calculateBucketSize({ start, end }: { start?: number; end?: number }) {
if (start && end) {
return getBucketSize({ start, end, minInterval: '60s' });
@ -72,9 +75,14 @@ export function OverviewPage({ routeParams }: Props) {
const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);
const indexNames = useAlertIndexNames();
const { cases, docLinks, http } = useKibana<ObservabilityAppServices>().services;
const { ObservabilityPageTemplate, config } = usePluginContext();
const {
cases,
docLinks,
http,
application: { capabilities },
} = useKibana<ObservabilityAppServices>().services;
const { ObservabilityPageTemplate, config } = usePluginContext();
const { relativeStart, relativeEnd, absoluteStart, absoluteEnd } = useDatePickerContext();
const { data: newsFeed } = useFetcher(() => getNewsFeed({ http }), [http]);
@ -112,6 +120,20 @@ export function OverviewPage({ routeParams }: Props) {
const CasesContext = cases.ui.getCasesContext();
const userPermissions = useGetUserCasesPermissions();
useEffect(() => {
if (hasAnyData !== true) {
return;
}
CAPABILITIES_KEYS.forEach((feature) => {
if (capabilities[feature].show === false) {
trackMetric({
metric: `oblt_disabled_feature_${feature === 'infrastructure' ? 'metrics' : feature}`,
});
}
});
}, [capabilities, hasAnyData, trackMetric]);
if (hasAnyData === undefined) {
return <LoadingObservability />;
}