mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Synthetics][Ux][Uptime] Use Observability Page Template from Observability Shared (#154774)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Shahzad <shahzad31comp@gmail.com>
This commit is contained in:
parent
d694a0d75f
commit
88f4f8082a
43 changed files with 209 additions and 108 deletions
|
@ -28,7 +28,7 @@ export const App = (props: {
|
|||
plugins: StartDependencies;
|
||||
defaultIndexPattern: DataView | null;
|
||||
}) => {
|
||||
const ExploratoryViewComponent = props.plugins.observability.ExploratoryViewEmbeddable;
|
||||
const ExploratoryViewComponent = props.plugins.exploratoryView.ExploratoryViewEmbeddable;
|
||||
|
||||
const seriesList: AllSeries = [
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
"guidedOnboarding",
|
||||
"inspector",
|
||||
"lens",
|
||||
"observability",
|
||||
"observabilityShared",
|
||||
"security",
|
||||
"share",
|
||||
"triggersActionsUi",
|
||||
|
@ -32,7 +32,6 @@
|
|||
"kibanaReact",
|
||||
"kibanaUtils",
|
||||
"lens",
|
||||
"observability",
|
||||
"unifiedSearch",
|
||||
"visualizations"
|
||||
],
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
XYState,
|
||||
} from '@kbn/lens-plugin/public';
|
||||
import { ViewMode } from '@kbn/embeddable-plugin/common';
|
||||
import { observabilityFeatureId } from '@kbn/observability-plugin/public';
|
||||
import { observabilityFeatureId } from '@kbn/observability-shared-plugin/public';
|
||||
import styled from 'styled-components';
|
||||
import { useKibanaSpace } from '../../../../hooks/use_kibana_space';
|
||||
import { HeatMapLensAttributes } from '../configurations/lens_attributes/heatmap_attributes';
|
||||
|
|
|
@ -11,11 +11,11 @@ import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common';
|
|||
import type { CoreStart } from '@kbn/core/public';
|
||||
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
|
||||
import { EuiErrorBoundary } from '@elastic/eui';
|
||||
import { useFetcher } from '@kbn/observability-plugin/public';
|
||||
import styled from 'styled-components';
|
||||
import { DataView } from '@kbn/data-views-plugin/common';
|
||||
import { FormulaPublicApi } from '@kbn/lens-plugin/public';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { useFetcher } from '../../../../hooks/use_fetcher';
|
||||
import { useAppDataView } from './use_app_data_view';
|
||||
import type { ExploratoryViewPublicPluginsStart } from '../../../..';
|
||||
import type { ExploratoryEmbeddableProps, ExploratoryEmbeddableComponentProps } from './embeddable';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { useState } from 'react';
|
||||
import { DataView } from '@kbn/data-views-plugin/common';
|
||||
import { useFetcher } from '@kbn/observability-plugin/public';
|
||||
import { useFetcher } from '../../../../hooks/use_fetcher';
|
||||
import { useLocalDataView } from './use_local_data_view';
|
||||
import { ExploratoryEmbeddableProps, ExploratoryViewPublicPluginsStart } from '../../../..';
|
||||
import type { DataViewState } from '../hooks/use_app_data_view';
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { useEffect } from 'react';
|
||||
import useLocalStorage from 'react-use/lib/useLocalStorage';
|
||||
import { useFetcher } from '@kbn/observability-plugin/public';
|
||||
import { useFetcher } from '../../../../hooks/use_fetcher';
|
||||
import { getDataTypeIndices } from '../../../../utils/observability_data_views';
|
||||
import { AppDataType } from '../types';
|
||||
import { ExploratoryEmbeddableProps } from '../../../..';
|
||||
|
|
|
@ -15,7 +15,10 @@ import {
|
|||
GetAllCasesSelectorModalProps,
|
||||
} from '@kbn/cases-plugin/public';
|
||||
import { TypedLensByValueInput } from '@kbn/lens-plugin/public';
|
||||
import { observabilityFeatureId, observabilityAppId } from '@kbn/observability-plugin/public';
|
||||
import {
|
||||
observabilityFeatureId,
|
||||
observabilityAppId,
|
||||
} from '@kbn/observability-shared-plugin/public';
|
||||
import { useGetUserCasesPermissions } from '../../../../hooks/use_get_user_cases_permissions';
|
||||
import { ObservabilityAppServices } from '../../../../application/types';
|
||||
import { useAddToCase } from '../hooks/use_add_to_case';
|
||||
|
|
|
@ -11,7 +11,7 @@ import { HttpSetup, MountPoint } from '@kbn/core/public';
|
|||
import { Case } from '@kbn/cases-plugin/common';
|
||||
import { TypedLensByValueInput } from '@kbn/lens-plugin/public';
|
||||
import { CasesDeepLinkId, DRAFT_COMMENT_STORAGE_ID } from '@kbn/cases-plugin/public';
|
||||
import { observabilityFeatureId } from '@kbn/observability-plugin/public';
|
||||
import { observabilityFeatureId } from '@kbn/observability-shared-plugin/public';
|
||||
import { useKibana } from '../../../../utils/kibana_react';
|
||||
import { AddToCaseProps } from '../header/add_to_case_action';
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
import { useMemo } from 'react';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { useFetcher } from '@kbn/observability-plugin/public';
|
||||
import { useFetcher } from '../../../../hooks/use_fetcher';
|
||||
import { ExploratoryViewPublicPluginsStart } from '../../../..';
|
||||
|
||||
export const useLensFormulaHelper = () => {
|
||||
|
|
|
@ -15,7 +15,7 @@ import {
|
|||
createSessionStorageStateStorage,
|
||||
} from '@kbn/kibana-utils-plugin/public';
|
||||
import { TypedLensByValueInput } from '@kbn/lens-plugin/public';
|
||||
import { useTrackPageview } from '@kbn/observability-plugin/public';
|
||||
import { useTrackPageview } from '../../../hooks/use_track_metric';
|
||||
import { ExploratoryView } from './exploratory_view';
|
||||
import { ExploratoryViewPublicPluginsStart } from '../../../plugin';
|
||||
import { useBreadcrumbs } from '../../../hooks/use_breadcrumbs';
|
||||
|
@ -39,12 +39,12 @@ export function ExploratoryViewPage({
|
|||
useSessionStorage = false,
|
||||
}: ExploratoryViewPageProps) {
|
||||
const {
|
||||
services: { uiSettings, notifications, observability },
|
||||
services: { uiSettings, notifications, observabilityShared },
|
||||
} = useKibana<ExploratoryViewPublicPluginsStart>();
|
||||
|
||||
const history = useHistory();
|
||||
|
||||
const ObservabilityPageTemplate = observability.navigation.PageTemplate;
|
||||
const ObservabilityPageTemplate = observabilityShared.navigation.PageTemplate;
|
||||
|
||||
useTrackPageview({ app: 'observability-overview', path: 'exploratory-view' });
|
||||
useTrackPageview({
|
||||
|
|
|
@ -9,7 +9,7 @@ import React, { useState } from 'react';
|
|||
import { EuiPopover, EuiToolTip, EuiButtonEmpty, EuiIcon } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { useFetcher } from '@kbn/observability-plugin/public';
|
||||
import { useFetcher } from '../../../../../hooks/use_fetcher';
|
||||
import { ExploratoryViewPublicPluginsStart } from '../../../../../plugin';
|
||||
import { SeriesUrl } from '../../../../..';
|
||||
import { SeriesConfig } from '../../types';
|
||||
|
|
|
@ -10,7 +10,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiFormRow, EuiIcon, EuiSuperSelect } from '
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { SeriesType } from '@kbn/lens-plugin/public';
|
||||
import { useFetcher } from '@kbn/observability-plugin/public';
|
||||
import { useFetcher } from '../../../../../hooks/use_fetcher';
|
||||
import { ExploratoryViewPublicPluginsStart } from '../../../../../plugin';
|
||||
import { SeriesUrl } from '../../../../..';
|
||||
import { useSeriesStorage } from '../../hooks/use_series_storage';
|
||||
|
|
|
@ -17,7 +17,7 @@ import type { DatePickerProps } from './date_picker';
|
|||
import type { FilterValueLabelProps } from './filter_value_label/filter_value_label';
|
||||
import type { SelectableUrlListProps } from './exploratory_view/components/url_search/selectable_url_list';
|
||||
import type { ExploratoryViewPageProps } from './exploratory_view';
|
||||
export type { LazyObservabilityPageTemplateProps } from '@kbn/observability-plugin/public';
|
||||
export type { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public';
|
||||
|
||||
const CoreVitalsLazy = lazy(() => import('./core_web_vitals'));
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
import type { Space } from '@kbn/spaces-plugin/common';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { useFetcher } from '@kbn/observability-plugin/public';
|
||||
import { useFetcher } from './use_fetcher';
|
||||
import { ExploratoryViewPublicPluginsStart } from '..';
|
||||
|
||||
export const useKibanaSpace = () => {
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
Plugin as PluginClass,
|
||||
PluginInitializerContext,
|
||||
} from '@kbn/core/public';
|
||||
import type { ObservabilitySharedPluginStart } from '@kbn/observability-shared-plugin/public';
|
||||
import type { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plugin/public';
|
||||
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
|
||||
import type { DiscoverStart } from '@kbn/discover-plugin/public';
|
||||
|
@ -36,10 +37,6 @@ import { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/publi
|
|||
import { SpacesPluginStart } from '@kbn/spaces-plugin/public';
|
||||
import { LicensingPluginStart } from '@kbn/licensing-plugin/public';
|
||||
import { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
|
||||
import {
|
||||
ObservabilityPublicSetup,
|
||||
ObservabilityPublicStart,
|
||||
} from '@kbn/observability-plugin/public';
|
||||
import { getExploratoryViewEmbeddable } from './components/shared/exploratory_view/embeddable';
|
||||
import { createExploratoryViewUrl } from './components/shared/exploratory_view/configurations/exploratory_view_url';
|
||||
import getAppDataView from './utils/observability_data_views/get_app_data_view';
|
||||
|
@ -48,7 +45,6 @@ import { APP_ROUTE } from './constants';
|
|||
|
||||
export interface ExploratoryViewPublicPluginsSetup {
|
||||
data: DataPublicPluginSetup;
|
||||
observability: ObservabilityPublicSetup;
|
||||
share: SharePluginSetup;
|
||||
triggersActionsUi: TriggersAndActionsUIPublicPluginSetup;
|
||||
usageCollection: UsageCollectionSetup;
|
||||
|
@ -62,10 +58,11 @@ export interface ExploratoryViewPublicPluginsStart {
|
|||
dataViews: DataViewsPublicPluginStart;
|
||||
discover: DiscoverStart;
|
||||
embeddable: EmbeddableStart;
|
||||
|
||||
guidedOnboarding: GuidedOnboardingPluginStart;
|
||||
lens: LensPublicStart;
|
||||
licensing: LicensingPluginStart;
|
||||
observability: ObservabilityPublicStart;
|
||||
observabilityShared: ObservabilitySharedPluginStart;
|
||||
security: SecurityPluginStart;
|
||||
share: SharePluginStart;
|
||||
spaces?: SpacesPluginStart;
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
"@kbn/charts-plugin",
|
||||
"@kbn/shared-ux-router",
|
||||
"@kbn/core-application-browser",
|
||||
"@kbn/observability-plugin"
|
||||
"@kbn/observability-shared-plugin"
|
||||
],
|
||||
"exclude": ["target/**/*"]
|
||||
}
|
||||
|
|
|
@ -13,36 +13,22 @@
|
|||
"charts",
|
||||
"data",
|
||||
"dataViews",
|
||||
"embeddable",
|
||||
"features",
|
||||
"files",
|
||||
"guidedOnboarding",
|
||||
"inspector",
|
||||
"lens",
|
||||
"observabilityShared",
|
||||
"ruleRegistry",
|
||||
"triggersActionsUi",
|
||||
"inspector",
|
||||
"unifiedSearch",
|
||||
"security",
|
||||
"guidedOnboarding",
|
||||
"share"
|
||||
],
|
||||
"optionalPlugins": [
|
||||
"discover",
|
||||
"embeddable",
|
||||
"home",
|
||||
"lens",
|
||||
"licensing",
|
||||
"spaces",
|
||||
"usageCollection"
|
||||
],
|
||||
"requiredBundles": [
|
||||
"share",
|
||||
"unifiedSearch",
|
||||
"data",
|
||||
"dataViews",
|
||||
"embeddable",
|
||||
"kibanaReact",
|
||||
"kibanaUtils",
|
||||
"lens",
|
||||
"visualizations"
|
||||
],
|
||||
"optionalPlugins": ["discover", "home", "licensing", "spaces", "usageCollection"],
|
||||
"requiredBundles": ["data", "kibanaReact", "kibanaUtils", "unifiedSearch"],
|
||||
"extraPublicDirs": ["common"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { Route } from '@kbn/shared-ux-router';
|
||||
import { AppMountParameters, APP_WRAPPER_CLASS, CoreStart } from '@kbn/core/public';
|
||||
import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common';
|
||||
import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public';
|
||||
import {
|
||||
KibanaContextProvider,
|
||||
KibanaThemeProvider,
|
||||
|
@ -21,7 +22,6 @@ import {
|
|||
} from '@kbn/kibana-react-plugin/public';
|
||||
import { Storage } from '@kbn/kibana-utils-plugin/public';
|
||||
import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
|
||||
import type { LazyObservabilityPageTemplateProps } from '../components/shared/page_template/lazy_page_template';
|
||||
import { HasDataContextProvider } from '../context/has_data_context';
|
||||
import { PluginContext } from '../context/plugin_context';
|
||||
import { ConfigSchema, ObservabilityPublicPluginsStart } from '../plugin';
|
||||
|
|
|
@ -24,8 +24,14 @@ import type { DataPublicPluginSetup, DataPublicPluginStart } from '@kbn/data-plu
|
|||
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
|
||||
import type { DiscoverStart } from '@kbn/discover-plugin/public';
|
||||
import type { EmbeddableStart } from '@kbn/embeddable-plugin/public';
|
||||
import type { ExploratoryViewPublicPluginsStart } from '@kbn/exploratory-view-plugin/public';
|
||||
import type { HomePublicPluginSetup, HomePublicPluginStart } from '@kbn/home-plugin/public';
|
||||
import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
|
||||
import type {
|
||||
ObservabilitySharedPluginSetup,
|
||||
ObservabilitySharedPluginStart,
|
||||
NavigationEntry,
|
||||
} from '@kbn/observability-shared-plugin/public';
|
||||
import { CasesDeepLinkId, CasesUiStart, getCasesDeepLinks } from '@kbn/cases-plugin/public';
|
||||
import type { LensPublicStart } from '@kbn/lens-plugin/public';
|
||||
import {
|
||||
|
@ -45,19 +51,13 @@ import { LicensingPluginStart } from '@kbn/licensing-plugin/public';
|
|||
import { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public';
|
||||
import { RuleDetailsLocatorDefinition } from './locators/rule_details';
|
||||
import { observabilityAppId, observabilityFeatureId, casesPath } from '../common';
|
||||
import { createLazyObservabilityPageTemplate } from './components/shared';
|
||||
import { registerDataHandler } from './data_handler';
|
||||
import {
|
||||
createObservabilityRuleTypeRegistry,
|
||||
ObservabilityRuleTypeRegistry,
|
||||
} from './rules/create_observability_rule_type_registry';
|
||||
import { createCallObservabilityApi } from './services/call_observability_api';
|
||||
import { createNavigationRegistry, NavigationEntry } from './services/navigation_registry';
|
||||
import { updateGlobalNavigation } from './update_global_navigation';
|
||||
import { getExploratoryViewEmbeddable } from './components/shared/exploratory_view/embeddable';
|
||||
import { createExploratoryViewUrl } from './components/shared/exploratory_view/configurations/exploratory_view_url';
|
||||
import { createUseRulesLink } from './hooks/create_use_rules_link';
|
||||
import getAppDataView from './utils/observability_data_views/get_app_data_view';
|
||||
import { registerObservabilityRuleTypes } from './rules/register_observability_rule_types';
|
||||
|
||||
export interface ConfigSchema {
|
||||
|
@ -79,6 +79,7 @@ export type ObservabilityPublicSetup = ReturnType<Plugin['setup']>;
|
|||
|
||||
export interface ObservabilityPublicPluginsSetup {
|
||||
data: DataPublicPluginSetup;
|
||||
observabilityShared: ObservabilitySharedPluginSetup;
|
||||
share: SharePluginSetup;
|
||||
triggersActionsUi: TriggersAndActionsUIPublicPluginSetup;
|
||||
home?: HomePublicPluginSetup;
|
||||
|
@ -93,9 +94,11 @@ export interface ObservabilityPublicPluginsStart {
|
|||
dataViews: DataViewsPublicPluginStart;
|
||||
discover: DiscoverStart;
|
||||
embeddable: EmbeddableStart;
|
||||
exploratoryView: ExploratoryViewPublicPluginsStart;
|
||||
guidedOnboarding: GuidedOnboardingPluginStart;
|
||||
lens: LensPublicStart;
|
||||
licensing: LicensingPluginStart;
|
||||
observabilityShared: ObservabilitySharedPluginStart;
|
||||
ruleTypeRegistry: RuleTypeRegistryContract;
|
||||
security: SecurityPluginStart;
|
||||
share: SharePluginStart;
|
||||
|
@ -118,7 +121,6 @@ export class Plugin
|
|||
>
|
||||
{
|
||||
private readonly appUpdater$ = new BehaviorSubject<AppUpdater>(() => ({}));
|
||||
private readonly navigationRegistry = createNavigationRegistry();
|
||||
private observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry =
|
||||
{} as ObservabilityRuleTypeRegistry;
|
||||
|
||||
|
@ -194,7 +196,7 @@ export class Plugin
|
|||
// Load application bundle
|
||||
const { renderApp } = await import('./application');
|
||||
// Get start services
|
||||
const [coreStart, pluginsStart, { navigation }] = await coreSetup.getStartServices();
|
||||
const [coreStart, pluginsStart] = await coreSetup.getStartServices();
|
||||
|
||||
const { ruleTypeRegistry, actionTypeRegistry } = pluginsStart.triggersActionsUi;
|
||||
|
||||
|
@ -204,7 +206,7 @@ export class Plugin
|
|||
plugins: { ...pluginsStart, ruleTypeRegistry, actionTypeRegistry },
|
||||
appMountParameters: params,
|
||||
observabilityRuleTypeRegistry: this.observabilityRuleTypeRegistry,
|
||||
ObservabilityPageTemplate: navigation.PageTemplate,
|
||||
ObservabilityPageTemplate: pluginsStart.observabilityShared.navigation.PageTemplate,
|
||||
usageCollection: pluginsSetup.usageCollection,
|
||||
isDev: this.initContext.env.mode.dev,
|
||||
kibanaVersion,
|
||||
|
@ -260,7 +262,7 @@ export class Plugin
|
|||
});
|
||||
}
|
||||
|
||||
this.navigationRegistry.registerSections(
|
||||
pluginsSetup.observabilityShared.navigation.registerSections(
|
||||
from(appUpdater$).pipe(
|
||||
map((value) => {
|
||||
const deepLinks = value(app)?.deepLinks ?? [];
|
||||
|
@ -307,9 +309,6 @@ export class Plugin
|
|||
return {
|
||||
dashboard: { register: registerDataHandler },
|
||||
observabilityRuleTypeRegistry: this.observabilityRuleTypeRegistry,
|
||||
navigation: {
|
||||
registerSections: this.navigationRegistry.registerSections,
|
||||
},
|
||||
useRulesLink: createUseRulesLink(),
|
||||
};
|
||||
}
|
||||
|
@ -318,21 +317,12 @@ export class Plugin
|
|||
const { application } = coreStart;
|
||||
const config = this.initContext.config.get();
|
||||
|
||||
updateGlobalNavigation({
|
||||
pluginsStart.observabilityShared.updateGlobalNavigation({
|
||||
capabilities: application.capabilities,
|
||||
deepLinks: this.deepLinks,
|
||||
updater$: this.appUpdater$,
|
||||
});
|
||||
|
||||
const PageTemplate = createLazyObservabilityPageTemplate({
|
||||
currentAppId$: application.currentAppId$,
|
||||
getUrlForApp: application.getUrlForApp,
|
||||
navigateToApp: application.navigateToApp,
|
||||
navigationSections$: this.navigationRegistry.sections$,
|
||||
guidedOnboardingApi: pluginsStart.guidedOnboarding.guidedOnboardingApi,
|
||||
getPageTemplateServices: () => ({ coreStart }),
|
||||
});
|
||||
|
||||
const getAsyncO11yAlertsTableConfiguration = async () => {
|
||||
const { getAlertsTableConfiguration } = await import(
|
||||
'./components/alerts_table/get_alerts_table_configuration'
|
||||
|
@ -348,12 +338,6 @@ export class Plugin
|
|||
|
||||
return {
|
||||
observabilityRuleTypeRegistry: this.observabilityRuleTypeRegistry,
|
||||
navigation: {
|
||||
PageTemplate,
|
||||
},
|
||||
createExploratoryViewUrl,
|
||||
getAppDataView: getAppDataView(pluginsStart.dataViews),
|
||||
ExploratoryViewEmbeddable: getExploratoryViewEmbeddable({ ...coreStart, ...pluginsStart }),
|
||||
useRulesLink: createUseRulesLink(),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -74,7 +74,9 @@
|
|||
"@kbn/core-application-browser",
|
||||
"@kbn/files-plugin",
|
||||
"@kbn/core-theme-browser",
|
||||
"@kbn/core-elasticsearch-server"
|
||||
"@kbn/core-elasticsearch-server",
|
||||
"@kbn/observability-shared-plugin",
|
||||
"@kbn/exploratory-view-plugin"
|
||||
],
|
||||
"exclude": ["target/**/*"]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { useEffect, useMemo } from 'react';
|
||||
import { METRIC_TYPE, UiCounterMetricType } from '@kbn/analytics';
|
||||
import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import { ObservabilityApp } from '../../typings/common';
|
||||
|
||||
/**
|
||||
* Note: The usage_collection plugin will take care of sending this data to the telemetry server.
|
||||
* You can find the metrics that are collected by these hooks in Stack Telemetry.
|
||||
* Search the index `kibana-ui-counter`. You can filter for `eventName` and/or `appName`.
|
||||
*/
|
||||
|
||||
interface TrackOptions {
|
||||
app?: ObservabilityApp;
|
||||
metricType?: UiCounterMetricType;
|
||||
delay?: number; // in ms
|
||||
}
|
||||
type EffectDeps = unknown[];
|
||||
|
||||
interface ServiceDeps {
|
||||
usageCollection: UsageCollectionSetup; // TODO: This should really be start. Looking into it.
|
||||
}
|
||||
|
||||
export type TrackMetricOptions = TrackOptions & { metric: string };
|
||||
export type UiTracker = ReturnType<typeof useUiTracker>;
|
||||
export type TrackEvent = (options: TrackMetricOptions) => void;
|
||||
|
||||
export { METRIC_TYPE };
|
||||
|
||||
export function useUiTracker<Services extends ServiceDeps>({
|
||||
app: defaultApp,
|
||||
}: { app?: ObservabilityApp } = {}): TrackEvent {
|
||||
const reportUiCounter = useKibana<Services>().services?.usageCollection?.reportUiCounter;
|
||||
const trackEvent = useMemo(() => {
|
||||
return ({ app = defaultApp, metric, metricType = METRIC_TYPE.COUNT }: TrackMetricOptions) => {
|
||||
if (reportUiCounter) {
|
||||
reportUiCounter(app as string, metricType, metric);
|
||||
}
|
||||
};
|
||||
}, [defaultApp, reportUiCounter]);
|
||||
return trackEvent;
|
||||
}
|
||||
|
||||
export function useTrackMetric<Services extends ServiceDeps>(
|
||||
{ app, metric, metricType = METRIC_TYPE.COUNT, delay = 0 }: TrackMetricOptions,
|
||||
effectDependencies: EffectDeps = []
|
||||
) {
|
||||
const reportUiCounter = useKibana<Services>().services?.usageCollection?.reportUiCounter;
|
||||
|
||||
useEffect(() => {
|
||||
if (!reportUiCounter) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(
|
||||
'usageCollection.reportUiCounter is unavailable. Ensure this is setup via <KibanaContextProvider />.'
|
||||
);
|
||||
} else {
|
||||
let decoratedMetric = metric;
|
||||
if (delay > 0) {
|
||||
decoratedMetric += `__delayed_${delay}ms`;
|
||||
}
|
||||
const id = setTimeout(
|
||||
() => reportUiCounter(app as string, metricType, decoratedMetric),
|
||||
Math.max(delay, 0)
|
||||
);
|
||||
return () => clearTimeout(id);
|
||||
}
|
||||
// the dependencies are managed externally
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, effectDependencies);
|
||||
}
|
||||
|
||||
/**
|
||||
* useTrackPageview is a convenience wrapper for tracking a pageview
|
||||
* Its metrics will be found at:
|
||||
* stack_stats.kibana.plugins.ui_metric.{app}.pageview__{path}(__delayed_{n}ms)?
|
||||
*/
|
||||
type TrackPageviewProps = TrackOptions & { path: string };
|
||||
|
||||
export function useTrackPageview<Services extends ServiceDeps>(
|
||||
{ path, ...rest }: TrackPageviewProps,
|
||||
effectDependencies: EffectDeps = []
|
||||
) {
|
||||
useTrackMetric<Services>({ ...rest, metric: `pageview__${path}` }, effectDependencies);
|
||||
}
|
|
@ -19,8 +19,15 @@ export type {
|
|||
|
||||
export type { NavigationEntry } from './components/page_template/page_template';
|
||||
|
||||
export { useObservabilityTourContext } from './components/tour';
|
||||
|
||||
export const plugin = () => {
|
||||
return new ObservabilitySharedPlugin();
|
||||
};
|
||||
|
||||
export { observabilityFeatureId, casesFeatureId, sloFeatureId } from '../common';
|
||||
export {
|
||||
observabilityFeatureId,
|
||||
observabilityAppId,
|
||||
casesFeatureId,
|
||||
sloFeatureId,
|
||||
} from '../common';
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
"@kbn/shared-ux-page-kibana-template",
|
||||
"@kbn/i18n-react",
|
||||
"@kbn/shared-ux-page-kibana-template-mocks",
|
||||
"@kbn/analytics",
|
||||
"@kbn/usage-collection-plugin",
|
||||
],
|
||||
"exclude": ["target/**/*"]
|
||||
}
|
||||
|
|
|
@ -39,10 +39,10 @@ export function ProfilingAppPageTemplate({
|
|||
pageTitle?: React.ReactNode;
|
||||
}) {
|
||||
const {
|
||||
start: { observability },
|
||||
start: { observabilityShared },
|
||||
} = useProfilingDependencies();
|
||||
|
||||
const { PageTemplate: ObservabilityPageTemplate } = observability.navigation;
|
||||
const { PageTemplate: ObservabilityPageTemplate } = observabilityShared.navigation;
|
||||
|
||||
const history = useHistory();
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ const pageHeader = {
|
|||
|
||||
function ErrorWithTemplate({ error }: { error: Error }) {
|
||||
const { services } = useKibana<ProfilingPluginPublicStartDeps>();
|
||||
const { observability } = services;
|
||||
const { observabilityShared } = services;
|
||||
|
||||
const ObservabilityPageTemplate = observability.navigation.PageTemplate;
|
||||
const ObservabilityPageTemplate = observabilityShared.navigation.PageTemplate;
|
||||
|
||||
if (error instanceof NotFoundRouteException) {
|
||||
return (
|
||||
|
|
|
@ -13,7 +13,10 @@ import type {
|
|||
ObservabilityPublicSetup,
|
||||
ObservabilityPublicStart,
|
||||
} from '@kbn/observability-plugin/public';
|
||||
import { ObservabilitySharedPluginSetup } from '@kbn/observability-shared-plugin/public/plugin';
|
||||
import {
|
||||
ObservabilitySharedPluginSetup,
|
||||
ObservabilitySharedPluginStart,
|
||||
} from '@kbn/observability-shared-plugin/public/plugin';
|
||||
import { ChartsPluginSetup, ChartsPluginStart } from '@kbn/charts-plugin/public';
|
||||
import { LicensingPluginSetup } from '@kbn/licensing-plugin/public';
|
||||
|
||||
|
@ -28,6 +31,7 @@ export interface ProfilingPluginPublicSetupDeps {
|
|||
|
||||
export interface ProfilingPluginPublicStartDeps {
|
||||
observability: ObservabilityPublicStart;
|
||||
observabilityShared: ObservabilitySharedPluginStart;
|
||||
dataViews: DataViewsPublicPluginStart;
|
||||
data: DataPublicPluginStart;
|
||||
charts: ChartsPluginStart;
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
"id": "synthetics",
|
||||
"server": true,
|
||||
"browser": true,
|
||||
"configPath": [
|
||||
"xpack",
|
||||
"uptime"
|
||||
],
|
||||
"configPath": ["xpack", "uptime"],
|
||||
"requiredPlugins": [
|
||||
"actions",
|
||||
"alerting",
|
||||
|
@ -24,6 +21,7 @@
|
|||
"inspector",
|
||||
"licensing",
|
||||
"observability",
|
||||
"observabilityShared",
|
||||
"ruleRegistry",
|
||||
"security",
|
||||
"share",
|
||||
|
@ -33,15 +31,7 @@
|
|||
"unifiedSearch",
|
||||
"bfetch"
|
||||
],
|
||||
"optionalPlugins": [
|
||||
"cloud",
|
||||
"data",
|
||||
"fleet",
|
||||
"home",
|
||||
"ml",
|
||||
"spaces",
|
||||
"telemetry"
|
||||
],
|
||||
"optionalPlugins": ["cloud", "data", "fleet", "home", "ml", "spaces", "telemetry"],
|
||||
"requiredBundles": [
|
||||
"data",
|
||||
"unifiedSearch",
|
||||
|
|
|
@ -68,10 +68,10 @@ export const StdErrorLogs = ({
|
|||
|
||||
const { items, loading } = useStdErrorLogs({ monitorId, checkGroup });
|
||||
|
||||
const { discover, observability } = useKibana<ClientPluginsStart>().services;
|
||||
const { discover, exploratoryView } = useKibana<ClientPluginsStart>().services;
|
||||
|
||||
const { data: discoverLink } = useFetcher(async () => {
|
||||
const dataView = await observability.getAppDataView('synthetics', SYNTHETICS_INDEX_PATTERN);
|
||||
const dataView = await exploratoryView.getAppDataView('synthetics', SYNTHETICS_INDEX_PATTERN);
|
||||
return discover.locator?.getUrl({
|
||||
query: { language: 'kuery', query: `monitor.check_group: ${checkGroup}` },
|
||||
indexPatternId: dataView?.id,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { LazyObservabilityPageTemplateProps } from '@kbn/observability-plugin/public';
|
||||
import { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public';
|
||||
import React from 'react';
|
||||
import { euiStyled } from '@kbn/kibana-react-plugin/common';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
|
@ -13,8 +13,8 @@ import { useKibana } from '@kbn/kibana-react-plugin/public';
|
|||
import { ClientPluginsStart } from '../../../../../plugin';
|
||||
|
||||
export const WrappedPageTemplate = (props: LazyObservabilityPageTemplateProps) => {
|
||||
const { observability } = useKibana<ClientPluginsStart>().services;
|
||||
const PageTemplateComponent = observability.navigation.PageTemplate;
|
||||
const { observabilityShared } = useKibana<ClientPluginsStart>().services;
|
||||
const PageTemplateComponent = observabilityShared.navigation.PageTemplate;
|
||||
|
||||
return <PageTemplateComponent {...props} />;
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { NotFoundPrompt } from '@kbn/shared-ux-prompt-not-found';
|
||||
import { APP_WRAPPER_CLASS } from '@kbn/core/public';
|
||||
import { useKibana } from '@kbn/kibana-react-plugin/public';
|
||||
import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-plugin/public';
|
||||
import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public';
|
||||
import { useInspectorContext } from '@kbn/observability-plugin/public';
|
||||
import { useSyntheticsPrivileges } from './hooks/use_synthetics_priviliges';
|
||||
import { ClientPluginsStart } from '../../plugin';
|
||||
|
|
|
@ -91,6 +91,7 @@ const Application = (props: SyntheticsAppProps) => {
|
|||
inspector: startPlugins.inspector,
|
||||
triggersActionsUi: startPlugins.triggersActionsUi,
|
||||
observability: startPlugins.observability,
|
||||
observabilityShared: startPlugins.observabilityShared,
|
||||
exploratoryView: startPlugins.exploratoryView,
|
||||
cases: startPlugins.cases,
|
||||
spaces: startPlugins.spaces,
|
||||
|
|
|
@ -135,8 +135,16 @@ export const mockCore: () => Partial<CoreStart> = () => {
|
|||
triggersActionsUi: triggersActionsUiMock.createStart(),
|
||||
storage: createMockStore(),
|
||||
data: dataPluginMock.createStartContract(),
|
||||
// @ts-ignore
|
||||
observability: {
|
||||
useRulesLink: () => ({ href: 'newRuleLink' }),
|
||||
observabilityRuleTypeRegistry: {
|
||||
register: jest.fn(),
|
||||
getFormatter: jest.fn(),
|
||||
list: jest.fn(),
|
||||
},
|
||||
},
|
||||
observabilityShared: {
|
||||
navigation: {
|
||||
// @ts-ignore
|
||||
PageTemplate: EuiPageTemplate,
|
||||
|
@ -168,6 +176,7 @@ export function MockKibanaProvider<ExtraCore>({
|
|||
<SyntheticsStartupPluginsContextProvider
|
||||
data={(coreOptions as any).data}
|
||||
observability={(coreOptions as any).observability}
|
||||
observabilityShared={(coreOptions as any).observabilityShared}
|
||||
exploratoryView={(coreOptions as any).exploratoryView}
|
||||
>
|
||||
<EuiThemeProvider darkMode={false}>
|
||||
|
|
|
@ -124,6 +124,7 @@ const Application = (props: UptimeAppProps) => {
|
|||
inspector: startPlugins.inspector,
|
||||
triggersActionsUi: startPlugins.triggersActionsUi,
|
||||
observability: startPlugins.observability,
|
||||
observabilityShared: startPlugins.observabilityShared,
|
||||
exploratoryView: startPlugins.exploratoryView,
|
||||
cases: startPlugins.cases,
|
||||
}}
|
||||
|
|
|
@ -28,10 +28,10 @@ export const UptimePageTemplateComponent: React.FC<Props & EuiPageTemplateProps>
|
|||
...pageTemplateProps
|
||||
}) => {
|
||||
const {
|
||||
services: { observability },
|
||||
services: { observabilityShared },
|
||||
} = useKibana<ClientPluginsStart>();
|
||||
|
||||
const PageTemplateComponent = observability.navigation.PageTemplate;
|
||||
const PageTemplateComponent = observabilityShared.navigation.PageTemplate;
|
||||
|
||||
const noDataConfig = useNoDataConfig();
|
||||
|
||||
|
|
|
@ -133,8 +133,16 @@ export const mockCore: () => Partial<CoreStart> = () => {
|
|||
triggersActionsUi: triggersActionsUiMock.createStart(),
|
||||
storage: createMockStore(),
|
||||
data: dataPluginMock.createStartContract(),
|
||||
// @ts-ignore
|
||||
observability: {
|
||||
useRulesLink: () => ({ href: 'newRuleLink' }),
|
||||
observabilityRuleTypeRegistry: {
|
||||
register: jest.fn(),
|
||||
getFormatter: jest.fn(),
|
||||
list: jest.fn(),
|
||||
},
|
||||
},
|
||||
observabilityShared: {
|
||||
navigation: {
|
||||
// @ts-ignore
|
||||
PageTemplate: EuiPageTemplate,
|
||||
|
|
|
@ -13,7 +13,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { APP_WRAPPER_CLASS } from '@kbn/core/public';
|
||||
import { useInspectorContext } from '@kbn/observability-plugin/public';
|
||||
import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-plugin/public';
|
||||
import type { LazyObservabilityPageTemplateProps } from '@kbn/observability-shared-plugin/public';
|
||||
import {
|
||||
CERTIFICATES_ROUTE,
|
||||
MAPPING_ERROR_ROUTE,
|
||||
|
|
|
@ -46,6 +46,10 @@ import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
|
|||
import { SpacesPluginStart } from '@kbn/spaces-plugin/public';
|
||||
import type { DocLinksStart } from '@kbn/core-doc-links-browser';
|
||||
import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public';
|
||||
import type {
|
||||
ObservabilitySharedPluginSetup,
|
||||
ObservabilitySharedPluginStart,
|
||||
} from '@kbn/observability-shared-plugin/public';
|
||||
import { PLUGIN } from '../common/constants/plugin';
|
||||
import { OVERVIEW_ROUTE } from '../common/constants/ui';
|
||||
import {
|
||||
|
@ -66,6 +70,7 @@ export interface ClientPluginsSetup {
|
|||
data: DataPublicPluginSetup;
|
||||
exploratoryView: ExploratoryViewPublicSetup;
|
||||
observability: ObservabilityPublicSetup;
|
||||
observabilityShared: ObservabilitySharedPluginSetup;
|
||||
share: SharePluginSetup;
|
||||
triggersActionsUi: TriggersAndActionsUIPublicPluginSetup;
|
||||
cloud?: CloudSetup;
|
||||
|
@ -80,6 +85,7 @@ export interface ClientPluginsStart {
|
|||
embeddable: EmbeddableStart;
|
||||
exploratoryView: ExploratoryViewPublicStart;
|
||||
observability: ObservabilityPublicStart;
|
||||
observabilityShared: ObservabilitySharedPluginStart;
|
||||
share: SharePluginStart;
|
||||
triggersActionsUi: TriggersAndActionsUIPublicPluginStart;
|
||||
cases: CasesUiStart;
|
||||
|
@ -273,7 +279,7 @@ function registerUptimeRoutesWithNavigation(
|
|||
core: CoreSetup<ClientPluginsStart, unknown>,
|
||||
plugins: ClientPluginsSetup
|
||||
) {
|
||||
plugins.observability.navigation.registerSections(
|
||||
plugins.observabilityShared.navigation.registerSections(
|
||||
from(core.getStartServices()).pipe(
|
||||
map(([coreStart]) => {
|
||||
if (coreStart.application.capabilities.uptime.show) {
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
"@kbn/shared-ux-router",
|
||||
"@kbn/alerts-as-data-utils",
|
||||
"@kbn/exploratory-view-plugin",
|
||||
"@kbn/observability-shared-plugin",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
"exploratoryView",
|
||||
"licensing",
|
||||
"triggersActionsUi",
|
||||
"observabilityShared",
|
||||
"embeddable",
|
||||
"infra",
|
||||
"inspector",
|
||||
|
|
|
@ -110,6 +110,7 @@ export function UXAppRoot({
|
|||
inspector,
|
||||
maps,
|
||||
observability,
|
||||
observabilityShared,
|
||||
exploratoryView,
|
||||
data,
|
||||
dataViews,
|
||||
|
@ -138,6 +139,7 @@ export function UXAppRoot({
|
|||
...plugins,
|
||||
inspector,
|
||||
observability,
|
||||
observabilityShared,
|
||||
embeddable,
|
||||
exploratoryView,
|
||||
data,
|
||||
|
|
|
@ -25,9 +25,9 @@ export const DASHBOARD_LABEL = i18n.translate('xpack.ux.title', {
|
|||
});
|
||||
|
||||
export function RumHome() {
|
||||
const { docLinks, http, observability } = useKibanaServices();
|
||||
const { docLinks, http, observabilityShared } = useKibanaServices();
|
||||
|
||||
const PageTemplateComponent = observability.navigation.PageTemplate;
|
||||
const PageTemplateComponent = observabilityShared.navigation.PageTemplate;
|
||||
|
||||
const { hasData, loading: isLoading } = useHasRumData();
|
||||
|
||||
|
|
|
@ -38,6 +38,10 @@ import { MapsStartApi } from '@kbn/maps-plugin/public';
|
|||
import { Start as InspectorPluginStart } from '@kbn/inspector-plugin/public';
|
||||
import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
|
||||
import { LensPublicStart } from '@kbn/lens-plugin/public';
|
||||
import {
|
||||
ObservabilitySharedPluginSetup,
|
||||
ObservabilitySharedPluginStart,
|
||||
} from '@kbn/observability-shared-plugin/public';
|
||||
|
||||
export type UxPluginSetup = void;
|
||||
export type UxPluginStart = void;
|
||||
|
@ -49,6 +53,7 @@ export interface ApmPluginSetupDeps {
|
|||
home?: HomePublicPluginSetup;
|
||||
licensing: LicensingPluginSetup;
|
||||
observability: ObservabilityPublicSetup;
|
||||
observabilityShared: ObservabilitySharedPluginSetup;
|
||||
}
|
||||
|
||||
export interface ApmPluginStartDeps {
|
||||
|
@ -59,6 +64,7 @@ export interface ApmPluginStartDeps {
|
|||
maps?: MapsStartApi;
|
||||
inspector: InspectorPluginStart;
|
||||
observability: ObservabilityPublicStart;
|
||||
observabilityShared: ObservabilitySharedPluginStart;
|
||||
exploratoryView: ExploratoryViewPublicStart;
|
||||
dataViews: DataViewsPublicPluginStart;
|
||||
lens: LensPublicStart;
|
||||
|
@ -126,7 +132,7 @@ export class UxPlugin implements Plugin<UxPluginSetup, UxPluginStart> {
|
|||
}
|
||||
|
||||
// register observability nav if user has access to plugin
|
||||
plugins.observability.navigation.registerSections(
|
||||
plugins.observabilityShared.navigation.registerSections(
|
||||
from(core.getStartServices()).pipe(
|
||||
map(([coreStart]) => {
|
||||
// checking apm capability, since ux for now doesn't have it's
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
"@kbn/i18n-react",
|
||||
"@kbn/es-query",
|
||||
"@kbn/exploratory-view-plugin",
|
||||
"@kbn/observability-shared-plugin",
|
||||
],
|
||||
"exclude": [
|
||||
"target/**/*",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue