-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
Copy pathconfig.ts
54 lines (49 loc) · 1.87 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { schema, TypeOf, Type } from '@kbn/config-schema';
import { getConfigPath } from '@kbn/utils';
import { PluginConfigDescriptor } from 'kibana/server';
const clusterEnvSchema: [Type<'prod'>, Type<'staging'>] = [
schema.literal('prod'),
schema.literal('staging'),
];
const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
allowChangingOptInStatus: schema.boolean({ defaultValue: true }),
optIn: schema.conditional(
schema.siblingRef('allowChangingOptInStatus'),
schema.literal(false),
schema.maybe(schema.literal(true)),
schema.boolean({ defaultValue: true }),
{ defaultValue: true }
),
// `config` is used internally and not intended to be set
config: schema.string({ defaultValue: getConfigPath() }),
banner: schema.boolean({ defaultValue: true }),
sendUsageTo: schema.conditional(
schema.contextRef('dist'),
schema.literal(false), // Point to staging if it's not a distributable release
schema.oneOf(clusterEnvSchema, { defaultValue: 'staging' }),
schema.oneOf(clusterEnvSchema, { defaultValue: 'prod' })
),
sendUsageFrom: schema.oneOf([schema.literal('server'), schema.literal('browser')], {
defaultValue: 'server',
}),
});
export type TelemetryConfigType = TypeOf<typeof configSchema>;
export const config: PluginConfigDescriptor<TelemetryConfigType> = {
schema: configSchema,
exposeToBrowser: {
enabled: true,
banner: true,
allowChangingOptInStatus: true,
optIn: true,
sendUsageFrom: true,
sendUsageTo: true,
},
};