Files
supabase/apps/studio/components/layouts/APIKeys/APIKeysLayout.tsx
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

37 lines
1.0 KiB
TypeScript

import { PropsWithChildren } from 'react'
import { PageContainer } from 'ui-patterns/PageContainer'
import {
PageHeader,
PageHeaderAside,
PageHeaderDescription,
PageHeaderMeta,
PageHeaderSummary,
PageHeaderTitle,
} from 'ui-patterns/PageHeader'
import { DocsButton } from '@/components/ui/DocsButton'
import { DOCS_URL } from '@/lib/constants'
const ApiKeysLayout = ({ children }: PropsWithChildren) => {
return (
<>
<PageHeader>
<PageHeaderMeta>
<PageHeaderSummary>
<PageHeaderTitle>API Keys</PageHeaderTitle>
<PageHeaderDescription>
Configure API keys to securely control access to your project
</PageHeaderDescription>
</PageHeaderSummary>
<PageHeaderAside>
<DocsButton href={`${DOCS_URL}/guides/api/api-keys`} />
</PageHeaderAside>
</PageHeaderMeta>
</PageHeader>
<PageContainer className="flex flex-col py-8 pb-16 gap-8">{children}</PageContainer>
</>
)
}
export default ApiKeysLayout