-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
f3799c3
commit c6e86cf
Showing
8 changed files
with
102 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters