12 Commits
Author SHA1 Message Date
Drew McLellan f8cd1ee63e feat(studio): track docs button clicks (#54119)
## Problem

We don't track clicks on the shared `DocsButton`, so we can't tell which
pages send people to the docs most or where the UI needs more
explanation. Closes FE-5020.

## Solution

Add a `docs_button_clicked` event, fired once per click from the click
handler in the shared `DocsButton`. One call covers every page that
renders it.

- Properties: optional `topic` (a fixed label passed by the caller,
omitted when unset). `pathname` is already attached to every event by
`useTrack`.
- Groups are `Partial<TelemetryGroups>` because the button renders on
project, organization, and account pages.
- Click still stops propagation, as before.

## Review instructions

1. Run `pnpm dev:studio` and open a page with a docs button (e.g. a
project's Auth or Database page).
2. Click it and check the `docs_button_clicked` event is sent once, with
`topic` when the button has one.
3. Run `pnpm --filter studio exec vitest run
components/ui/DocsButton.test.tsx`.

Still to do after merge: verify the event in PostHog on staging.
2026-11-26 16:28:37 +00:00
Drew McLellan 433d95afd0 feat(studio): track usage on the API keys pages (#54070)
## Problem

Nothing is tracked on the API keys pages (new and legacy), so we can't
tell which keys people copy, how often they create or delete keys, or
how quickly projects disable legacy keys. Closes FE-5030.

## Solution

Adds five events, defined in `packages/common/telemetry-constants.ts`
and fired through `useTrack()`:

| Event | When | Properties |
| --- | --- | --- |
| `api_key_copied` | User copies a publishable, secret, or legacy
anon/service_role key with its Copy button. Keyboard copies aren't
counted. Not fired when blocked by permissions or when the copy fails. |
`keyType` |
| `api_key_reveal_clicked` | User reveals a secret or legacy
service_role key (not on hide) | `keyType` |
| `api_key_created` | Key created from the dialog, or by the first-time
setup (fires once per key) | `keyType`, `source` |
| `api_key_removed` | Key deleted after confirming in the modal |
`keyType` |
| `legacy_api_keys_updated` | Legacy keys disabled or re-enabled |
`enabled` |

- Create, delete, and legacy toggle fire in the mutation hook's
`onSuccess`, so failed attempts aren't counted and the event still fires
if the component unmounts mid-request. They're attributed to the
mutation's own project. Copy and reveal fire in the click handler.
- Delete is tracked in `SecretAPIKeys` / `PublishableAPIKeys`, where the
confirm modal and mutation live, not in the dropdown item.
- No key names or values in properties.
- `data-attr` added to the copy, reveal, create, delete, and docs
controls (static strings; Studio's PostHog autocapture is currently off,
so these send nothing today). `DocsButton` gets an optional `data-attr`
prop.
- `ui-patterns` `Input` gets optional `onReveal` and `onCopied`
callbacks. `onCopied` fires only for the Copy button, so legacy and new
keys count copies the same way.
- The empty-state sample keys are `inert`, so their buttons don't copy
or track.
- New `getLegacyApiKeyType` helper maps the legacy `anon` /
`service_role` tags to the event's `keyType`.

Tests cover copy, reveal, the no-event-on-hide and denied-grant cases,
the legacy toggle, and the key-type helper. Success paths for the create
dialogs and delete aren't covered.

## How to test

- [ ] Open `/project/[ref]/settings/api-keys`, copy a publishable and a
secret key, reveal a secret key, and check `api_key_copied` and
`api_key_reveal_clicked` in PostHog (staging) with the expected
`keyType`
- [ ] Create and delete a publishable and a secret key and check
`api_key_created` / `api_key_removed`
- [ ] On the legacy page, copy anon and service_role, reveal
service_role, then disable and re-enable the keys and check
`legacy_api_keys_updated`
2026-11-26 11:24:05 +00:00
Joshen Lim cea3232469 Joshenlim/fe 5166 refactor pagelayout for auth api pages (#53716)
## Context

Just some housekeeping to move off old layout components - this PR
targets Auth and Settings pages, specifically
- Auth -> Emails
- Auth -> Providers
- Settings -> API Keys
- Settings -> JWT Keys
- Settings -> Log Drains
- Settings -> Read Replica/id

The only visual change is just that navigation tabs take the full width
of the viewport now

Just need to make sure that these pages still render fine
2026-11-23 10:58:53 +07:00
kemal.earth 38ae9fea1c feat(studio): add admonition for api keys settings view (#52250)
## Problem

API Keys Settings view needs updating.

## Solution

Added admonition with update and link to docs.
2026-11-02 16:26:42 +00:00
1966209483 chore(deps): upgrade vitest to v5 (#49994)
Upgrades Vitest from 4.1.4 to 5.0.0 across the monorepo, fixes the
handful of things v5 turned into hard errors, and drops the
`vi.clearAllMocks()` boilerplate that v5's `clearMocks` default makes
redundant.

**Changed:**
- `vitest`, `@vitest/ui`, `@vitest/coverage-v8` 4.1.4 → 5.0.0 (catalog)
- `vi.mock` calls that lived inside `beforeAll`/`beforeEach`/test bodies
moved to module scope (v5 throws on nested calls). Affects the Studio
and docs setup files and four Studio tests.
- `detectBrowser` test restores `navigator` via `vi.unstubAllGlobals()`
instead of assigning `global.navigator`, which now reaches jsdom's
getter-only property.
- `RowEditor.utils.test.ts` restores its `JSON.stringify` spy. It used
to leak a throwing mock for the rest of the file, which v5's coverage
provider now trips over. A later test in the same file had been
asserting the leak's side effect (valid JSON reported as invalid) and
now asserts the correct behavior.
- `@testing-library/jest-dom` 6.6 → 7.0.1. Its vitest type augmentation
resolves through a peer now, so it lands on each package's own `vitest`
instead of whichever copy pnpm hoisted. Fixes `toBeInTheDocument` type
errors in dev-tools after the reshuffle.
- `@testing-library/react` 16.0.0 → 16.3.3 for the React 19 peer range.
- `vite: catalog:` added to dev-tools, www, and common. Without it they
resolved a newer vite than the catalog pin, which forked a second vitest
instance in the lockfile. There's now one.
- ai-commands custom matcher types use v5's `Matchers<R, T>` form.
- 110 test files: `vi.clearAllMocks()` removed from
`beforeEach`/`afterEach` hooks, along with hooks that only did that and
the imports they left unused. Calls that also reset/restore mocks are
untouched. Second commit, mechanical.

**Added:**
- `.vitest/` to the root gitignore (v5 writes JSON/JUnit/HTML reporter
output there)

**Removed:**
- `vite-tsconfig-paths` catalog entry and deps. Vitest 5 resolves
tsconfig paths itself.

Release-age note: this sat in draft with a temporary
`minimumReleaseAgeExclude` entry for `vitest` and `@vitest/*` while
5.0.0 was inside the workspace's 3-day `minimumReleaseAge` window. That
window has closed, so the exclusion is gone and nothing bypasses the
release-age gate.

**Perf** (local, medians of 3 runs, same machine):

| Suite | v4.1.4 | v5.0.0 |
|---|---|---|
| studio | 144.1s | 141.7s (-2%) |
| studio `--coverage` | 156.9s | 146.4s (-7%) |
| ui-patterns | 6.27s | 5.07s (-19%) |
| ui `--coverage` | 3.35s | 2.14s (-36%) |
| www | 0.89s | 0.47s (-47%) |

Studio is dominated by jsdom environment setup per file, which v5
doesn't change. `vitest doctor` recommends keeping the current pool
config: the vm pools and `isolate: false` all break tests.

## To test

- `pnpm install --frozen-lockfile` succeeds with no
`minimumReleaseAgeExclude` entry for vitest.
- CI: Studio unit tests, ui, ui-patterns, www, docs, and typecheck/lint
should all be green. The lint ratchet was checked locally: warning
counts on touched Studio files are identical to master.
- `pnpm test:studio` locally passes with coverage (588 files, 6240
tests).
- Open a Studio test that uses `toBeInTheDocument` in your editor and
confirm no type errors on jest-dom matchers, in Studio and in
`packages/dev-tools`.
- Known pre-existing failures unrelated to this PR: one dev-tools test
(`getEventCountBadge` capped pill) fails on master too.


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

## Tests
- Improved test coverage for JSON validation and mobile navigation
behavior.
- Updated test setup, cleanup, environment configuration, and matcher
support across application and shared package suites.
- Removed obsolete coverage for alternate MCP transport selection.

## Chores
- Streamlined TypeScript path resolution and Vitest reporter output
handling.
- Updated testing libraries and Vitest tooling across documentation,
Studio, website, and shared packages.
- Added Vitest reporter output to ignored files.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2026-09-10 16:45:54 +08:00
Ali WaseemandJoshen Lim e8f9359a98 fix(studio): hide legacy API keys on High Availability projects (#49552)
Multigres (High Availability) projects ship with legacy API keys
disabled and the management API rejects re-enabling them, so the
Dashboard should not surface them at all.

Hides the "Legacy anon, service_role API keys" tab, renders an empty
state on the legacy page for direct URL access, and drops the "Copy
anonymous API key" / "Copy service API key" commands from the command
menu. Non-HA projects are unchanged.

Fixes FE-4276

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

* **New Features**
* High Availability projects now hide legacy API key navigation and
commands.
* Legacy API key settings display an unavailable message for High
Availability projects.
  * Publishable and secret key options remain available where supported.
* Other projects continue to provide access to supported legacy API key
options.

* **Bug Fixes**
* Prevented unsupported legacy API key controls from appearing on High
Availability projects.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-08-26 10:17:28 +00:00
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
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
Stojan Dimitrovski 34ca04300c feat: make publishable, secret api keys page front-and-center (#40751) 2025-11-24 19:08:00 +01:00
Ali Waseem c058867999 Feat: Update API key display settings to show new ones rather than legacy (#40537)
* updated placement of API keys

* changed position of API keys
2025-11-18 11:05:02 -07:00
Stojan DimitrovskiandJoshen Lim e0a3ab2c74 fix: additional fixes for api keys, jwt signing keys (#37069)
* fix: additional fixes for api keys, jwt signing keys

* Smol fix

* fix issue with screen

* Fix success handler for migrate JWT secret

* Tiny

* text fix

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-07-14 10:04:24 +02:00
9318404e61 Feat/api keys rollout prep (#35559)
* first pass

* init

* updated types

* fix up key reveal

* Update QuickKeyCopy.tsx

* remove quick key copy

* api key pill now only allows reveal and copy if you have perm

* Update LegacyAPIKeys.tsx

* fix up layouts

* fix copy

* Fix action menu dropdown position, few small nudges

* Remove unused files.

* Remove the hardcoded and rename the feature flag for basic API keys.

* add support for name and description, some smaller improvements

* Fix the trims for the description.

---------

Co-authored-by: Terry Sutton <saltcod@gmail.com>
Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
Co-authored-by: Stojan Dimitrovski <sdimitrovski@gmail.com>
2025-05-27 15:50:42 +02:00