From 291c46ff136e25c371f027c85e1d6b19bac21774 Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Thu, 18 Jul 2024 10:44:08 +0100 Subject: [PATCH 01/10] [APM][ECO] Adding Service inventory view type to telemetry context --- ...ter_service_inventory_view_type_context.ts | 32 +++++++++++++++++++ .../entity_manager_context.tsx | 7 +++- .../apm/public/plugin.ts | 2 ++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts diff --git a/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts b/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts new file mode 100644 index 0000000000000..9e6b6b75f706f --- /dev/null +++ b/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts @@ -0,0 +1,32 @@ +/* + * 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 { AnalyticsServiceSetup } from '@kbn/core/public'; +import { BehaviorSubject } from 'rxjs'; +import { + serviceInventoryStorageKey, + ServiceInventoryView, +} from '../context/entity_manager_context/entity_manager_context'; + +export const serviceInventoryViewType$ = new BehaviorSubject({ + serviceInventoryViewType: JSON.parse( + window.localStorage.getItem(serviceInventoryStorageKey) || ServiceInventoryView.classic + ), +}); + +export function registerServiceInventoryViewTypeContext(analytics: AnalyticsServiceSetup) { + analytics.registerContextProvider({ + name: 'serviceInventoryViewType', + context$: serviceInventoryViewType$, + schema: { + serviceInventoryViewType: { + type: 'keyword', + _meta: { description: 'The APM service inventory view type' }, + }, + }, + }); +} diff --git a/x-pack/plugins/observability_solution/apm/public/context/entity_manager_context/entity_manager_context.tsx b/x-pack/plugins/observability_solution/apm/public/context/entity_manager_context/entity_manager_context.tsx index 14ff0fecc8878..d4f07964c8415 100644 --- a/x-pack/plugins/observability_solution/apm/public/context/entity_manager_context/entity_manager_context.tsx +++ b/x-pack/plugins/observability_solution/apm/public/context/entity_manager_context/entity_manager_context.tsx @@ -9,6 +9,7 @@ import { entityCentricExperience } from '@kbn/observability-plugin/common'; import { ENTITY_FETCH_STATUS, useEntityManager } from '../../hooks/use_entity_manager'; import { useLocalStorage } from '../../hooks/use_local_storage'; import { useApmPluginContext } from '../apm_plugin/use_apm_plugin_context'; +import { serviceInventoryViewType$ } from '../../analytics/register_service_inventory_view_type_context'; export interface EntityManagerEnablementContextValue { isEntityManagerEnabled: boolean; @@ -60,7 +61,11 @@ export function EntityManagerEnablementContextProvider({ isEnablementPending: status === ENTITY_FETCH_STATUS.LOADING, refetch, serviceInventoryViewLocalStorageSetting, - setServiceInventoryViewLocalStorageSetting, + setServiceInventoryViewLocalStorageSetting: (nextView) => { + setServiceInventoryViewLocalStorageSetting(nextView); + // Updates the telemetry context variable every time the user switches views + serviceInventoryViewType$.next({ serviceInventoryViewType: nextView }); + }, isEntityCentricExperienceViewEnabled, }} > diff --git a/x-pack/plugins/observability_solution/apm/public/plugin.ts b/x-pack/plugins/observability_solution/apm/public/plugin.ts index a07c8c5f4c206..c45d8f7abba64 100644 --- a/x-pack/plugins/observability_solution/apm/public/plugin.ts +++ b/x-pack/plugins/observability_solution/apm/public/plugin.ts @@ -82,6 +82,7 @@ import { getLazyAPMPolicyEditExtension } from './components/fleet_integration/la import { featureCatalogueEntry } from './feature_catalogue_entry'; import { APMServiceDetailLocator } from './locator/service_detail_locator'; import { ITelemetryClient, TelemetryService } from './services/telemetry'; +import { registerServiceInventoryViewTypeContext } from './analytics/register_service_inventory_view_type_context'; export type ApmPluginSetup = ReturnType; export type ApmPluginStart = void; @@ -273,6 +274,7 @@ export class ApmPlugin implements Plugin { }; this.telemetry.setup({ analytics: core.analytics }); + registerServiceInventoryViewTypeContext(core.analytics); // Registers a status check callback for the tutorial to call and verify if the APM integration is installed on fleet. pluginSetupDeps.home?.tutorials.registerCustomStatusCheck( From 650ea54ea1b86faff443e4fddb75d7a5f912e2fb Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Thu, 18 Jul 2024 12:37:54 +0100 Subject: [PATCH 02/10] entity_experience_status --- ...ister_service_inventory_view_type_context.ts | 7 +++---- .../entity_manager_context.tsx | 13 ++++++++++--- .../services/telemetry/telemetry_client.ts | 11 ++++++++++- .../services/telemetry/telemetry_events.ts | 17 ++++++++++++++++- .../apm/public/services/telemetry/types.ts | 12 +++++++++--- 5 files changed, 48 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts b/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts index 9e6b6b75f706f..ec80677aa7422 100644 --- a/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts +++ b/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts @@ -7,10 +7,9 @@ import { AnalyticsServiceSetup } from '@kbn/core/public'; import { BehaviorSubject } from 'rxjs'; -import { - serviceInventoryStorageKey, - ServiceInventoryView, -} from '../context/entity_manager_context/entity_manager_context'; +import { ServiceInventoryView } from '../context/entity_manager_context/entity_manager_context'; + +export const serviceInventoryStorageKey = 'apm.service.inventory.view'; export const serviceInventoryViewType$ = new BehaviorSubject({ serviceInventoryViewType: JSON.parse( diff --git a/x-pack/plugins/observability_solution/apm/public/context/entity_manager_context/entity_manager_context.tsx b/x-pack/plugins/observability_solution/apm/public/context/entity_manager_context/entity_manager_context.tsx index d4f07964c8415..6675fbc7a8855 100644 --- a/x-pack/plugins/observability_solution/apm/public/context/entity_manager_context/entity_manager_context.tsx +++ b/x-pack/plugins/observability_solution/apm/public/context/entity_manager_context/entity_manager_context.tsx @@ -9,7 +9,12 @@ import { entityCentricExperience } from '@kbn/observability-plugin/common'; import { ENTITY_FETCH_STATUS, useEntityManager } from '../../hooks/use_entity_manager'; import { useLocalStorage } from '../../hooks/use_local_storage'; import { useApmPluginContext } from '../apm_plugin/use_apm_plugin_context'; -import { serviceInventoryViewType$ } from '../../analytics/register_service_inventory_view_type_context'; +import { + serviceInventoryStorageKey, + serviceInventoryViewType$, +} from '../../analytics/register_service_inventory_view_type_context'; +import { useKibana } from '../kibana_context/use_kibana'; +import { ApmPluginStartDeps, ApmServices } from '../../plugin'; export interface EntityManagerEnablementContextValue { isEntityManagerEnabled: boolean; @@ -26,8 +31,6 @@ export enum ServiceInventoryView { entity = 'entity', } -export const serviceInventoryStorageKey = 'apm.service.inventory.view'; - export const EntityManagerEnablementContext = createContext( {} as EntityManagerEnablementContextValue ); @@ -38,6 +41,7 @@ export function EntityManagerEnablementContextProvider({ children: React.ReactChild; }) { const { core } = useApmPluginContext(); + const { services } = useKibana(); const { isEnabled: isEntityManagerEnabled, status, refetch } = useEntityManager(); const [serviceInventoryViewLocalStorageSetting, setServiceInventoryViewLocalStorageSetting] = @@ -65,6 +69,9 @@ export function EntityManagerEnablementContextProvider({ setServiceInventoryViewLocalStorageSetting(nextView); // Updates the telemetry context variable every time the user switches views serviceInventoryViewType$.next({ serviceInventoryViewType: nextView }); + services.telemetry.reportEntityExperienceStatusChange({ + status: nextView === ServiceInventoryView.entity ? 'enabled' : 'disabled', + }); }, isEntityCentricExperienceViewEnabled, }} diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_client.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_client.ts index ecbe95355e241..dd060cc9140d5 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_client.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_client.ts @@ -6,7 +6,12 @@ */ import { AnalyticsServiceSetup } from '@kbn/core-analytics-server'; -import { TelemetryEventTypes, ITelemetryClient, SearchQuerySubmittedParams } from './types'; +import { + ITelemetryClient, + SearchQuerySubmittedParams, + EntityExperienceStatusParams, + TelemetryEventTypes, +} from './types'; export class TelemetryClient implements ITelemetryClient { constructor(private analytics: AnalyticsServiceSetup) {} @@ -22,4 +27,8 @@ export class TelemetryClient implements ITelemetryClient { action, }); }; + + public reportEntityExperienceStatusChange = ({ status }: EntityExperienceStatusParams) => { + this.analytics.reportEvent(TelemetryEventTypes.ENTITY_EXPERIENCE_STATUS, { status }); + }; } diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts index e4f4878342133..30fa9f3d0c504 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts @@ -33,4 +33,19 @@ const searchQuerySubmittedEventType: TelemetryEvent = { }, }; -export const apmTelemetryEventBasedTypes = [searchQuerySubmittedEventType]; +const entityExperienceStatusEventType: TelemetryEvent = { + eventType: TelemetryEventTypes.ENTITY_EXPERIENCE_STATUS, + schema: { + status: { + type: 'keyword', + _meta: { + description: 'The status of the Entity experience (Enabled or Disabled)', + }, + }, + }, +}; + +export const apmTelemetryEventBasedTypes = [ + searchQuerySubmittedEventType, + entityExperienceStatusEventType, +]; diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts index 5592974de2d40..283526eb0e6c4 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts @@ -21,17 +21,23 @@ export interface SearchQuerySubmittedParams { action: SearchQueryActions; } -export type TelemetryEventParams = SearchQuerySubmittedParams; +export interface EntityExperienceStatusParams { + status: 'enabled' | 'disabled'; +} + +export type TelemetryEventParams = SearchQuerySubmittedParams | EntityExperienceStatusParams; export interface ITelemetryClient { reportSearchQuerySubmitted(params: SearchQuerySubmittedParams): void; + reportEntityExperienceStatusChange(params: EntityExperienceStatusParams): void; } export enum TelemetryEventTypes { SEARCH_QUERY_SUBMITTED = 'Search Query Submitted', + ENTITY_EXPERIENCE_STATUS = 'entity_experience_status', } export interface TelemetryEvent { - eventType: TelemetryEventTypes.SEARCH_QUERY_SUBMITTED; - schema: RootSchema; + eventType: TelemetryEventTypes; + schema: RootSchema; } From be0747a75dc9a08d9cfc1e9acaacf23306fe50e1 Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Thu, 18 Jul 2024 13:09:29 +0100 Subject: [PATCH 03/10] entity_inventory_page_state --- .../multi_signal_inventory/index.tsx | 11 ++++++++++- .../table/no_entities_empty_state.tsx | 9 ++++++++- .../public/services/telemetry/telemetry_client.ts | 5 +++++ .../public/services/telemetry/telemetry_events.ts | 13 +++++++++++++ .../apm/public/services/telemetry/types.ts | 11 ++++++++++- 5 files changed, 46 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/index.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/index.tsx index 004599c31357f..eea4168b73c92 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/index.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/index.tsx @@ -6,7 +6,7 @@ */ import { EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import React from 'react'; +import React, { useEffect } from 'react'; import { v4 as uuidv4 } from 'uuid'; import { ApmDocumentType } from '../../../../../common/document_type'; import { APIReturnType } from '../../../../services/rest/create_call_apm_api'; @@ -27,6 +27,8 @@ import { ServiceListItem } from '../../../../../common/service_inventory'; import { usePreferredDataSourceAndBucketSize } from '../../../../hooks/use_preferred_data_source_and_bucket_size'; import { useProgressiveFetcher } from '../../../../hooks/use_progressive_fetcher'; import { NoEntitiesEmptyState } from './table/no_entities_empty_state'; +import { useKibana } from '../../../../context/kibana_context/use_kibana'; +import { ApmPluginStartDeps, ApmServices } from '../../../../plugin'; type MainStatisticsApiResponse = APIReturnType<'GET /internal/apm/entities/services'>; @@ -143,6 +145,7 @@ function useServicesEntitiesDetailedStatisticsFetcher({ export function MultiSignalInventory() { const [searchQuery, setSearchQuery] = React.useState(''); + const { services } = useKibana(); const { mainStatisticsData, mainStatisticsStatus } = useServicesEntitiesMainStatisticsFetcher(); const mainStatisticsFetch = useServicesEntitiesMainStatisticsFetcher(); @@ -163,6 +166,12 @@ export function MultiSignalInventory() { return callApmApi('GET /internal/apm/has_entities'); }, []); + useEffect(() => { + if (data?.hasData) { + services.telemetry.reportEntityInventoryPageState({ state: 'available' }); + } + }, [services.telemetry, data?.hasData]); + if (!data?.hasData && status === FETCH_STATUS.SUCCESS) { return ; } diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx index 7a04cea29dc16..934224d89acc4 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React from 'react'; +import React, { useEffect } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiCallOut, @@ -27,15 +27,22 @@ import { AssociateServiceLogs, CollectServiceLogs, } from '../../../../shared/add_data_buttons/buttons'; +import { useKibana } from '../../../../../context/kibana_context/use_kibana'; +import { ApmPluginStartDeps, ApmServices } from '../../../../../plugin'; export function NoEntitiesEmptyState() { const { core } = useApmPluginContext(); + const { services } = useKibana(); const { basePath } = core.http; const [userHasDismissedCallout, setUserHasDismissedCallout] = useLocalStorage( 'apm.uiNewExperienceCallout', false ); + useEffect(() => { + services.telemetry.reportEntityInventoryPageState({ state: 'empty_state' }); + }, [services.telemetry]); + return ( diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_client.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_client.ts index dd060cc9140d5..92bc34a415b77 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_client.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_client.ts @@ -11,6 +11,7 @@ import { SearchQuerySubmittedParams, EntityExperienceStatusParams, TelemetryEventTypes, + EntityInventoryPageStateParams, } from './types'; export class TelemetryClient implements ITelemetryClient { @@ -31,4 +32,8 @@ export class TelemetryClient implements ITelemetryClient { public reportEntityExperienceStatusChange = ({ status }: EntityExperienceStatusParams) => { this.analytics.reportEvent(TelemetryEventTypes.ENTITY_EXPERIENCE_STATUS, { status }); }; + + public reportEntityInventoryPageState = ({ state }: EntityInventoryPageStateParams) => { + this.analytics.reportEvent(TelemetryEventTypes.ENTITY_INVENTORY_PAGE_STATE, { state }); + }; } diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts index 30fa9f3d0c504..1568f0f902f96 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts @@ -45,7 +45,20 @@ const entityExperienceStatusEventType: TelemetryEvent = { }, }; +const entityInventoryPageStateEventType: TelemetryEvent = { + eventType: TelemetryEventTypes.ENTITY_INVENTORY_PAGE_STATE, + schema: { + state: { + type: 'keyword', + _meta: { + description: 'The current entity inventory page state (empty_state or available)', + }, + }, + }, +}; + export const apmTelemetryEventBasedTypes = [ searchQuerySubmittedEventType, entityExperienceStatusEventType, + entityInventoryPageStateEventType, ]; diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts index 283526eb0e6c4..c6258e3c99543 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts @@ -25,16 +25,25 @@ export interface EntityExperienceStatusParams { status: 'enabled' | 'disabled'; } -export type TelemetryEventParams = SearchQuerySubmittedParams | EntityExperienceStatusParams; +export interface EntityInventoryPageStateParams { + state: 'empty_state' | 'available'; +} + +export type TelemetryEventParams = + | SearchQuerySubmittedParams + | EntityExperienceStatusParams + | EntityInventoryPageStateParams; export interface ITelemetryClient { reportSearchQuerySubmitted(params: SearchQuerySubmittedParams): void; reportEntityExperienceStatusChange(params: EntityExperienceStatusParams): void; + reportEntityInventoryPageState(params: EntityInventoryPageStateParams): void; } export enum TelemetryEventTypes { SEARCH_QUERY_SUBMITTED = 'Search Query Submitted', ENTITY_EXPERIENCE_STATUS = 'entity_experience_status', + ENTITY_INVENTORY_PAGE_STATE = 'entity_inventory_page_state', } export interface TelemetryEvent { From e8c70e6c1a91ff0e41fadcd2fb03baa08e89bc56 Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Thu, 18 Jul 2024 14:56:46 +0100 Subject: [PATCH 04/10] entity_inventory_data --- .../app/entities/logs/add_apm_callout.tsx | 19 +++++--- .../table/get_service_columns.tsx | 2 - .../table/no_entities_empty_state.tsx | 28 ++++++++++-- .../add_data_context_menu.tsx | 22 +++++++++ .../shared/add_data_buttons/buttons.tsx | 45 ++++++++++--------- .../shared/not_available_apm_metrics.tsx | 23 ++++++---- .../services/telemetry/telemetry_client.ts | 13 ++++-- .../services/telemetry/telemetry_events.ts | 22 +++++++++ .../apm/public/services/telemetry/types.ts | 10 ++++- 9 files changed, 139 insertions(+), 45 deletions(-) diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/entities/logs/add_apm_callout.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/entities/logs/add_apm_callout.tsx index 77bec8cebb188..43026305def18 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/entities/logs/add_apm_callout.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/entities/logs/add_apm_callout.tsx @@ -20,11 +20,21 @@ import { } from '@elastic/eui'; import { apmLight } from '@kbn/shared-svg'; import { FormattedMessage } from '@kbn/i18n-react'; -import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context'; +import { useHistory } from 'react-router-dom'; +import { useKibana } from '../../../../context/kibana_context/use_kibana'; +import { ApmPluginStartDeps, ApmServices } from '../../../../plugin'; export function AddAPMCallOut() { - const { core } = useApmPluginContext(); const { euiTheme } = useEuiTheme(); + const { services } = useKibana(); + const history = useHistory(); + + function handleClick() { + services.telemetry.reportEntityInventoryAddData({ + type: 'add_apm_cta', + }); + history.push('/tutorial'); + } return ( @@ -68,10 +78,7 @@ export function AddAPMCallOut() {
- + {i18n.translate('xpack.apm.logsServiceOverview.callout.addApm', { defaultMessage: 'Add APM', })} diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/get_service_columns.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/get_service_columns.tsx index 0fe647b2c5127..b874d74ba8655 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/get_service_columns.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/get_service_columns.tsx @@ -46,13 +46,11 @@ type ServicesDetailedStatisticsAPIResponse = export function getServiceColumns({ query, breakpoints, - link, timeseriesDataLoading, timeseriesData, }: { query: TypeOf['query']; breakpoints: Breakpoints; - link: any; timeseriesDataLoading: boolean; timeseriesData?: ServicesDetailedStatisticsAPIResponse; }): Array> { diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx index 934224d89acc4..361dc72169d7c 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx @@ -29,6 +29,7 @@ import { } from '../../../../shared/add_data_buttons/buttons'; import { useKibana } from '../../../../../context/kibana_context/use_kibana'; import { ApmPluginStartDeps, ApmServices } from '../../../../../plugin'; +import { EntityInventoryAddDataParams } from '../../../../../services/telemetry'; export function NoEntitiesEmptyState() { const { core } = useApmPluginContext(); @@ -43,6 +44,13 @@ export function NoEntitiesEmptyState() { services.telemetry.reportEntityInventoryPageState({ state: 'empty_state' }); }, [services.telemetry]); + function reportButtonClick(journey: EntityInventoryAddDataParams['journey']) { + services.telemetry.reportEntityInventoryAddData({ + type: 'empty_state', + journey, + }); + } + return ( @@ -83,9 +91,23 @@ export function NoEntitiesEmptyState() { actions={ - - - + { + reportButtonClick('add_apm_agent'); + }} + /> + { + reportButtonClick('associate_existing_service_logs'); + }} + /> + { + reportButtonClick('collect_new_service_logs'); + }} + /> {!userHasDismissedCallout && ( diff --git a/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/apm_header_action_menu/add_data_context_menu.tsx b/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/apm_header_action_menu/add_data_context_menu.tsx index 32019f60aa09f..ae1b5b7c8ef89 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/apm_header_action_menu/add_data_context_menu.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/apm_header_action_menu/add_data_context_menu.tsx @@ -14,6 +14,9 @@ import { import { i18n } from '@kbn/i18n'; import React, { useState } from 'react'; import { useApmPluginContext } from '../../../../context/apm_plugin/use_apm_plugin_context'; +import { useKibana } from '../../../../context/kibana_context/use_kibana'; +import { ApmPluginStartDeps, ApmServices } from '../../../../plugin'; +import { EntityInventoryAddDataParams } from '../../../../services/telemetry'; import { associateServiceLogs, collectServiceLogs, @@ -26,6 +29,7 @@ const addData = i18n.translate('xpack.apm.addDataContextMenu.link', { export function AddDataContextMenu() { const [popoverOpen, setPopoverOpen] = useState(false); + const { services } = useKibana(); const { core: { http: { basePath }, @@ -44,6 +48,13 @@ export function AddDataContextMenu() { ); + function reportButtonClick(journey: EntityInventoryAddDataParams['journey']) { + services.telemetry.reportEntityInventoryAddData({ + type: 'add_data_button', + journey, + }); + } + const panels: EuiContextMenuPanelDescriptor[] = [ { id: 0, @@ -53,17 +64,28 @@ export function AddDataContextMenu() { name: associateServiceLogs.name, href: associateServiceLogs.link, 'data-test-subj': 'apmAddDataAssociateServiceLogs', + target: '_blank', + onClick: () => { + reportButtonClick('associate_existing_service_logs'); + }, }, { name: collectServiceLogs.name, href: basePath.prepend(collectServiceLogs.link), 'data-test-subj': 'apmAddDataCollectServiceLogs', + target: '_blank', + onClick: () => { + reportButtonClick('collect_new_service_logs'); + }, }, { name: addApmAgent.name, href: basePath.prepend(addApmAgent.link), icon: 'plusInCircle', 'data-test-subj': 'apmAddDataApmAgent', + onClick: () => { + reportButtonClick('add_apm_agent'); + }, }, ], }, diff --git a/x-pack/plugins/observability_solution/apm/public/components/shared/add_data_buttons/buttons.tsx b/x-pack/plugins/observability_solution/apm/public/components/shared/add_data_buttons/buttons.tsx index e02934897b69f..6b37614261174 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/shared/add_data_buttons/buttons.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/shared/add_data_buttons/buttons.tsx @@ -30,40 +30,43 @@ export const collectServiceLogs = { link: '/app/observabilityOnboarding/?category=logs', }; -export function AddApmAgent({ basePath }: { basePath: IBasePath }) { +export function AddApmAgent({ basePath, onClick }: { basePath: IBasePath; onClick?: () => void }) { + function handleClick() { + window.open(basePath.prepend(addApmAgent.link), '_blank'); + onClick?.(); + } return ( - + {addApmAgent.name} ); } -export function AssociateServiceLogs() { +export function AssociateServiceLogs({ onClick }: { onClick?: () => void }) { + function handleClick() { + window.open(associateServiceLogs.link, '_blank'); + onClick?.(); + } return ( - + {associateServiceLogs.name} ); } -export function CollectServiceLogs({ basePath }: { basePath: IBasePath }) { +export function CollectServiceLogs({ + basePath, + onClick, +}: { + basePath: IBasePath; + onClick?: () => void; +}) { + function handleClick() { + window.open(basePath.prepend(collectServiceLogs.link), '_blank'); + onClick?.(); + } return ( - + {collectServiceLogs.name} ); diff --git a/x-pack/plugins/observability_solution/apm/public/components/shared/not_available_apm_metrics.tsx b/x-pack/plugins/observability_solution/apm/public/components/shared/not_available_apm_metrics.tsx index 03253fa4282d4..7e1483b435ad6 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/shared/not_available_apm_metrics.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/shared/not_available_apm_metrics.tsx @@ -8,11 +8,21 @@ import React from 'react'; import { EuiButton } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import { useHistory } from 'react-router-dom'; import { PopoverBadge } from './popover_badge'; -import { useApmPluginContext } from '../../context/apm_plugin/use_apm_plugin_context'; +import { useKibana } from '../../context/kibana_context/use_kibana'; +import { ApmPluginStartDeps, ApmServices } from '../../plugin'; -export const NotAvailableApmMetrics = () => { - const { core } = useApmPluginContext(); +export function NotAvailableApmMetrics() { + const { services } = useKibana(); + const history = useHistory(); + + function handleClick() { + services.telemetry.reportEntityInventoryAddData({ + type: 'add_apm_n/a', + }); + history.push('/tutorial'); + } return ( { 'Understand key metrics like transaction latency, throughput and error rate by instrumenting your service with APM.', })} footer={ - + {i18n.translate('xpack.apm.servicesTable.notAvailableApmMetrics.footer', { defaultMessage: 'Add APM', })} @@ -34,4 +41,4 @@ export const NotAvailableApmMetrics = () => { } /> ); -}; +} diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_client.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_client.ts index 92bc34a415b77..4b1d645fab78c 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_client.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_client.ts @@ -12,6 +12,7 @@ import { EntityExperienceStatusParams, TelemetryEventTypes, EntityInventoryPageStateParams, + EntityInventoryAddDataParams, } from './types'; export class TelemetryClient implements ITelemetryClient { @@ -29,11 +30,15 @@ export class TelemetryClient implements ITelemetryClient { }); }; - public reportEntityExperienceStatusChange = ({ status }: EntityExperienceStatusParams) => { - this.analytics.reportEvent(TelemetryEventTypes.ENTITY_EXPERIENCE_STATUS, { status }); + public reportEntityExperienceStatusChange = (params: EntityExperienceStatusParams) => { + this.analytics.reportEvent(TelemetryEventTypes.ENTITY_EXPERIENCE_STATUS, params); }; - public reportEntityInventoryPageState = ({ state }: EntityInventoryPageStateParams) => { - this.analytics.reportEvent(TelemetryEventTypes.ENTITY_INVENTORY_PAGE_STATE, { state }); + public reportEntityInventoryPageState = (params: EntityInventoryPageStateParams) => { + this.analytics.reportEvent(TelemetryEventTypes.ENTITY_INVENTORY_PAGE_STATE, params); + }; + + public reportEntityInventoryAddData = (params: EntityInventoryAddDataParams) => { + this.analytics.reportEvent(TelemetryEventTypes.ENTITY_INVENTORY_ADD_DATA, params); }; } diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts index 1568f0f902f96..09279ee6dd3d7 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts @@ -57,8 +57,30 @@ const entityInventoryPageStateEventType: TelemetryEvent = { }, }; +const entityInventoryAddDataEventType: TelemetryEvent = { + eventType: TelemetryEventTypes.ENTITY_INVENTORY_ADD_DATA, + schema: { + type: { + type: 'keyword', + _meta: { + description: + 'Where the action was initiated (empty_state or add_data_button or add_apm_cta)', + }, + }, + journey: { + type: 'keyword', + _meta: { + optional: true, + description: + 'Which action was performed (add_apm_agent or associate_existing_service_logs orcollect_new_service_logs)', + }, + }, + }, +}; + export const apmTelemetryEventBasedTypes = [ searchQuerySubmittedEventType, entityExperienceStatusEventType, entityInventoryPageStateEventType, + entityInventoryAddDataEventType, ]; diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts index c6258e3c99543..f5f06041acfac 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts @@ -29,21 +29,29 @@ export interface EntityInventoryPageStateParams { state: 'empty_state' | 'available'; } +export interface EntityInventoryAddDataParams { + type: 'empty_state' | 'add_data_button' | 'add_apm_cta' | 'add_apm_n/a'; + journey?: 'add_apm_agent' | 'associate_existing_service_logs' | 'collect_new_service_logs'; +} + export type TelemetryEventParams = | SearchQuerySubmittedParams | EntityExperienceStatusParams - | EntityInventoryPageStateParams; + | EntityInventoryPageStateParams + | EntityInventoryAddDataParams; export interface ITelemetryClient { reportSearchQuerySubmitted(params: SearchQuerySubmittedParams): void; reportEntityExperienceStatusChange(params: EntityExperienceStatusParams): void; reportEntityInventoryPageState(params: EntityInventoryPageStateParams): void; + reportEntityInventoryAddData(params: EntityInventoryAddDataParams): void; } export enum TelemetryEventTypes { SEARCH_QUERY_SUBMITTED = 'Search Query Submitted', ENTITY_EXPERIENCE_STATUS = 'entity_experience_status', ENTITY_INVENTORY_PAGE_STATE = 'entity_inventory_page_state', + ENTITY_INVENTORY_ADD_DATA = 'entity_inventory_data', } export interface TelemetryEvent { From b32f2a5a88dd1f03ba5912033a484d0f700d1d8d Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Thu, 18 Jul 2024 14:56:57 +0100 Subject: [PATCH 05/10] entity_inventory_add_data --- .../apm/public/services/telemetry/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts index f5f06041acfac..ec5282c9ac6ad 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts @@ -51,7 +51,7 @@ export enum TelemetryEventTypes { SEARCH_QUERY_SUBMITTED = 'Search Query Submitted', ENTITY_EXPERIENCE_STATUS = 'entity_experience_status', ENTITY_INVENTORY_PAGE_STATE = 'entity_inventory_page_state', - ENTITY_INVENTORY_ADD_DATA = 'entity_inventory_data', + ENTITY_INVENTORY_ADD_DATA = 'entity_inventory_add_data', } export interface TelemetryEvent { From 170f3e365b536d2a26723cde83a8c7f4bf9dbe4b Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Mon, 22 Jul 2024 09:43:43 +0100 Subject: [PATCH 06/10] PR comments --- ...ter_service_inventory_view_type_context.ts | 4 ++-- .../table/no_entities_empty_state.tsx | 23 ++++++++++--------- .../entity_manager_context.tsx | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts b/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts index ec80677aa7422..d25504d8ee446 100644 --- a/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts +++ b/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts @@ -9,11 +9,11 @@ import { AnalyticsServiceSetup } from '@kbn/core/public'; import { BehaviorSubject } from 'rxjs'; import { ServiceInventoryView } from '../context/entity_manager_context/entity_manager_context'; -export const serviceInventoryStorageKey = 'apm.service.inventory.view'; +export const SERVICE_INVENTORY_STORAGE_KEY = 'apm.service.inventory.view'; export const serviceInventoryViewType$ = new BehaviorSubject({ serviceInventoryViewType: JSON.parse( - window.localStorage.getItem(serviceInventoryStorageKey) || ServiceInventoryView.classic + window.localStorage.getItem(SERVICE_INVENTORY_STORAGE_KEY) || ServiceInventoryView.classic ), }); diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx index 361dc72169d7c..3cab86437fc00 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx @@ -5,31 +5,32 @@ * 2.0. */ -import React, { useEffect } from 'react'; -import { i18n } from '@kbn/i18n'; import { EuiCallOut, - EuiLink, EuiEmptyPrompt, - EuiImage, + EuiFlexGroup, + EuiFlexItem, EuiHorizontalRule, + EuiImage, + EuiLink, EuiText, EuiTextColor, - EuiFlexGroup, - EuiFlexItem, } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import React from 'react'; import { dashboardsLight } from '@kbn/shared-svg'; +import useEffectOnce from 'react-use/lib/useEffectOnce'; import { useApmPluginContext } from '../../../../../context/apm_plugin/use_apm_plugin_context'; +import { useKibana } from '../../../../../context/kibana_context/use_kibana'; import { useLocalStorage } from '../../../../../hooks/use_local_storage'; +import { ApmPluginStartDeps, ApmServices } from '../../../../../plugin'; +import { EntityInventoryAddDataParams } from '../../../../../services/telemetry'; import { AddApmAgent, AssociateServiceLogs, CollectServiceLogs, } from '../../../../shared/add_data_buttons/buttons'; -import { useKibana } from '../../../../../context/kibana_context/use_kibana'; -import { ApmPluginStartDeps, ApmServices } from '../../../../../plugin'; -import { EntityInventoryAddDataParams } from '../../../../../services/telemetry'; export function NoEntitiesEmptyState() { const { core } = useApmPluginContext(); @@ -40,9 +41,9 @@ export function NoEntitiesEmptyState() { false ); - useEffect(() => { + useEffectOnce(() => { services.telemetry.reportEntityInventoryPageState({ state: 'empty_state' }); - }, [services.telemetry]); + }); function reportButtonClick(journey: EntityInventoryAddDataParams['journey']) { services.telemetry.reportEntityInventoryAddData({ diff --git a/x-pack/plugins/observability_solution/apm/public/context/entity_manager_context/entity_manager_context.tsx b/x-pack/plugins/observability_solution/apm/public/context/entity_manager_context/entity_manager_context.tsx index 6675fbc7a8855..f68ca17bb8dad 100644 --- a/x-pack/plugins/observability_solution/apm/public/context/entity_manager_context/entity_manager_context.tsx +++ b/x-pack/plugins/observability_solution/apm/public/context/entity_manager_context/entity_manager_context.tsx @@ -10,7 +10,7 @@ import { ENTITY_FETCH_STATUS, useEntityManager } from '../../hooks/use_entity_ma import { useLocalStorage } from '../../hooks/use_local_storage'; import { useApmPluginContext } from '../apm_plugin/use_apm_plugin_context'; import { - serviceInventoryStorageKey, + SERVICE_INVENTORY_STORAGE_KEY, serviceInventoryViewType$, } from '../../analytics/register_service_inventory_view_type_context'; import { useKibana } from '../kibana_context/use_kibana'; @@ -45,7 +45,7 @@ export function EntityManagerEnablementContextProvider({ const { isEnabled: isEntityManagerEnabled, status, refetch } = useEntityManager(); const [serviceInventoryViewLocalStorageSetting, setServiceInventoryViewLocalStorageSetting] = - useLocalStorage(serviceInventoryStorageKey, ServiceInventoryView.classic); + useLocalStorage(SERVICE_INVENTORY_STORAGE_KEY, ServiceInventoryView.classic); const isEntityCentricExperienceSettingEnabled = core.uiSettings.get( entityCentricExperience, From a81f4019a16181f796e625817cbba400add307bc Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Mon, 22 Jul 2024 10:45:04 +0100 Subject: [PATCH 07/10] PR comment --- .../apm/public/services/telemetry/telemetry_events.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts index 09279ee6dd3d7..66f081361e7a5 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts @@ -72,7 +72,7 @@ const entityInventoryAddDataEventType: TelemetryEvent = { _meta: { optional: true, description: - 'Which action was performed (add_apm_agent or associate_existing_service_logs orcollect_new_service_logs)', + 'Which action was performed (add_apm_agent or associate_existing_service_logs or collect_new_service_logs)', }, }, }, From bbb444ac21b2afcd571dd2e61d6cad5d70733ad3 Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Mon, 22 Jul 2024 15:11:28 +0100 Subject: [PATCH 08/10] PR comments --- .../apm/public/components/app/entities/logs/add_apm_callout.tsx | 2 +- .../multi_signal_inventory/table/no_entities_empty_state.tsx | 2 +- .../app_root/apm_header_action_menu/add_data_context_menu.tsx | 2 +- .../apm/public/components/shared/not_available_apm_metrics.tsx | 2 +- .../apm/public/services/telemetry/telemetry_events.ts | 2 +- .../apm/public/services/telemetry/types.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/entities/logs/add_apm_callout.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/entities/logs/add_apm_callout.tsx index 43026305def18..276ed47d68b67 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/entities/logs/add_apm_callout.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/entities/logs/add_apm_callout.tsx @@ -31,7 +31,7 @@ export function AddAPMCallOut() { function handleClick() { services.telemetry.reportEntityInventoryAddData({ - type: 'add_apm_cta', + view: 'add_apm_cta', }); history.push('/tutorial'); } diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx index 3cab86437fc00..e3472aecd0f61 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/no_entities_empty_state.tsx @@ -47,7 +47,7 @@ export function NoEntitiesEmptyState() { function reportButtonClick(journey: EntityInventoryAddDataParams['journey']) { services.telemetry.reportEntityInventoryAddData({ - type: 'empty_state', + view: 'empty_state', journey, }); } diff --git a/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/apm_header_action_menu/add_data_context_menu.tsx b/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/apm_header_action_menu/add_data_context_menu.tsx index ae1b5b7c8ef89..f7d8110d8aa79 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/apm_header_action_menu/add_data_context_menu.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/routing/app_root/apm_header_action_menu/add_data_context_menu.tsx @@ -50,7 +50,7 @@ export function AddDataContextMenu() { function reportButtonClick(journey: EntityInventoryAddDataParams['journey']) { services.telemetry.reportEntityInventoryAddData({ - type: 'add_data_button', + view: 'add_data_button', journey, }); } diff --git a/x-pack/plugins/observability_solution/apm/public/components/shared/not_available_apm_metrics.tsx b/x-pack/plugins/observability_solution/apm/public/components/shared/not_available_apm_metrics.tsx index 7e1483b435ad6..4576fde756828 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/shared/not_available_apm_metrics.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/shared/not_available_apm_metrics.tsx @@ -19,7 +19,7 @@ export function NotAvailableApmMetrics() { function handleClick() { services.telemetry.reportEntityInventoryAddData({ - type: 'add_apm_n/a', + view: 'add_apm_n/a', }); history.push('/tutorial'); } diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts index 66f081361e7a5..9cc3cc772a621 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/telemetry_events.ts @@ -60,7 +60,7 @@ const entityInventoryPageStateEventType: TelemetryEvent = { const entityInventoryAddDataEventType: TelemetryEvent = { eventType: TelemetryEventTypes.ENTITY_INVENTORY_ADD_DATA, schema: { - type: { + view: { type: 'keyword', _meta: { description: diff --git a/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts b/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts index ec5282c9ac6ad..173831bbf0d7c 100644 --- a/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts +++ b/x-pack/plugins/observability_solution/apm/public/services/telemetry/types.ts @@ -30,7 +30,7 @@ export interface EntityInventoryPageStateParams { } export interface EntityInventoryAddDataParams { - type: 'empty_state' | 'add_data_button' | 'add_apm_cta' | 'add_apm_n/a'; + view: 'empty_state' | 'add_data_button' | 'add_apm_cta' | 'add_apm_n/a'; journey?: 'add_apm_agent' | 'associate_existing_service_logs' | 'collect_new_service_logs'; } From 1cc21776b65ce752762da7f608d63b656ef6290b Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Tue, 23 Jul 2024 12:52:30 +0100 Subject: [PATCH 09/10] fixing tests --- ...egister_service_inventory_view_type_context.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts b/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts index d25504d8ee446..c26a84bb07b6c 100644 --- a/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts +++ b/x-pack/plugins/observability_solution/apm/public/analytics/register_service_inventory_view_type_context.ts @@ -11,13 +11,18 @@ import { ServiceInventoryView } from '../context/entity_manager_context/entity_m export const SERVICE_INVENTORY_STORAGE_KEY = 'apm.service.inventory.view'; -export const serviceInventoryViewType$ = new BehaviorSubject({ - serviceInventoryViewType: JSON.parse( - window.localStorage.getItem(SERVICE_INVENTORY_STORAGE_KEY) || ServiceInventoryView.classic - ), -}); +export let serviceInventoryViewType$: BehaviorSubject<{ serviceInventoryViewType: string }>; export function registerServiceInventoryViewTypeContext(analytics: AnalyticsServiceSetup) { + const serviceInventoryLocalStorageValue = window.localStorage.getItem( + SERVICE_INVENTORY_STORAGE_KEY + ); + serviceInventoryViewType$ = new BehaviorSubject({ + serviceInventoryViewType: + serviceInventoryLocalStorageValue === null + ? ServiceInventoryView.classic + : JSON.parse(serviceInventoryLocalStorageValue), + }); analytics.registerContextProvider({ name: 'serviceInventoryViewType', context$: serviceInventoryViewType$, From 88c93758a67a017c22cface60d099a57864c1bfa Mon Sep 17 00:00:00 2001 From: Caue Marcondes Date: Tue, 23 Jul 2024 16:20:09 +0100 Subject: [PATCH 10/10] fixin ci --- .../table/multi_signal_services_table.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/multi_signal_services_table.tsx b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/multi_signal_services_table.tsx index 12980917d82c0..eede4b2ef346c 100644 --- a/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/multi_signal_services_table.tsx +++ b/x-pack/plugins/observability_solution/apm/public/components/app/service_inventory/multi_signal_inventory/table/multi_signal_services_table.tsx @@ -9,7 +9,6 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { omit } from 'lodash'; import React, { useMemo } from 'react'; import { useApmParams } from '../../../../../hooks/use_apm_params'; -import { useApmRouter } from '../../../../../hooks/use_apm_router'; import { useBreakpoints } from '../../../../../hooks/use_breakpoints'; import { FETCH_STATUS, isFailure, isPending } from '../../../../../hooks/use_fetcher'; import { APIReturnType } from '../../../../../services/rest/create_call_apm_api'; @@ -53,18 +52,16 @@ export function MultiSignalServicesTable({ }: Props) { const breakpoints = useBreakpoints(); const { query } = useApmParams('/services'); - const { link } = useApmRouter(); const serviceColumns = useMemo(() => { return getServiceColumns({ // removes pagination and sort instructions from the query so it won't be passed down to next route query: omit(query, 'page', 'pageSize', 'sortDirection', 'sortField'), breakpoints, - link, timeseriesDataLoading, timeseriesData, }); - }, [query, breakpoints, link, timeseriesDataLoading, timeseriesData]); + }, [query, breakpoints, timeseriesDataLoading, timeseriesData]); return (