Commit Graph

33 Commits

Author SHA1 Message Date
Jordi Enric
5d9cf3971f fix(studio): improve memory and swap units in DB reports (#45889)
Fixes [DEBUG-94](https://linear.app/supabase/issue/DEBUG-94)

## Summary

- **Min MB units**: Added \`formatBytesMinMB\` helper that always
formats byte values in at least MB. Applied to RAM and swap y-axis tick
formatters, tooltips, and chart headers.
- **Swap chart scale**: Every Supabase compute instance is provisioned
with **1 GB of swap regardless of size** (per
[docs](https://supabase.com/docs/guides/troubleshooting/memory-and-swap-usage-explained-aPNgm0)),
so the swap y-axis always shows at least 0 to 1 GB. Low swap usage no
longer fills the full chart height. Removed the show/hide limit toggle
since the limit is implicit in the y-axis scale.
- **Swap units in header/tooltip**: Fixed all three formatters (initial
header, hover-sync header, tooltip) to use \`formatBytesMinMB\` for swap
so the value always shows a unit like "2.00 MB".
- **Reference-line defensive fix**: Added a \`customValue\` fallback in
\`useAttributeQueries\` so future reference-line attributes that use
\`customValue\` instead of \`value\` are not silently overwritten to 0.

## Test plan

- [ ] Open DB Reports and verify RAM/Swap y-axis labels show MB (or GB
for large values), never KB or bytes
- [ ] Hover a bar in the swap chart and verify tooltip and header show
the same value with a unit (e.g. "2.00 MB")
- [ ] With low or zero swap usage, the chart bars are flat and the
y-axis goes 0 to 1 GB
- [ ] CPU chart limit toggle still renders at 100% (regression check on
the \`useAttributeQueries\` fallback change)

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 13:12:25 +00:00
Jordi Enric
f38872c7a6 refactor(reports): use LazyComposedChartHandler for replication lag (#45748) 2026-05-11 15:36:55 +02:00
Jordi Enric
bef828ae48 feat(studio): apply timezone picker to observability/reports charts (#45667)
## Problem

The dashboard's timezone picker (#45517) propagates to log timestamps
and the shared TimestampInfo component, but observability and reports
charts still render their X-axis labels, range labels, and tooltip
headers in the browser's local timezone. The result is jarring once a
user picks a non-local timezone: hover a chart and you get one tz, hover
a log row and you get another.

## Fix

Routes all display-side timestamp formatting in the chart layer through
the existing picker-aware helpers (\`useFormatDateTime\` /
\`formatDateTime\`) so chart UI matches the rest of the dashboard.

- **ComposedChart.utils** \`CustomTooltip\` (the hotspot — drives every
observability dashboard tooltip): reads the active timezone via
\`useTimezone\` for both the header label and the formatted timestamp.
- **AreaChart** / **BarChart**: introduce a \`formatChartDate\` helper
that honours each component's existing \`displayDateInUtc\` prop,
otherwise routes through the picker.
- **ChartBlock**: the two recharts \`labelFormatter\` arrows now close
over \`useFormatDateTime\`.
- **ChartHighlightActions**: range labels in the zoom dropdown migrated
to the same hook.

Intentionally untouched (must stay UTC):
- \`ChartHandler\` / \`ChartBlock\` \`startDate\`/\`endDate\` (API range
params, day boundary).
- \`ChartBlock.tsx:166\` explicit \`.utc()\` data-key normalisation.
- \`useFillTimeseriesSorted\` and friends (range math, no display).

## How to test

- Sign in. Open the avatar dropdown, pick a timezone different from your
browser local (e.g. Asia/Tokyo).
- Visit any project, then \`/project/<ref>/reports/database\` (or any
\`/observability/...\` page).
- Hover any chart series — the tooltip header should display the chosen
IANA name and times in that timezone.
- Click-drag a range on a chart to open the zoom dropdown — start/end
labels in the menu should also be in the chosen timezone.
- Switch back to "Auto detect" and confirm everything reverts to
browser-local.
- For an AreaChart/BarChart that uses \`displayDateInUtc\` (e.g. some
legacy reports), confirm those still render in UTC regardless of picker.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Refactor**
* Standardized date/time formatting across charts, tooltips, axis
labels, header/footer labels, and highlight range labels in Reports and
chart components.
* Switched to a shared, timezone-aware formatter that respects UTC
display mode or the selected picker/timezone, ensuring consistent,
human-readable timestamps throughout the UI.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-07 19:31:59 +02:00
Ivan Vasilov
56de26fe22 chore: Migrate the monorepo to use Tailwind v4 (#45318)
This PR migrates the whole monorepo to use Tailwind v4:
- Removed `@tailwindcss/container-queries` plugin since it's included by
default in v4,
- Bump all instances of Tailwind to v4. Made minimal changes to the
shared config to remove non-supported features (`alpha` mentions),
- Migrate all apps to be compatible with v4 configs,
- Fix the `typography.css` import in 3 apps,
- Add missing rules which were included by default in v3,
- Run `pnpm dlx @tailwindcss/upgrade` on all apps, which renames a lot
of classes
- Rename all misnamed classes according to
https://tailwindcss.com/docs/upgrade-guide#renamed-utilities in all
apps.

---------

Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2026-04-30 10:53:24 +00:00
Ivan Vasilov
308cd791a2 chore: Prep work for migrating to Tailwind v4 (#45285)
This PR preps the monorepo for a migration to Tailwind v4:
- Bump all Tailwind dependencies and libraries to the latest possible
version, while still compatible with Tailwind 3.
- Cleans up obsolete Tailwind 3 specific options and configs.
- Cleans up unused CSS files and fixes the CSS imports.
- Migrates all `important` uses in `@apply` lines to using the `!`
prefix.
- Move `typography.css` to the `config` package and import it from the
apps.
- Migrated all occurrences of `flex-grow`, `flex-shrink`,
`overflow-clip` and `overflow-ellipsis` since they're deprecated and
will be removed in Tailwind 4.
- Make the default theme object typesafe in the `ui` package.
- Migrate all `bg-opacity`, `border-opacity`, `ring-opacity` and
`divider-opacity` to the new format where they're declared as part of
the property color.
- Bump and unify all imports of `postcss` dependency.
2026-04-28 11:33:53 +02:00
Joshen Lim
7f5865872a Enforce noUnusedLocals and noUnusedParameters in tsconfig.json + fix all related issues (#45264)
## Context

Enforce `noUnusedLocals` and `noUnusedParameters` in tsconfig.json + fix
all related issues
2026-04-27 17:42:34 +08:00
Charis
4a0bb36ca8 style: require sorted imports in studio/components (#44408)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2026-04-01 10:22:37 +02:00
Ali Waseem
8a26132bde fix(studio): resolve outstanding Sentry issues (#44106)
## Summary

Fixes several high-impact Sentry errors reported in production.

### Fixed Issues

- **[SUPABASE-APP-EJ3](https://supabase.sentry.io/issues/7356937474/)**
— `TypeError: Cannot read properties of undefined (reading 'direct')`.
`connectionStringPooler` could be `undefined` when the connection source
doesn't match any key in the connection strings map. Added an early
return guard in `resolveConnectionString`.

- **[SUPABASE-APP-B17](https://supabase.sentry.io/issues/7117468199/)**
— `RangeError: Invalid time zone specified: Etc/Unknown`.
`dayjs.tz.guess()` returns `"Etc/Unknown"` for some users with
misconfigured browser/OS timezones. Added a shared
`guessLocalTimezone()` helper that validates the guessed timezone via
`Intl.DateTimeFormat` and falls back to UTC. Applied across all 4 call
sites.

- **[SUPABASE-APP-BCM](https://supabase.sentry.io/issues/7192934901/)**
— `TypeError: Cannot convert undefined or null to object`.
`Object.entries(definition.properties)` crashed when a JSON schema
definition existed but had no `properties` field. Updated the guard to
check `definition?.properties` instead of just `definition`.
- https://supabase.sentry.io/issues/7357780302/?project=5459134
- https://supabase.sentry.io/issues/7358344652/?project=5459134
- https://supabase.sentry.io/issues/7096737077/?project=5459134

## Test plan

- [ ] Verify connect dialog renders without errors when connection data
is still loading
- [ ] Verify API docs Entity view handles schema definitions without
properties
- [ ] Verify charts/tooltips display correct timezone labels

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2026-03-23 21:20:47 +00:00
Jordi Enric
dc862370f6 feat: improve readability of CPU chart O11Y-1290 (#43822)
## Problem
The CPU usage chart in the Observability dashboard could show values
exceeding 100%, differing from the internal Grafana panel that support
uses for debugging.

## Solution
Add a stackedPercent prop to the chart system that locks the Y-axis to
[0, 100]. When enabled, the chart never visually overflows 100% while
tooltip values remain completely untouched. We fill the rest of the
unused with an "Idle" prop.

# Before
<img width="1240" height="684" alt="CleanShot 2026-03-18 at 16 04 26@2x"
src="https://github.com/user-attachments/assets/c1b1a5ac-86e0-4d6b-9bc4-c7837f30c28c"
/>

## After
<img width="1240" height="684" alt="CleanShot 2026-03-18 at 16 03 13@2x"
src="https://github.com/user-attachments/assets/419eea55-176d-46c4-8780-b8c372428047"
/>
<img width="934" height="700" alt="CleanShot 2026-03-18 at 16 03 41@2x"
src="https://github.com/user-attachments/assets/9b5ef61d-21f4-40e4-ab0c-1a11caadb1f8"
/>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 15:28:16 +01:00
Ivan Vasilov
9fa96977be chore: Minor prettier fixes (#43849)
This PR fixes some prettier issues:
- Bump and unify all prettier versions to 3.7.3 across teh whole repo
- Bump the SQL prettier plugin
- When running `test:prettier`, check `mdx` files also
- Run the new prettier format on all files

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-03-17 11:17:42 +01:00
Ignacio Dobronich
60a2a5e092 chore: observability dashboard entitlements (#43502)
## Changes
- Replaces plan ID-based chart gating with entitlement-based checks
across all observability pages (database, auth, realtime,
edge-functions)
- Adds requiredPlan display field so the upsell shows the correct target
plan (e.g. "Upgrade to Team" for disk throughput, not just "Upgrade")
- Decouples database-charts.ts from Organization Plan, now accepts
pre-computed entitlement flags instead

### Note on `requiredPlan`
The entitlement system currently tells us whether a user has access, but
not what plan they need to get access. `requiredPlan` is a frontend-only
display hint. Ideally the backend entitlement response would include a
minimumPlan field so we can remove this hardcoded mapping. For now, this
is a pragmatic workaround to avoid misleading upsell copy (e.g. a Free
user seeing "Upgrade" for a Team-only feature and landing on Pro).


## Testing 

### Database
- Head to `/project/_/observability/database` with an Org on the Free
Plan and assert that the Disk throughput is gated.

<img width="1402" height="682" alt="image"
src="https://github.com/user-attachments/assets/b783d866-774d-44dc-88d1-797d26502f02"
/>

### Auth
- Head to `/project/_/observability/auth` with an Org on the Free Plan
and assert that the following metrics are gated:

<img width="1402" height="682" alt="image"
src="https://github.com/user-attachments/assets/cb062dd7-5864-4e40-a11f-ad6be1f7fd41"
/>

### Edge Functions
- Head to `/project/_/observability/edge-functions` with an Org on the
Free Plan and assert that the following metrics are gated:

<img width="1402" height="320" alt="image"
src="https://github.com/user-attachments/assets/517b5483-4575-493c-9401-2c67ac9e684c"
/>


### Realtime
- Head to `/project/_/observability/realtime` with an Org on the Free
Plan and assert that the following metrics are gated:

<img width="1402" height="722" alt="image"
src="https://github.com/user-attachments/assets/0c2757a2-8482-43f4-a65c-c0dde3d878c7"
/>
2026-03-11 16:57:53 -03:00
Jordi Enric
eb85515acb minor percentage formatting fixes (#41923)
* support total percentage normalization and show idle time in cpu usage chart

* pretier

* improve test

* clarify in comment why new prop is necessary

* fix type error int est

* refactor to use max value instead of idle property, add more tests

* cleanup composed chart

* prettier

* fix tests

* react improvements

* remove unused stacking properties

* remove rest property references as it wont be used

* fix comment and max cpu desc

* test the resolvehighlightedvalue function

* undo unnecessary composedcharthandler change

* remove unnecessary comment

* minor db charts percentage formatting fixes

* move format check

* fix issue with conflict resolution
2026-01-27 13:07:39 +00:00
kemal.earth
6c6d74fa21 fix(studio): modify area chart colours (#41496)
* fix: modify area chart colours

* feat: tones for dark and light

* chore: cleaning up

* chore: remove weird ai added debug fetches

* fix: suggestion from coderabbit

* chore: clean up

* feat: change from natural to bump on line charts

* fix: much better colour offset

* chore: remove comments

* feat: better dot implementation

* chore: remove unused props

* chore: remove pointless try catch
2026-01-08 10:06:51 +00:00
Jordi Enric
434634f59f fix(reports): update disk metrics (#41108)
* update docs

* update composedchart to accept bytes per sec

* handle bytes per sec

* update charts
2025-12-09 18:08:32 +01:00
Joshen Lim
cac225b24a Clean up barrel files part 4 (#40015)
* Clean up barrel files part 4

* nit
2025-10-31 00:30:42 +08:00
Jordi Enric
c55266b425 feat: add tz in tooltip FE-1849 (#39596)
* add tz in tooltip

* clean
2025-10-16 17:16:42 +02:00
Jordi Enric
133271894c FE-1862 Report Chart: Always show tooltip values (#39160) 2025-10-01 14:17:20 +02:00
Jordi Enric
9a2140b291 chart footer tooltip improvs (#38858)
improvs
2025-09-23 13:56:03 +02:00
Jordi Enric
c75bb1b60d Auth Report tests and improvements (#38550)
* move to new ReportConfig

* separate types

* add auth report config

* add auth report transofmration test

* add fetchlogs util for reports

* rm auth-charts

* rm auth-report-query

* rm dupped code

* simplify upsell compo

* rm unnecessary hook

* use upsell in database report instead of old component

* rip ReportChart you wont be missed

* more tests

* rm unnecessary import

* Fix SQL in active users

* support hide inside report chart component

* add max bar size to avoid having big ass bars when theres little data

* fix incorrect timestamp key passed on to fillTimeseries

* add tooltip to auth report

* fix bug with timestamp key inside tooltips

* add report settings

* rm debugging check

* Update apps/studio/data/reports/v2/auth.config.ts

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* safely access result

* fix sign in latency query

* add toggleable attributes

* handle toggleable attributes

* pass on hideHighlightedValue

* fix signup latency

* pass hideHighlighted

* report chart pass on hide highlighted value

* cleanup finalChartData

* simplify tests, use timestamp for everything

* fix test

* rm dupped attribute

* add tooltip to auth errors

* Update apps/studio/data/reports/v2/auth.config.ts

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* Update apps/studio/components/ui/Charts/ComposedChart.tsx

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* prettify

---------

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
2025-09-17 17:41:10 +02:00
Jordi Enric
f65884f341 Reports consolidation 1: Edge Functions (#38129)
* wip

* add formatTimestamp for reports

* add tests for formatTimestamp

* fix type err

* rm old chart logic

* do not retry replication sources

* update report config schema

* use report config

* fix charts, simplify config

* sync charts

* rm comment

* usefilltimeseries

* move chart upsell to its own component

* cleanup v2 chart component

* fix chartheader function format bug

* make attributes dynamic

* move types to its own file

* update reportv2chart types

* update reportv2 chart type

* use new edgefn report

* rm mock

* rm old code

* fix type err

* fix type err

* rename hook

* return sql in dataprovider

* add button to open in log explorer in chart header

* fix type

* fix chart type toggle

* fix type error

* export data transformation for testing

* add tests for data transformation

* rm dupped code

* add report settings to edge fn report

* rm mocked data

* rename

* fix type err

* Apply suggestion from @joshenlim

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>

* rm unnecessary div

* rm unnecessary props from report upsell

* cleaner query keys

* move loadin/error/empty states to inside panel content to prevent layout shift

* use card instead of panel

* use buttontooltip in chartheader

* use buttontooltips in buttons with tooltips

* rm export default

* rm export defualt

* rm i from key

* fix status code transformation

* fix filltimeseries

* add tests for filltimeseries

* fix data transform

* pass xaxis key to chart

* refactor hover state to use timestamp not index

* fix tests

* fix areachart

* fix barchart

* fix chartheader

* fix composedchart

* fix stacked

* fix type missing xaxiskey

* type fix

* Revert "refactor hover state to use timestamp not index"

This reverts commit cfd7886460.

* undo charthover changes, fix data aggregation

* Revert "fix tests"

This reverts commit e5200a2035.

* move transforms to testable functions, add tests

* nit refactors and clean up

* feat: add aws nimbus cloud provider (#38312)

* feat: add aws nimbus cloud provider

* Fix return type of useCustomContent hook

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>

* add utc plugin to dayjs

* move plugins to vitest setup

* rm customparser plugin

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
2025-09-01 11:10:30 +02:00
Cemal Kılıç
09fc7776b5 feat: update auth sign in report query (#37240)
* feat: update auth sign in report query

* fix chart config

* fix type error for custom properties in chart attributes

---------

Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2025-07-17 15:45:44 +02:00
Jordi Enric
d8acd6752c fix timestamp missing (#37242)
fix
2025-07-17 12:33:33 +02:00
Francesco Sansalvadore
097ded6906 standardize db report (#37198)
* init standardization

* same charts

* clean up charts

* cleanup

* restore condition

* remove comment

* show availableIn placeholder
2025-07-16 12:29:01 +02:00
Jordi Enric
ae1d25d22b fix filltimeseries for reports (#37160)
* fix filltimeseries

* fix type err

* fix seconds in tooltip changing

* fix filter default values
2025-07-15 20:38:03 +02:00
Jordi Enric
804f270c3a reports pricing (#36992)
* add database pricing config

* pricing paywalls

* fix showing correct charts

* fix test

* remove disabled helpers in favor of upsell dialog

* fix missing fn to calc time

* rm clog

* show badge next to helpers

* ui fix

* fix type errs

* fix hallucinated import fml
2025-07-14 16:45:29 +02:00
Jordi Enric
302d15b5fd format data to ms in execution time - edge fn report (#36836)
* add formatter

* add format prop

* fix type err
2025-07-10 14:53:07 +02:00
Francesco Sansalvadore
c508348b07 fix db charts (#36803)
* fix db chart tooltip
* fix condition
* move Disk Size chart close to Db size panel
2025-07-08 08:22:46 +00:00
Jordi Enric
3b3a75202e feat: add auth reports FE-1569 (#36555)
* feat: add auth reports

* fix reports dates, fix missing queries

* add flag

* fix errorbystatus chart

* fix sign in by grant type

* move formatting to auth report query file

* fix signup by provider, add ratelimitted reqs

* fix sign ups query

* cleanup unused stuff

* cleanup

* rm console logs

* undo logs.utils

* add status code lib, use edge_logs for query

* fix auth error chart footer

* rm redundant rate limited requests chart

* fix db report breaking due to useAuthReport throwing

* move state up, reduce conditional logic in composed chart handler

* reorder reports nav

* rm bg

* fix type err

* fix useChartData

* empty

* fix report header bg

* move to utils

* add AnalyticsInterval import to report.utils for granularity conversion
2025-06-27 11:10:25 +02:00
Francesco Sansalvadore
265ca68786 update db report (#36328)
* release charts to Teams and Enterprise

* update db charts

* clean up chart types and add disk_fs_used_system

* show update data for Disk Size chart

* remove feature flag release

* update PostgREST connections tooltip

* show percentage in tooltip only if value is not percentage itself

* show percentage in tooltip only if value is not percentage itself

* insert disk_fs_used_system

* update db disk size chart

* reorder admin connection
2025-06-18 13:05:31 +02:00
Francesco Sansalvadore
01503ea083 Chore/db report legend (#35871)
* fix ram chart valuePrecision

* fix total aggregation
2025-05-23 12:50:10 +02:00
Francesco Sansalvadore
fda426b9ad Improvements to Reports > Database (#35477)
* improve legend items hover

* show yAxis label

* open range in logs explorer

* add provisioned disk size to Memory Usage chart

* temp new charts

* Network Traffic chart

* sync charts marker

* update api types

* fix layout

* add max memory

* add db size

* chore: remove unused properties

* disk_io_usage

* add max db and pooler connections

* chart header tooltip

* clean charts

* add cpu max

* refactor charts and change max color

* reference line on Database Size chart

* reference line text

* reference lines on Database Size chart

* fix aggregation

* legend spacing

* reference line

* add docsUrl
2025-05-23 10:32:33 +02:00
Joshen Lim
4a5e1a8bd4 Update query block bar hover behaviour (#35374)
* Update query block bar hover behaviour

* Smol fix
2025-04-30 17:47:47 +08:00
Francesco Sansalvadore
939e5c855a feat: reports infra o11y (#33310)
* test client connections charts

* add granularity to database dashboard

* add range selection

* add selection to area charts

* refactor ChartHeader

* fix default

* fix time preset selected label and add tooltip actions

* client connections stacked chart

* polish all new chartts

* change attribute

* fix

* add real queries

* memory stack

* cleanup

* precision 1

* update charts

* add endpoints

* tooltip

* format

* improve charts

* toggle max value

* show limit

* cleanup

* cleanup

* update api schema

* fix ram_usage_max_available

* remove pgbouncer and comments

* show total with percentage in chart header

* pretty

* hide

* update reports database

* remove client_connections

* revert

* fix connectionStrings error

* restore correct queries and conditions

* vertically zoom in to percentage data

* add feature flag logic on charts

* add feature flag logic to date picker

* chore: remove comment

* add tooltip to charts metrics

* chore: comment new pg endpoints

* feat: lazy load ComposedChartHandler queries

* feat: dim non-hovered chart values when hovering chart label item

* feat: improve dim styling

* chore: improve light mode stacked chart colors

* chore: remove 15s interval

* chore: sync types

* chore: remove type

* chore: restore type

* fix hook error

* show chart type toggle

* remove console log

* temp

* keep connections charts as before

* restore DateRangePicker

* show last aggregate value when not hovering

* clean up imports

* disk IOps read and write

* restore flag

* refactor queries

* clean up grafana promo banner

* Update database-charts.ts | updated language

* fix hook error

* fix hook error

* fix hook error

* attempt fix hook error

---------

Co-authored-by: TheOtherBrian1 <91111415+TheOtherBrian1@users.noreply.github.com>
2025-04-14 10:53:52 +02:00