diff --git a/x-pack/plugins/enterprise_search/server/collectors/app_search/telemetry.ts b/x-pack/plugins/enterprise_search/server/collectors/app_search/telemetry.ts index 2a396ead2f718..f9376f65f79a7 100644 --- a/x-pack/plugins/enterprise_search/server/collectors/app_search/telemetry.ts +++ b/x-pack/plugins/enterprise_search/server/collectors/app_search/telemetry.ts @@ -12,7 +12,23 @@ import { } from 'src/core/server'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; -import { AS_TELEMETRY_NAME, ITelemetrySavedObject } from '../../saved_objects/app_search/telemetry'; +interface ITelemetry { + ui_viewed: { + setup_guide: number; + engines_overview: number; + }; + ui_error: { + cannot_connect: number; + no_as_account: number; + }; + ui_clicked: { + create_first_engine_button: number; + header_launch_button: number; + engine_table_link: number; + }; +} + +export const AS_TELEMETRY_NAME = 'app_search_telemetry'; /** * Register the telemetry collector @@ -22,10 +38,25 @@ export const registerTelemetryUsageCollector = ( usageCollection: UsageCollectionSetup, savedObjects: SavedObjectsServiceStart ) => { - const telemetryUsageCollector = usageCollection.makeUsageCollector({ + const telemetryUsageCollector = usageCollection.makeUsageCollector({ type: 'app_search', fetch: async () => fetchTelemetryMetrics(savedObjects), isReady: () => true, + schema: { + ui_viewed: { + setup_guide: { type: 'long' }, + engines_overview: { type: 'long' }, + }, + ui_error: { + cannot_connect: { type: 'long' }, + no_as_account: { type: 'long' }, + }, + ui_clicked: { + create_first_engine_button: { type: 'long' }, + header_launch_button: { type: 'long' }, + engine_table_link: { type: 'long' }, + }, + }, }); usageCollection.registerCollector(telemetryUsageCollector); }; @@ -40,7 +71,7 @@ const fetchTelemetryMetrics = async (savedObjects: SavedObjectsServiceStart) => savedObjectsRepository )) as SavedObjectAttributes; - const defaultTelemetrySavedObject: ITelemetrySavedObject = { + const defaultTelemetrySavedObject: ITelemetry = { ui_viewed: { setup_guide: 0, engines_overview: 0, @@ -68,7 +99,7 @@ const fetchTelemetryMetrics = async (savedObjects: SavedObjectsServiceStart) => set(telemetryObj, key, savedObjectAttributes[key]); }); - return telemetryObj as ITelemetrySavedObject; + return telemetryObj as ITelemetry; }; /** diff --git a/x-pack/plugins/enterprise_search/server/saved_objects/app_search/telemetry.ts b/x-pack/plugins/enterprise_search/server/saved_objects/app_search/telemetry.ts index 02bfe450ce7eb..e581b4a69790f 100644 --- a/x-pack/plugins/enterprise_search/server/saved_objects/app_search/telemetry.ts +++ b/x-pack/plugins/enterprise_search/server/saved_objects/app_search/telemetry.ts @@ -3,73 +3,17 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ +/* istanbul ignore file */ import { SavedObjectsType } from 'src/core/server'; - -export const AS_TELEMETRY_NAME = 'app_search_telemetry'; - -export interface ITelemetrySavedObject { - ui_viewed: { - setup_guide: number; - engines_overview: number; - }; - ui_error: { - cannot_connect: number; - no_as_account: number; - }; - ui_clicked: { - create_first_engine_button: number; - header_launch_button: number; - engine_table_link: number; - }; -} +import { AS_TELEMETRY_NAME } from '../../collectors/app_search/telemetry'; export const appSearchTelemetryType: SavedObjectsType = { name: AS_TELEMETRY_NAME, hidden: false, namespaceType: 'single', mappings: { - properties: { - ui_viewed: { - properties: { - setup_guide: { - type: 'long', - null_value: 0, - }, - engines_overview: { - type: 'long', - null_value: 0, - }, - }, - }, - ui_error: { - properties: { - cannot_connect: { - type: 'long', - null_value: 0, - }, - no_as_account: { - type: 'long', - null_value: 0, - }, - }, - }, - ui_clicked: { - properties: { - create_first_engine_button: { - type: 'long', - null_value: 0, - }, - header_launch_button: { - type: 'long', - null_value: 0, - }, - engine_table_link: { - type: 'long', - null_value: 0, - }, - }, - }, - }, + dynamic: false, + properties: {}, }, }; diff --git a/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json b/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json index 13d7c62316040..7b5bd3fd578d5 100644 --- a/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json +++ b/x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @@ -7,6 +7,43 @@ } } }, + "app_search": { + "properties": { + "ui_viewed": { + "properties": { + "setup_guide": { + "type": "long" + }, + "engines_overview": { + "type": "long" + } + } + }, + "ui_error": { + "properties": { + "cannot_connect": { + "type": "long" + }, + "no_as_account": { + "type": "long" + } + } + }, + "ui_clicked": { + "properties": { + "create_first_engine_button": { + "type": "long" + }, + "header_launch_button": { + "type": "long" + }, + "engine_table_link": { + "type": "long" + } + } + } + } + }, "fileUploadTelemetry": { "properties": { "filesUploadedTotalCount": {