mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Problem Project home tracked most interactions, but not which credential people copy from the "Copy" popover, or how often they use the custom report and notebooks beyond adding blocks. Opening the Connect sheet from the popover's "Get Connected" button also reported a stale `connect_sheet_opened` source, because the popover never set one. ## Solution Project home gets three new events: `home_project_credential_copied` (with a `credentialType` enum), `home_custom_report_refresh_clicked`, and `home_notebook_action_clicked` (`action: 'create' | 'analyze'`). "Get Connected" in the popover now sets a new `home_popover` Connect sheet source. The compute and GitHub stats now send `home_activity_stat_clicked` as well, with two new `stat_type` values. Every event fires from its click handler with a typed `track()` call, and none sends the copied value or any user-defined name. This follows the telemetry standards, so no `data-attr` attributes are added. ## How to verify 1. On a project's home page, open the "Copy" popover and copy each item. Each copy sends one `home_project_credential_copied` event, with `credentialType` set to `project_url`, `publishable_key`, `direct_connection_string`, or `cli_setup`. No event contains the copied value. 2. In the same popover, click "Get Connected". The Connect sheet opens and sends `connect_sheet_opened` with `source: 'home_popover'`. Opening it from the header button afterwards still sends `source: 'header_button'`. 3. Click the "Compute size" stat. It sends `home_activity_stat_clicked` with `stat_type: 'compute'` and no `stat_value`. 4. Click the "GitHub" stat. It sends `home_activity_stat_clicked` with `stat_type: 'github'`, and `stat_value` is 1 when a repository is connected and 0 when none is. 5. With the custom report section shown, click "Refresh report". It sends one `home_custom_report_refresh_clicked` event. 6. With the Notebooks section shown, click "New notebook" (or "Create your first notebook" when there are none). It sends `home_notebook_action_clicked` with `action: 'create'`. Click "Analyze" on a notebook with cells: it sends `action: 'analyze'`. ## Checks Ran `tsc --noEmit` in `apps/studio` and `packages/common`, `eslint` and the type-aware `eslint.type-checks.config.cjs` lint on the changed Studio files, `oxfmt --check` on every changed file, and `vitest run` for `ProjectConnectionPopover.platform.test.tsx` and `ActivityStats.test.tsx`. ## Checklist - [x] I have read the [Contributing Guidelines](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [ ] I have checked that the change works in the preview deployment ## Feedback for Tedd To ask Tedd for a change to this PR, reply in Tedd's session on [FE-5026](https://linear.app/supabase/issue/FE-5026/track-usage-on-project-home-gaps-only). Tedd doesn't read comments on this PR. --------- Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import type { HomeActivityStatClickedEvent } from 'common/telemetry-constants'
|
|
import type { ReactNode } from 'react'
|
|
import { cn } from 'ui'
|
|
|
|
import { DynamicLink } from '@/components/ui/DynamicLink'
|
|
import { useTrack } from '@/lib/telemetry/track'
|
|
|
|
type SingleStatProps = {
|
|
icon: ReactNode
|
|
label: ReactNode
|
|
value: ReactNode
|
|
className?: string
|
|
href?: string
|
|
onClick?: () => void
|
|
trackingProperties?: HomeActivityStatClickedEvent['properties']
|
|
}
|
|
|
|
export const SingleStat = ({
|
|
icon,
|
|
label,
|
|
value,
|
|
className,
|
|
href,
|
|
onClick,
|
|
trackingProperties,
|
|
}: SingleStatProps) => {
|
|
const track = useTrack()
|
|
|
|
const trackActivityStat = () => {
|
|
if (trackingProperties) {
|
|
track('home_activity_stat_clicked', trackingProperties)
|
|
}
|
|
}
|
|
const content = (
|
|
<div
|
|
className={cn('group flex items-center gap-4 p-0 text-base justify-start min-w-0', className)}
|
|
>
|
|
<div className="min-w-16 w-16 h-16 rounded-md bg-surface-75 group-hover:bg-muted border flex items-center justify-center">
|
|
{icon}
|
|
</div>
|
|
<div className="min-w-0 flex-1">
|
|
<div className="text-left heading-meta text-foreground-light">{label}</div>
|
|
<div className="text-foreground min-h-[34px] flex items-center capitalize-sentence py-0.5">
|
|
{value}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
|
|
if (href) {
|
|
return (
|
|
<DynamicLink className="group block" href={href} onClick={trackActivityStat}>
|
|
{content}
|
|
</DynamicLink>
|
|
)
|
|
}
|
|
|
|
if (onClick) {
|
|
return (
|
|
<button type="button" className="group" tabIndex={0} onClick={onClick}>
|
|
{content}
|
|
</button>
|
|
)
|
|
}
|
|
|
|
return content
|
|
}
|