The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: studio functions logs fixes
Alaister Young22e41f088570
diff --git a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionInvocationSelectionRender.tsx b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionInvocationSelectionRender.tsxindex 087efa95153..3a18152dc3c 100644--- a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionInvocationSelectionRender.tsx+++ b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionInvocationSelectionRender.tsx@@ -1,15 +1,16 @@import dayjs from 'dayjs'+import { filterFunctionsRequestResponse } from 'lib/logs'import { LOGS_TAILWIND_CLASSES } from '../Logs.constants'import { jsonSyntaxHighlight, ResponseCodeFormatter } from '../LogsFormatters'const FunctionInvocationSelectionRender = ({ log }: any) => {- const functionId = log.metadataconst request = log?.requestconst response = log?.responseconst method = log?.methodconst status = log?.status_code- const requestUrl = request?.url- const host = request?.host+ const requestUrl = new URL(request?.url)+ const executionTimeMs = log?.execution_time_ms+ const timestamp = dayjs(log.timestamp / 1000)const DetailedRow = ({label,@@ -35,12 +36,11 @@ const FunctionInvocationSelectionRender = ({ log }: any) => {<div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding} space-y-2`}><DetailedRow label="Status" value={<ResponseCodeFormatter value={status} />} /><DetailedRow label="Method" value={method} />- <DetailedRow label="Timestamp" value={dayjs(log.timestamp).toISOString()} />+ <DetailedRow label="Timestamp" value={dayjs(timestamp).format('DD MMM, YYYY HH:mm')} />+ <DetailedRow label="Execution Time" value={`${executionTimeMs}ms`} /><DetailedRow label="Deployment ID" value={log.deployment_id} />- <DetailedRow label="Function ID" value={log.function_id} /><DetailedRow label="Log ID" value={log.id} />- <DetailedRow label="Request url" value={requestUrl} />- <DetailedRow label="Host" value={host} />+ <DetailedRow label="Request Path" value={requestUrl.pathname + requestUrl.search} /></div><div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding}`}><h3 className="text-lg text-scale-1200 mb-4">Request body</h3>@@ -48,7 +48,7 @@ const FunctionInvocationSelectionRender = ({ log }: any) => {<divclassName="text-wrap"dangerouslySetInnerHTML={{- __html: request ? jsonSyntaxHighlight(request) : '',+ __html: request ? jsonSyntaxHighlight(filterFunctionsRequestResponse(request)) : '',}}/></pre>@@ -60,7 +60,7 @@ const FunctionInvocationSelectionRender = ({ log }: any) => {<pre className="text-sm syntax-highlight overflow-x-auto"><divdangerouslySetInnerHTML={{- __html: response ? jsonSyntaxHighlight(response) : '',+ __html: response ? jsonSyntaxHighlight(filterFunctionsRequestResponse(response)) : '',}}/></pre>diff --git a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionLogsSelectionRender.tsx b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionLogsSelectionRender.tsxindex 325005b83f8..c4ed2901af8 100644--- a/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionLogsSelectionRender.tsx+++ b/studio/components/interfaces/Settings/Logs/LogSelectionRenderers/FunctionLogsSelectionRender.tsx@@ -1,9 +1,9 @@import dayjs from 'dayjs'import { LOGS_TAILWIND_CLASSES } from '../Logs.constants'-import { jsonSyntaxHighlight, ResponseCodeFormatter, SeverityFormatter } from '../LogsFormatters'+import { jsonSyntaxHighlight, SeverityFormatter } from '../LogsFormatters'const FunctionLogsSelectionRender = ({ log }: any) => {- const request = log?.request+ const timestamp = dayjs(log.timestamp / 1000)const DetailedRow = ({label,@@ -40,10 +40,9 @@ const FunctionLogsSelectionRender = ({ log }: any) => {<DetailedRow label="Severity" value={<SeverityFormatter value={log.metadata.level} />} /><DetailedRow label="Log ID" value={log.id} /><DetailedRow label="Deployment version" value={log?.metadata?.version} />- <DetailedRow label="Timestamp" value={dayjs(log.timestamp).toISOString()} />+ <DetailedRow label="Timestamp" value={timestamp.format('DD MMM, YYYY HH:mm')} /><DetailedRow label="Execution ID" value={log.metadata.execution_id} /><DetailedRow label="Deployment ID" value={log.metadata.deployment_id} />- <DetailedRow label="Function ID" value={log.metadata.function_id} /></div><div className={`${LOGS_TAILWIND_CLASSES.log_selection_x_padding}`}><h3 className="text-lg text-scale-1200 mb-4">Metadata</h3>diff --git a/studio/lib/logs.ts b/studio/lib/logs.tsnew file mode 100644index 00000000000..85621dea74f--- /dev/null+++ b/studio/lib/logs.ts@@ -0,0 +1,18 @@+export function filterFunctionsRequestResponse(re: any) {+ return Object.fromEntries(+ Object.entries(re)+ .filter(([key]) => !['host', 'url'].includes(key))+ .map(([key, value]) => {+ if (key === 'headers') {+ return [+ key,+ (value as any[]).map((headers) =>+ Object.fromEntries(Object.entries(headers).filter(([key]) => !key.startsWith('_')))+ ),+ ]+ }++ return [key, value]+ })+ )+}