Skip to content

Commit c9bc857

Browse files
authored
[Maps] add settings to maps telemetry (#50161) (#50401)
1 parent a9fab62 commit c9bc857

File tree

2 files changed

+61
-50
lines changed

2 files changed

+61
-50
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function getUniqueLayerCounts(layerCountsList, mapsCount) {
3232
}, {});
3333
}
3434

35-
export function buildMapsTelemetry(savedObjects) {
35+
export function buildMapsTelemetry(savedObjects, settings) {
3636
const layerLists = savedObjects
3737
.map(savedMapObject =>
3838
JSON.parse(savedMapObject.attributes.layerListJSON));
@@ -57,7 +57,8 @@ export function buildMapsTelemetry(savedObjects) {
5757

5858
const dataSourcesCountSum = _.sum(dataSourcesCount);
5959
const layersCountSum = _.sum(layersCount);
60-
const mapsTelem = {
60+
return {
61+
settings,
6162
// Total count of maps
6263
mapsTotalCount: mapsCount,
6364
// Time of capture
@@ -85,7 +86,6 @@ export function buildMapsTelemetry(savedObjects) {
8586
}
8687
}
8788
};
88-
return mapsTelem;
8989
}
9090

9191
async function getSavedObjects(savedObjectsClient) {
@@ -98,7 +98,10 @@ async function getSavedObjects(savedObjectsClient) {
9898
export async function getMapsTelemetry(server, callCluster) {
9999
const savedObjectsClient = getSavedObjectsClient(server, callCluster);
100100
const savedObjects = await getSavedObjects(savedObjectsClient);
101-
const mapsTelemetry = buildMapsTelemetry(savedObjects);
101+
const settings = {
102+
showMapVisualizationTypes: server.config().get('xpack.maps.showMapVisualizationTypes')
103+
};
104+
const mapsTelemetry = buildMapsTelemetry(savedObjects, settings);
102105

103106
return await savedObjectsClient.create('maps-telemetry',
104107
mapsTelemetry, {

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

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,79 +10,87 @@ import { buildMapsTelemetry } from './maps_telemetry';
1010

1111
describe('buildMapsTelemetry', () => {
1212

13+
const settings = { showMapVisualizationTypes: false };
14+
1315
test('returns zeroed telemetry data when there are no saved objects',
1416
async () => {
1517

1618
const gisMaps = [];
17-
const result = buildMapsTelemetry(gisMaps);
19+
const result = buildMapsTelemetry(gisMaps, settings);
1820

1921
expect(result).toMatchObject({
20-
'attributesPerMap': {
21-
'dataSourcesCount': {
22-
'avg': 0,
23-
'max': 0,
24-
'min': 0
22+
attributesPerMap: {
23+
dataSourcesCount: {
24+
avg: 0,
25+
max: 0,
26+
min: 0
2527
},
26-
'emsVectorLayersCount': {},
27-
'layerTypesCount': {},
28-
'layersCount': {
29-
'avg': 0,
30-
'max': 0,
31-
'min': 0
28+
emsVectorLayersCount: {},
29+
layerTypesCount: {},
30+
layersCount: {
31+
avg: 0,
32+
max: 0,
33+
min: 0
3234
}
3335
},
34-
'mapsTotalCount': 0
36+
mapsTotalCount: 0,
37+
settings: {
38+
showMapVisualizationTypes: false
39+
}
3540
});
3641
});
3742

3843
test('returns expected telemetry data from saved objects', async () => {
3944

4045
const gisMaps = savedObjectsPayload.saved_objects;
41-
const result = buildMapsTelemetry(gisMaps);
46+
const result = buildMapsTelemetry(gisMaps, settings);
4247

4348
expect(result).toMatchObject({
44-
'attributesPerMap': {
45-
'dataSourcesCount': {
46-
'avg': 2.6666666666666665,
47-
'max': 3,
48-
'min': 2
49+
attributesPerMap: {
50+
dataSourcesCount: {
51+
avg: 2.6666666666666665,
52+
max: 3,
53+
min: 2
4954
},
50-
'emsVectorLayersCount': {
51-
'canada_provinces': {
52-
'avg': 0.3333333333333333,
53-
'max': 1,
54-
'min': 1
55+
emsVectorLayersCount: {
56+
canada_provinces: {
57+
avg: 0.3333333333333333,
58+
max: 1,
59+
min: 1
5560
},
56-
'france_departments': {
57-
'avg': 0.3333333333333333,
58-
'max': 1,
59-
'min': 1
61+
france_departments: {
62+
avg: 0.3333333333333333,
63+
max: 1,
64+
min: 1
6065
},
61-
'italy_provinces': {
62-
'avg': 0.3333333333333333,
63-
'max': 1,
64-
'min': 1
66+
italy_provinces: {
67+
avg: 0.3333333333333333,
68+
max: 1,
69+
min: 1
6570
}
6671
},
67-
'layerTypesCount': {
68-
'TILE': {
69-
'avg': 1,
70-
'max': 1,
71-
'min': 1
72+
layerTypesCount: {
73+
TILE: {
74+
avg: 1,
75+
max: 1,
76+
min: 1
7277
},
73-
'VECTOR': {
74-
'avg': 1.6666666666666667,
75-
'max': 2,
76-
'min': 1
78+
VECTOR: {
79+
avg: 1.6666666666666667,
80+
max: 2,
81+
min: 1
7782
}
7883
},
79-
'layersCount': {
80-
'avg': 2.6666666666666665,
81-
'max': 3,
82-
'min': 2
84+
layersCount: {
85+
avg: 2.6666666666666665,
86+
max: 3,
87+
min: 2
8388
}
8489
},
85-
'mapsTotalCount': 3
90+
mapsTotalCount: 3,
91+
settings: {
92+
showMapVisualizationTypes: false
93+
}
8694
});
8795
});
8896
});

0 commit comments

Comments
 (0)