/* Copyright 2021 The Matrix.org Foundation C.I.C. Licensed 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 BaseDialog from "./BaseDialog"; import { _t } from "../../../languageHandler"; import DialogButtons from "../elements/DialogButtons"; import Modal from "../../../Modal"; import SdkConfig from "../../../SdkConfig"; import { getPolicyUrl } from "../../../toasts/AnalyticsToast"; export enum ButtonClicked { Primary, Cancel, } interface IProps { onFinished?(buttonClicked?: ButtonClicked): void; analyticsOwner: string; privacyPolicyUrl?: string; primaryButton?: string; cancelButton?: string; hasCancel?: boolean; } export const AnalyticsLearnMoreDialog: React.FC = ({ onFinished, analyticsOwner, privacyPolicyUrl, primaryButton, cancelButton, hasCancel, }) => { const onPrimaryButtonClick = (): void => onFinished?.(ButtonClicked.Primary); const onCancelButtonClick = (): void => onFinished?.(ButtonClicked.Cancel); const privacyPolicyLink = privacyPolicyUrl ? ( {_t( "You can read all our terms here", {}, { PrivacyPolicyUrl: (sub) => { return ( {sub} ); }, }, )} ) : ( "" ); return (
{_t( "Help us identify issues and improve %(analyticsOwner)s by sharing anonymous usage data. " + "To understand how people use multiple devices, we'll generate a random identifier, " + "shared by your devices.", { analyticsOwner }, )}
  • {_t( "We don't record or profile any account data", {}, { Bold: (sub) => {sub} }, )}
  • {_t( "We don't share information with third parties", {}, { Bold: (sub) => {sub} }, )}
  • {_t("You can turn this off anytime in settings")}
{privacyPolicyLink}
); }; export const showDialog = (props: Omit): void => { const privacyPolicyUrl = getPolicyUrl(); const analyticsOwner = SdkConfig.get("analytics_owner") ?? SdkConfig.get("brand"); Modal.createDialog( AnalyticsLearnMoreDialog, { privacyPolicyUrl, analyticsOwner, ...props, }, "mx_AnalyticsLearnMoreDialog_wrapper", ); };