diff --git a/x-pack/legacy/plugins/maps/index.js b/x-pack/legacy/plugins/maps/index.js index e5b3d5c615013..6bff1bd54fde9 100644 --- a/x-pack/legacy/plugins/maps/index.js +++ b/x-pack/legacy/plugins/maps/index.js @@ -100,7 +100,6 @@ export function maps(kibana) { server.log(['info', 'maps'], 'Maps app disabled by configuration'); return; } - initTelemetryCollection(usageCollection, server); const coreSetup = server.newPlatform.setup.core; const newPlatformPlugins = server.newPlatform.setup.plugins; @@ -131,6 +130,19 @@ export function maps(kibana) { const mapPluginSetup = new MapPlugin().setup(coreSetup, pluginsSetup, __LEGACY); server.expose('getMapConfig', mapPluginSetup.getMapConfig); + + const { kbnServer } = server.plugins.xpack_main.status.plugin; + kbnServer.afterPluginsInit(() => { + // The code block below can't await directly within "afterPluginsInit" + // callback due to circular dependency. The server isn't "ready" until + // this code block finishes. Migrations wait for server to be ready before + // executing. Saved objects repository waits for migrations to finish before + // finishing the request. To avoid this, we'll await within a separate + // function block. + (() => { + initTelemetryCollection(usageCollection, server); + })(); + }); } }); } diff --git a/x-pack/legacy/plugins/maps/mappings.json b/x-pack/legacy/plugins/maps/mappings.json index 7f80512980f0a..5e2e8c2c7e6e5 100644 --- a/x-pack/legacy/plugins/maps/mappings.json +++ b/x-pack/legacy/plugins/maps/mappings.json @@ -26,6 +26,16 @@ }, "maps-telemetry": { "properties": { + "settings": { + "properties": { + "showMapVisualizationTypes": { + "type": "boolean" + } + } + }, + "indexPatternsWithGeoFieldCount": { + "type": "long" + }, "mapsTotalCount": { "type": "long" }, @@ -72,4 +82,4 @@ } } } -} \ No newline at end of file +} diff --git a/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_usage_collector.js b/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_usage_collector.js index c4d755b5908f0..185c11d95fc31 100644 --- a/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_usage_collector.js +++ b/x-pack/legacy/plugins/maps/server/maps_telemetry/maps_usage_collector.js @@ -7,9 +7,9 @@ import _ from 'lodash'; import { TASK_ID, scheduleTask, registerMapsTelemetryTask } from './telemetry_task'; -export function initTelemetryCollection(usageCollection, server) { +export async function initTelemetryCollection(usageCollection, server) { registerMapsTelemetryTask(server); - scheduleTask(server); + await scheduleTask(server); registerMapsUsageCollector(usageCollection, server); } diff --git a/x-pack/legacy/plugins/maps/server/maps_telemetry/telemetry_task.js b/x-pack/legacy/plugins/maps/server/maps_telemetry/telemetry_task.js index 78b04543e72f2..545415dd08c52 100644 --- a/x-pack/legacy/plugins/maps/server/maps_telemetry/telemetry_task.js +++ b/x-pack/legacy/plugins/maps/server/maps_telemetry/telemetry_task.js @@ -10,7 +10,7 @@ const TELEMETRY_TASK_TYPE = 'maps_telemetry'; export const TASK_ID = `Maps-${TELEMETRY_TASK_TYPE}`; -export function scheduleTask(server) { +export async function scheduleTask(server) { const taskManager = server.plugins.task_manager; if (!taskManager) { @@ -18,27 +18,15 @@ export function scheduleTask(server) { return; } - const { kbnServer } = server.plugins.xpack_main.status.plugin; - - kbnServer.afterPluginsInit(() => { - // The code block below can't await directly within "afterPluginsInit" - // callback due to circular dependency. The server isn't "ready" until - // this code block finishes. Migrations wait for server to be ready before - // executing. Saved objects repository waits for migrations to finish before - // finishing the request. To avoid this, we'll await within a separate - // function block. - (async () => { - try { - await taskManager.ensureScheduled({ - id: TASK_ID, - taskType: TELEMETRY_TASK_TYPE, - state: { stats: {}, runs: 0 }, - }); - } catch(e) { - server.log(['warning', 'maps'], `Error scheduling telemetry task, received ${e.message}`); - } - })(); - }); + try { + await taskManager.ensureScheduled({ + id: TASK_ID, + taskType: TELEMETRY_TASK_TYPE, + state: { stats: {}, runs: 0 }, + }); + } catch(e) { + server.log(['warning', 'maps'], `Error scheduling telemetry task, received ${e.message}`); + } } export function registerMapsTelemetryTask(server) {