Skip to content

Commit

Permalink
[Remote clusters] guard against usageCollection plugin if unav… (#63284)
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth authored Apr 14, 2020
1 parent e6095fc commit b38c98a
Showing 1 changed file with 14 additions and 7 deletions.
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

0 comments on commit b38c98a

Please sign in to comment.