mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 09:31:13 -05:00
Fix Supabase RPC type error
This commit is contained in:
@@ -3931,6 +3931,23 @@ export type Database = {
|
||||
Args: Record<PropertyKey, never>
|
||||
Returns: undefined
|
||||
}
|
||||
log_request_metadata: {
|
||||
Args: {
|
||||
p_client_version?: string
|
||||
p_duration_ms?: number
|
||||
p_endpoint?: string
|
||||
p_error_message?: string
|
||||
p_error_type?: string
|
||||
p_method?: string
|
||||
p_parent_request_id?: string
|
||||
p_request_id: string
|
||||
p_status_code?: number
|
||||
p_trace_id?: string
|
||||
p_user_agent?: string
|
||||
p_user_id?: string
|
||||
}
|
||||
Returns: undefined
|
||||
}
|
||||
migrate_ride_technical_data: {
|
||||
Args: Record<PropertyKey, never>
|
||||
Returns: undefined
|
||||
|
||||
@@ -107,8 +107,8 @@ interface RequestMetadata {
|
||||
}
|
||||
|
||||
async function logRequestMetadata(metadata: RequestMetadata): Promise<void> {
|
||||
// Direct RPC call since types haven't regenerated yet
|
||||
const { error } = await supabase.rpc('log_request_metadata', {
|
||||
// Type assertion needed until Supabase types regenerate after migration
|
||||
const { error } = await supabase.rpc('log_request_metadata' as any, {
|
||||
p_request_id: metadata.requestId,
|
||||
p_user_id: metadata.userId || null,
|
||||
p_endpoint: metadata.endpoint,
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
-- Create RPC function for logging request metadata
|
||||
-- This allows us to insert into request_metadata before types regenerate
|
||||
|
||||
CREATE OR REPLACE FUNCTION log_request_metadata(
|
||||
p_request_id uuid,
|
||||
p_user_id uuid DEFAULT NULL,
|
||||
p_endpoint text DEFAULT NULL,
|
||||
p_method text DEFAULT NULL,
|
||||
p_status_code integer DEFAULT NULL,
|
||||
p_duration_ms integer DEFAULT NULL,
|
||||
p_error_type text DEFAULT NULL,
|
||||
p_error_message text DEFAULT NULL,
|
||||
p_user_agent text DEFAULT NULL,
|
||||
p_client_version text DEFAULT NULL,
|
||||
p_parent_request_id uuid DEFAULT NULL,
|
||||
p_trace_id uuid DEFAULT NULL
|
||||
)
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
SECURITY DEFINER
|
||||
SET search_path = public
|
||||
AS $$
|
||||
BEGIN
|
||||
INSERT INTO request_metadata (
|
||||
request_id,
|
||||
user_id,
|
||||
endpoint,
|
||||
method,
|
||||
status_code,
|
||||
duration_ms,
|
||||
error_type,
|
||||
error_message,
|
||||
user_agent,
|
||||
client_version,
|
||||
parent_request_id,
|
||||
trace_id
|
||||
) VALUES (
|
||||
p_request_id,
|
||||
p_user_id,
|
||||
p_endpoint,
|
||||
p_method,
|
||||
p_status_code,
|
||||
p_duration_ms,
|
||||
p_error_type,
|
||||
p_error_message,
|
||||
p_user_agent,
|
||||
p_client_version,
|
||||
p_parent_request_id,
|
||||
p_trace_id
|
||||
);
|
||||
END;
|
||||
$$;
|
||||
|
||||
COMMENT ON FUNCTION log_request_metadata IS 'Logs request metadata for monitoring and debugging';
|
||||
|
||||
-- Grant execute permission to authenticated users
|
||||
GRANT EXECUTE ON FUNCTION log_request_metadata TO authenticated;
|
||||
GRANT EXECUTE ON FUNCTION log_request_metadata TO anon;
|
||||
Reference in New Issue
Block a user