From 30b339af0f24b8f525290c3c4acd190c82900600 Mon Sep 17 00:00:00 2001 From: Joel Griffith Date: Mon, 11 Nov 2019 09:40:52 -0800 Subject: [PATCH 1/8] Removing tel splash page in UI layer --- .../kibana/public/home/components/home.js | 8 --- .../kibana/public/home/components/home_app.js | 6 --- .../kibana/public/home/components/welcome.tsx | 53 +++---------------- 3 files changed, 8 insertions(+), 59 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/home/components/home.js b/src/legacy/core_plugins/kibana/public/home/components/home.js index e4c7de9b495a0..067f4a4234ab2 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/home.js +++ b/src/legacy/core_plugins/kibana/public/home/components/home.js @@ -228,10 +228,6 @@ export class Home extends Component { ); } @@ -254,10 +250,6 @@ export class Home extends Component { Home.propTypes = { addBasePath: PropTypes.func.isRequired, - fetchTelemetry: PropTypes.func.isRequired, - getTelemetryBannerId: PropTypes.func.isRequired, - setOptIn: PropTypes.func.isRequired, - shouldShowTelemetryOptIn: PropTypes.bool, directories: PropTypes.arrayOf( PropTypes.shape({ id: PropTypes.string.isRequired, diff --git a/src/legacy/core_plugins/kibana/public/home/components/home_app.js b/src/legacy/core_plugins/kibana/public/home/components/home_app.js index 005d4bdb0a99e..9e25fc0d50a09 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/home_app.js +++ b/src/legacy/core_plugins/kibana/public/home/components/home_app.js @@ -36,8 +36,6 @@ import { export function HomeApp({ directories }) { const { - telemetryOptInProvider, - shouldShowTelemetryOptIn, getInjected, savedObjectsClient, getBasePath, @@ -101,10 +99,6 @@ export function HomeApp({ directories }) { find={savedObjectsClient.find} localStorage={localStorage} urlBasePath={getBasePath()} - shouldShowTelemetryOptIn={shouldShowTelemetryOptIn} - setOptIn={telemetryOptInProvider.setOptIn} - fetchTelemetry={telemetryOptInProvider.fetchExample} - getTelemetryBannerId={telemetryOptInProvider.getBannerId} /> diff --git a/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx b/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx index afe43a23e18cb..c39a59d186d32 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx +++ b/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx @@ -37,29 +37,17 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { getServices } from '../kibana_services'; import { SampleDataCard } from './sample_data'; -import { TelemetryOptInCard } from './telemetry_opt_in'; interface Props { urlBasePath: string; onSkip: () => {}; - fetchTelemetry: () => Promise; - setOptIn: (enabled: boolean) => Promise; - getTelemetryBannerId: () => string; - shouldShowTelemetryOptIn: boolean; -} - -interface State { - step: number; } /** * Shows a full-screen welcome page that gives helpful quick links to beginners. */ -export class Welcome extends React.PureComponent { +export class Welcome extends React.PureComponent { private services = getServices(); - public readonly state: State = { - step: 0, - }; private hideOnEsc = (e: KeyboardEvent) => { if (e.key === 'Escape') { @@ -72,19 +60,11 @@ export class Welcome extends React.PureComponent { window.location.href = path; } - private async handleTelemetrySelection(confirm: boolean) { - const metricName = `telemetryOptIn${confirm ? 'Confirm' : 'Decline'}`; - this.services.trackUiMetric(this.services.METRIC_TYPE.CLICK, metricName); - await this.props.setOptIn(confirm); - const bannerId = this.props.getTelemetryBannerId(); - this.services.banners.remove(bannerId); - this.setState(() => ({ step: 1 })); - } - private onSampleDataDecline = () => { this.services.trackUiMetric(this.services.METRIC_TYPE.CLICK, 'sampleDataDecline'); this.props.onSkip(); }; + private onSampleDataConfirm = () => { this.services.trackUiMetric(this.services.METRIC_TYPE.CLICK, 'sampleDataConfirm'); this.redirecToSampleData(); @@ -92,12 +72,6 @@ export class Welcome extends React.PureComponent { componentDidMount() { this.services.trackUiMetric(this.services.METRIC_TYPE.LOADED, 'welcomeScreenMount'); - if (this.props.shouldShowTelemetryOptIn) { - this.services.trackUiMetric( - this.services.METRIC_TYPE.COUNT, - 'welcomeScreenWithTelemetryOptIn' - ); - } document.addEventListener('keydown', this.hideOnEsc); } @@ -106,8 +80,7 @@ export class Welcome extends React.PureComponent { } render() { - const { urlBasePath, shouldShowTelemetryOptIn, fetchTelemetry } = this.props; - const { step } = this.state; + const { urlBasePath } = this.props; return ( @@ -137,21 +110,11 @@ export class Welcome extends React.PureComponent {
- {shouldShowTelemetryOptIn && step === 0 && ( - - )} - {(!shouldShowTelemetryOptIn || step === 1) && ( - - )} + From 774bd42803b4406f83555b103c014e6e5bbb76ff Mon Sep 17 00:00:00 2001 From: Joel Griffith Date: Mon, 11 Nov 2019 09:59:10 -0800 Subject: [PATCH 2/8] Removing more components --- .../home/components/telemetry_opt_in/index.ts | 23 ------ .../telemetry_opt_in_card.tsx | 81 ------------------- 2 files changed, 104 deletions(-) delete mode 100644 src/legacy/core_plugins/kibana/public/home/components/telemetry_opt_in/index.ts delete mode 100644 src/legacy/core_plugins/kibana/public/home/components/telemetry_opt_in/telemetry_opt_in_card.tsx diff --git a/src/legacy/core_plugins/kibana/public/home/components/telemetry_opt_in/index.ts b/src/legacy/core_plugins/kibana/public/home/components/telemetry_opt_in/index.ts deleted file mode 100644 index 63636433bc00b..0000000000000 --- a/src/legacy/core_plugins/kibana/public/home/components/telemetry_opt_in/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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 { renderTelemetryOptInCard, Props } from './telemetry_opt_in_card'; - -export const TelemetryOptInCard = (props: Props) => { - return renderTelemetryOptInCard(props); -}; diff --git a/src/legacy/core_plugins/kibana/public/home/components/telemetry_opt_in/telemetry_opt_in_card.tsx b/src/legacy/core_plugins/kibana/public/home/components/telemetry_opt_in/telemetry_opt_in_card.tsx deleted file mode 100644 index 572188d9c9b93..0000000000000 --- a/src/legacy/core_plugins/kibana/public/home/components/telemetry_opt_in/telemetry_opt_in_card.tsx +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 { FormattedMessage } from '@kbn/i18n/react'; -import { - // @ts-ignore - EuiCard, - EuiButton, -} from '@elastic/eui'; -import { OptInMessage } from '../../../../../telemetry/public/components/opt_in_message'; - -export interface Props { - urlBasePath: string; - onConfirm: () => void; - onDecline: () => void; - fetchTelemetry: () => Promise; -} - -export function renderTelemetryOptInCard({ - urlBasePath, - fetchTelemetry, - onConfirm, - onDecline, -}: Props) { - return ( - - } - description={} - footer={ -
- - - - - - -
- } - /> - ); -} From ce837aa7fdb1da6b9656d338db925a760d0ddbb4 Mon Sep 17 00:00:00 2001 From: Joel Griffith Date: Mon, 11 Nov 2019 10:52:18 -0800 Subject: [PATCH 3/8] New disclaimer text --- .../kibana/public/home/components/welcome.tsx | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx b/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx index c39a59d186d32..702b87b40b399 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx +++ b/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx @@ -25,6 +25,8 @@ import React from 'react'; import { + EuiLink, + EuiTextColor, EuiTitle, EuiSpacer, EuiFlexGroup, @@ -46,7 +48,7 @@ interface Props { /** * Shows a full-screen welcome page that gives helpful quick links to beginners. */ -export class Welcome extends React.PureComponent { +export class Welcome extends React.Component { private services = getServices(); private hideOnEsc = (e: KeyboardEvent) => { @@ -115,6 +117,29 @@ export class Welcome extends React.PureComponent { onConfirm={this.onSampleDataConfirm} onDecline={this.onSampleDataDecline} /> + + + + + + + + + + + From b69142c970525ff8cd521bfcc5960971f380c04c Mon Sep 17 00:00:00 2001 From: Joel Griffith Date: Mon, 11 Nov 2019 12:26:41 -0800 Subject: [PATCH 4/8] Removing telemetry i18n text --- x-pack/plugins/translations/translations/ja-JP.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 057ae6e2ce994..943ee8d930344 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -2459,9 +2459,6 @@ "kbn.home.addData.siem.addSiemEventsButtonLabel": "セキュリティイベントを追加", "kbn.home.addData.siem.nameDescription": "即利用可能なビジュアライゼーションで、セキュリティイベントをまとめてインタラクティブな調査を可能にします。", "kbn.home.addData.siem.nameTitle": "SIEM", - "kbn.home.telemtery.optInCardConfirmButtonLabel": "はい", - "kbn.home.telemtery.optInCardDeclineButtonLabel": "いいえ", - "kbn.home.telemtery.optInCardTitle": "Elastic Stack の改善にご協力ください", "kbn.home.tutorial.tabs.siemTitle": "SIEM", "kbn.home.welcomeHomePageHeader": "Kibana ホーム", "kbn.discover.reloadSavedSearchButton": "検索をリセット", From 46b9f5cc97fad64255c6afa2589e1e887bde0486 Mon Sep 17 00:00:00 2001 From: Joel Griffith Date: Mon, 11 Nov 2019 13:24:29 -0800 Subject: [PATCH 5/8] More i18n text removals --- x-pack/plugins/translations/translations/zh-CN.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 8a0e3d78139b1..2e4167cec2ed8 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -2460,9 +2460,6 @@ "kbn.home.addData.siem.addSiemEventsButtonLabel": "添加安全事件", "kbn.home.addData.siem.nameDescription": "集中安全事件,以通过即用型可视化实现交互式调查。", "kbn.home.addData.siem.nameTitle": "SIEM", - "kbn.home.telemtery.optInCardConfirmButtonLabel": "是", - "kbn.home.telemtery.optInCardDeclineButtonLabel": "否", - "kbn.home.telemtery.optInCardTitle": "帮助我们改进 Elastic Stack", "kbn.home.tutorial.tabs.siemTitle": "SIEM", "kbn.home.welcomeHomePageHeader": "Kibana 主页", "kbn.discover.reloadSavedSearchButton": "重置搜索", From 440a37339f0a6580933693f5755c84f68b776030 Mon Sep 17 00:00:00 2001 From: Joel Griffith Date: Mon, 11 Nov 2019 14:27:32 -0800 Subject: [PATCH 6/8] Snapshot updates --- .../public/home/components/__snapshots__/home.test.js.snap | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/home.test.js.snap b/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/home.test.js.snap index 71c336b1d48d2..0e2546cf2580b 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/home.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/home.test.js.snap @@ -1072,10 +1072,7 @@ exports[`home welcome should show the normal home page if welcome screen is disa exports[`home welcome should show the welcome screen if enabled, and there are no index patterns defined 1`] = ` `; From 6faff3e3b3381b58d26148829a8e183685e83be4 Mon Sep 17 00:00:00 2001 From: Joel Griffith Date: Tue, 12 Nov 2019 10:23:41 -0800 Subject: [PATCH 7/8] Snapshot tests + quick links for tel opt-out when possible --- .../__snapshots__/home.test.js.snap | 1 + .../__snapshots__/welcome.test.tsx.snap | 188 ++++++++++++++++++ .../kibana/public/home/components/home.js | 3 + .../public/home/components/welcome.test.tsx | 51 +++++ .../kibana/public/home/components/welcome.tsx | 47 +++-- 5 files changed, 270 insertions(+), 20 deletions(-) create mode 100644 src/legacy/core_plugins/kibana/public/home/components/__snapshots__/welcome.test.tsx.snap create mode 100644 src/legacy/core_plugins/kibana/public/home/components/welcome.test.tsx diff --git a/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/home.test.js.snap b/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/home.test.js.snap index 0e2546cf2580b..0bf8c808ae920 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/home.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/home.test.js.snap @@ -1073,6 +1073,7 @@ exports[`home welcome should show the normal home page if welcome screen is disa exports[`home welcome should show the welcome screen if enabled, and there are no index patterns defined 1`] = ` `; diff --git a/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/welcome.test.tsx.snap b/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/welcome.test.tsx.snap new file mode 100644 index 0000000000000..5a6c6eba5c8db --- /dev/null +++ b/src/legacy/core_plugins/kibana/public/home/components/__snapshots__/welcome.test.tsx.snap @@ -0,0 +1,188 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render a Welcome screen with no telemetry disclaimer 1`] = ` + +
+
+
+ + + + + +

+ +

+
+ +

+ +

+
+ +
+
+
+ + + + + + + +
+
+
+`; + +exports[`should render a Welcome screen with the telemetry disclaimer 1`] = ` + +
+
+
+ + + + + +

+ +

+
+ +

+ +

+
+ +
+
+
+ + + + + + + + + + + + + + + + + +
+
+
+`; diff --git a/src/legacy/core_plugins/kibana/public/home/components/home.js b/src/legacy/core_plugins/kibana/public/home/components/home.js index 4dd86017f90ac..3266bbb79c625 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/home.js +++ b/src/legacy/core_plugins/kibana/public/home/components/home.js @@ -51,6 +51,7 @@ export class Home extends Component { getServices().getInjected('disableWelcomeScreen') || props.localStorage.getItem(KEY_ENABLE_WELCOME) === 'false' ); + const showTelemetryDisclaimer = getServices().getInjected('allowChangingOptInStatus'); this.state = { // If welcome is enabled, we wait for loading to complete @@ -60,6 +61,7 @@ export class Home extends Component { isLoading: isWelcomeEnabled, isNewKibanaInstance: false, isWelcomeEnabled, + showTelemetryDisclaimer, }; } @@ -228,6 +230,7 @@ export class Home extends Component { ); } diff --git a/src/legacy/core_plugins/kibana/public/home/components/welcome.test.tsx b/src/legacy/core_plugins/kibana/public/home/components/welcome.test.tsx new file mode 100644 index 0000000000000..d5731411329b4 --- /dev/null +++ b/src/legacy/core_plugins/kibana/public/home/components/welcome.test.tsx @@ -0,0 +1,51 @@ +/* + * 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 { shallow } from 'enzyme'; +import { Welcome } from './welcome'; + +jest.mock('../kibana_services', () => ({ + getServices: () => ({ + addBasePath: (path: string) => `root${path}`, + trackUiMetric: () => {}, + METRIC_TYPE: { + LOADED: 'loaded', + CLICK: 'click', + }, + }), +})); + +test('should render a Welcome screen with the telemetry disclaimer', () => { + // @ts-ignore + const component = shallow(( + {}} showTelemetryDisclaimer={true} /> + ) as any); + + expect(component).toMatchSnapshot(); +}); + +test('should render a Welcome screen with no telemetry disclaimer', () => { + // @ts-ignore + const component = shallow( + {}} showTelemetryDisclaimer={false} /> + ); + + expect(component).toMatchSnapshot(); +}); diff --git a/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx b/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx index 702b87b40b399..d919a4ecf239c 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx +++ b/src/legacy/core_plugins/kibana/public/home/components/welcome.tsx @@ -42,7 +42,8 @@ import { SampleDataCard } from './sample_data'; interface Props { urlBasePath: string; - onSkip: () => {}; + onSkip: () => void; + showTelemetryDisclaimer: boolean; } /** @@ -82,7 +83,7 @@ export class Welcome extends React.Component { } render() { - const { urlBasePath } = this.props; + const { urlBasePath, showTelemetryDisclaimer } = this.props; return ( @@ -118,28 +119,34 @@ export class Welcome extends React.Component { onDecline={this.onSampleDataDecline} /> - - - + {showTelemetryDisclaimer && ( + - - - + + + - - + + + + + )} From fe98b938e47266667a73db01f3b8d5656c1ef905 Mon Sep 17 00:00:00 2001 From: Joel Griffith Date: Tue, 12 Nov 2019 10:24:54 -0800 Subject: [PATCH 8/8] Fixing TS issues in test --- .../kibana/public/home/components/welcome.test.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/home/components/welcome.test.tsx b/src/legacy/core_plugins/kibana/public/home/components/welcome.test.tsx index d5731411329b4..195a527707af6 100644 --- a/src/legacy/core_plugins/kibana/public/home/components/welcome.test.tsx +++ b/src/legacy/core_plugins/kibana/public/home/components/welcome.test.tsx @@ -33,10 +33,10 @@ jest.mock('../kibana_services', () => ({ })); test('should render a Welcome screen with the telemetry disclaimer', () => { - // @ts-ignore - const component = shallow(( + const component = shallow( + // @ts-ignore {}} showTelemetryDisclaimer={true} /> - ) as any); + ); expect(component).toMatchSnapshot(); }); @@ -44,6 +44,7 @@ test('should render a Welcome screen with the telemetry disclaimer', () => { test('should render a Welcome screen with no telemetry disclaimer', () => { // @ts-ignore const component = shallow( + // @ts-ignore {}} showTelemetryDisclaimer={false} /> );