mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
In-chart "Explore underlying data" action telemetry (#74516)
* feat: 🎸 add telemetry for in-chart "Explore underlying data" * refactor: 💡 use shared Config type from /common folder * feat: 🎸 register usage collector * chore: 🤖 upate telemetry schema * fix: 🐛 use relative import for usage_collector * fix: 🐛 use relative imports for core * fix: 🐛 use relative import Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
f3799c37f6
commit
c6e86cf773
8 changed files with 102 additions and 7 deletions
|
@ -13,6 +13,19 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"search": {
|
||||
"properties": {
|
||||
"successCount": {
|
||||
"type": "number"
|
||||
},
|
||||
"errorCount": {
|
||||
"type": "number"
|
||||
},
|
||||
"averageDuration": {
|
||||
"type": "long"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sample-data": {
|
||||
"properties": {
|
||||
"installed": {
|
||||
|
|
9
x-pack/plugins/discover_enhanced/common/config.ts
Normal file
9
x-pack/plugins/discover_enhanced/common/config.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export interface Config {
|
||||
actions: { exploreDataInChart: { enabled: boolean } };
|
||||
}
|
7
x-pack/plugins/discover_enhanced/common/index.ts
Normal file
7
x-pack/plugins/discover_enhanced/common/index.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export * from './config';
|
|
@ -5,7 +5,7 @@
|
|||
"server": true,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["uiActions", "embeddable", "discover"],
|
||||
"optionalPlugins": ["share", "kibanaLegacy"],
|
||||
"optionalPlugins": ["share", "kibanaLegacy", "usageCollection"],
|
||||
"configPath": ["xpack", "discoverEnhanced"],
|
||||
"requiredBundles": ["kibanaUtils", "data"]
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import {
|
|||
ACTION_EXPLORE_DATA_CHART,
|
||||
ExploreDataChartActionContext,
|
||||
} from './actions';
|
||||
import { Config } from '../common';
|
||||
|
||||
declare module '../../../../src/plugins/ui_actions/public' {
|
||||
export interface ActionContextMapping {
|
||||
|
@ -55,10 +56,10 @@ export interface DiscoverEnhancedStartDependencies {
|
|||
export class DiscoverEnhancedPlugin
|
||||
implements
|
||||
Plugin<void, void, DiscoverEnhancedSetupDependencies, DiscoverEnhancedStartDependencies> {
|
||||
public readonly config: { actions: { exploreDataInChart: { enabled: boolean } } };
|
||||
public readonly config: Config;
|
||||
|
||||
constructor(protected readonly context: PluginInitializerContext) {
|
||||
this.config = context.config.get();
|
||||
this.config = context.config.get<Config>();
|
||||
}
|
||||
|
||||
setup(
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext } from '../../../../src/core/server';
|
||||
import { DiscoverEnhancedPlugin } from './plugin';
|
||||
|
||||
export { config } from './config';
|
||||
|
||||
export const plugin = () => ({
|
||||
setup() {},
|
||||
start() {},
|
||||
});
|
||||
export const plugin = (context: PluginInitializerContext) => new DiscoverEnhancedPlugin(context);
|
||||
|
|
58
x-pack/plugins/discover_enhanced/server/plugin.ts
Normal file
58
x-pack/plugins/discover_enhanced/server/plugin.ts
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { take } from 'rxjs/operators';
|
||||
import {
|
||||
CoreSetup,
|
||||
CoreStart,
|
||||
Plugin,
|
||||
PluginInitializerContext,
|
||||
} from '../../../../src/core/server';
|
||||
import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/server';
|
||||
import { Config } from '../common';
|
||||
|
||||
interface SetupDependencies {
|
||||
usageCollection?: UsageCollectionSetup;
|
||||
}
|
||||
|
||||
interface StartDependencies {
|
||||
usageCollection?: unknown;
|
||||
}
|
||||
|
||||
export class DiscoverEnhancedPlugin
|
||||
implements Plugin<void, void, SetupDependencies, StartDependencies> {
|
||||
private config$: Observable<Config>;
|
||||
|
||||
constructor(protected readonly context: PluginInitializerContext) {
|
||||
this.config$ = context.config.create<Config>();
|
||||
}
|
||||
|
||||
public setup(core: CoreSetup, { usageCollection }: SetupDependencies) {
|
||||
if (!!usageCollection) {
|
||||
const collector = usageCollection.makeUsageCollector<{
|
||||
exploreDataInChartActionEnabled: boolean;
|
||||
}>({
|
||||
type: 'discoverEnhanced',
|
||||
schema: {
|
||||
exploreDataInChartActionEnabled: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
isReady: () => true,
|
||||
fetch: async () => {
|
||||
const config = await this.config$.pipe(take(1)).toPromise();
|
||||
return {
|
||||
exploreDataInChartActionEnabled: config.actions.exploreDataInChart.enabled,
|
||||
};
|
||||
},
|
||||
});
|
||||
usageCollection.registerCollector(collector);
|
||||
}
|
||||
}
|
||||
|
||||
public start(core: CoreStart) {}
|
||||
}
|
|
@ -7,6 +7,13 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"discoverEnhanced": {
|
||||
"properties": {
|
||||
"exploreDataInChartActionEnabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"app_search": {
|
||||
"properties": {
|
||||
"ui_viewed": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue