Skip to content

Commit 34867ec

Browse files
committed
ignore sample data visualizations
1 parent 6984c0b commit 34867ec

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

src/plugins/vis_type_vega/server/usage_collector/get_usage_collector.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,30 @@ describe('Vega visualization usage collector', () => {
112112
expect(result).toBeUndefined();
113113
});
114114

115+
test('Should ingnore sample data visualizations', async () => {
116+
const result = await usageCollector.fetch(
117+
getMockCallCluster([
118+
{
119+
_id: 'visualization:sampledata-123',
120+
_source: {
121+
type: 'visualization',
122+
visualization: {
123+
visState: JSON.stringify({
124+
type: 'vega',
125+
title: '[Logs] Visitors Map',
126+
params: {
127+
spec: '{"$schema": "https://vega.github.io/schema/vega/v5.json" }',
128+
},
129+
}),
130+
},
131+
},
132+
},
133+
])
134+
);
135+
136+
expect(result).toBeUndefined();
137+
});
138+
115139
test('Summarizes visualizations response data', async () => {
116140
const result = await usageCollector.fetch(getMockCallCluster(mockedSavedObjects));
117141

src/plugins/vis_type_vega/server/usage_collector/get_usage_collector.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ const VEGA_USAGE_TYPE = 'vis_type_vega';
3232
const checkVegaSchemaType = (schemaURL: string, type: VegaType) =>
3333
schemaURL.includes(`//vega.github.io/schema/${type}/`);
3434

35+
// we want to exclude the Vega Sample Data visualizations from the stats
36+
// in order to have more accurate results
37+
const excludedFromStatsVisualizations = [
38+
'[Flights] Airport Connections (Hover Over Airport)',
39+
'[Flights] Departure Count Map',
40+
'[Logs] File Type Scatter Plot',
41+
'[Logs] Source and Destination Sankey Chart',
42+
'[Logs] Visitors Map',
43+
'[eCommerce] Sales Count Map',
44+
];
45+
3546
const getStats = async (callCluster: LegacyAPICaller, index: string) => {
3647
const searchParams = {
3748
size: 10000,
@@ -56,11 +67,15 @@ const getStats = async (callCluster: LegacyAPICaller, index: string) => {
5667
const finalTelemetry = esResponse.hits.hits.reduce(
5768
(telemetry, hit) => {
5869
const visualization = get(hit, '_source.visualization', { visState: '{}' });
59-
const visState: { type?: string; params?: { spec?: string } } = JSON.parse(
70+
const visState: { title: string; type?: string; params?: { spec?: string } } = JSON.parse(
6071
visualization.visState
6172
);
6273

63-
if (visState.type === 'vega' && visState.params?.spec)
74+
if (
75+
visState.type === 'vega' &&
76+
visState.params?.spec &&
77+
!excludedFromStatsVisualizations.includes(visState.title)
78+
)
6479
try {
6580
const spec = parse(visState.params.spec, { legacyRoot: false });
6681

0 commit comments

Comments
 (0)