1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00
unleash.unleash/src/lib/routes/admin-api/telemetry.ts
David Leek 78ba72d861
feat: remove experimental flag for telemetry (#4123)
<!-- Thanks for creating a PR! To make it easier for reviewers and
everyone else to understand what your changes relate to, please add some
relevant content to the headings below. Feel free to ignore or delete
sections that you don't think are relevant. Thank you! ❤️ -->

## About the changes
<!-- Describe the changes introduced. What are they and why are they
being introduced? Feel free to also add screenshots or steps to view the
changes if they're visual. -->

This removes the experimental feature flag that defaulted to turn off
telemetry collection
2023-06-30 11:27:54 +02:00

64 lines
2.1 KiB
TypeScript

import { Response } from 'express';
import { OpenApiService } from 'lib/services';
import { IAuthRequest } from '../unleash-types';
import { IUnleashConfig } from '../../types/option';
import Controller from '../controller';
import { NONE } from '../../types/permissions';
import { IUnleashServices } from 'lib/types';
import { createResponseSchema } from '../../openapi/util/create-response-schema';
import {
telemetrySettingsSchema,
TelemetrySettingsSchema,
} from '../../openapi/spec/telemetry-settings-schema';
class TelemetryController extends Controller {
config: IUnleashConfig;
openApiService: OpenApiService;
constructor(
config: IUnleashConfig,
{ openApiService }: Pick<IUnleashServices, 'openApiService'>,
) {
super(config);
this.config = config;
this.openApiService = openApiService;
this.route({
method: 'get',
path: '/settings',
handler: this.getTelemetrySettings,
permission: NONE,
middleware: [
openApiService.validPath({
tags: ['Telemetry'],
summary: 'Get telemetry settings',
description:
'Provides the configured settings for [telemetry information collection](https://docs.getunleash.io/topics/data-collection)',
operationId: 'getTelemetrySettings',
responses: {
200: createResponseSchema('telemetrySettingsSchema'),
},
}),
],
});
}
async getTelemetrySettings(
req: IAuthRequest,
res: Response<TelemetrySettingsSchema>,
): Promise<void> {
this.openApiService.respondWithValidation(
200,
res,
telemetrySettingsSchema.$id,
{
versionInfoCollectionEnabled: this.config.versionCheck.enable,
featureInfoCollectionEnabled: this.config.telemetry,
},
);
}
}
export default TelemetryController;