-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdebug-save-network.ts
More file actions
67 lines (52 loc) · 2.03 KB
/
debug-save-network.ts
File metadata and controls
67 lines (52 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { connectToSuperhuman, disconnect, openCompose, setSubject, addRecipient, setBody, saveDraft, textToHtml } from "./src/superhuman-api";
async function saveAndWatch() {
console.log("=== Watching Network During Save ===\n");
const conn = await connectToSuperhuman(9333, true);
if (!conn) {
console.error("Failed to connect");
return;
}
// Enable network monitoring
await conn.Network.enable();
const requests: any[] = [];
const responses: any[] = [];
// Capture network requests
conn.Network.requestWillBeSent((params) => {
if (params.request.url.includes('draft') || params.request.url.includes('gmail')) {
requests.push({
url: params.request.url,
method: params.request.method,
postData: params.request.postData?.substring(0, 500)
});
}
});
conn.Network.responseReceived((params) => {
if (params.response.url.includes('draft') || params.response.url.includes('gmail')) {
responses.push({
url: params.response.url,
status: params.response.status,
statusText: params.response.statusText
});
}
});
// Open compose and set content
console.log("1. Opening compose...");
const draftKey = await openCompose(conn);
console.log(` draftKey: ${draftKey}`);
console.log("2. Setting content...");
await addRecipient(conn, "networktest@test.com", undefined, draftKey!);
await setSubject(conn, "Network Test Subject", draftKey!);
await setBody(conn, textToHtml("Network test body"), draftKey!);
console.log("3. Saving draft...");
const saved = await saveDraft(conn, draftKey!);
console.log(` saveDraft returned: ${saved}`);
// Wait for network to complete
await new Promise(r => setTimeout(r, 3000));
console.log("\n4. Network requests related to drafts:");
console.log(JSON.stringify(requests, null, 2));
console.log("\n5. Network responses related to drafts:");
console.log(JSON.stringify(responses, null, 2));
await conn.Network.disable();
await disconnect(conn);
}
saveAndWatch().catch(console.error);