* quick fix for 7.13 lens migration not being run on by value panels Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
72 lines
2.5 KiB
TypeScript
72 lines
2.5 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
* 2.0.
|
|
*/
|
|
|
|
import { Plugin, CoreSetup, CoreStart, PluginInitializerContext, Logger } from 'src/core/server';
|
|
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
|
|
import { Observable } from 'rxjs';
|
|
import { PluginStart as DataPluginStart } from 'src/plugins/data/server';
|
|
import { TaskManagerSetupContract, TaskManagerStartContract } from '../../task_manager/server';
|
|
import { setupRoutes } from './routes';
|
|
import {
|
|
registerLensUsageCollector,
|
|
initializeLensTelemetry,
|
|
scheduleLensTelemetry,
|
|
} from './usage';
|
|
import { setupSavedObjects } from './saved_objects';
|
|
import { EmbeddableSetup } from '../../../../src/plugins/embeddable/server';
|
|
import { lensEmbeddableFactory } from './embeddable/lens_embeddable_factory';
|
|
|
|
export interface PluginSetupContract {
|
|
usageCollection?: UsageCollectionSetup;
|
|
taskManager?: TaskManagerSetupContract;
|
|
embeddable: EmbeddableSetup;
|
|
}
|
|
|
|
export interface PluginStartContract {
|
|
taskManager?: TaskManagerStartContract;
|
|
data: DataPluginStart;
|
|
}
|
|
|
|
export class LensServerPlugin implements Plugin<{}, {}, {}, {}> {
|
|
private readonly kibanaIndexConfig: Observable<{ kibana: { index: string } }>;
|
|
private readonly telemetryLogger: Logger;
|
|
|
|
constructor(private initializerContext: PluginInitializerContext) {
|
|
this.kibanaIndexConfig = initializerContext.config.legacy.globalConfig$;
|
|
this.telemetryLogger = initializerContext.logger.get('usage');
|
|
}
|
|
setup(core: CoreSetup<PluginStartContract>, plugins: PluginSetupContract) {
|
|
setupSavedObjects(core);
|
|
setupRoutes(core, this.initializerContext.logger.get());
|
|
if (plugins.usageCollection && plugins.taskManager) {
|
|
registerLensUsageCollector(
|
|
plugins.usageCollection,
|
|
core
|
|
.getStartServices()
|
|
.then(([_, { taskManager }]) => taskManager as TaskManagerStartContract)
|
|
);
|
|
initializeLensTelemetry(
|
|
this.telemetryLogger,
|
|
core,
|
|
this.kibanaIndexConfig,
|
|
plugins.taskManager
|
|
);
|
|
}
|
|
plugins.embeddable.registerEmbeddableFactory(lensEmbeddableFactory());
|
|
return {};
|
|
}
|
|
|
|
start(core: CoreStart, plugins: PluginStartContract) {
|
|
if (plugins.taskManager) {
|
|
scheduleLensTelemetry(this.telemetryLogger, plugins.taskManager);
|
|
}
|
|
return {};
|
|
}
|
|
|
|
stop() {}
|
|
}
|