Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ export default class LabsUserSettingsTab extends React.Component<EmptyObject> {
groups
.getOrCreate(LabGroup.Analytics, [])
.push(
<SettingsFlag
key="automaticErrorReporting"
name="automaticErrorReporting"
level={SettingLevel.DEVICE}
/>,
<SettingsFlag
key="automaticDecryptionErrorReporting"
name="automaticDecryptionErrorReporting"
Expand Down
1 change: 0 additions & 1 deletion apps/web/src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,6 @@
},
"labs": {
"ask_to_join": "Enable ask to join",
"automatic_debug_logs": "Automatically send debug logs on any error",
"automatic_debug_logs_decryption": "Automatically send debug logs on decryption errors",
"beta_description": "What's next for %(brand)s? Labs are the best way to get things early, test out new features and help shape them before they actually launch.",
"beta_feature": "This is a beta feature",
Expand Down
11 changes: 3 additions & 8 deletions apps/web/src/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ export async function sendSentryReport(userText: string, issueUrl: string, error
}

export function setSentryUser(mxid: string): void {
if (!SdkConfig.get().sentry || !SettingsStore.getValue("automaticErrorReporting")) return;
Sentry.setUser({ username: mxid });
if (SdkConfig.get().sentry) {
Sentry.setUser({ username: mxid });
}
}

export async function initSentry(sentryConfig: IConfigOptions["sentry"]): Promise<void> {
if (!sentryConfig) return;
// Only enable Integrations.GlobalHandlers, which hooks uncaught exceptions, if automaticErrorReporting is true
const integrations = [
Sentry.inboundFiltersIntegration(),
Sentry.functionToStringIntegration(),
Expand All @@ -203,11 +203,6 @@ export async function initSentry(sentryConfig: IConfigOptions["sentry"]): Promis
Sentry.dedupeIntegration(),
];

if (SettingsStore.getValue("automaticErrorReporting")) {
integrations.push(Sentry.globalHandlersIntegration({ onerror: false, onunhandledrejection: true }));
integrations.push(Sentry.browserApiErrorsIntegration());
}

Sentry.init({
dsn: sentryConfig.dsn,
release: process.env.VERSION,
Expand Down
8 changes: 1 addition & 7 deletions apps/web/src/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import MediaPreviewConfigController from "./controllers/MediaPreviewConfigContro
import InviteRulesConfigController from "./controllers/InviteRulesConfigController.ts";
import { type ComputedInviteConfig } from "../@types/invite-rules.ts";
import BlockInvitesConfigController from "./controllers/BlockInvitesConfigController.ts";
import CompatibilityCheckController from "./controllers/CompatibilityCheckController.ts";

export const defaultWatchManager = new WatchManager();

Expand Down Expand Up @@ -350,7 +351,6 @@ export interface Settings {
"Spaces.enabledMetaSpaces": IBaseSetting<Partial<Record<MetaSpace, boolean>>>;
"Spaces.showPeopleInSpace": IBaseSetting<boolean>;
"developerMode": IBaseSetting<boolean>;
"automaticErrorReporting": IBaseSetting<boolean>;
"automaticDecryptionErrorReporting": IBaseSetting<boolean>;
"debug_scroll_panel": IBaseSetting<boolean>;
"debug_timeline_panel": IBaseSetting<boolean>;
Expand Down Expand Up @@ -1310,12 +1310,6 @@ export const SETTINGS: Settings = {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
default: false,
},
"automaticErrorReporting": {
displayName: _td("labs|automatic_debug_logs"),
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
default: false,
controller: new ReloadOnChangeController(),
},
"automaticDecryptionErrorReporting": {
displayName: _td("labs|automatic_debug_logs_decryption"),
supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS,
Expand Down
53 changes: 53 additions & 0 deletions apps/web/src/settings/controllers/CompatibilityCheckController.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Copyright 2026 Element Creations Ltd.

SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/

import SettingController from "./SettingController";
import { type SettingLevel } from "../SettingLevel";
import PlatformPeg from "../../PlatformPeg";

/**
* Enforces that a boolean setting cannot be changed if a function returns false.
*/
export default class CompatibilityCheckController extends SettingController {
/**
* @param compatibleCheck A function that checks if the setting is incompatible. May return a reason string.
* @param forcedValue The forced value if the setting is incompatible.
*/
public constructor(
private readonly compatibleCheck: () => boolean | string,
private readonly forcedValue = false,
private readonly reloadOnChange = false,
) {
super();
}

public getValueOverride(
level: SettingLevel,
roomId: string,
calculatedValue: any,
calculatedAtLevel: SettingLevel | null,
): any {
if (!this.compatibleSetting) {
return this.forcedValue;
}
return null; // no override
}

public onChange(): void {
if (this.reloadOnChange) {
PlatformPeg.get()?.reload();
}
}

public get settingDisabled(): boolean | string {
return this.compatibleSetting;
}

public get compatibleSetting(): boolean | string {
return this.compatibleCheck();
}
}
Loading