mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 09:51:13 -05:00
Fix edge function console statements
This commit is contained in:
@@ -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': '*',
|
||||
@@ -70,7 +70,8 @@ serve(async (req) => {
|
||||
throw new Error('Invalid severity level. Must be: info, warning, or critical');
|
||||
}
|
||||
|
||||
console.log('Processing system announcement:', {
|
||||
edgeLogger.info('Processing system announcement', {
|
||||
action: 'notify_system_announcement',
|
||||
title: payload.title,
|
||||
severity: payload.severity,
|
||||
publishedBy: profile?.username || 'unknown',
|
||||
@@ -86,12 +87,12 @@ serve(async (req) => {
|
||||
.maybeSingle();
|
||||
|
||||
if (templateError) {
|
||||
console.error('Error fetching workflow:', templateError);
|
||||
edgeLogger.error('Error fetching workflow', { action: 'notify_system_announcement', requestId: tracking.requestId, error: templateError });
|
||||
throw new Error(`Failed to fetch workflow: ${templateError.message}`);
|
||||
}
|
||||
|
||||
if (!template) {
|
||||
console.warn('No active system-announcement workflow found');
|
||||
edgeLogger.warn('No active system-announcement workflow found', { action: 'notify_system_announcement', requestId: tracking.requestId });
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
success: false,
|
||||
@@ -120,7 +121,7 @@ serve(async (req) => {
|
||||
publishedBy,
|
||||
};
|
||||
|
||||
console.log('Triggering announcement to all users via "users" topic');
|
||||
edgeLogger.info('Triggering announcement to all users via "users" topic', { action: 'notify_system_announcement', requestId: tracking.requestId });
|
||||
|
||||
// Invoke the trigger-notification function with users topic
|
||||
const { data: result, error: notifyError } = await supabase.functions.invoke(
|
||||
@@ -135,11 +136,11 @@ serve(async (req) => {
|
||||
);
|
||||
|
||||
if (notifyError) {
|
||||
console.error('Error triggering notification:', notifyError);
|
||||
edgeLogger.error('Error triggering notification', { action: 'notify_system_announcement', requestId: tracking.requestId, error: notifyError });
|
||||
throw notifyError;
|
||||
}
|
||||
|
||||
console.log('System announcement triggered successfully:', result);
|
||||
edgeLogger.info('System announcement triggered successfully', { action: 'notify_system_announcement', requestId: tracking.requestId, result });
|
||||
|
||||
endRequest(tracking, 200);
|
||||
|
||||
@@ -161,7 +162,7 @@ serve(async (req) => {
|
||||
}
|
||||
);
|
||||
} catch (error: any) {
|
||||
console.error('Error in notify-system-announcement:', error);
|
||||
edgeLogger.error('Error in notify-system-announcement', { action: 'notify_system_announcement', requestId: tracking.requestId, error: error.message });
|
||||
|
||||
endRequest(tracking, error.message.includes('Unauthorized') ? 403 : 500, error.message);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user