Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] add settings showMapVisualizationTypes to telemetry #50161

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
});
});
});