Skip to content

Commit 2481de8

Browse files
committed
Fix maps telemetry
1 parent c3ddb53 commit 2481de8

4 files changed

Lines changed: 36 additions & 26 deletions

File tree

x-pack/legacy/plugins/maps/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ export function maps(kibana) {
100100
server.log(['info', 'maps'], 'Maps app disabled by configuration');
101101
return;
102102
}
103-
initTelemetryCollection(usageCollection, server);
104103

105104
const coreSetup = server.newPlatform.setup.core;
106105
const newPlatformPlugins = server.newPlatform.setup.plugins;
@@ -131,6 +130,19 @@ export function maps(kibana) {
131130

132131
const mapPluginSetup = new MapPlugin().setup(coreSetup, pluginsSetup, __LEGACY);
133132
server.expose('getMapConfig', mapPluginSetup.getMapConfig);
133+
134+
const { kbnServer } = server.plugins.xpack_main.status.plugin;
135+
kbnServer.afterPluginsInit(() => {
136+
// The code block below can't await directly within "afterPluginsInit"
137+
// callback due to circular dependency. The server isn't "ready" until
138+
// this code block finishes. Migrations wait for server to be ready before
139+
// executing. Saved objects repository waits for migrations to finish before
140+
// finishing the request. To avoid this, we'll await within a separate
141+
// function block.
142+
(() => {
143+
initTelemetryCollection(usageCollection, server);
144+
})();
145+
});
134146
}
135147
});
136148
}

x-pack/legacy/plugins/maps/mappings.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@
2626
},
2727
"maps-telemetry": {
2828
"properties": {
29+
"settings": {
30+
"properties": {
31+
"showMapVisualizationTypes": {
32+
"type": "boolean"
33+
}
34+
}
35+
},
36+
"indexPatternsWithGeoFieldCount": {
37+
"type": "long"
38+
},
2939
"mapsTotalCount": {
3040
"type": "long"
3141
},
@@ -72,4 +82,4 @@
7282
}
7383
}
7484
}
75-
}
85+
}

x-pack/legacy/plugins/maps/server/maps_telemetry/maps_usage_collector.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import _ from 'lodash';
88
import { TASK_ID, scheduleTask, registerMapsTelemetryTask } from './telemetry_task';
99

10-
export function initTelemetryCollection(usageCollection, server) {
10+
export async function initTelemetryCollection(usageCollection, server) {
1111
registerMapsTelemetryTask(server);
12-
scheduleTask(server);
12+
await scheduleTask(server);
1313
registerMapsUsageCollector(usageCollection, server);
1414
}
1515

x-pack/legacy/plugins/maps/server/maps_telemetry/telemetry_task.js

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,23 @@ const TELEMETRY_TASK_TYPE = 'maps_telemetry';
1010

1111
export const TASK_ID = `Maps-${TELEMETRY_TASK_TYPE}`;
1212

13-
export function scheduleTask(server) {
13+
export async function scheduleTask(server) {
1414
const taskManager = server.plugins.task_manager;
1515

1616
if (!taskManager) {
1717
server.log(['debug', 'telemetry'], `Task manager is not available`);
1818
return;
1919
}
2020

21-
const { kbnServer } = server.plugins.xpack_main.status.plugin;
22-
23-
kbnServer.afterPluginsInit(() => {
24-
// The code block below can't await directly within "afterPluginsInit"
25-
// callback due to circular dependency. The server isn't "ready" until
26-
// this code block finishes. Migrations wait for server to be ready before
27-
// executing. Saved objects repository waits for migrations to finish before
28-
// finishing the request. To avoid this, we'll await within a separate
29-
// function block.
30-
(async () => {
31-
try {
32-
await taskManager.ensureScheduled({
33-
id: TASK_ID,
34-
taskType: TELEMETRY_TASK_TYPE,
35-
state: { stats: {}, runs: 0 },
36-
});
37-
} catch(e) {
38-
server.log(['warning', 'maps'], `Error scheduling telemetry task, received ${e.message}`);
39-
}
40-
})();
41-
});
21+
try {
22+
await taskManager.ensureScheduled({
23+
id: TASK_ID,
24+
taskType: TELEMETRY_TASK_TYPE,
25+
state: { stats: {}, runs: 0 },
26+
});
27+
} catch(e) {
28+
server.log(['warning', 'maps'], `Error scheduling telemetry task, received ${e.message}`);
29+
}
4230
}
4331

4432
export function registerMapsTelemetryTask(server) {

0 commit comments

Comments
 (0)