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] Remove telemetry splash page and add conditional messaging #50189

Merged
merged 12 commits into from
Nov 12, 2019
8 changes: 0 additions & 8 deletions src/legacy/core_plugins/kibana/public/home/components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,6 @@ export class Home extends Component {
<Welcome
onSkip={this.skipWelcome}
urlBasePath={this.props.urlBasePath}
shouldShowTelemetryOptIn={this.props.shouldShowTelemetryOptIn}
fetchTelemetry={this.props.fetchTelemetry}
setOptIn={this.props.setOptIn}
getTelemetryBannerId={this.props.getTelemetryBannerId}
/>
);
}
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import { getServices } from '../kibana_services';

export function HomeApp({ directories }) {
const {
telemetryOptInProvider,
shouldShowTelemetryOptIn,
getInjected,
savedObjectsClient,
getBasePath,
Expand Down Expand Up @@ -85,10 +83,6 @@ export function HomeApp({ directories }) {
find={savedObjectsClient.find}
localStorage={localStorage}
urlBasePath={getBasePath()}
shouldShowTelemetryOptIn={shouldShowTelemetryOptIn}
setOptIn={telemetryOptInProvider.setOptIn}
fetchTelemetry={telemetryOptInProvider.fetchExample}
getTelemetryBannerId={telemetryOptInProvider.getBannerId}
/>
</Route>
<Route path="/home">
Expand Down

This file was deleted.

This file was deleted.

74 changes: 31 additions & 43 deletions src/legacy/core_plugins/kibana/public/home/components/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

import React from 'react';
import {
EuiLink,
EuiTextColor,
EuiTitle,
EuiSpacer,
EuiFlexGroup,
Expand All @@ -37,29 +39,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<any[]>;
setOptIn: (enabled: boolean) => Promise<boolean>;
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<Props, State> {
export class Welcome extends React.Component<Props> {
private services = getServices();
public readonly state: State = {
step: 0,
};

private hideOnEsc = (e: KeyboardEvent) => {
if (e.key === 'Escape') {
Expand All @@ -72,32 +62,18 @@ export class Welcome extends React.PureComponent<Props, State> {
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();
};

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);
}

Expand All @@ -106,8 +82,7 @@ export class Welcome extends React.PureComponent<Props, State> {
}

render() {
const { urlBasePath, shouldShowTelemetryOptIn, fetchTelemetry } = this.props;
const { step } = this.state;
const { urlBasePath } = this.props;

return (
<EuiPortal>
Expand Down Expand Up @@ -137,21 +112,34 @@ export class Welcome extends React.PureComponent<Props, State> {
<div className="homWelcome__content homWelcome-body">
<EuiFlexGroup gutterSize="l">
<EuiFlexItem>
{shouldShowTelemetryOptIn && step === 0 && (
<TelemetryOptInCard
urlBasePath={urlBasePath}
fetchTelemetry={fetchTelemetry}
onConfirm={this.handleTelemetrySelection.bind(this, true)}
onDecline={this.handleTelemetrySelection.bind(this, false)}
<SampleDataCard
urlBasePath={urlBasePath}
onConfirm={this.onSampleDataConfirm}
onDecline={this.onSampleDataDecline}
/>
<EuiSpacer size="s" />
<EuiTextColor className="euiText--small" color="subdued">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is a bit hectic, but I couldn't find a better mechanism for embedding links into a formatted message. Would love to know if folks have a better alternative as this is super noisy.

<FormattedMessage
id="kbn.home.dataManagementDisclaimerPrivacy"
defaultMessage="To learn about how usage data helps us manage and improve our products and services, see our "
/>
)}
{(!shouldShowTelemetryOptIn || step === 1) && (
<SampleDataCard
urlBasePath={urlBasePath}
onConfirm={this.onSampleDataConfirm}
onDecline={this.onSampleDataDecline}
<EuiLink href="#">
<FormattedMessage
id="kbn.home.dataManagementDisclaimerPrivacyLink"
defaultMessage="Privacy Policy."
/>
</EuiLink>
<FormattedMessage
id="kbn.home.dataManagementDisableCollection"
defaultMessage=" To disable collection, "
/>
)}
<EuiLink href="#">
<FormattedMessage
id="kbn.home.dataManagementDisableCollectionLink"
defaultMessage="click here."
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clicking here just causes the page to refresh and ends up in the same place. 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with the privacy policy link, which seems like it should go to https://www.elastic.co/legal/telemetry-privacy-statement , but perhaps we're waiting for updated links ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, these are just placeholders for now, thanks for calling it out!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added links!

</EuiLink>
</EuiTextColor>
<EuiSpacer size="xs" />
</EuiFlexItem>
</EuiFlexGroup>
Expand Down