Add the debug packet recorder behind the developer-tools toggle.
This commit is contained in:
@@ -37,6 +37,7 @@ type DeveloperToolsProps = {
|
||||
export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
const mx = useMatrixClient();
|
||||
const [developerTools, setDeveloperTools] = useSetting(settingsAtom, 'developerTools');
|
||||
const [debugPackets, setDebugPackets] = useSetting(settingsAtom, 'debugPackets');
|
||||
const [expand, setExpend] = useState(false);
|
||||
const [accountDataType, setAccountDataType] = useState<string | null>();
|
||||
const [profileExpand, setProfileExpand] = useState(false);
|
||||
@@ -162,6 +163,30 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||
/>
|
||||
}
|
||||
/>
|
||||
<SettingTile
|
||||
title="Debug Packets"
|
||||
description="Record every Matrix HTTP request and response."
|
||||
after={
|
||||
<Switch variant="Primary" value={debugPackets} onChange={setDebugPackets} />
|
||||
}
|
||||
/>
|
||||
{window.electron?.debug && (
|
||||
<SettingTile
|
||||
title="Packet Window"
|
||||
after={
|
||||
<Button
|
||||
onClick={() => window.electron?.debug?.openWindow()}
|
||||
variant="Secondary"
|
||||
fill="Soft"
|
||||
size="300"
|
||||
radii="300"
|
||||
outlined
|
||||
>
|
||||
<Text size="B300">Open packet window</Text>
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</SequenceCard>
|
||||
{developerTools && (
|
||||
<SequenceCard
|
||||
|
||||
@@ -253,6 +253,11 @@ export const SETTINGS_SEARCH_CATALOG: SettingsSearchEntry[] = [
|
||||
keywords: ['debug'],
|
||||
},
|
||||
{ page: SettingsPages.DeveloperToolsPage, title: 'Access Token', keywords: ['auth', 'secret'] },
|
||||
{
|
||||
page: SettingsPages.DeveloperToolsPage,
|
||||
title: 'Debug Packets',
|
||||
keywords: ['http', 'network', 'request', 'response'],
|
||||
},
|
||||
{ page: SettingsPages.DeveloperToolsPage, title: 'Account Data', keywords: ['global', 'events'] },
|
||||
{
|
||||
page: SettingsPages.DeveloperToolsPage,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
export interface DebugPacket {
|
||||
id: number;
|
||||
ts: number;
|
||||
phase: 'start' | 'end';
|
||||
method: string;
|
||||
url: string;
|
||||
path: string;
|
||||
status?: number;
|
||||
ms?: number;
|
||||
txnId?: string;
|
||||
eventId?: string;
|
||||
req?: string;
|
||||
res?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
let nextId = 0;
|
||||
|
||||
export function recordPacket(packet: Omit<DebugPacket, 'id'>) {
|
||||
const full: DebugPacket = { id: nextId, ...packet };
|
||||
nextId += 1;
|
||||
|
||||
// Web and mobile builds have no electron bridge, so nothing is recorded there
|
||||
window.electron?.debug?.send(full);
|
||||
}
|
||||
@@ -63,6 +63,7 @@ export interface Settings {
|
||||
dateFormatString: string;
|
||||
|
||||
developerTools: boolean;
|
||||
debugPackets: boolean;
|
||||
|
||||
autoJoinSpaceRooms: boolean;
|
||||
|
||||
@@ -109,6 +110,7 @@ const defaultSettings: Settings = {
|
||||
dateFormatString: 'D MMM YYYY',
|
||||
|
||||
developerTools: false,
|
||||
debugPackets: false,
|
||||
|
||||
autoJoinSpaceRooms: true,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user