Включить диагностику ошибок браузера

This commit is contained in:
AidarKC
2026-11-16 12:13:42 +03:00
parent 102feccb2e
commit d9fdaf1930
14 changed files with 382 additions and 214 deletions
+17 -2
View File
@@ -89,6 +89,7 @@ export class WsJsonClient {
const error = new Error(t('remaining.websocket.this_page_uses_https_but_the_server_uses_ws_use_wss_for_th'));
captureClientError({
kind: 'ws_mixed_content_blocked',
skipTransport: true,
message: error.message,
context: { url: this.url, pageProtocol: window.location.protocol },
});
@@ -107,7 +108,8 @@ export class WsJsonClient {
ws.addEventListener('error', () => {
captureClientError({
kind: 'ws_open_error',
message: `Failed to connect WebSocket ${this.url}`,
skipTransport: true,
message: 'WebSocket connection failed',
context: { url: this.url },
});
reject(new Error(`Не удалось подключиться к ${this.url}`));
@@ -191,7 +193,7 @@ export class WsJsonClient {
captureClientError({
kind: 'ws_bad_json',
message: 'Received non-JSON message from server',
context: { raw: String(raw).slice(0, 1000) },
context: { code: 'invalid_json' },
});
return;
}
@@ -207,6 +209,18 @@ export class WsJsonClient {
const slot = this.pending.get(requestId);
if (!slot) return;
this.pending.delete(requestId);
// Обработанные 4xx — обычные отказы. Только неожиданные 5xx диагностируем.
const status = Number(data?.status);
if (slot.op !== 'ClientErrorLog' && Number.isInteger(status)
&& status >= 500 && status < 600 && status !== 507) {
captureClientError({
kind: 'api_server_error',
message: `Server returned HTTP-like status ${status} for ${slot.op}`,
requestOp: slot.op,
requestIdRef: requestId,
context: { status },
});
}
slot.resolve(data);
}
@@ -238,6 +252,7 @@ export class WsJsonClient {
if (pendingOps.length > 0) {
captureClientError({
kind: 'ws_closed',
skipTransport: true,
message,
context: { url: this.url, pendingOps },
});