Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: LogEventChart onClick handler not firing

TzeYiing6d948f7ed8d7
diff --git a/studio/components/interfaces/Settings/Logs/LogEventChart.tsx b/studio/components/interfaces/Settings/Logs/LogEventChart.tsx
index 18a856a5a1c..0f13cec73f5 100644
--- a/studio/components/interfaces/Settings/Logs/LogEventChart.tsx
+++ b/studio/components/interfaces/Settings/Logs/LogEventChart.tsx
@@ -1,4 +1,5 @@
import BarChart, { BarChartProps } from 'components/ui/Charts/BarChart'
+import { Datum } from 'components/ui/Charts/Charts.types'
import { EventChartData, isUnixMicro, LogData, unixMicroToIsoTimestamp } from '.'
export interface LogEventChartProps {
@@ -12,16 +13,11 @@ const LogEventChart = ({ data, onBarClick }: LogEventChartProps) => (
size="tiny"
yAxisKey="count"
xAxisKey="timestamp"
- data={data as unknown as BarChartProps['data']}
+ data={data}
title="Logs / Time"
- onBarClick={(v?: { activePayload?: { payload: any }[] }) => {
- if (!v || !v?.activePayload?.[0]?.payload) return
- const unixOrIsoTimestamp = v.activePayload[0].payload.timestamp
- const isoTimestamp = isUnixMicro(unixOrIsoTimestamp)
- ? unixMicroToIsoTimestamp(unixOrIsoTimestamp)
- : unixOrIsoTimestamp
- // 60s before
- onBarClick(isoTimestamp)
+ onBarClick={(datum: Datum | EventChartData) => {
+ if (!datum.timestamp) return
+ onBarClick(datum.timestamp as string)
}}
customDateFormat="MMM D, HH:mm:s"
/>
diff --git a/studio/components/interfaces/Settings/Logs/Logs.types.ts b/studio/components/interfaces/Settings/Logs/Logs.types.ts
index b31bb16bf08..955bc0364d0 100644
--- a/studio/components/interfaces/Settings/Logs/Logs.types.ts
+++ b/studio/components/interfaces/Settings/Logs/Logs.types.ts
@@ -1,3 +1,4 @@
+import { Datum } from 'components/ui/Charts/Charts.types'
import React from 'react'
interface Metadata {
@@ -49,9 +50,9 @@ export interface CountData {
count: number
}
-export interface EventChartData {
+export interface EventChartData extends Datum {
count: number
- timestamp: string | number
+ timestamp: string
}
type LFResponse<T> = {
diff --git a/studio/components/ui/Charts/Charts.types.tsx b/studio/components/ui/Charts/Charts.types.tsx
index bf0d1c0aa97..2890e58f444 100644
--- a/studio/components/ui/Charts/Charts.types.tsx
+++ b/studio/components/ui/Charts/Charts.types.tsx
@@ -28,7 +28,7 @@ export interface StackedChartProps<D> extends CommonChartProps<D> {
export type HeaderType<D> = {
attribute: string
focus: number | null
- format?: string | ((value: unknown) => string);
+ format?: string | ((value: unknown) => string)
highlightedValue?: number | string
highlightedLabel?: string
data: D[]
@@ -38,9 +38,7 @@ export type HeaderType<D> = {
displayDateInUtc?: boolean
}
-export interface Datum {
- [attribute: string]: number | string
-}
+export type Datum = Record<string, string | number>
export interface TimeseriesDatum extends Datum {
timestamp: string