8000 fix: Copy button in UI Library extracts the wrong framework (#35098) · CodersSampling/supabase@8b55ffe · GitHub
[go: up one dir, main page]

Skip to content

Commit 8b55ffe

Browse files
authored
fix: Copy button in UI Library extracts the wrong framework (supabase#35098)
* Fix the telemetry for the copy button in the library. * Minor fix.
1 parent 8a340ae commit 8b55ffe

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

apps/ui-library/components/command-copy-button.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ export function CommandCopyButton({ command }: { command: string }) {
1919

2020
const parseCommandForTelemetry = (cmd: string) => {
2121
// Extract framework from URL (e.g., 'nextjs' from 'password-based-auth-nextjs.json')
22-
const frameworkMatch = cmd.match(/\/ui\/r\/.*?-(\w+)\.json/)
22+
const frameworkMatch = cmd.match(/ui\/r\/.*?-(nextjs|react|react-router|tanstack)\.json/)
23+
24+
// if the block doesn't have a framework defined (like infinite query), default to react
2325
const framework = frameworkMatch
2426
? (frameworkMatch[1] as 'nextjs' | 'react-router' | 'tanstack' | 'react')
25-
: 'nextjs'
27+
: 'react'
2628

2729
// Extract package manager from command prefix (npx, pnpm, yarn, bun)
2830
const packageManager = cmd.startsWith('npx')
@@ -36,8 +38,8 @@ export function CommandCopyButton({ command }: { command: string }) {
3638
: ('npm' as const)
3739

3840
// Extract template title from URL (e.g., 'password-based-auth' from 'password-based-auth-nextjs.json')
39-
const titleMatch = cmd.match(/\/ui\/r\/(.*?)-\w+\.json/)
40-
const title = titleMatch ? titleMatch[1] : ''
41+
const titleMatch = cmd.match(/\/ui\/r\/(.*?)\.json/)
42+
const title = (titleMatch ? titleMatch[1] : '').replaceAll(`-${framework}`, '')
4143

4244
return {
4345
framework,

0 commit comments

Comments
 (0)
0