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

[Telemetry] Move to OSS #45769

Merged
merged 31 commits into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c01fd26
update paths and licenses
Bamieh Sep 16, 2019
96f2c32
localization collector in oss
Bamieh Sep 16, 2019
e9765a9
node-crypto typings in oss
Bamieh Sep 16, 2019
d4b2be8
update telemetry i18n labels
Bamieh Sep 16, 2019
11cf28d
Merge branch 'master' of github.com:elastic/kibana into telemetry/oss
Bamieh Sep 16, 2019
badc1b2
update translation rc files
Bamieh Sep 16, 2019
9adbca9
merge master + rename fn
Bamieh Oct 2, 2019
3eb22a0
remove duplicate components in home for telemetry
Bamieh Oct 2, 2019
53e28d7
update tests
Bamieh Oct 2, 2019
0b1384e
finalize collection + move csp collector to oss
Bamieh Oct 2, 2019
0441d3f
update constants
Bamieh Oct 2, 2019
2b1db4c
self review
Bamieh Oct 2, 2019
d83e637
use apm instead of beats
Bamieh Oct 2, 2019
90d7d80
xpack collection
Bamieh Oct 3, 2019
782fb8c
fix collection tests
Bamieh Oct 3, 2019
e07644c
remove space specific settings
Bamieh Oct 4, 2019
a9fcec9
mock npSetup and npStart
Bamieh Oct 4, 2019
cc1eeb2
disable banner in tests
Bamieh Oct 5, 2019
5d1e679
Merge branch 'master' of github.com:elastic/kibana into telemetry/oss
Bamieh Oct 5, 2019
60379a2
Merge branch 'master' of github.com:elastic/kibana into telemetry/oss
Bamieh Oct 7, 2019
0676f8a
Merge branch 'master' of github.com:elastic/kibana into telemetry/oss
Bamieh Oct 8, 2019
1ede425
remove commented mock
Bamieh Oct 9, 2019
fcdc9c4
Merge branch 'master' of github.com:elastic/kibana into telemetry/oss
Bamieh Oct 9, 2019
2a203c6
test ec2 plugin
Bamieh Oct 14, 2019
bcb05d7
Merge branch 'master' of github.com:elastic/kibana into telemetry/oss
Bamieh Oct 15, 2019
982ef43
monitoring np telemetry fixes
Bamieh Oct 15, 2019
dba4e9d
Merge branch 'master' of github.com:elastic/kibana into telemetry/oss
Bamieh Oct 16, 2019
c03c567
replace telemetryOptedIn in oss instead of xpack_main
Bamieh Oct 16, 2019
c2d6f0a
fix telemetry OptIn test
Bamieh Oct 16, 2019
2432023
Merge branch 'master' of github.com:elastic/kibana into telemetry/oss
Bamieh Oct 16, 2019
048f37e
Merge branch 'master' of github.com:elastic/kibana into telemetry/oss
Bamieh Oct 16, 2019
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
2 changes: 1 addition & 1 deletion docs/settings/monitoring-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Specifies the password that {kib} uses for authentication when it retrieves data
from the monitoring cluster. If not set, {kib} uses the value of the
`elasticsearch.password` setting.

`xpack.telemetry.enabled`::
`telemetry.enabled`::
Set to `true` (default) to send cluster statistics to Elastic. Reporting your
cluster statistics helps us improve your user experience. Your data is never
shared with anyone. Set to `false` to disable statistics reporting from any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ kibana_vars=(
xpack.security.encryptionKey
xpack.security.secureCookies
xpack.security.sessionTimeout
xpack.telemetry.enabled
telemetry.enabled
)

longopts=''
Expand Down
66 changes: 66 additions & 0 deletions src/legacy/core_plugins/telemetry/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { i18n } from '@kbn/i18n';

/*
* config options opt into telemetry
* @type {string}
*/
export const CONFIG_TELEMETRY = 'telemetry:optIn';
/*
* config description for opting into telemetry
* @type {string}
*/
export const getConfigTelemetryDesc = () => {
return i18n.translate('telemetry.telemetryConfigDescription', {
defaultMessage:
'Help us improve the Elastic Stack by providing usage statistics for basic features. We will not share this data outside of Elastic.',
});
};

/**
* The amount of time, in milliseconds, to wait between reports when enabled.
*
* Currently 24 hours.
* @type {Number}
*/
export const REPORT_INTERVAL_MS = 86400000;

/*
* Key for the localStorage service
*/
export const LOCALSTORAGE_KEY = 'xpack.data';

/**
* Link to the Elastic Telemetry privacy statement.
*/
export const PRIVACY_STATEMENT_URL = `https://www.elastic.co/legal/telemetry-privacy-statement`;

/**
* The type name used within the Monitoring index to publish localization stats.
* @type {string}
*/
export const KIBANA_LOCALIZATION_STATS_TYPE = 'localization';

/**
* UI metric usage type
* @type {string}
*/
export const UI_METRIC_USAGE_TYPE = 'ui_metric';
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { KibanaConfig } from 'src/legacy/server/kbn_server';

export function getXpackConfigWithDeprecated(config: KibanaConfig, configPath: string) {
try {
const deprecatedXpackmainConfig = config.get(`xpack.xpack_main.${configPath}`);
if (typeof deprecatedXpackmainConfig !== 'undefined') {
return deprecatedXpackmainConfig;
}
} catch (err) {
// swallow error
}
try {
const deprecatedXpackConfig = config.get(`xpack.${configPath}`);
if (typeof deprecatedXpackConfig !== 'undefined') {
return deprecatedXpackConfig;
}
} catch (err) {
// swallow error
}

return config.get(configPath);
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { resolve } from 'path';
import JoiNamespace from 'joi';
import { Server } from 'hapi';
import { CoreSetup, PluginInitializerContext } from 'src/core/server';
import { i18n } from '@kbn/i18n';
// @ts-ignore
import mappings from './mappings.json';
import { CONFIG_TELEMETRY, getConfigTelemetryDesc, REPORT_INTERVAL_MS } from './common/constants';
import { CONFIG_TELEMETRY, getConfigTelemetryDesc } from './common/constants';
import { getXpackConfigWithDeprecated } from './common/get_xpack_config_with_deprecated';
import { telemetryPlugin } from './server';

Expand All @@ -22,10 +36,10 @@ import {

const ENDPOINT_VERSION = 'v2';

export const telemetry = (kibana: any) => {
const telemetry = (kibana: any) => {
return new kibana.Plugin({
id: 'telemetry',
configPrefix: 'xpack.telemetry',
configPrefix: 'telemetry',
publicDir: resolve(__dirname, 'public'),
require: ['elasticsearch'],
config(Joi: typeof JoiNamespace) {
Expand All @@ -49,7 +63,7 @@ export const telemetry = (kibana: any) => {
managementSections: ['plugins/telemetry/views/management'],
uiSettingDefaults: {
[CONFIG_TELEMETRY]: {
name: i18n.translate('xpack.telemetry.telemetryConfigTitle', {
name: i18n.translate('telemetry.telemetryConfigTitle', {
defaultMessage: 'Telemetry opt-in',
}),
description: getConfigTelemetryDesc(),
Expand All @@ -65,8 +79,9 @@ export const telemetry = (kibana: any) => {
injectDefaultVars(server: Server) {
const config = server.config();
return {
telemetryEnabled: getXpackConfigWithDeprecated(config, 'telemetry.enabled'),
telemetryUrl: getXpackConfigWithDeprecated(config, 'telemetry.url'),
telemetryBanner: config.get('xpack.telemetry.banner'),
telemetryBanner: getXpackConfigWithDeprecated(config, 'telemetry.banner'),
telemetryOptedIn: null,
};
},
Expand All @@ -85,9 +100,9 @@ export const telemetry = (kibana: any) => {
server.usage.collectorSet.register(createLocalizationUsageCollector(server));
server.usage.collectorSet.register(createTelemetryUsageCollector(server));
server.usage.collectorSet.register(createUiMetricUsageCollector(server));

// expose
server.expose('telemetryCollectionInterval', REPORT_INTERVAL_MS);
},
});
};

// eslint-disable-next-line import/no-default-export
export default telemetry;
4 changes: 4 additions & 0 deletions src/legacy/core_plugins/telemetry/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "telemetry",
"version": "kibana"
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions src/legacy/core_plugins/telemetry/public/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// @ts-ignore
export { TelemetryForm } from './telemetry_form';
export { OptInExampleFlyout } from './opt_in_details_component';
export { OptInBanner } from './opt_in_banner_component';
export { OptInMessage } from './opt_in_message';
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import * as React from 'react';
Expand All @@ -21,7 +34,7 @@ export class OptInBanner extends React.PureComponent<Props> {
render() {
const title = (
<FormattedMessage
id="xpack.telemetry.welcomeBanner.title"
id="telemetry.welcomeBanner.title"
defaultMessage="Help us improve the Elastic Stack!"
/>
);
Expand All @@ -32,18 +45,12 @@ export class OptInBanner extends React.PureComponent<Props> {
<EuiFlexGroup gutterSize="s" alignItems="center">
<EuiFlexItem grow={false}>
<EuiButton size="s" onClick={() => this.props.optInClick(true)}>
<FormattedMessage
id="xpack.telemetry.welcomeBanner.yesButtonLabel"
defaultMessage="Yes"
/>
<FormattedMessage id="telemetry.welcomeBanner.yesButtonLabel" defaultMessage="Yes" />
</EuiButton>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton size="s" onClick={() => this.props.optInClick(false)}>
<FormattedMessage
id="xpack.telemetry.welcomeBanner.noButtonLabel"
defaultMessage="No"
/>
<FormattedMessage id="telemetry.welcomeBanner.noButtonLabel" defaultMessage="No" />
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
import { OptInExampleFlyout } from './opt_in_details_component';

describe('OptInDetailsComponent', () => {
it('renders as expected', () => {
expect(
shallowWithIntl(
<OptInExampleFlyout
fetchTelemetry={jest.fn(async () => ({ data: [] }))}
onClose={jest.fn()}
/>
)
).toMatchSnapshot();
});
});
Loading