Disabled console debug log Statements from the production build output

This commit is contained in:
Tola Leng
2025-07-15 17:36:12 +07:00
parent debf35703b
commit fd7035965f
7 changed files with 42 additions and 42 deletions
@@ -31,8 +31,8 @@ export async function pauseMonitoring(serviceId: string): Promise<void> {
// We'll skip the notification here since it will be handled by the UI component
// This prevents duplicate notifications for the paused status
console.log(`Service ${service.name} paused at ${now}, skipping notification to prevent duplication`);
// console.log(`Service ${service.name} paused at ${now}, skipping notification to prevent duplication`);
} catch (error) {
console.error("Error pausing monitoring:", error);
// console.error("Error pausing monitoring:", error);
}
}
@@ -16,7 +16,7 @@ export async function resumeMonitoring(serviceId: string): Promise<void> {
// Fetch the current service to get its name for better logging
const service = await pb.collection('services').getOne(serviceId);
console.log(`Resuming service ${service.name} at ${now}`);
// console.log(`Resuming service ${service.name} at ${now}`);
// First, clear any existing interval just to be safe
const existingInterval = monitoringIntervals.get(serviceId);
@@ -57,7 +57,7 @@ export async function resumeMonitoring(serviceId: string): Promise<void> {
const alertsMuted = service.alerts === "muted" || serviceForNotification.alerts === "muted";
if (!alertsMuted) {
console.log(`Alerts NOT muted for service ${service.name}, sending resume notification`);
// console.log(`Alerts NOT muted for service ${service.name}, sending resume notification`);
// Send notification that service has been resumed
await notificationService.sendNotification({
service: serviceForNotification,
@@ -65,7 +65,7 @@ export async function resumeMonitoring(serviceId: string): Promise<void> {
timestamp: now
});
} else {
console.log(`Alerts muted for service ${service.name}, skipping resume notification`);
// console.log(`Alerts muted for service ${service.name}, skipping resume notification`);
}
// IMPORTANT: Wait a brief moment to ensure the status update is processed
@@ -76,6 +76,6 @@ export async function resumeMonitoring(serviceId: string): Promise<void> {
console.log(`Service ${service.name} resumed and ready for monitoring`);
} catch (error) {
console.error("Error resuming service:", error);
// console.error("Error resuming service:", error);
}
}
+18 -18
View File
@@ -31,20 +31,20 @@ export const notificationService = {
try {
const { service, status, responseTime } = data;
console.log(`Preparing to send notification for service: ${service.name}, status: ${status}`);
console.log(`Service alerts status: ${service.alerts}`);
// console.log(`Preparing to send notification for service: ${service.name}, status: ${status}`);
// console.log(`Service alerts status: ${service.alerts}`);
// First check if alerts are muted for this service
// STRICT equality check against "muted" string value
if (service.alerts === "muted") {
console.log(`NOTIFICATION BLOCKED: Alerts are muted for service: ${service.name}`);
// console.log(`NOTIFICATION BLOCKED: Alerts are muted for service: ${service.name}`);
return true; // Return true as this is expected behavior
}
// For paused status, check if this is a duplicate notification from another source
// This helps prevent the double-notification issue
if (status === "paused" && data._notificationSource === "duplicate_check") {
console.log("NOTIFICATION BLOCKED: Duplicate pause notification detected");
// console.log("NOTIFICATION BLOCKED: Duplicate pause notification detected");
return true; // Return true as this is expected behavior
}
@@ -62,20 +62,20 @@ export const notificationService = {
if (timeSinceLastNotif < NOTIFICATION_COOLDOWN) {
// Increment count only if we haven't reached max retries
if (lastNotif.count < maxRetries) {
console.log(`DOWN notification for ${service.name}: ${lastNotif.count + 1}/${maxRetries}`);
// console.log(`DOWN notification for ${service.name}: ${lastNotif.count + 1}/${maxRetries}`);
lastNotifications[serviceId].count += 1;
} else {
console.log(`DOWN notification for ${service.name} skipped: Max retries (${maxRetries}) reached. Next notification after cooldown.`);
// console.log(`DOWN notification for ${service.name} skipped: Max retries (${maxRetries}) reached. Next notification after cooldown.`);
return true; // Skip notification but return success
}
} else {
// Reset count after cooldown period
console.log(`Cooldown period elapsed for ${service.name}. Resetting notification count.`);
// console.log(`Cooldown period elapsed for ${service.name}. Resetting notification count.`);
lastNotifications[serviceId] = { timestamp: now, count: 1 };
}
} else {
// First notification for this service
console.log(`First DOWN notification for ${service.name}: 1/${maxRetries}`);
// console.log(`First DOWN notification for ${service.name}: 1/${maxRetries}`);
lastNotifications[serviceId] = { timestamp: now, count: 1 };
}
@@ -85,7 +85,7 @@ export const notificationService = {
// Check if notification channel is set
if (!service.notificationChannel) {
console.log(`No notification channel set for service: ${service.name}`);
// console.log(`No notification channel set for service: ${service.name}`);
return false;
}
@@ -93,12 +93,12 @@ export const notificationService = {
const alertConfigRecord = await pb.collection('alert_configurations').getOne(service.notificationChannel);
if (!alertConfigRecord) {
console.error(`Alert configuration not found for ID: ${service.notificationChannel}`);
// console.error(`Alert configuration not found for ID: ${service.notificationChannel}`);
return false;
}
if (!alertConfigRecord.enabled) {
console.log(`Alert configuration is disabled for service: ${service.name}`);
// console.log(`Alert configuration is disabled for service: ${service.name}`);
return false;
}
@@ -127,7 +127,7 @@ export const notificationService = {
try {
template = await templateService.getTemplate(service.alertTemplate);
} catch (error) {
console.error(`Error fetching template for ID: ${service.alertTemplate}`, error);
// console.error(`Error fetching template for ID: ${service.alertTemplate}`, error);
}
}
@@ -146,7 +146,7 @@ export const notificationService = {
message += `\n\nAlert ${retryInfo.count}/${maxRetries}`;
}
console.log(`Prepared notification message: ${message}`);
// console.log(`Prepared notification message: ${message}`);
// Send notification based on notification type
const notificationType = alertConfig.notification_type;
@@ -156,10 +156,10 @@ export const notificationService = {
}
// For other types like discord, slack, etc. (not implemented yet)
console.log(`Notification type ${notificationType} not implemented yet`);
// console.log(`Notification type ${notificationType} not implemented yet`);
return false;
} catch (error) {
console.error("Error sending notification:", error);
// console.error("Error sending notification:", error);
return false;
}
},
@@ -173,10 +173,10 @@ export const notificationService = {
? `Service ${serviceName} is UP${responseTime ? ` (Response time: ${responseTime}ms)` : ''}`
: `Service ${serviceName} is DOWN`;
console.log(`Test notification would have been sent: ${message}`);
// console.log(`Test notification would have been sent: ${message}`);
return true; // Just log, don't actually send
} catch (error) {
console.error("Error in test notification:", error);
// console.error("Error in test notification:", error);
return false;
}
},
@@ -187,7 +187,7 @@ export const notificationService = {
*/
resetNotificationCount(serviceId: string): void {
if (lastNotifications[serviceId]) {
console.log(`Resetting notification count for service ${serviceId}`);
// console.log(`Resetting notification count for service ${serviceId}`);
delete lastNotifications[serviceId];
}
}