Fix edge function console statements

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 19:09:28 +00:00
parent 7663205512
commit c0f468451f
8 changed files with 92 additions and 64 deletions

View File

@@ -1,6 +1,6 @@
import { serve } from "https://deno.land/std@0.168.0/http/server.ts";
import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4";
import { startRequest, endRequest } from "../_shared/logger.ts";
import { edgeLogger, startRequest, endRequest } from "../_shared/logger.ts";
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
@@ -33,7 +33,8 @@ serve(async (req) => {
const payload: NotificationPayload = await req.json();
console.log('Processing report notification:', {
edgeLogger.info('Processing report notification', {
action: 'notify_moderators_report',
reportId: payload.reportId,
reportType: payload.reportType,
reportedEntityType: payload.reportedEntityType,
@@ -78,12 +79,12 @@ serve(async (req) => {
.maybeSingle();
if (templateError) {
console.error('Error fetching workflow:', templateError);
edgeLogger.error('Error fetching workflow', { action: 'notify_moderators_report', requestId: tracking.requestId, error: templateError });
throw new Error(`Failed to fetch workflow: ${templateError.message}`);
}
if (!template) {
console.warn('No active report-alert workflow found');
edgeLogger.warn('No active report-alert workflow found', { action: 'notify_moderators_report', requestId: tracking.requestId });
return new Response(
JSON.stringify({
success: false,
@@ -126,7 +127,7 @@ serve(async (req) => {
reportedEntityName = submission?.content?.name || 'Submission';
}
} catch (error) {
console.warn('Could not fetch entity name:', error);
edgeLogger.warn('Could not fetch entity name', { action: 'notify_moderators_report', requestId: tracking.requestId, error });
}
// Build enhanced notification payload
@@ -145,7 +146,7 @@ serve(async (req) => {
priority,
};
console.log('Triggering notification with payload:', notificationPayload);
edgeLogger.info('Triggering notification with payload', { action: 'notify_moderators_report', requestId: tracking.requestId });
// Invoke the trigger-notification function
const { data: result, error: notifyError } = await supabase.functions.invoke(
@@ -160,11 +161,11 @@ serve(async (req) => {
);
if (notifyError) {
console.error('Error triggering notification:', notifyError);
edgeLogger.error('Error triggering notification', { action: 'notify_moderators_report', requestId: tracking.requestId, error: notifyError });
throw notifyError;
}
console.log('Notification triggered successfully:', result);
edgeLogger.info('Notification triggered successfully', { action: 'notify_moderators_report', requestId: tracking.requestId, result });
endRequest(tracking, 200);
@@ -185,7 +186,7 @@ serve(async (req) => {
}
);
} catch (error: any) {
console.error('Error in notify-moderators-report:', error);
edgeLogger.error('Error in notify-moderators-report', { action: 'notify_moderators_report', requestId: tracking.requestId, error: error.message });
endRequest(tracking, 500, error.message);