"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TelemetryService = void 0; var _telemetry_events = require("./telemetry_events"); var _telemetry_client = require("./telemetry_client"); /* * 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. */ /** * Service that interacts with the Core's analytics module * to trigger custom event for the Infra plugin features */ class TelemetryService { constructor(analytics = null) { this.analytics = analytics; } setup({ analytics }) { this.analytics = analytics; _telemetry_events.infraTelemetryEvents.forEach(eventConfig => analytics.registerEventType(eventConfig)); } start() { if (!this.analytics) { throw new Error('The TelemetryService.setup() method has not been invoked, be sure to call it during the plugin setup.'); } return new _telemetry_client.TelemetryClient(this.analytics); } } exports.TelemetryService = TelemetryService;