Commit Graph

52 Commits

Author SHA1 Message Date
Joshen Lim 944c5862f3 Chore/small refactors (#47740)
## Context

Just extracting the fixes which I think are applicable from this
[PR](https://github.com/supabase/supabase/pull/47695)

Main files are
- `apps/studio/hooks/analytics/useLogsQuery.tsx`
- `packages/common/auth.tsx`
- `packages/common/feature-flags.tsx`

## Changes involved
- Adjust `useLogsQuery` to accept an object as prop, rather than 4
individual params
- This one doesn't address any Sentry issues, but is just a improvement
to the function's API imo, more readable
- Adjust how user email is retrieved in `feature-flags`
- Related Sentry issue
[here](https://supabase.sentry.io/issues/7592718607/?project=5459134)
- The error is a bit vague, but Claude's attempt to fix looks alright in
general IMO
  - Minimally verified that feature flags are loading as expected still

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

## Summary by CodeRabbit

* **Bug Fixes**
* Improved log-related screens and queries for more reliable loading and
filtering across the app.
* Fixed profile and account data handling so identity details are
retrieved more consistently.
* Improved authentication handling to better recognize missing user data
and keep the app stable.
* Updated feature flag personalization to use more accurate account
information.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-08 23:21:48 +08:00
Gildas Garcia c6fc456910 chore: cleanup duplicate exports studio (#47387)
## Problem

Knip reports many duplicate exports (both named and default). Besides,
we're moving away from default exports and even have an eslint rule to
enforce it on new code.

## Solution

- Cleanup those exports
- Update imports when necessary

No functional changes. If it builds, it's fine
2026-06-29 15:46:16 +02:00
Jordi Enric 2aa1b52234 feat(studio): add feature to rewrite queries DEBUG-145 (#47266)
## Problem

Moving the Logs Explorer to ClickHouse means users' saved BigQuery
queries no longer run.
<img width="2430" height="1010" alt="CleanShot 2026-06-29 at 11 36
04@2x"
src="https://github.com/user-attachments/assets/ae0ab155-7d3d-4ae9-81c3-22bf3a88cf8c"
/>

## Fix

Rewrite the query with AI instead of a SQL transpiler. AI handles the
long tail of nested fields and dialect differences far better than a
rule-based rewriter, and it needs no extra runtime dependency.

- `rewriteLogsSqlWithAI` posts the current query to
`/api/ai/code/complete` with `dialect: 'clickhouse'`. The endpoint skips
the Postgres schema and best-practices for that dialect and uses
logs-specific instructions and model so the output is ClickHouse logs
SQL (FROM `logs` + `source` filter, no `unnest` joins, nested fields
read from `log_attributes['...']`).
- The query's `source` is detected and its real `log_attributes` keys
are fetched and passed to the model, so it maps to exact paths instead
of guessing.
- The rewrite runs in the background and is proposed as a side-by-side
accept/discard diff in the editor. The AI Assistant panel is not opened.
- Entry points: a banner shown only for legacy-looking queries
(dismissal persisted), and a "Fix Query" button next to Field Reference.
- The Field Reference drawers discover `log_attributes` keys from real
data so the listed fields match what the source actually emits.

## Dependencies

Built on top of #47265 (Logs Explorer -> OTEL endpoint) — that is the
base branch of this PR. Merge #47265 first. Behind `otelLegacyLogs` (off
by default).

Part of DEBUG-145 (split from #47087).

## How to test

- Open the Logs Explorer with a BigQuery logs query (the templates have
some), click "Fix Query", and confirm the diff shows valid ClickHouse
SQL. Accept it and confirm the applied query runs.

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

* **New Features**
* Added an OTEL legacy logs workflow (behind a feature flag) with an
interactive banner and a “Fix Query” ClickHouse rewrite action,
including an accept/discard diff review overlay.
* Introduced OTEL-aware field reference rendering with dynamic discovery
of `log_attributes` keys and updated OTEL source insertion behavior.
* Enabled dialect-aware SQL completion for ClickHouse logs, using
logs-specific instructions and output constraints.
* **Bug Fixes**
* Improved rewrite flow validation and handling, including log source
detection and cleanup of AI-generated SQL formatting.
* **Tests**
* Added Vitest coverage for rewrite prompt generation,
detection/classification utilities, SQL fence stripping, OTEL field
mapping, and OTEL log attribute key discovery.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-06-29 14:31:18 +02:00
Jordi Enric e0ba04caf4 feat(studio): migrate per-service log pages to OTEL endpoint behind a flag DEBUG-145 (#47264)
## Problem

The legacy per-service log pages (postgres, auth, api, edge functions,
storage, realtime, cron, etc.) and the single-log detail panel query the
BigQuery-backed `logs.all` analytics endpoint. We are moving these reads
onto the OTEL ClickHouse endpoint (`logs.all.otel`).

## Fix

- Add `Logs.utils.otel.ts`: ClickHouse query builders
(rows/count/chart/single) + row mappers that target the single `logs`
table keyed by `source`, reading fields from the `log_attributes` map
and aliasing columns to the leaf names the renderers expect.
- Parameterize `buildWhereClauses` / `genWhereStatement` in
`Logs.utils.ts` so the OTEL builders reuse the shared nested AND/OR
filter grouping. Defaults keep the BigQuery behavior unchanged.
- Gate `useLogsPreview` (rows, count, chart) and `useSingleLog` (detail)
on the new `otelLegacyLogs` flag. BigQuery stays the default when the
flag is off.
- Extract the OTEL timestamp parser into `parseOtelTimestamp`
(`otel-inspection.utils.ts`) and reuse it in
`unified-logs-infinite-query.ts` (replaces an inline copy of the same
logic; no behavior change).

## Dependencies

None. Standalone, safe to merge on its own. Behind `otelLegacyLogs` (off
by default), so no user-facing change.

Part of DEBUG-145 (split from #47087).

## How to test

- In staging, go to Legacy Logs. 
- All logs pages should work the same as before. 

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

* **New Features**
* Added OTEL-backed logs support for preview, count, chart, and
single-log details when enabled.
* **Bug Fixes**
* Improved timestamp parsing/normalization for OTEL data to ensure
correct display and pagination.
* Enhanced filtering behavior, including safer handling of unknown
filter keys and invalid values across OTEL queries.
* Improved single-log result shaping to preserve expected API/database
metadata in OTEL mode.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 13:31:22 +02:00
Ivan Vasilov 92e79e67d9 feat: Add error state to charts (#46991)
This PR adds an error state to the usage charts on the Project home
page.

<img width="1708" height="471" alt="Screenshot 2026-06-16 at 18 10 20"
src="https://github.com/user-attachments/assets/cba87dad-5e23-4cd1-b787-0ea699445d7f"
/>

I also added an error state to the charts in the [design
system](https://design-system-git-feat-chart-error-state-supabase.vercel.app/design-system/docs/ui-patterns/charts#chart-states).


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

## Summary by CodeRabbit

* **New Features**
* Charts now display error states when data retrieval or processing
fails, providing users with clear feedback about issues.
* Improved error visibility and handling across analytics and charting
components for better transparency.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-06-16 16:18:17 +00:00
Joshen Lim 1baaded0bb Consolidate execute-sql-query into execute-sql-mutation (#46944)
## Context

Just some clean up as I was going through stuff
- `useExecuteSqlQuery` is deprecated and not used at all
- As such `execute-sql-query` is technically irrelevant, the more
relevant file is `execute-sql-mutation`
- Hence opting to consolidate `execute-sql-query` into
`execute-sql-mutation`
- Also removing `ExecuteSqlError` since its just re-exporting the
`ResponseError` type

There's a lot of file changes but its essentially just updating the
importing statements across the files
2026-06-16 00:07:16 +08:00
Jordi Enric 2c915ca9fb fix(observability): align overview Connections count with details view DEBUG-75 (#46271) 2026-06-09 16:23:26 +02:00
Etienne Stalmans fa55a9c4bd chore: use ro connstring for observability (#44806)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

function change

## What is the current behavior?

defaults to the read-write connection string when doing observability
report queries

## What is the new behavior?

uses the read-only connection string instead

## Additional context

these should only ever be read-only operations, reporting should not
have side effects and this adds a guardrail to ensure that remains the
case


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

## Summary by CodeRabbit

**Bug Fixes**
- Corrected database replica query handling by using read-only
connection strings for replica database access.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-06-02 17:03:22 +02:00
Charis fd1f437eca feat(logs): brand remaining analytics SQL callers with SafeLogSqlFragment (#46476)
## Summary

PR 10 of the analytics SQL safety series. Migrates the last surface of
analytics queries that flowed through plain
`get(.../analytics/endpoints/logs.all, { query: { sql } })` or the
`fetchLogs(projectRef, sql: string, ...)` helper over to
`executeAnalyticsSql` with branded `SafeLogSqlFragment` inputs.

After this PR, every analytics SQL call site builds its query through
the safe-analytics-sql helpers and hits the wire through the single
`executeAnalyticsSql` boundary. User-controlled values (filter
operators, numeric thresholds, function IDs, regions, provider names)
all flow through `analyticsLiteral` / branded operator maps; static
fragments are wrapped in `safeSql`. PR 11 (ESLint / vitest rule
forbidding direct analytics-endpoint POST/GET outside
`executeAnalyticsSql`) is the next and final step.

## Changes

- **`hooks/analytics/useProjectUsageStats.tsx`** — route the
already-branded `genChartQuery` output through `executeAnalyticsSql`
(parallels `useLogsPreview`).
- **`data/reports/report.utils.ts`** — tighten `fetchLogs(sql)` from
`string` to `SafeLogSqlFragment`; the wire boundary is now the same
single `executeAnalyticsSql` wrapper used by the rest of the analytics
path. Adds two pre-branded fragment maps reused by the report configs:
- `SAFE_GRANULARITY_SQL` — closed set returned by
`analyticsIntervalToGranularity`.
- `SAFE_COMPARISON_OPERATOR_SQL` — closed set on
`NumericFilter.operator`.
- **`components/interfaces/Auth/Overview/OverviewErrors.constants.ts`**
— wrap the two static `AUTH_TOP_*_SQL` fragments in `safeSql` (no
interpolation, but the type now flows).
- **`data/reports/v2/edge-functions.config.ts`** — `filterToWhereClause`
and every entry in `METRIC_SQL` now return `SafeLogSqlFragment`.
User-controlled values (`status_code.value`, `execution_time.value`,
function IDs, regions) pass through `analyticsLiteral`; operators look
up the branded map; the granularity uses the branded map. The
wire-format strings are unchanged, so the existing
`edge-functions.test.tsx` exact-string expectations still hold.
- **`data/reports/v2/auth.config.ts`** — same shape applied to all ten
`AUTH_REPORT_SQL` entries. The legacy `whereClause.replace(/^WHERE\s+/,
'')` pattern is replaced by two helpers that emit `AND`-prefixed
predicate fragments directly (`authFiltersToAndPredicates`,
`edgeLogsFiltersToAndPredicates`). Static provider SELECT / GROUP BY
fragments are pre-branded.

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

## Summary by CodeRabbit

* **Refactor**
* Enhanced security for analytics and reporting queries by updating
query construction methods across auth, edge functions, and project
usage reports.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46476?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-29 09:26:06 -04:00
Charis a7d51cdf52 feat(logs): brand legacy analytics SQL stack with SafeLogSqlFragment (#46351)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Refactor / type safety improvement

## What is the current behavior?

The legacy log query stack (`genDefaultQuery`, `genCountQuery`,
`genChartQuery`, `genWhereStatement`, `useLogsPreview`, `useSingleLog`)
builds SQL from raw strings with no type-level guarantee that values are
safely interpolated. Identifier helpers (`bqIdent`, `bqDottedIdent`,
`clickhouseIdent`, `clickhouseDottedIdent`) are duplicated across
BigQuery and ClickHouse variants, and `bqDottedIdent` wraps the entire
dotted path in one backtick pair (`` `request.pathname` ``), which
BigQuery treats as a literal column name rather than a UNNEST alias
field — causing runtime query failures on dotted filter keys.

## What is the new behavior?

- All gen functions return `SafeLogSqlFragment` and all callers route
through `executeAnalyticsSql`, enforcing compile-time SQL provenance
tracking across the legacy stack.
- `bqIdent` / `bqDottedIdent` / `clickhouseIdent` /
`clickhouseDottedIdent` are replaced by a single `quotedIdent` function
that backtick-quotes each segment individually (e.g. ``
`request`.`pathname` ``). ClickHouse natively accepts backticks, so one
function serves both engines and the dotted-path quoting bug is fixed.
- `SQL_FILTER_TEMPLATES` entries are converted to `SafeLogSqlFragment`
(static via `safeSql`, dynamic via `safeSql` + `analyticsLiteral`).
- `buildWhereClauses` is extracted as a private helper returning
`SafeLogSqlFragment[]` so the pg_cron path can merge clauses without
unsafe slice-and-cast.

## Additional context

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

* **Refactor**
* Logs query generation migrated to safer, engine-agnostic SQL
fragments, typed filter templates, and unified identifier quoting for
stronger injection protection and more consistent queries.
* Logs preview and single-log retrieval now execute analytics SQL
end-to-end using the unified executor.

* **New Features**
* Analytics SQL executor can call the backend via GET or POST and
accepts method selection.

* **Tests**
* Updated tests to validate unified identifier quoting and safe-SQL
helper behavior.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46351?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-26 15:20:54 -04:00
Joshen Lim dc211a972c Fix count query for unified logs (#46093)
## Context

The query to retrieve counts in unified logs have been error-ing out
with this
`sql parser error: Expected: end of statement, found: UNION at Line: 71,
Column: 2`

This PR fixes that - can verify visually as the status filters are now
populated correctly
<img width="365" height="148" alt="image"
src="https://github.com/user-attachments/assets/9397cca1-0519-4fe1-9397-c37d399c4b44"
/>



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

* **Refactor**
* Improved status-based log filtering so single-value and multi-value
filters return more accurate results across all log sources.
* Made facet count calculations (method, status, pathname) more robust
for consistent counts.

* **Bug Fixes**
* Standardized log endpoint resolution so log retrieval behaves
consistently when telemetry mode changes.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46093?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-19 20:53:30 +07:00
Charis 2d4e87f579 studio: SafeSql for reports, query performance, privileges (4/7) (#45998)
## Summary

Part 4 of the SafeSql migration stack
([#45897](https://github.com/supabase/supabase/pull/45897),
[#45903](https://github.com/supabase/supabase/pull/45903),
[#45990](https://github.com/supabase/supabase/pull/45990), this PR, …).

Converts the remaining reports, query performance, observability, index
advisor, and privileges call sites of `executeSql` to produce
`SafeSqlFragment` values. The `ReportQuery.sql` field flips from
`string` to `SafeSqlFragment`, which cascades into every consumer —
landed here atomically so each branch typechecks cleanly.

Touched areas:

- `interfaces/Reports/*` — `ReportQuery.sql: SafeSqlFragment`, plus all
report definitions/utilities updated
- `interfaces/QueryPerformance/useQueryPerformanceQuery.ts`
- `interfaces/Database/IndexAdvisor/*` and
`data/database/{table-index-advisor,retrieve-index-advisor-result}-query.ts`
-
`data/privileges/{table-api-access,update-exposed-entities}-mutation.ts`
- `interfaces/Storage/StoragePolicies/StoragePolicies.tsx`
- `hooks/analytics/useDbQuery.tsx`
- `Observability/useSlowQueriesCount.ts` +
`useQueryInsightsIssues.utils.test.ts`

## Test plan

- [x] `pnpm typecheck` passes
- [x] `useQueryInsightsIssues.utils.test.ts` passes
- [x] Dev-server smoke test: reports pages, query performance, index
advisor, storage policies

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

* **Refactor**
* Reworked SQL construction and typings across reporting, query
performance, index advisor, and privilege features to use safer SQL
fragments, improving reliability and preventing query composition
issues.
* **Types**
* Reporting query types were split to distinguish database vs. logs
queries, enabling correct handling and validation.
* **Docs/Utils**
  * Added a helper to consistently generate logs SQL for report hooks.
* **Tests**
  * Updated tests to exercise the new SQL-building API.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45998)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-05-15 14:50:38 -04:00
Jordi Enric 19e0b36650 feat(logs): migrate unified logs queries to OTEL endpoint DEBUG-71 (#45642) 2026-05-14 08:56:32 +02:00
Jordi Enric dfd3eec8e9 feat(studio): compute metrics on project diagram Primary Database card (#45274)
## Problem

The Primary Database card in the project homepage diagram showed region
and instance size, but no live health data. Users had no quick way to
spot a high-disk or high-CPU situation without navigating to the
database report.

## Fix

Added a clickable metrics row at the bottom of the Primary Database card
showing CPU, Disk, and RAM as percentages, plus active/max connections
when available. Each metric is color-coded (warning at 80%, destructive
at 90%). Clicking the row navigates to the database observability
report.

The metrics are powered by a new \`useComputeMetrics\` hook that wraps
the existing \`useInfraMonitoringAttributesQuery\` and
\`useMaxConnectionsQuery\`, reusing the parse utilities already used by
the database infrastructure section. The \`metricColor\` threshold logic
is extracted into a separate util with unit tests.

## How to test

- Open the project homepage for a running project
- The Primary Database card should show a new bottom row: "CPU X% · Disk
X% · RAM X% · Y/Z conns"
- Values above 80% should appear in amber, above 90% in red
- Click the metrics row and confirm it navigates to
\`/project/<ref>/observability/database\`
- While metrics are loading, a spinner should appear in the row
- If the infra monitoring API is unavailable, the row should show
"Metrics unavailable" instead of zeroes

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

## Summary by CodeRabbit

## Release Notes

* **New Features**
* Infrastructure configuration page now displays real-time compute
metrics (CPU, disk, memory usage) with color-coded usage indicators
based on thresholds.
  * Connection information is displayed when available.
  * Includes loading states and error handling for metric retrieval.

* **Tests**
  * Added test coverage for metric color-coding logic.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-27 14:15:11 +02:00
Charis 180ce515f6 style: require @ imports and sort imports for studio/hooks (#44444)
* **Chores**
* Updated internal module import paths across hook files to use
standardized path aliases for improved code consistency and
maintainability.
2026-04-01 11:48:02 -04:00
Jordi Enric db0a2ab752 refactor useFillTimeSeriesSorted hook (#42255)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Safer error rendering across analytics and reporting with a fallback
"Unknown error".

* **Tests**
* Added unit tests covering timeseries sorting and timestamp validation.

* **Refactor**
* Standardized timeseries hook and all callers to accept a single
options object and improved nullish handling.

* **New Features**
* Exposed timeseries utilities and explicit options/result types;
exported chart data type.

* **Chores**
  * Relaxed index signatures to allow dynamic metric keys.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-01-29 21:05:09 +01:00
Joshen Lim 27188c147c Support creating multiple publishable keys, and deleting publishable keys (#41186)
* Support creating multiple publishable keys, and deleting publishable keys

* FIx types

* Smol

* Smol fix

* Address issues

* Update comment

* Replace all usage of useApiKeysVisiblity for checking permissions to just call useAsyncCheckPermissions directly

* Clean up and deprecate useApiKeysVisibility hook

* ADdress
2025-12-12 16:07:36 +08:00
Ivan Vasilov 0d5be306ef chore: Bump React Query to v5 (#40174)
* Bump the deps, refactor deprecated code.

* Migrate keepPreviousData usage.

* Migrate all uses of InfiniteQuery.

* Fix refetchInterval in queries.

* Migrate all use of isLoading to isPending in mutations.

* Fix accessing location in claim-project.

* Fix a bug in duplicate query keys.

* Migrate all queries to use isPending.

* Revert "Fix accessing location in claim-project."

This reverts commit 2a07df64b5.

* Revert the rss.xml file to master.
2025-12-10 10:10:29 +01:00
Ivan Vasilov da4a40e308 chore: Migrate RQ functions to use object syntax style (#39895)
* Migrate all uses of invalidateQueries to use object syntax.

* Migrate the remainder of useInfiniteQuery.

* Migrate all setQueriesData.

* Migrate all fetchQuery uses.

* Migrate some leftover functions from RQ.

* Fix issues found by Charis.
2025-10-28 10:43:14 +01:00
Alaister Young 8855d05803 chore(studio): swap react-query to object syntax (#39842)
* chore(studio): swap react-query to object syntax

* Fix small issues found

* Fix realtime settings

* Nit

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-10-27 09:38:27 +01:00
Joshen Lim 57256efaaa Add flag for logs explorer showing metadata (#39171)
* Add flag for logs explorer showing metadata

* Simplify

* Flip

* Check logs metadata in useSingleLog

* Update unified logs

* remove comment

* Shortcircuit earlier on logsMetadata boolean

---------

Co-authored-by: Matt Linkous <matthew.linkous@gmail.com>
Co-authored-by: Alaister Young <a@alaisteryoung.com>
2025-10-01 18:53:54 +00:00
Alaister Young 5f533247e1 Update docs url to env var (#38772)
* Update Supabase docs URLs to use env variable

Co-authored-by: a <a@alaisteryoung.com>

* Refactor: Use DOCS_URL constant for documentation links

This change centralizes documentation links using a new DOCS_URL constant, improving maintainability and consistency.

Co-authored-by: a <a@alaisteryoung.com>

* Refactor: Use DOCS_URL constant for all documentation links

This change replaces hardcoded documentation URLs with a centralized constant, improving maintainability and consistency.

Co-authored-by: a <a@alaisteryoung.com>

* replace more instances

* ci: Autofix updates from GitHub workflow

* remaining instances

* fix duplicate useRouter

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: alaister <10985857+alaister@users.noreply.github.com>
2025-09-26 10:16:33 +00:00
Saxon Fletcher 3bea8f5bf0 Home New: Project Usage (#38339)
* new home top

* advisors

* add project usage section

* fix ts

* postgres

* add advisor section

* Nit

* Nit

* Attempt to fix ui library build issue

* Revert changes to Row/index.tsx

* Fix icon positioning

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-09-12 09:34:28 +10:00
Joshen Lim cab0585533 Fe 1799/consolidate to useselectedprojectquery and (#37684)
* Replace all usage of useProjectContext with useSelectedProjectQuery

* Replace all usage of useSelectedProject with useSelectedProjectQuery

* Replace all usage of useProjectByRef with useProjectByRefQuery

* Replace all usage of useSelectedOrganization with useSelectedOrganizationQuery

* Deprecate useSelectedProject, useSelectedOrganization, and useProjectByRef hooks

* Deprecate ProjecContext
2025-08-06 10:53:10 +07:00
Jordi Enric e4837267f6 Warehouse Clean Up (#37507) 2025-07-28 17:14:57 +02:00
Joshen Lim a7ea24c6b9 fix logs project param (#36633) 2025-06-24 11:23:58 +00:00
Joshen Lim ea9cfe1b39 Remove project parameter for all calls to logs.all endpoint (#36627) 2025-06-24 15:10:14 +08:00
Jordi Enric cd573086b1 Log Explorer improvements (#36140)
* make create button go directly to log explorer if warehouse is disabled

* fix limit clause in uppercase not caught by warnings

* make warning tooltip improve spacing

* fix date not updated on log explorer
2025-06-04 18:36:26 +02:00
Jonathan Summers-Muir 2815dac7e0 Feat/index suggestions inline (#35107)
* init

* hovercard

* adds button to install index advisor

* hover card now now insert indexes

* update

* moved hook

* align alert dialog to design syste,

* Update index-advisor.utils.ts

* shows all index statements now

* Update query-performance.tsx

* Some refactors

* Clean up

* Fix

* One last nit refactor

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-05-07 19:09:58 +08:00
Jordi Enric 8a340ae610 FE-1338: New UI for LogsDatePickers (FE-1512) (#33164)
* add more date range options to log previewer

* new ui for logs datepickers

* update logsquerypanel

* update previewfilterpanel

* fix some bugs and add copypasting date range support

* handle updating times in copypaste events

* add handlepaste to timesplitinput

* update warehouse datepicker

* update reports datepicker

* rm consolelog

* update logsquerypanel

* update tests

* fix reportsfilterbar

* update api-overview report

* rm consolelogs

* update storage report

* add large range wraning

* update large range max const

* fix default values and label

* fix tests

* add default value to logs previewer

* disable helpers fix

* rm last 7 days helper

* add test for disabled helpers

* add label test

* add helper label test

* reset state when closing without saving

* undo rm

* fm datefns, fix test class

* fix year format

* rm disabled from label

* fix type err in test

* fix test

* fix tests

* max 2 days for warning

* fix refresh not using latest timestamp end

* refactor log explorer to use new logs datepicker state hook

* Remove round to hour/day in helpers

* Use now instead of end of day for datepicker TO

* fix types

* update global timeout for e2e tests

* update test with new default

* fix test

* analytics container taking too long to return data so adding more timeout

* force ci

* fix first render issues

* Smol refactor

* Do not reset timestamp end when refreshing in LogsPreviewer

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-04-18 14:28:47 +08:00
Jordi Enric e687a4792c fix crashes in useLogsPreview (#34228)
* fix crashes

* fix crash
2025-03-17 12:50:11 +01:00
Jordi Enric 64bfd6dc72 remove consolelog (#33738)
rm clog
2025-02-20 11:12:39 +00:00
Jordi Enric ee7f7e4b42 Update Log Detail (#33536)
* state refactor & new log detail

* fix type in tests

* use new hook in auth page logs
2025-02-19 16:44:44 +01:00
Alexandre Villeneuve b122914b12 chore: convert logs.all endpoints to new fetchers (#33097)
* fix(logs): fix logs api request

* chore: convert logs.all endpoints to new fetchers

---------

Co-authored-by: Alaister Young <a@alaisteryoung.com>
2025-02-04 12:14:01 +01:00
Jordi Enric d9fbf14a81 Fix chart click (#32834)
fix chart click
2025-01-21 17:24:42 +01:00
Ivan Vasilov 492c81c9c8 feat: Cron tab for previous runs (#30690)
* Redo cron ui to use a data table

* Add component for form header

* Add next run column

* add cron jobs page

* Load jobs from url, add runs footer, link to logs

* Type issue

* Fix height of tab area

* Use nuqs with history

* improve pgcron logs, add severity filters

* Check for v1.5 to see if seconds are supported

* fix cron jobs logs table name

* Add type to the table

* Move expression warning to own function

* Fit to new layout

* Types

* Fix long code blocks

* Revert some of the changes.

* Use job name as a tab name. Other minor fixes.

* Use Infinite query for the cron runs.

* Revert some extra changes. Will be added to another PR.

* Rename pg functions

---------

Co-authored-by: Terry Sutton <saltcod@gmail.com>
Co-authored-by: Jordi Enric <jordi.err@gmail.com>
2024-11-27 21:46:03 +01:00
Jordi Enric 52657f7eb6 fix log filters (#30102) 2024-10-25 12:45:34 -02:30
Jordi Enric b6647d445c store selected logs to url (#29802)
* add selected logs to url

* Add mocks for nuqs package.

* fix layout issues n remove magic numbers for height

* fix chart height issue

* fix bug where logs not in first page wouldnt load correctly

* fix spacing between charts and header

* fix postgtres_logs issues, improve size in log detail

* fix borders

* fix default renderer

* fix detail width

* rm maxheight references

* fix tests

* fix typeerrs

* fix stories typerr

* improve colelctions empty state

* move state UP for logs and warehouse tables

* cleanup

* rm params

* rm params

* rm params

* fix log explorer selection

* fix tests types

* cleanup divs

* fix selected log delay

* use isEq for comparison in rows

* fix selection stuck open

* fix btnlink combo

---------

Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2024-10-25 12:40:14 +02:00
Joshen Lim 17bd786cb4 Chore/user management v2 part 3b (#29656)
* Init log panel

* Set up auth logs panel for user management

* small fix

* Add comment

* Small adjustment to padding

* Remove unused key

* Remove unused imports

* Fix disabled buttons if 0 logs

* Update apps/studio/components/interfaces/Auth/Users/Users.utils.tsx

Co-authored-by: Alaister Young <alaister@users.noreply.github.com>

* Address feedback

---------

Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
2024-10-03 14:19:43 +08:00
Jordi Enric 6b66d68df1 prevent use of WITH, ILIKE or wildcards (*) in logs explorer (#29282)
* prevent with

* fix layout, add with clause err

* fix log explorer err message issues and test

* fix type error

* add check for ilike adn tests

* add wildcard check

* rm consolelog
2024-09-17 17:37:42 +02:00
Joshen Lim 91c63be9c9 Surface error from fillTimeseries to the UI (#28086)
* Surface error from fillTimeseries to the UI

* rm consolelog

---------

Co-authored-by: Jordi Enric <37541088+jordienr@users.noreply.github.com>
2024-07-20 00:47:23 +08:00
Jordi Enric 003cfd6425 feat: warehouse explorer (#27611)
* add basic feature

* rename to datasource

* rename elements in left sidebar

* update copy in titles in left sidebar

* Add optional 'enabled' parameter in useLogsQuery hook

* Update warehouse query state and components

* add template selector for warehouse query builder

* update deprecated input compo

* fix create token and console warnings

* fix type errors

* fix dupped import

* update endpoints and add missing permissions

* update queries with new api path

* fix type errors

* undo last commit

* undo missing file

* fix imports in logs page

* import fixes

* add settings link like in storage menu

* sort imports, fix form submit

* rename access tokens settings section

* align dropdwn

* add overflow to templates dropdown

* add name as defaultvalue to udpate form

* update rm collection dialog

* capitalize

* Update apps/studio/pages/project/[ref]/logs/explorer/index.tsx

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

* fix typo

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-07-11 12:05:44 +02:00
Alaister Young 70da0f1d1d chore: cleanup packages (#27770)
* chore: cleanup packages

- Avoid circular imports
- Export API-types as types
- pg-format without depending on Node internal Buffer (not browser-compatible)
- Avoid importing from barrel files in ui dir

* chore: avoid barrel file imports in studio (#27771)

* chore: avoid barrel file imports

- Removes some unused imports
- Avoids barrel file import for faster builds + less memory

* add eslint rule

* type fixes

* delete layouts barrel

* delete components/grid barrel file

* delete components/grid/utils barrel file

* delete components/grid/components/common barrel file

* delete components/grid/components/editor barrel file

* delete components/grid/components/formatter barrel file

* delete components/grid/components/grid barrel file

* delete components/grid/components/header/filter barrel file

* remote components/grid/store barrel file

* remove components/interfaces/Auth/Policies barrel file

* delete components/interfaces/Settings/Logs barrel file

* delete components/ui/CodeEditor barrel file

* delete components/ui/Forms barrel file

* delete components/ui/Shimmers barrel file

* delete data/analytics barrel file

* delete hooks barrel file

* cleanup lib/common/fetch barrel file

* final * barral files cleanup

* global react-data-grid styles

* remove console.log

---------

Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>

* fix build

---------

Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
2024-07-04 14:48:10 +08:00
Jordi Enric 9fd85e76fb feature: warehouse (#23714)
* add event collection ui, queries, routing

* fix alignment issue

* renaming

* wip

* feat: initial data hooks and integration with feature flagging

* update with naming, correct mocks, etc

* feat: add source crud integration

* mock data, fix form, add motion to drawer

* feat: optimize warehouse fetch behaviour

* feat: add in valid query

* chore: ermove collection mocks

* feat: optimize tenant fetching

* cleanup + update openapi client + fix fetch calls

* cleanup imporst

* on delete success, redirect to main logs page

* fix dropdown event propagating to link and opening page

* Refactor code to use useParams and useRouter in CreateWarehouseCollection.tsx, WarehouseCollectionDetail.tsx, and LogsLayout.tsx

* clean warehouse query

* warehouse access tokens create, list

* add warehouse access token revokal

* fix access tokens table, fix access tokens revoke feature

* format date in access tokens table

* fix some state issues and warnings in access tokens forms

* warehouse/feat: introduction when creating event collections (#23244)

feat: add introduction for event collections

* warehouse/feat: rename headers and nav items (#23243)

* feat: rename headers

* feat: use feature flag for navigation bar

* move header name flag to component

* fix typeerror in create collection query

---------

Co-authored-by: Jordi Enric <jordi.err@gmail.com>

* ui fixes, rm deprecated icons

* render table with events

* fix typeerror results arr

* add pagination

* some ui fixes

* fix loading states, format dates, test connection dialog

* patch type errors

* Fix access token selection in TestCollectionDialog and update column name in WarehouseAccessTokens

* rm unused querytype

* rm unused querytype in logtable

* patch type errors in warhouse collection mutations

* rm unused component

* mr unused import

* show connection dialog in staging

* fix Run btn now showing up

* fix undef argument

* show pagination only when there are results

* fix issues in connection dialog, improve ux

* Update apps/studio/components/interfaces/DataWarehouse/CreateWarehouseAccessToken.tsx

Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>

* Update apps/studio/components/interfaces/DataWarehouse/CreateWarehouseAccessToken.tsx

Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>

* fix infinite render loop, adapt component to render log metadata on log selection

* rm unused import, prevent ui from breaking when some data may be missing from an event

* update WAT create mutation to use template

* follow mutation template in delete access token mutation

* refactor naming, improve code in some areas

* rm unused mocks for msw

* skip tests - this will get fixed on the vitest PR

* Update apps/studio/components/interfaces/Settings/Logs/LogsQueryPanel.tsx

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

* fix loading compo

* rm unused import

* use correct alert title

* rm unnecessary div

* fix layout in projectpaused alert

* fix type err, refactor to new method

* rm observer

* rm observer

* refactor warehouse collections update

* use correct get method, comment out so it doesnt err

* use correct method

* fix formatting issues

* ref imports

* ref imports

* clean up imports

* clean imports

* clean imports

* rename props

* destructure props

* cleanup imports

* Update apps/studio/components/interfaces/DataWarehouse/CreateWarehouseCollection.tsx

Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>

* ref scale class

* cleanup divs

* Update apps/studio/components/interfaces/DataWarehouse/TestCollectionDialog.tsx

Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>

* refactor to rhf

* reuse types, cleanup, refactor to react query hooks instead of el events

* refactor table component to handle empty state

* Update TestCollectionDialog to use unique keys for SelectItem components

* Update TestCollectionDialog to use unique keys for SelectItem components

* Update TestCollectionDialog to use unique keys for SelectItem components

* fix empty state ui

* use destructured queries

* rename query types

* Update apps/studio/components/interfaces/DataWarehouse/WarehouseAccessTokens.tsx

Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>

* chore: Refactor WarehouseCollectionDetail component

* rm unused imports

* rename loadolder

* rm typcast

* rhf in create token

* improve err handling

* refactor to rhf, refactor queries, use cn utils, cleanup

* fix loading logselection

* add correct type to warehouse access tokens query

* use correct types in err & clean unused types

* toggle token in curl exampel

* use product empty state component in warehouse

* add client side validation of collection name, temp fix

* add New badge

* update testcolldialog

* cleanup unnecessary div and rm double border

* code style fixes

* handle err

* code style fix

* add correct type

* add correct err type

* fix type error

* fix type err

* fix missing type

---------

Co-authored-by: TzeYiing <ty@tzeyiing.com>
Co-authored-by: Ziinc <Ziinc@users.noreply.github.com>
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-05-29 10:32:46 +02:00
Joshen Lim cd4b7c0497 Remove all usage of read replicas enabled flag (#26819)
* Remove all usage of read replicas enabled flag

* Add fix for fly

* Fixes

* Prettier

* Swap to DropdownMenuRadioGroup
2024-05-29 11:46:15 +08:00
Joshen Lim 3f07934905 Support checking API reports by replicas (#26238)
* Support checking API reports by replicas

* Fix API report for replica and add error handling

* Fix tests

* Add load balancer as an option for API reports
2024-05-14 14:13:33 +08:00
Joshen Lim 1afaae6447 Chore/reports read replicas filter (#23711)
* Scaffold for API reports

* Add support for filtering database reports by replicas

* midway adding read replica support for custom reports

* Refactor reports page to use react query and deprecate project content mobxstore

* Reports add chart labels if metric is read replica specific

* Give an easier way to remove charts from reports

* make reports layout non-blocking

* Update apps/studio/components/interfaces/Reports/Reports.tsx

Co-authored-by: Alaister Young <alaister@users.noreply.github.com>

---------

Co-authored-by: Alaister Young <a@alaisteryoung.com>
Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
2024-05-07 16:44:23 +08:00
Joshen Lim 755d75e55d Chore/add replica filter for query performance (#23409)
* Add replica filter for query performance

* Small fix

* Add ref in dep array

* Hide database selector if read replicas is not enabled for project
2024-05-03 16:24:49 +08:00
Joshen Lim ec59752bc0 Query Performance Facelift (#22568)
* Update

* Clean up + fix UI

* Add data values to tab

* Add comment

* Format sql query in query details

* Clean uo

* Deprecate old files

* Address comments

* chore: update styles (#22591)

* Add feature flag, reinstate old UI for feature flag

* Update apps/studio/components/interfaces/QueryPerformanceV2/QueryPerformance.tsx

Co-authored-by: Alaister Young <alaister@users.noreply.github.com>

* Update apps/studio/components/interfaces/QueryPerformance/QueryPerformance.tsx

Co-authored-by: Alaister Young <alaister@users.noreply.github.com>

* Address feedback

---------

Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>
Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
2024-04-11 12:57:46 +08:00
Kevin Grüneberg f9a55935f5 chore: use type imports for types/interfaces (#21738) 2024-03-04 20:48:22 +08:00