Skip to content

Commit

Permalink
Keep route there
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Nov 11, 2019
1 parent 9c523b9 commit 5734361
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
8 changes: 1 addition & 7 deletions src/legacy/core_plugins/telemetry/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,21 @@
* under the License.
*/

import { first } from 'rxjs/operators';
import { Observable } from 'rxjs';
import { CoreSetup, PluginInitializerContext } from 'src/core/server';
import { registerRoutes } from './routes';
import { telemetryCollectionManager } from './collection_manager';
import { getStats } from './telemetry_collection';

export class TelemetryPlugin {
private readonly currentKibanaVersion: string;
private readonly config$: Observable<any>;

constructor(initializerContext: PluginInitializerContext) {
this.currentKibanaVersion = initializerContext.env.packageInfo.version;
this.config$ = initializerContext.config.create();
}

public async setup(core: CoreSetup) {
const currentKibanaVersion = this.currentKibanaVersion;
telemetryCollectionManager.setStatsGetter(getStats, 'local');

const { allowChangingOptInStatus } = await this.config$.pipe(first()).toPromise();
registerRoutes({ allowChangingOptInStatus, core, currentKibanaVersion });
registerRoutes({ core, currentKibanaVersion });
}
}
12 changes: 2 additions & 10 deletions src/legacy/core_plugins/telemetry/server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,9 @@ import { registerTelemetryDataRoutes } from './telemetry_stats';
interface RegisterRoutesParams {
core: CoreSetup;
currentKibanaVersion: string;
allowChangingOptInStatus: boolean;
}

export function registerRoutes({
allowChangingOptInStatus,
core,
currentKibanaVersion,
}: RegisterRoutesParams) {
export function registerRoutes({ core, currentKibanaVersion }: RegisterRoutesParams) {
registerTelemetryDataRoutes(core);

if (allowChangingOptInStatus) {
registerOptInRoutes({ core, currentKibanaVersion });
}
registerOptInRoutes({ core, currentKibanaVersion });
}

0 comments on commit 5734361

Please sign in to comment.