querysub 0.677.0 → 0.678.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -20,6 +20,7 @@ import { createLink } from "../../../library-components/ATag";
|
|
|
20
20
|
import { showingManagementURL, managementPageURL } from "../../managementPages";
|
|
21
21
|
import { atomic } from "../../../2-proxy/PathValueProxyWatcher";
|
|
22
22
|
import { magenta } from "socket-function/src/formatting/logColors";
|
|
23
|
+
import { formatTime } from "socket-function/src/formatting/format";
|
|
23
24
|
import { TicketServiceBase } from "../errorTickets/tickets";
|
|
24
25
|
import { getArchives2 } from "../../../-a-archives/archives2";
|
|
25
26
|
|
|
@@ -48,6 +49,8 @@ let pendingDiscordNotifications = new Map<string, {
|
|
|
48
49
|
errorCount: number;
|
|
49
50
|
isNew: boolean;
|
|
50
51
|
}>();
|
|
52
|
+
// Time the currently pending batch started collecting, so the digest can state the window it covers instead of reading as "this is happening right now".
|
|
53
|
+
let pendingDiscordNotificationsStartTime = 0;
|
|
51
54
|
export async function getSuppressionEntries(): Promise<SuppressionEntry[]> {
|
|
52
55
|
return await suppression.values();
|
|
53
56
|
}
|
|
@@ -247,6 +250,9 @@ Respond with a JSON object with a "pattern" field containing the search string.`
|
|
|
247
250
|
}
|
|
248
251
|
|
|
249
252
|
function queueDiscordNotification(suppressionId: string, errorCount: number, isNew: boolean) {
|
|
253
|
+
if (pendingDiscordNotifications.size === 0) {
|
|
254
|
+
pendingDiscordNotificationsStartTime = Date.now();
|
|
255
|
+
}
|
|
250
256
|
const existing = pendingDiscordNotifications.get(suppressionId);
|
|
251
257
|
if (existing) {
|
|
252
258
|
existing.errorCount += errorCount;
|
|
@@ -307,8 +313,10 @@ const trySendDiscordNotificationsBase = batchFunction({ delay: 1000 * 3 }, async
|
|
|
307
313
|
{ param: showingManagementURL, value: true },
|
|
308
314
|
{ param: managementPageURL, value: "ErrorNotificationPage" },
|
|
309
315
|
]);
|
|
316
|
+
|
|
317
|
+
const digestWindow = Date.now() - (pendingDiscordNotificationsStartTime || Date.now());
|
|
310
318
|
const messageText = messageLines.join("\n");
|
|
311
|
-
const message = `[${messageText}](${link})`;
|
|
319
|
+
const message = `Digest for errors for ${formatTime(digestWindow)}:\n[${messageText}](${link})`;
|
|
312
320
|
|
|
313
321
|
try {
|
|
314
322
|
await sendDiscordMessage({ webhookURL, message });
|
|
@@ -326,6 +334,7 @@ const trySendDiscordNotificationsBase = batchFunction({ delay: 1000 * 3 }, async
|
|
|
326
334
|
}, EXISTING_SUPPRESSION_THROTTLE);
|
|
327
335
|
|
|
328
336
|
pendingDiscordNotifications.clear();
|
|
337
|
+
pendingDiscordNotificationsStartTime = 0;
|
|
329
338
|
} catch (error) {
|
|
330
339
|
console.error("Failed to send Discord notification:", error);
|
|
331
340
|
}
|