import { useParams } from 'common' import { Clock, ExternalLink, RefreshCw } from 'lucide-react' import Link from 'next/link' import { useRouter } from 'next/router' import { Button, cn } from 'ui' import { Admonition, TimestampInfo } from 'ui-patterns' import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader' import { parseEdgeFunctionEventMessage } from './EdgeFunctionRecentInvocations.utils' import { LOGS_TABLES } from '@/components/interfaces/Settings/Logs/Logs.constants' import useLogsPreview from '@/hooks/analytics/useLogsPreview' interface EdgeFunctionRecentInvocationsProps { functionId: string functionSlug: string } export const EdgeFunctionRecentInvocations = ({ functionId, functionSlug, }: EdgeFunctionRecentInvocationsProps) => { const { ref } = useParams() const router = useRouter() const { logData, isLoading, isSuccess, refresh } = useLogsPreview({ projectRef: ref as string, table: LOGS_TABLES.fn_edge, filterOverride: { function_id: functionId }, limit: 10, }) return (

Recent Invocations

Latest invocation requests for this function

{isLoading && !isSuccess ? ( ) : logData.length === 0 ? ( ) : (
{logData.map((log) => { const statusCode = String(log.status_code ?? '') const method = String(log.method ?? '') const executionTime = log.execution_time_ms const is2xx = statusCode.startsWith('2') const is4xx = statusCode.startsWith('4') const is5xx = statusCode.startsWith('5') const logUrl = `/project/${ref}/functions/${functionSlug}/invocations?log=${log.id}` return (
router.push(logUrl)} onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault() router.push(logUrl) } }} className="group flex items-center font-mono px-3 py-2 gap-3 bg-surface-100 cursor-pointer hover:bg-surface-200 transition-colors" >
{statusCode ? (
{statusCode}
) : ( - )}
{method || '-'} {executionTime !== undefined && ( {Number(executionTime).toFixed(0)}ms )} {parseEdgeFunctionEventMessage( String(log.event_message ?? ''), method, statusCode )}
) })} View all invocations
)}
) }