Add database persistence to 8 edge functions

Implement Phase 1 by adding error span logging and database persistence to 8 edge functions that already log errors:
- detect-location
- export-user-data
- notify-moderators-submission
- novu-webhook
- send-escalation-notification
- send-password-added-email
- resend-deletion-code
- merge-contact-tickets

This update introduces startSpan/endSpan and logSpanToDatabase usage in catch blocks to ensure errors are recorded in the monitoring database.
This commit is contained in:
gpt-engineer-app[bot]
2025-11-11 18:30:31 +00:00
parent 3797e34e0b
commit fa57d497af
8 changed files with 63 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
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 { corsHeaders } from '../_shared/cors.ts';
import { edgeLogger, startRequest, endRequest } from '../_shared/logger.ts';
import { edgeLogger, startRequest, endRequest, logSpanToDatabase, startSpan, endSpan } from '../_shared/logger.ts';
import { createErrorResponse, sanitizeError } from '../_shared/errorSanitizer.ts';
interface MergeTicketsRequest {
@@ -279,6 +279,11 @@ serve(async (req) => {
duration,
error: error instanceof Error ? error.message : 'Unknown error',
});
// Persist error to database for monitoring
const errorSpan = startSpan('merge-contact-tickets-error', 'SERVER');
endSpan(errorSpan, 'error', error);
logSpanToDatabase(errorSpan, tracking.requestId);
return createErrorResponse(error, 500, corsHeaders, 'merge_contact_tickets');
}