Skip to content

Commit 3630eac

Browse files
add telemetry
1 parent 601c2bc commit 3630eac

3 files changed

Lines changed: 41 additions & 5 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ describe('buildMapsTelemetry', () => {
2020

2121
expect(result).toMatchObject({
2222
indexPatternsWithGeoFieldCount: 0,
23+
indexPatternsWithGeoPointFieldCount: 0,
24+
indexPatternsWithGeoShapeFieldCount: 0,
2325
attributesPerMap: {
2426
dataSourcesCount: {
2527
avg: 0,
@@ -45,7 +47,9 @@ describe('buildMapsTelemetry', () => {
4547
const result = buildMapsTelemetry({ mapSavedObjects, indexPatternSavedObjects, settings });
4648

4749
expect(result).toMatchObject({
48-
indexPatternsWithGeoFieldCount: 2,
50+
indexPatternsWithGeoFieldCount: 3,
51+
indexPatternsWithGeoPointFieldCount: 2,
52+
indexPatternsWithGeoShapeFieldCount: 1,
4953
attributesPerMap: {
5054
dataSourcesCount: {
5155
avg: 2.6666666666666665,

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,27 @@ function getIndexPatternsWithGeoFieldCount(indexPatterns: IIndexPattern[]) {
6161
? JSON.parse(indexPattern.attributes.fields)
6262
: []
6363
);
64+
6465
const fieldListsWithGeoFields = fieldLists.filter(fields =>
6566
fields.some(
6667
(field: IFieldType) =>
6768
field.type === ES_GEO_FIELD_TYPE.GEO_POINT || field.type === ES_GEO_FIELD_TYPE.GEO_SHAPE
6869
)
6970
);
70-
return fieldListsWithGeoFields.length;
71+
72+
const fieldListsWithGeoPointFields = fieldLists.filter(fields =>
73+
fields.some((field: IFieldType) => field.type === ES_GEO_FIELD_TYPE.GEO_POINT)
74+
);
75+
76+
const fieldListsWithGeoShapeFields = fieldLists.filter(fields =>
77+
fields.some((field: IFieldType) => field.type === ES_GEO_FIELD_TYPE.GEO_SHAPE)
78+
);
79+
80+
return {
81+
indexPatternsWithGeoFieldCount: fieldListsWithGeoFields.length,
82+
indexPatternsWithGeoPointFieldCount: fieldListsWithGeoPointFields.length,
83+
indexPatternsWithGeoShapeFieldCount: fieldListsWithGeoShapeFields.length,
84+
};
7185
}
7286

7387
export function buildMapsTelemetry({
@@ -110,12 +124,16 @@ export function buildMapsTelemetry({
110124
const dataSourcesCountSum = _.sum(dataSourcesCount);
111125
const layersCountSum = _.sum(layersCount);
112126

113-
const indexPatternsWithGeoFieldCount = getIndexPatternsWithGeoFieldCount(
114-
indexPatternSavedObjects
115-
);
127+
const {
128+
indexPatternsWithGeoFieldCount,
129+
indexPatternsWithGeoPointFieldCount,
130+
indexPatternsWithGeoShapeFieldCount,
131+
} = getIndexPatternsWithGeoFieldCount(indexPatternSavedObjects);
116132
return {
117133
settings,
118134
indexPatternsWithGeoFieldCount,
135+
indexPatternsWithGeoPointFieldCount,
136+
indexPatternsWithGeoShapeFieldCount,
119137
// Total count of maps
120138
mapsTotalCount: mapsCount,
121139
// Time of capture

x-pack/legacy/plugins/maps/server/maps_telemetry/test_resources/sample_index_pattern_saved_objects.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@
2828
"updated_at": "2019-11-19T20:05:37.607Z",
2929
"version": "WzExMSwxXQ=="
3030
},
31+
{
32+
"attributes": {
33+
"fields": "[{\"name\":\"geometry\",\"type\":\"geo_point\",\"esTypes\":[\"geo_point\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]",
34+
"title": "indexpattern-with-geopoint2"
35+
},
36+
"id": "55d572f0-0b07-11ea-9dd2-95afd7ad44d4",
37+
"migrationVersion": {
38+
"index-pattern": "7.6.0"
39+
},
40+
"references": [],
41+
"type": "index-pattern",
42+
"updated_at": "2019-11-19T20:05:37.607Z",
43+
"version": "WzExMSwxXQ=="
44+
},
3145
{
3246
"attributes": {
3347
"fields": "[{\"name\":\"assessment_date\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"date_exterior_condition\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"recording_date\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true},{\"name\":\"sale_date\",\"type\":\"date\",\"esTypes\":[\"date\"],\"count\":0,\"scripted\":false,\"searchable\":true,\"aggregatable\":true,\"readFromDocValues\":true}]",

0 commit comments

Comments
 (0)