mirror of https://github.com/vector-im/riot-web
commit
dbe463dc33
|
@ -55,6 +55,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@sentry/browser": "^6.11.0",
|
||||
"@sentry/tracing": "^6.11.0",
|
||||
"await-lock": "^2.1.0",
|
||||
"blurhash": "^1.1.3",
|
||||
"browser-encrypt-attachment": "^0.3.0",
|
||||
|
|
|
@ -108,6 +108,7 @@ import SoftLogout from './auth/SoftLogout';
|
|||
import { makeRoomPermalink } from "../../utils/permalinks/Permalinks";
|
||||
import { copyPlaintext } from "../../utils/strings";
|
||||
import { PosthogAnalytics } from '../../PosthogAnalytics';
|
||||
import { initSentry } from "../../sentry";
|
||||
|
||||
/** constants for MatrixChat.state.view */
|
||||
export enum Views {
|
||||
|
@ -393,6 +394,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
|||
PosthogAnalytics.instance.updatePlatformSuperProperties();
|
||||
|
||||
CountlyAnalytics.instance.enable(/* anonymous = */ true);
|
||||
|
||||
initSentry(SdkConfig.get()["sentry"]);
|
||||
}
|
||||
|
||||
private async postLoginSetup() {
|
||||
|
|
|
@ -29,11 +29,13 @@ import BaseDialog from "./BaseDialog";
|
|||
import Field from '../elements/Field';
|
||||
import Spinner from "../elements/Spinner";
|
||||
import DialogButtons from "../elements/DialogButtons";
|
||||
import { sendSentryReport } from "../../../sentry";
|
||||
|
||||
interface IProps {
|
||||
onFinished: (success: boolean) => void;
|
||||
initialText?: string;
|
||||
label?: string;
|
||||
error?: Error;
|
||||
}
|
||||
|
||||
interface IState {
|
||||
|
@ -113,6 +115,8 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
sendSentryReport(this.state.text, this.state.issueUrl, this.props.error);
|
||||
};
|
||||
|
||||
private onDownload = async (): Promise<void> => {
|
||||
|
@ -200,8 +204,8 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
|
|||
{ _t(
|
||||
"Debug logs contain application usage data including your " +
|
||||
"username, the IDs or aliases of the rooms or groups you " +
|
||||
"have visited and the usernames of other users. They do " +
|
||||
"not contain messages.",
|
||||
"have visited, which UI elements you last interacted with, " +
|
||||
"and the usernames of other users. They do not contain messages.",
|
||||
) }
|
||||
</p>
|
||||
<p><b>
|
||||
|
|
|
@ -71,6 +71,7 @@ export default class ErrorBoundary extends React.PureComponent<{}, IState> {
|
|||
private onBugReport = (): void => {
|
||||
Modal.createTrackedDialog('Bug Report Dialog', '', BugReportDialog, {
|
||||
label: 'react-soft-crash',
|
||||
error: this.state.error,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -93,8 +94,9 @@ export default class ErrorBoundary extends React.PureComponent<{}, IState> {
|
|||
"If you've submitted a bug via GitHub, debug logs can help " +
|
||||
"us track down the problem. Debug logs contain application " +
|
||||
"usage data including your username, the IDs or aliases of " +
|
||||
"the rooms or groups you have visited and the usernames of " +
|
||||
"other users. They do not contain messages.",
|
||||
"the rooms or groups you have visited, which UI elements you " +
|
||||
"last interacted with, and the usernames of other users. " +
|
||||
"They do not contain messages.",
|
||||
) }</p>
|
||||
<AccessibleButton onClick={this.onBugReport} kind='primary'>
|
||||
{ _t("Submit debug logs") }
|
||||
|
|
|
@ -51,6 +51,7 @@ export default class TileErrorBoundary extends React.Component<IProps, IState> {
|
|||
private onBugReport = (): void => {
|
||||
Modal.createTrackedDialog('Bug Report Dialog', '', BugReportDialog, {
|
||||
label: 'react-soft-crash-tile',
|
||||
error: this.state.error,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -268,7 +268,8 @@ export default class HelpUserSettingsTab extends React.Component<IProps, IState>
|
|||
"If you've submitted a bug via GitHub, debug logs can help " +
|
||||
"us track down the problem. Debug logs contain application " +
|
||||
"usage data including your username, the IDs or aliases of " +
|
||||
"the rooms or groups you have visited and the usernames of " +
|
||||
"the rooms or groups you have visited, which UI elements you " +
|
||||
"last interacted with, and the usernames of " +
|
||||
"other users. They do not contain messages.",
|
||||
) }
|
||||
<div className='mx_HelpUserSettingsTab_debugButton'>
|
||||
|
|
|
@ -1291,7 +1291,7 @@
|
|||
"For help with using %(brand)s, click <a>here</a> or start a chat with our bot using the button below.": "For help with using %(brand)s, click <a>here</a> or start a chat with our bot using the button below.",
|
||||
"Chat with %(brand)s Bot": "Chat with %(brand)s Bot",
|
||||
"Bug reporting": "Bug reporting",
|
||||
"If you've submitted a bug via GitHub, debug logs can help us track down the problem. Debug logs contain application usage data including your username, the IDs or aliases of the rooms or groups you have visited and the usernames of other users. They do not contain messages.": "If you've submitted a bug via GitHub, debug logs can help us track down the problem. Debug logs contain application usage data including your username, the IDs or aliases of the rooms or groups you have visited and the usernames of other users. They do not contain messages.",
|
||||
"If you've submitted a bug via GitHub, debug logs can help us track down the problem. Debug logs contain application usage data including your username, the IDs or aliases of the rooms or groups you have visited, which UI elements you last interacted with, and the usernames of other users. They do not contain messages.": "If you've submitted a bug via GitHub, debug logs can help us track down the problem. Debug logs contain application usage data including your username, the IDs or aliases of the rooms or groups you have visited, which UI elements you last interacted with, and the usernames of other users. They do not contain messages.",
|
||||
"Submit debug logs": "Submit debug logs",
|
||||
"To report a Matrix-related security issue, please read the Matrix.org <a>Security Disclosure Policy</a>.": "To report a Matrix-related security issue, please read the Matrix.org <a>Security Disclosure Policy</a>.",
|
||||
"Help & About": "Help & About",
|
||||
|
@ -2168,7 +2168,7 @@
|
|||
"Failed to send logs: ": "Failed to send logs: ",
|
||||
"Preparing to download logs": "Preparing to download logs",
|
||||
"Reminder: Your browser is unsupported, so your experience may be unpredictable.": "Reminder: Your browser is unsupported, so your experience may be unpredictable.",
|
||||
"Debug logs contain application usage data including your username, the IDs or aliases of the rooms or groups you have visited and the usernames of other users. They do not contain messages.": "Debug logs contain application usage data including your username, the IDs or aliases of the rooms or groups you have visited and the usernames of other users. They do not contain messages.",
|
||||
"Debug logs contain application usage data including your username, the IDs or aliases of the rooms or groups you have visited, which UI elements you last interacted with, and the usernames of other users. They do not contain messages.": "Debug logs contain application usage data including your username, the IDs or aliases of the rooms or groups you have visited, which UI elements you last interacted with, and the usernames of other users. They do not contain messages.",
|
||||
"Before submitting logs, you must <a>create a GitHub issue</a> to describe your problem.": "Before submitting logs, you must <a>create a GitHub issue</a> to describe your problem.",
|
||||
"Download logs": "Download logs",
|
||||
"GitHub issue": "GitHub issue",
|
||||
|
|
|
@ -0,0 +1,229 @@
|
|||
/*
|
||||
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 * as Sentry from "@sentry/browser";
|
||||
import PlatformPeg from "./PlatformPeg";
|
||||
import SdkConfig from "./SdkConfig";
|
||||
import { MatrixClientPeg } from "./MatrixClientPeg";
|
||||
import SettingsStore from "./settings/SettingsStore";
|
||||
import { MatrixClient } from "matrix-js-sdk";
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
type StorageContext = {
|
||||
storageManager_persisted?: string;
|
||||
storageManager_quota?: string;
|
||||
storageManager_usage?: string;
|
||||
storageManager_usageDetails?: string;
|
||||
};
|
||||
|
||||
type UserContext = {
|
||||
username: string;
|
||||
enabled_labs: string;
|
||||
low_bandwidth: string;
|
||||
};
|
||||
|
||||
type CryptoContext = {
|
||||
device_keys?: string;
|
||||
cross_signing_ready?: string;
|
||||
cross_signing_supported_by_hs?: string;
|
||||
cross_signing_key?: string;
|
||||
cross_signing_privkey_in_secret_storage?: string;
|
||||
cross_signing_master_privkey_cached?: string;
|
||||
cross_signing_user_signing_privkey_cached?: string;
|
||||
secret_storage_ready?: string;
|
||||
secret_storage_key_in_account?: string;
|
||||
session_backup_key_in_secret_storage?: string;
|
||||
session_backup_key_cached?: string;
|
||||
session_backup_key_well_formed?: string;
|
||||
};
|
||||
|
||||
type DeviceContext = {
|
||||
device_id: string;
|
||||
mx_local_settings: string;
|
||||
modernizr_missing_features?: string;
|
||||
};
|
||||
|
||||
type Contexts = {
|
||||
user: UserContext;
|
||||
crypto: CryptoContext;
|
||||
device: DeviceContext;
|
||||
storage: StorageContext;
|
||||
};
|
||||
|
||||
/* eslint-enable camelcase */
|
||||
|
||||
async function getStorageContext(): Promise<StorageContext> {
|
||||
const result = {};
|
||||
|
||||
// add storage persistence/quota information
|
||||
if (navigator.storage && navigator.storage.persisted) {
|
||||
try {
|
||||
result["storageManager_persisted"] = String(await navigator.storage.persisted());
|
||||
} catch (e) {}
|
||||
} else if (document.hasStorageAccess) { // Safari
|
||||
try {
|
||||
result["storageManager_persisted"] = String(await document.hasStorageAccess());
|
||||
} catch (e) {}
|
||||
}
|
||||
if (navigator.storage && navigator.storage.estimate) {
|
||||
try {
|
||||
const estimate = await navigator.storage.estimate();
|
||||
result["storageManager_quota"] = String(estimate.quota);
|
||||
result["storageManager_usage"] = String(estimate.usage);
|
||||
if (estimate.usageDetails) {
|
||||
const usageDetails = [];
|
||||
Object.keys(estimate.usageDetails).forEach(k => {
|
||||
usageDetails.push(`${k}: ${String(estimate.usageDetails[k])}`);
|
||||
});
|
||||
result[`storageManager_usage`] = usageDetails.join(", ");
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function getUserContext(client: MatrixClient): UserContext {
|
||||
return {
|
||||
"username": client.credentials.userId,
|
||||
"enabled_labs": getEnabledLabs(),
|
||||
"low_bandwidth": SettingsStore.getValue("lowBandwidth") ? "enabled" : "disabled",
|
||||
};
|
||||
}
|
||||
|
||||
function getEnabledLabs(): string {
|
||||
const enabledLabs = SettingsStore.getFeatureSettingNames().filter(f => SettingsStore.getValue(f));
|
||||
if (enabledLabs.length) {
|
||||
return enabledLabs.join(", ");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
async function getCryptoContext(client: MatrixClient): Promise<CryptoContext> {
|
||||
if (!client.isCryptoEnabled()) {
|
||||
return {};
|
||||
}
|
||||
const keys = [`ed25519:${client.getDeviceEd25519Key()}`];
|
||||
if (client.getDeviceCurve25519Key) {
|
||||
keys.push(`curve25519:${client.getDeviceCurve25519Key()}`);
|
||||
}
|
||||
const crossSigning = client.crypto.crossSigningInfo;
|
||||
const secretStorage = client.crypto.secretStorage;
|
||||
const pkCache = client.getCrossSigningCacheCallbacks();
|
||||
const sessionBackupKeyFromCache = await client.crypto.getSessionBackupPrivateKey();
|
||||
|
||||
return {
|
||||
"device_keys": keys.join(', '),
|
||||
"cross_signing_ready": String(await client.isCrossSigningReady()),
|
||||
"cross_signing_supported_by_hs":
|
||||
String(await client.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing")),
|
||||
"cross_signing_key": crossSigning.getId(),
|
||||
"cross_signing_privkey_in_secret_storage": String(
|
||||
!!(await crossSigning.isStoredInSecretStorage(secretStorage))),
|
||||
"cross_signing_master_privkey_cached": String(
|
||||
!!(pkCache && await pkCache.getCrossSigningKeyCache("master"))),
|
||||
"cross_signing_user_signing_privkey_cached": String(
|
||||
!!(pkCache && await pkCache.getCrossSigningKeyCache("user_signing"))),
|
||||
"secret_storage_ready": String(await client.isSecretStorageReady()),
|
||||
"secret_storage_key_in_account": String(!!(await secretStorage.hasKey())),
|
||||
"session_backup_key_in_secret_storage": String(!!(await client.isKeyBackupKeyStored())),
|
||||
"session_backup_key_cached": String(!!sessionBackupKeyFromCache),
|
||||
"session_backup_key_well_formed": String(sessionBackupKeyFromCache instanceof Uint8Array),
|
||||
};
|
||||
}
|
||||
|
||||
function getDeviceContext(client: MatrixClient): DeviceContext {
|
||||
const result = {
|
||||
"device_id": client?.deviceId,
|
||||
"mx_local_settings": localStorage.getItem('mx_local_settings'),
|
||||
};
|
||||
|
||||
if (window.Modernizr) {
|
||||
const missingFeatures = Object.keys(window.Modernizr).filter(key => window.Modernizr[key] === false);
|
||||
if (missingFeatures.length > 0) {
|
||||
result["modernizr_missing_features"] = missingFeatures.join(", ");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async function getContexts(): Promise<Contexts> {
|
||||
const client = MatrixClientPeg.get();
|
||||
return {
|
||||
"user": getUserContext(client),
|
||||
"crypto": await getCryptoContext(client),
|
||||
"device": getDeviceContext(client),
|
||||
"storage": await getStorageContext(),
|
||||
};
|
||||
}
|
||||
|
||||
export async function sendSentryReport(userText: string, issueUrl: string, error: Error): Promise<void> {
|
||||
const sentryConfig = SdkConfig.get()["sentry"];
|
||||
if (!sentryConfig) return;
|
||||
|
||||
const captureContext = {
|
||||
"contexts": await getContexts(),
|
||||
"extra": {
|
||||
"user_text": userText,
|
||||
"issue_url": issueUrl,
|
||||
},
|
||||
};
|
||||
|
||||
// If there's no error and no issueUrl, the report will just produce non-grouped noise in Sentry, so don't
|
||||
// upload it
|
||||
if (error) {
|
||||
Sentry.captureException(error, captureContext);
|
||||
} else if (issueUrl) {
|
||||
Sentry.captureMessage(`Issue: ${issueUrl}`, captureContext);
|
||||
}
|
||||
}
|
||||
|
||||
interface ISentryConfig {
|
||||
dsn: string;
|
||||
environment?: string;
|
||||
}
|
||||
|
||||
export async function initSentry(sentryConfig: ISentryConfig): Promise<void> {
|
||||
if (!sentryConfig) return;
|
||||
const platform = PlatformPeg.get();
|
||||
let appVersion = "unknown";
|
||||
try {
|
||||
appVersion = await platform.getAppVersion();
|
||||
} catch (e) {}
|
||||
|
||||
Sentry.init({
|
||||
dsn: sentryConfig.dsn,
|
||||
release: `${platform.getHumanReadableName()}@${appVersion}`,
|
||||
environment: sentryConfig.environment,
|
||||
defaultIntegrations: false,
|
||||
autoSessionTracking: false,
|
||||
debug: true,
|
||||
integrations: [
|
||||
// specifically disable Integrations.GlobalHandlers, which hooks uncaught exceptions - we don't
|
||||
// want to capture those at this stage, just explicit rageshakes
|
||||
new Sentry.Integrations.InboundFilters(),
|
||||
new Sentry.Integrations.FunctionToString(),
|
||||
new Sentry.Integrations.Breadcrumbs(),
|
||||
new Sentry.Integrations.UserAgent(),
|
||||
new Sentry.Integrations.Dedupe(),
|
||||
],
|
||||
// Set to 1.0 which is reasonable if we're only submitting Rageshakes; will need to be set < 1.0
|
||||
// if we collect more frequently.
|
||||
tracesSampleRate: 1.0,
|
||||
});
|
||||
}
|
63
yarn.lock
63
yarn.lock
|
@ -1502,11 +1502,74 @@
|
|||
tslib "^2.2.0"
|
||||
webcrypto-core "^1.2.0"
|
||||
|
||||
"@sentry/browser@^6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.11.0.tgz#9e90bbc0488ebcdd1e67937d8d5b4f13c3f6dee0"
|
||||
integrity sha512-Qr2QRA0t5/S9QQqxzYKvM9W8prvmiWuldfwRX4hubovXzcXLgUi4WK0/H612wSbYZ4dNAEcQbtlxFWJNN4wxdg==
|
||||
dependencies:
|
||||
"@sentry/core" "6.11.0"
|
||||
"@sentry/types" "6.11.0"
|
||||
"@sentry/utils" "6.11.0"
|
||||
tslib "^1.9.3"
|
||||
|
||||
"@sentry/core@6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.11.0.tgz#40e94043afcf6407a109be26655c77832c64e740"
|
||||
integrity sha512-09TB+f3pqEq8LFahFWHO6I/4DxHo+NcS52OkbWMDqEi6oNZRD7PhPn3i14LfjsYVv3u3AESU8oxSEGbFrr2UjQ==
|
||||
dependencies:
|
||||
"@sentry/hub" "6.11.0"
|
||||
"@sentry/minimal" "6.11.0"
|
||||
"@sentry/types" "6.11.0"
|
||||
"@sentry/utils" "6.11.0"
|
||||
tslib "^1.9.3"
|
||||
|
||||
"@sentry/hub@6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.11.0.tgz#ddf9ddb0577d1c8290dc02c0242d274fe84d6c16"
|
||||
integrity sha512-pT9hf+ZJfVFpoZopoC+yJmFNclr4NPqPcl2cgguqCHb69DklD1NxgBNWK8D6X05qjnNFDF991U6t1mxP9HrGuw==
|
||||
dependencies:
|
||||
"@sentry/types" "6.11.0"
|
||||
"@sentry/utils" "6.11.0"
|
||||
tslib "^1.9.3"
|
||||
|
||||
"@sentry/minimal@6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.11.0.tgz#806d5512658370e40827b3e3663061db708fff33"
|
||||
integrity sha512-XkZ7qrdlGp4IM/gjGxf1Q575yIbl5RvPbg+WFeekpo16Ufvzx37Mr8c2xsZaWosISVyE6eyFpooORjUlzy8EDw==
|
||||
dependencies:
|
||||
"@sentry/hub" "6.11.0"
|
||||
"@sentry/types" "6.11.0"
|
||||
tslib "^1.9.3"
|
||||
|
||||
"@sentry/tracing@^6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.11.0.tgz#9bd9287addea1ebc12c75b226f71c7713c0fac4f"
|
||||
integrity sha512-9VA1/SY++WeoMQI4K6n/sYgIdRtCu9NLWqmGqu/5kbOtESYFgAt1DqSyqGCr00ZjQiC2s7tkDkTNZb38K6KytQ==
|
||||
dependencies:
|
||||
"@sentry/hub" "6.11.0"
|
||||
"@sentry/minimal" "6.11.0"
|
||||
"@sentry/types" "6.11.0"
|
||||
"@sentry/utils" "6.11.0"
|
||||
tslib "^1.9.3"
|
||||
|
||||
"@sentry/types@6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.11.0.tgz#5122685478d32ddacd3a891cbcf550012df85f7c"
|
||||
integrity sha512-gm5H9eZhL6bsIy/h3T+/Fzzz2vINhHhqd92CjHle3w7uXdTdFV98i2pDpErBGNTSNzbntqOMifYEB5ENtZAvcg==
|
||||
|
||||
"@sentry/types@^6.10.0":
|
||||
version "6.10.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.10.0.tgz#6b1f44e5ed4dbc2710bead24d1b32fb08daf04e1"
|
||||
integrity sha512-M7s0JFgG7/6/yNVYoPUbxzaXDhnzyIQYRRJJKRaTD77YO4MHvi4Ke8alBWqD5fer0cPIfcSkBqa9BLdqRqcMWw==
|
||||
|
||||
"@sentry/utils@6.11.0":
|
||||
version "6.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.11.0.tgz#d1dee4faf4d9c42c54bba88d5a66fb96b902a14c"
|
||||
integrity sha512-IOvyFHcnbRQxa++jO+ZUzRvFHEJ1cZjrBIQaNVc0IYF0twUOB5PTP6joTcix38ldaLeapaPZ9LGfudbvYvxkdg==
|
||||
dependencies:
|
||||
"@sentry/types" "6.11.0"
|
||||
tslib "^1.9.3"
|
||||
|
||||
"@sinonjs/commons@^1.7.0":
|
||||
version "1.8.3"
|
||||
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d"
|
||||
|
|
Loading…
Reference in New Issue