Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Remote clusters] guard against usageCollection plugin #63465

Merged
merged 2 commits into from
Apr 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { UiStatsMetricType, METRIC_TYPE } from '@kbn/analytics';
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
import { UiStatsMetricType } from '@kbn/analytics';
import { UIM_APP_NAME } from '../constants';

export let trackUiMetric: (metricType: UiStatsMetricType, eventName: string) => void;
export let METRIC_TYPE: UsageCollectionSetup['METRIC_TYPE'];
export { METRIC_TYPE };

export let usageCollection: UsageCollectionSetup | undefined;

export function init(_usageCollection: UsageCollectionSetup): void {
usageCollection = _usageCollection;
}

export function init(usageCollection: UsageCollectionSetup): void {
trackUiMetric = usageCollection.reportUiStats.bind(usageCollection, UIM_APP_NAME);
METRIC_TYPE = usageCollection.METRIC_TYPE;
export function trackUiMetric(metricType: UiStatsMetricType, name: string) {
if (!usageCollection) {
return;
}
const { reportUiStats } = usageCollection;
reportUiStats(UIM_APP_NAME, metricType, name);
}

/**
Expand Down