mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 08:31:13 -05:00
Fix console statement violations
This commit is contained in:
@@ -564,7 +564,7 @@ export async function deleteSubmission(
|
||||
shouldRemoveFromQueue: true,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error deleting submission:', error);
|
||||
logger.error('Error deleting submission', { error, submissionId: item.id });
|
||||
return {
|
||||
success: false,
|
||||
message: 'Failed to delete submission',
|
||||
|
||||
@@ -7,6 +7,7 @@ import { supabase } from '@/integrations/supabase/client';
|
||||
import { requestContext, type RequestContext } from './requestContext';
|
||||
import { breadcrumbManager } from './errorBreadcrumbs';
|
||||
import { captureEnvironmentContext } from './environmentContext';
|
||||
import { logger } from './logger';
|
||||
|
||||
export interface RequestTrackingOptions {
|
||||
endpoint: string;
|
||||
@@ -54,7 +55,7 @@ export async function trackRequest<T>(
|
||||
parentRequestId: options.parentRequestId,
|
||||
traceId: context.traceId,
|
||||
}).catch(err => {
|
||||
console.error('[RequestTracking] Failed to log metadata:', err);
|
||||
logger.error('Failed to log request metadata', { error: err, context: 'RequestTracking' });
|
||||
});
|
||||
|
||||
// Cleanup context
|
||||
@@ -94,7 +95,7 @@ export async function trackRequest<T>(
|
||||
parentRequestId: options.parentRequestId,
|
||||
traceId: context.traceId,
|
||||
}).catch(err => {
|
||||
console.error('[RequestTracking] Failed to log error metadata:', err);
|
||||
logger.error('Failed to log error metadata', { error: err, context: 'RequestTracking' });
|
||||
});
|
||||
|
||||
// Cleanup context
|
||||
@@ -143,7 +144,7 @@ async function logRequestMetadata(metadata: RequestMetadata): Promise<void> {
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error('[RequestTracking] Failed to log metadata:', error);
|
||||
logger.error('Failed to log metadata to database', { error, context: 'RequestTracking' });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import DOMPurify from 'dompurify';
|
||||
import { logger } from './logger';
|
||||
|
||||
/**
|
||||
* Sanitize HTML content to prevent XSS attacks
|
||||
@@ -39,14 +40,14 @@ export function sanitizeURL(url: string): string {
|
||||
const allowedProtocols = ['http:', 'https:', 'mailto:'];
|
||||
|
||||
if (!allowedProtocols.includes(parsed.protocol)) {
|
||||
console.warn(`Blocked potentially dangerous URL protocol: ${parsed.protocol}`);
|
||||
logger.warn('Blocked potentially dangerous URL protocol', { protocol: parsed.protocol });
|
||||
return '#';
|
||||
}
|
||||
|
||||
return url;
|
||||
} catch {
|
||||
// Invalid URL format
|
||||
console.warn(`Invalid URL format: ${url}`);
|
||||
logger.warn('Invalid URL format', { url });
|
||||
return '#';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ export async function detectChanges(
|
||||
if (data?.name) entityName = `${data.name} (${formatEntityType(entityType)})`;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error fetching entity name for photo operation:', err);
|
||||
logger.error('Error fetching entity name for photo operation', { error: err, entityType: itemData.entity_type, entityId: itemData.entity_id });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ export async function detectChanges(
|
||||
entityName = `${formatEntityType(entityType)} - ${itemData.title}`;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error fetching entity name for milestone:', err);
|
||||
logger.error('Error fetching entity name for milestone', { error: err, entityType: itemData.entity_type, entityId: itemData.entity_id });
|
||||
// Fall back to just the title if database lookup fails
|
||||
if (itemData.title) {
|
||||
entityName = itemData.title;
|
||||
@@ -434,7 +434,7 @@ export async function detectChanges(
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Error resolving entity name for field display:', err);
|
||||
logger.error('Error resolving entity name for field display', { error: err, entityType: itemData.entity_type, entityId: itemData.entity_id });
|
||||
}
|
||||
|
||||
// Add entity name as an explicit field change at the beginning
|
||||
|
||||
@@ -338,9 +338,7 @@ async function createVersionForApprovedItem(
|
||||
// - app.current_user_id = original submitter
|
||||
// - app.submission_id = submission ID
|
||||
// Then the trigger creates the version automatically
|
||||
console.debug(
|
||||
`Version will be created automatically by trigger for ${itemType} ${entityId}`
|
||||
);
|
||||
logger.debug('Version will be created automatically by trigger', { itemType, entityId });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -613,7 +611,7 @@ async function createRide(data: any, dependencyMap: Map<string, string>, sortedI
|
||||
.eq('id', data.ride_id);
|
||||
|
||||
if (error) {
|
||||
console.error('Error updating ride:', error);
|
||||
logger.error('Error updating ride', { error: error.message, rideId: data.ride_id });
|
||||
throw new Error(`Database error: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -644,7 +642,7 @@ async function createRide(data: any, dependencyMap: Map<string, string>, sortedI
|
||||
.single();
|
||||
|
||||
if (error) {
|
||||
console.error('Error creating ride:', error);
|
||||
logger.error('Error creating ride', { error: error.message, rideName: resolvedData.name });
|
||||
throw new Error(`Database error: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -688,7 +686,7 @@ async function createCompany(
|
||||
.eq('id', data.id);
|
||||
|
||||
if (error) {
|
||||
console.error('Error updating company:', error);
|
||||
logger.error('Error updating company', { error: error.message, companyId: data.id });
|
||||
throw new Error(`Database error: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -723,7 +721,7 @@ async function createCompany(
|
||||
.single();
|
||||
|
||||
if (error) {
|
||||
console.error('Error creating company:', error);
|
||||
logger.error('Error creating company', { error: error.message, companyName: resolvedData.name, companyType });
|
||||
throw new Error(`Database error: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -762,7 +760,7 @@ async function createRideModel(data: any, dependencyMap: Map<string, string>, so
|
||||
.eq('id', data.ride_model_id);
|
||||
|
||||
if (error) {
|
||||
console.error('Error updating ride model:', error);
|
||||
logger.error('Error updating ride model', { error: error.message, rideModelId: data.ride_model_id });
|
||||
throw new Error(`Database error: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -799,7 +797,7 @@ async function createRideModel(data: any, dependencyMap: Map<string, string>, so
|
||||
.single();
|
||||
|
||||
if (error) {
|
||||
console.error('Error creating ride model:', error);
|
||||
logger.error('Error creating ride model', { error: error.message, modelName: resolvedData.name });
|
||||
throw new Error(`Database error: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -878,7 +876,7 @@ async function approvePhotos(data: any, dependencyMap: Map<string, string>, user
|
||||
.select();
|
||||
|
||||
if (error) {
|
||||
console.error('Error inserting photos:', error);
|
||||
logger.error('Error inserting photos', { error: error.message, photoCount: photosToInsert.length, entityType, entityId: finalEntityId });
|
||||
throw new Error(`Database error: ${error.message}`);
|
||||
}
|
||||
|
||||
@@ -960,7 +958,7 @@ async function updateEntityFeaturedImage(
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error updating ${entityType} featured image:`, error);
|
||||
logger.error('Error updating entity featured image', { error, entityType, entityId });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import type { ParkSubmissionData, RideSubmissionData, CompanySubmissionData, RideModelSubmissionData } from '@/types/submission-data';
|
||||
import { logger } from './logger';
|
||||
|
||||
// Preset configurations
|
||||
export const PRESETS = {
|
||||
@@ -254,12 +255,12 @@ export async function clearTestData(): Promise<{ deleted: number }> {
|
||||
.neq('id', '00000000-0000-0000-0000-000000000000'); // Delete all records
|
||||
|
||||
if (registryError) {
|
||||
console.error('Error clearing test data registry:', registryError);
|
||||
logger.error('Error clearing test data registry', { error: registryError });
|
||||
}
|
||||
|
||||
return { deleted: submissionCount };
|
||||
} catch (error: unknown) {
|
||||
console.error('Error clearing test data:', error instanceof Error ? error.message : String(error));
|
||||
logger.error('Error clearing test data', { error: error instanceof Error ? error.message : String(error) });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user