diff --git a/x-pack/plugins/observability/kibana.jsonc b/x-pack/plugins/observability/kibana.jsonc index ad5fac050d671..d49e3ea870a62 100644 --- a/x-pack/plugins/observability/kibana.jsonc +++ b/x-pack/plugins/observability/kibana.jsonc @@ -24,8 +24,7 @@ "unifiedSearch", "security", "guidedOnboarding", - "share", - "spaces" + "share" ], "optionalPlugins": [ "discover", diff --git a/x-pack/plugins/observability/public/hooks/use_kibana_space.tsx b/x-pack/plugins/observability/public/hooks/use_kibana_space.tsx index 11716e948d855..8f2ebf187dc77 100644 --- a/x-pack/plugins/observability/public/hooks/use_kibana_space.tsx +++ b/x-pack/plugins/observability/public/hooks/use_kibana_space.tsx @@ -15,7 +15,7 @@ export const useKibanaSpace = () => { data: space, loading, error, - } = useFetcher>(() => { + } = useFetcher | undefined>(() => { return services.spaces?.getActiveSpace(); }, [services.spaces]); diff --git a/x-pack/plugins/observability/public/pages/overview/containers/overview_page/helpers/use_metrics.ts b/x-pack/plugins/observability/public/pages/overview/containers/overview_page/helpers/use_metrics.ts index 78fffde25d629..dd9581bd67867 100644 --- a/x-pack/plugins/observability/public/pages/overview/containers/overview_page/helpers/use_metrics.ts +++ b/x-pack/plugins/observability/public/pages/overview/containers/overview_page/helpers/use_metrics.ts @@ -29,9 +29,22 @@ export const useOverviewMetrics = ({ hasAnyData }: { hasAnyData: boolean | undef } CAPABILITIES_KEYS.forEach((feature) => { - if (capabilities[feature].show === false) { + const name = feature === 'infrastructure' ? 'metrics' : feature; + + // Track metric if the feature has been disabled, either because it + // is missing or has show === false (manual disabling may not be + // possible in all versions of Kibana) + if (!capabilities[feature] || capabilities[feature]?.show === false) { + trackMetric({ + metric: `oblt_disabled_feature_${name}`, + }); + } + + // Track a separate metric if the feature is missing from the capabilities + // (This usually means the plugin was auto-disabled by Kibana) + if (!capabilities[feature]) { trackMetric({ - metric: `oblt_disabled_feature_${feature === 'infrastructure' ? 'metrics' : feature}`, + metric: `oblt_missing_feature_${name}`, }); } }); diff --git a/x-pack/plugins/observability/public/plugin.ts b/x-pack/plugins/observability/public/plugin.ts index e43725d0c5681..6af40e9a4345f 100644 --- a/x-pack/plugins/observability/public/plugin.ts +++ b/x-pack/plugins/observability/public/plugin.ts @@ -105,7 +105,7 @@ export interface ObservabilityPublicPluginsStart { ruleTypeRegistry: RuleTypeRegistryContract; security: SecurityPluginStart; share: SharePluginStart; - spaces: SpacesPluginStart; + spaces?: SpacesPluginStart; triggersActionsUi: TriggersAndActionsUIPublicPluginStart; usageCollection: UsageCollectionSetup; unifiedSearch: UnifiedSearchPublicPluginStart; diff --git a/x-pack/plugins/observability/server/plugin.ts b/x-pack/plugins/observability/server/plugin.ts index 39a69d7fa1666..e570fd7887952 100644 --- a/x-pack/plugins/observability/server/plugin.ts +++ b/x-pack/plugins/observability/server/plugin.ts @@ -17,6 +17,7 @@ import { PluginSetupContract } from '@kbn/alerting-plugin/server'; import { Dataset, RuleRegistryPluginSetupContract } from '@kbn/rule-registry-plugin/server'; import { PluginSetupContract as FeaturesSetup } from '@kbn/features-plugin/server'; import { createUICapabilities } from '@kbn/cases-plugin/common'; +import { SpacesPluginSetup } from '@kbn/spaces-plugin/server'; import { experimentalRuleFieldMap } from '@kbn/rule-registry-plugin/common/assets/field_maps/experimental_rule_field_map'; import { ECS_COMPONENT_TEMPLATE_NAME } from '@kbn/alerting-plugin/server'; import type { GuidedOnboardingPluginSetup } from '@kbn/guided-onboarding-plugin/server'; @@ -50,6 +51,7 @@ interface PluginSetup { features: FeaturesSetup; guidedOnboarding: GuidedOnboardingPluginSetup; ruleRegistry: RuleRegistryPluginSetupContract; + spaces?: SpacesPluginSetup; usageCollection?: UsageCollectionSetup; }