import { upperFirst } from 'lodash';
import * as React from 'react';
import { Subscription } from 'rxjs';
import { PageTitle } from '../components/PageTitle';
import { eventLogger } from '../tracking/eventLogger';
import { fetchSite } from './backend';
import { getUpdateChannel } from './configHelpers';
/**
 * A page displaying information about telemetry pings for the site.
 */
export class SiteAdminPingsPage extends React.Component {
    constructor() {
        super(...arguments);
        this.state = {};
        this.subscriptions = new Subscription();
    }
    componentDidMount() {
        eventLogger.logViewEvent('SiteAdminPings');
        this.subscriptions.add(fetchSite().subscribe(site => this.setState({
            channel: getUpdateChannel(site.configuration.effectiveContents),
            error: undefined,
        }), error => this.setState({ error: error.message })));
    }
    componentWillUnmount() {
        this.subscriptions.unsubscribe();
    }
    render() {
        const pingsEnabled = this.state.channel === 'release';
        return (React.createElement("div", { className: "site-admin-pings-page" },
            React.createElement(PageTitle, { title: "Pings - Admin" }),
            React.createElement("h2", null, "Pings"),
            this.state.error && React.createElement("p", { className: "alert alert-danger" },
                "Error: ",
                upperFirst(this.state.error)),
            React.createElement("p", null, "Sourcegraph periodically sends a ping to Sourcegraph.com to help our product and customer teams. It sends only the high-level data below. It never sends code, repository names, usernames, or any other specific data."),
            React.createElement("ul", null,
                React.createElement("li", null, "Sourcegraph version string"),
                React.createElement("li", null, "Deployment type (Docker, Kubernetes, or dev build)"),
                React.createElement("li", null, "Randomly generated site identifier"),
                React.createElement("li", null, "The email address of the initial site installer (or if deleted, the first active site admin), to know who to contact regarding sales, product updates, and policy updates"),
                React.createElement("li", null, "Which category of authentication provider is in use (built-in, OpenID Connect, an HTTP proxy, or SAML)"),
                React.createElement("li", null, "Whether code intelligence is enabled"),
                React.createElement("li", null, "Total count of existing user accounts"),
                React.createElement("li", null, "Aggregate counts of current daily, weekly, and monthly users"),
                React.createElement("li", null, "Aggregate counts of current users using code host integrations")),
            !pingsEnabled ? (React.createElement("p", null, "Pings are disabled.")) : (React.createElement("p", null,
                "To disable pings (for customers only),",
                ' ',
                React.createElement("a", { href: "https://about.sourcegraph.com/contact/", target: "_blank" }, "contact support"),
                "."))));
    }
}
//# sourceMappingURL=SiteAdminPingsPage.js.map