feat: add telemetry (#3822)

* feat: telemetry

Co-authored-by: Kinfe123 <kinfishtech@gmail.com>

* chore: remove changeset

* fix: do not generate project id unless telemetry is enabled

* fix: return `isInsiderContainerCached`

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* chore: remove unused utils file

* fix: properly cache generated project id

* feat: interpret empty env vars as false

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

* fix: use nullish coalescing to set fallback

* fix: should be `isInsideContainerCached`

* fix: unique icons + tooltip for telemetry component

* fix: import child process from node

* fix: remove quotes in description

Co-authored-by: Alex Yang <himself65@outlook.com>

* fix: address reviews

Co-authored-by: Alex Yang <himself65@outlook.com>

* chore: refactor

* refactor

* add tests

* cache pkg json

* add cli tracking

* add migrate

* chore fix xi

* skip tet

* update snapshot

* chore: fix typecheck

* Expand telemetry docs: list collected fields, clarify anonymous redaction via getTelemetryAuthConfig, and document CLI events and audit/opt‑out paths.

* docs

* doc cleanup

* fixes

* remove git first commit message

* update docs

---------

Co-authored-by: Kinfe123 <kinfishtech@gmail.com>
Co-authored-by: Bereket Engida <86073083+Bekacru@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: Alex Yang <himself65@outlook.com>
Co-authored-by: Bereket Engida <Bekacru@gmail.com>
This commit is contained in:
Fraol Lemecha
2025-08-10 11:11:56 +03:00
committed by GitHub
parent 0a596beb3a
commit 2915e4c92d
31 changed files with 1373 additions and 55 deletions

View File

@@ -0,0 +1,138 @@
import { Badge } from "@/components/ui/badge";
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
import {
Settings,
ShieldCheck,
Package2,
Terminal,
GitBranch,
Cpu,
CircleCheck,
Box,
Plug,
GitCommitHorizontal,
Globe,
MemoryStick,
CircuitBoard,
Brain,
ServerCog,
Container,
AppWindow,
TerminalSquare,
CirclePlay,
} from "lucide-react";
const telemetryPoints = [
{
icon: GitCommitHorizontal,
label: "Anonymous Project ID",
title: "Unique project identifier, anonymized for privacy.",
},
{
icon: ShieldCheck,
label: "Sanitized Config",
title:
"Auth configuration options passed into Better Auth, cleaned of sensitive info.",
},
{ icon: Plug, label: "Enabled Plugins", title: "List of active plugins." },
{
icon: Settings,
label: "Better Auth Version",
title: "Current version of Better Auth.",
},
{
icon: ServerCog,
label: "Database",
title: "Type and version of the database in use.",
},
{
icon: Box,
label: "Framework",
title: "The framework powering the app and its version.",
},
{
icon: Package2,
label: "Package Manager",
title: "The package manager in use and its version.",
},
{
icon: Terminal,
label: "Runtime",
title: "The JavaScript runtime in use and its version.",
},
{ icon: Globe, label: "OS", title: "Operating system of the host machine." },
{
icon: CircuitBoard,
label: "CPU Arch",
title: "Processor architecture type.",
},
{ icon: Cpu, label: "CPU Count", title: "Number of CPU cores available." },
{ icon: Brain, label: "CPU Model", title: "Model identifier of the CPU." },
{
icon: MemoryStick,
label: "Total Memory",
title: "Total system memory (RAM) installed.",
},
{
icon: GitBranch,
label: "isGit",
title: "Indicates if the project is version controlled by Git.",
},
{
icon: CircleCheck,
label: "isProduction",
title: "Flag showing if running in production mode.",
},
{
icon: CirclePlay,
label: "isCI",
title:
"Whether the code is running in a Continuous Integration environment.",
},
{
icon: AppWindow,
label: "isWSL",
title: "True if running inside Windows Subsystem for Linux.",
},
{
icon: Container,
label: "isDocker",
title: "True if running inside a Docker container.",
},
{
icon: TerminalSquare,
label: "isTTY",
title: "True if running inside a TTY shell.",
},
];
export default function Telemetry() {
return (
<TooltipProvider>
<div className="flex flex-wrap gap-2">
{telemetryPoints.map(({ icon: Icon, label, title }, index) => (
<Tooltip key={index}>
<TooltipTrigger asChild>
<Badge
variant="outline"
className="flex items-center gap-1.5 cursor-help"
>
<Icon className="w-3.5 h-3.5" />
{label}
</Badge>
</TooltipTrigger>
<TooltipContent>
<p className="text-sm">{title}</p>
</TooltipContent>
</Tooltip>
))}
</div>
</TooltipProvider>
);
}

View File

@@ -1,4 +1,5 @@
import {
Binoculars,
Book,
CircleHelp,
Database,
@@ -1963,11 +1964,17 @@ C0.7,239.6,62.1,0.5,62.2,0.4c0,0,54,13.8,119.9,30.8S302.1,62,302.2,62c0.2,0,0.2,
href: "/docs/reference/resources",
icon: () => <Book className="w-4 h-4 text-current" />,
},
{
title: "Security",
href: "/docs/reference/security",
icon: () => <ShieldCheck className="w-4 h-4 text-current" />,
},
{
title: "Telemetry",
href: "/docs/reference/telemetry",
icon: () => <Binoculars className="w-4 h-4 text-current" />,
},
{
title: "FAQ",
href: "/docs/reference/faq",
@@ -1975,45 +1982,6 @@ C0.7,239.6,62.1,0.5,62.2,0.4c0,0,54,13.8,119.9,30.8S302.1,62,302.2,62c0.2,0,0.2,
},
],
},
// {
// title: "Contribute",
// Icon: () => (
//
// ),
// list: [
// {
// title: "Getting Started",
// href: "/docs/contribute/getting-started",
// icon: () => <BookOpenCheck className="text-current size-4" />,
// },
// {
// title: "Areas to Contribute",
// href: "/docs/contribute/areas-to-contribute",
// icon: () => <HandHelping className="w-4 h-4 text-current" />,
// },
// // {
// // title: "Database Adapters",
// // href: "/docs/contribute/database-adapters",
// // icon: () => <Plug className="w-4 h-4 text-current" />,
// // },
// {
// title: "Testing",
// href: "/docs/contribute/testing",
// icon: () => <FlaskConical className="w-4 h-4 text-current" />,
// },
// {
// title: "Documenting",
// href: "/docs/contribute/documenting",
// icon: () => <NotebookPen className="w-4 h-4 text-current" />,
// },
// {
// title: "Security Issues",
// href: "/docs/contribute/security-issues",
// icon: () => <ShieldCheck className="w-4 h-4 text-current" />,
// },
// ],
// },
];
export const examples: Content[] = [

View File

@@ -52,7 +52,7 @@ function TooltipContent({
{...props}
>
{children}
<TooltipPrimitive.Arrow className="-z-10 relative bg-primary dark:bg-stone-900 dark:fill-stone-900 fill-primary size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
<TooltipPrimitive.Arrow className="-z-10 relative bg-primary fill-primary size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
</TooltipPrimitive.Content>
</TooltipPrimitive.Portal>
);