refactor(logging): remove agent logging from various components to streamline code and improve maintainability
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m49s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 1m49s
This commit is contained in:
@@ -197,9 +197,6 @@ function MainLayout() {
|
||||
}, [location.pathname, layout]);
|
||||
|
||||
useEffect(() => {
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'baseline',hypothesisId:'H5',location:'frontend/src/App.jsx:route-change',message:'Route changed in MainLayout',data:{pathname:String(location?.pathname||''),layout:String(layout||'')},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
}, [location.pathname, layout]);
|
||||
|
||||
// Состояние для управления выпадающими меню
|
||||
|
||||
@@ -152,9 +152,6 @@ export default function ResourceStatsPage() {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
const opts = { timeout: REQUEST_TIMEOUT_MS, noRetry: true, ...(abortSignal ? { signal: abortSignal } : {}) };
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'resource-stats-fix',hypothesisId:'H_RS_RETRY',location:'frontend/src/ResourceStatsPage.jsx:fetchStats',message:'Resource stats request started with noRetry',data:{timeoutMs:REQUEST_TIMEOUT_MS,noRetry:true,hasAbortSignal:Boolean(abortSignal)},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
try {
|
||||
const res = await api.get('/resources/stats', opts);
|
||||
const data = res?.data;
|
||||
|
||||
@@ -191,9 +191,6 @@ export default function UptimeMonitorPage() {
|
||||
ms = typeof checkData?.ms === 'number' ? checkData.ms : Date.now() - t0;
|
||||
} catch (e) {
|
||||
if (e?.code === 'ERR_CANCELED' || e?.name === 'CanceledError' || e?.name === 'AbortError') {
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'post-fix',hypothesisId:'H7',location:'frontend/src/UptimeMonitorPage.jsx:uptime-check-canceled',message:'Canceled uptime check request',data:{serverId:String(serverId||''),path:String(location?.pathname||'')},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
setCurrentCheckingServerIds((prev) => prev.filter((id) => id !== serverId));
|
||||
checkControllersRef.current.delete(controller);
|
||||
continue;
|
||||
@@ -246,9 +243,6 @@ export default function UptimeMonitorPage() {
|
||||
checkControllersRef.current.clear();
|
||||
setCurrentCheckingServerIds([]);
|
||||
setChecking(false);
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'post-fix',hypothesisId:'H7',location:'frontend/src/UptimeMonitorPage.jsx:leave-page',message:'Stopped uptime background checks on page leave',data:{pathname:String(location?.pathname||'')},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
}, [location.pathname]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -23,10 +23,7 @@ class ErrorBoundary extends Component {
|
||||
componentDidCatch(error, errorInfo) {
|
||||
// Логируем ошибку
|
||||
console.error('ErrorBoundary caught an error:', error, errorInfo);
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'baseline',hypothesisId:'H3',location:'frontend/src/components/ErrorBoundary.jsx:componentDidCatch',message:'React ErrorBoundary caught error',data:{message:String(error?.message||''),name:String(error?.name||''),componentStack:String(errorInfo?.componentStack||'').slice(0,500)},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
|
||||
|
||||
// Отправляем в мониторинг (если настроен)
|
||||
this.logErrorToService(error, errorInfo);
|
||||
|
||||
|
||||
@@ -63,10 +63,6 @@ export function PingProvider({ children }) {
|
||||
toRequest.push({ routerId, ip, key });
|
||||
});
|
||||
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'post-fix',hypothesisId:'H6',location:'frontend/src/contexts/PingContext.jsx:requestPings',message:'Ping batch scheduled',data:{scope,count:toRequest.length,force},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
|
||||
toRequest.forEach(({ routerId, ip, key }) => {
|
||||
const controller = new AbortController();
|
||||
controllersRef.current.set(key, controller);
|
||||
@@ -84,9 +80,6 @@ export function PingProvider({ children }) {
|
||||
})
|
||||
.catch((e) => {
|
||||
if (e?.code === 'ERR_CANCELED' || e?.name === 'CanceledError' || e?.name === 'AbortError') {
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'post-fix',hypothesisId:'H6',location:'frontend/src/contexts/PingContext.jsx:ping-canceled',message:'Ping request canceled',data:{routerId:String(routerId||''),gatewayIp:String(ip||''),scope:String(keyScopesRef.current.get(key)||'')},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
return;
|
||||
}
|
||||
console.warn('PingContext: failed to fetch ping for', routerId, ip, e?.message || e);
|
||||
@@ -111,9 +104,6 @@ export function PingProvider({ children }) {
|
||||
canceled += 1;
|
||||
}
|
||||
});
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'post-fix',hypothesisId:'H6',location:'frontend/src/contexts/PingContext.jsx:cancelScope',message:'Canceled ping scope',data:{scope:scopeName,canceled},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
}, []);
|
||||
|
||||
const value = {
|
||||
|
||||
@@ -39,9 +39,6 @@ function buildCacheKey(config) {
|
||||
// Улучшенный retry interceptor с поддержкой всех методов и типов ошибок
|
||||
api.interceptors.response.use(
|
||||
(response) => {
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'baseline',hypothesisId:'H1_H2',location:'frontend/src/lib/api.js:response',message:'API response received',data:{method:String(response?.config?.method||'get').toUpperCase(),url:String(response?.config?.url||''),status:Number(response?.status||0)},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
try {
|
||||
const method = String(response?.config?.method || 'get').toLowerCase();
|
||||
if (method === 'get') {
|
||||
@@ -66,9 +63,6 @@ api.interceptors.response.use(
|
||||
async (error) => {
|
||||
const isCanceled = error?.code === 'ERR_CANCELED' || error?.name === 'CanceledError' || error?.name === 'AbortError';
|
||||
if (isCanceled) {
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'post-fix',hypothesisId:'H1_H2',location:'frontend/src/lib/api.js:retry-skip-canceled',message:'Skip retry for canceled request',data:{method:String(error?.config?.method||'get').toUpperCase(),url:String(error?.config?.url||''),code:String(error?.code||'')},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
@@ -77,9 +71,6 @@ api.interceptors.response.use(
|
||||
const noRetry = config?.noRetry === true || config?.__noRetry === true;
|
||||
|
||||
if (noRetry) {
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'resource-stats-fix',hypothesisId:'H_RS_RETRY',location:'frontend/src/lib/api.js:retry-disabled-by-config',message:'Skip retry due to noRetry flag',data:{method:String(method),url:String(config?.url||''),code:String(error?.code||''),retryCount:Number(config?.__retryCount||0)},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
@@ -125,15 +116,8 @@ api.interceptors.response.use(
|
||||
(err) => {
|
||||
const isCanceled = err?.code === 'ERR_CANCELED' || err?.name === 'CanceledError' || err?.name === 'AbortError';
|
||||
if (isCanceled) {
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'post-fix',hypothesisId:'H1_H2',location:'frontend/src/lib/api.js:global-skip-canceled',message:'Skip global error handling for canceled request',data:{method:String(err?.config?.method||'get').toUpperCase(),url:String(err?.config?.url||''),code:String(err?.code||'')},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
return Promise.reject(err);
|
||||
}
|
||||
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'baseline',hypothesisId:'H1_H2',location:'frontend/src/lib/api.js:error',message:'API response error',data:{method:String(err?.config?.method||'get').toUpperCase(),url:String(err?.config?.url||''),status:Number(err?.response?.status||0),code:String(err?.response?.data?.code||err?.code||'')},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
try {
|
||||
// Не показываем уведомления если это повторная попытка
|
||||
const isRetrying = err?.config?.__retryCount > 0;
|
||||
@@ -165,9 +149,6 @@ api.interceptors.response.use(
|
||||
// Request интерсептор: If-Match из etag (если не задан явный заголовок)
|
||||
api.interceptors.request.use((config) => {
|
||||
try {
|
||||
// #region agent log
|
||||
fetch('http://192.168.10.2:7343/ingest/aa002dd6-6968-4a35-b09d-f05302d83266',{method:'POST',headers:{'Content-Type':'application/json','X-Debug-Session-Id':'378b5f'},body:JSON.stringify({sessionId:'378b5f',runId:'baseline',hypothesisId:'H1_H2',location:'frontend/src/lib/api.js:request',message:'API request started',data:{method:String(config?.method||'get').toUpperCase(),url:String(config?.url||'')},timestamp:Date.now()})}).catch(()=>{});
|
||||
// #endregion
|
||||
// If-None-Match для GET на базе кеша
|
||||
const method = String(config.method || 'get').toLowerCase();
|
||||
if (method === 'get') {
|
||||
|
||||
Reference in New Issue
Block a user