Skip to content

Commit

Permalink
[Maps] add settings to maps telemetry (#50161) (#50401)
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese authored Nov 12, 2019
1 parent a9fab62 commit c9bc857
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function getUniqueLayerCounts(layerCountsList, mapsCount) {
}, {});
}

export function buildMapsTelemetry(savedObjects) {
export function buildMapsTelemetry(savedObjects, settings) {
const layerLists = savedObjects
.map(savedMapObject =>
JSON.parse(savedMapObject.attributes.layerListJSON));
Expand All @@ -57,7 +57,8 @@ export function buildMapsTelemetry(savedObjects) {

const dataSourcesCountSum = _.sum(dataSourcesCount);
const layersCountSum = _.sum(layersCount);
const mapsTelem = {
return {
settings,
// Total count of maps
mapsTotalCount: mapsCount,
// Time of capture
Expand Down Expand Up @@ -85,7 +86,6 @@ export function buildMapsTelemetry(savedObjects) {
}
}
};
return mapsTelem;
}

async function getSavedObjects(savedObjectsClient) {
Expand All @@ -98,7 +98,10 @@ async function getSavedObjects(savedObjectsClient) {
export async function getMapsTelemetry(server, callCluster) {
const savedObjectsClient = getSavedObjectsClient(server, callCluster);
const savedObjects = await getSavedObjects(savedObjectsClient);
const mapsTelemetry = buildMapsTelemetry(savedObjects);
const settings = {
showMapVisualizationTypes: server.config().get('xpack.maps.showMapVisualizationTypes')
};
const mapsTelemetry = buildMapsTelemetry(savedObjects, settings);

return await savedObjectsClient.create('maps-telemetry',
mapsTelemetry, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,79 +10,87 @@ import { buildMapsTelemetry } from './maps_telemetry';

describe('buildMapsTelemetry', () => {

const settings = { showMapVisualizationTypes: false };

test('returns zeroed telemetry data when there are no saved objects',
async () => {

const gisMaps = [];
const result = buildMapsTelemetry(gisMaps);
const result = buildMapsTelemetry(gisMaps, settings);

expect(result).toMatchObject({
'attributesPerMap': {
'dataSourcesCount': {
'avg': 0,
'max': 0,
'min': 0
attributesPerMap: {
dataSourcesCount: {
avg: 0,
max: 0,
min: 0
},
'emsVectorLayersCount': {},
'layerTypesCount': {},
'layersCount': {
'avg': 0,
'max': 0,
'min': 0
emsVectorLayersCount: {},
layerTypesCount: {},
layersCount: {
avg: 0,
max: 0,
min: 0
}
},
'mapsTotalCount': 0
mapsTotalCount: 0,
settings: {
showMapVisualizationTypes: false
}
});
});

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

const gisMaps = savedObjectsPayload.saved_objects;
const result = buildMapsTelemetry(gisMaps);
const result = buildMapsTelemetry(gisMaps, settings);

expect(result).toMatchObject({
'attributesPerMap': {
'dataSourcesCount': {
'avg': 2.6666666666666665,
'max': 3,
'min': 2
attributesPerMap: {
dataSourcesCount: {
avg: 2.6666666666666665,
max: 3,
min: 2
},
'emsVectorLayersCount': {
'canada_provinces': {
'avg': 0.3333333333333333,
'max': 1,
'min': 1
emsVectorLayersCount: {
canada_provinces: {
avg: 0.3333333333333333,
max: 1,
min: 1
},
'france_departments': {
'avg': 0.3333333333333333,
'max': 1,
'min': 1
france_departments: {
avg: 0.3333333333333333,
max: 1,
min: 1
},
'italy_provinces': {
'avg': 0.3333333333333333,
'max': 1,
'min': 1
italy_provinces: {
avg: 0.3333333333333333,
max: 1,
min: 1
}
},
'layerTypesCount': {
'TILE': {
'avg': 1,
'max': 1,
'min': 1
layerTypesCount: {
TILE: {
avg: 1,
max: 1,
min: 1
},
'VECTOR': {
'avg': 1.6666666666666667,
'max': 2,
'min': 1
VECTOR: {
avg: 1.6666666666666667,
max: 2,
min: 1
}
},
'layersCount': {
'avg': 2.6666666666666665,
'max': 3,
'min': 2
layersCount: {
avg: 2.6666666666666665,
max: 3,
min: 2
}
},
'mapsTotalCount': 3
mapsTotalCount: 3,
settings: {
showMapVisualizationTypes: false
}
});
});
});

0 comments on commit c9bc857

Please sign in to comment.