(edited)
My site has 2 endpoints that are in the same nextjs project / is the main endpoint for customers /admin is for admin
I want to isolate their stats in SpeedInsights and Analytics so I've tried doing like this.
'use client'
import { usePathname } from "next/navigation";import { SpeedInsights } from "@vercel/speed-insights/next"import { Analytics } from "@vercel/analytics/react"
type InsightsProps = {}
export const Insights = ({ }: InsightsProps) => { const pathname = usePathname();
const isAdminPortal = pathname.startsWith('/admin');
const endpoint = isAdminPortal ? `${process.env.NEXT_PUBLIC_SITE_URL}/admin/_vercel/speed-insights/vitals` : `${process.env.NEXT_PUBLIC_SITE_URL}/_vercel/speed-insights/vitals`
return <> {!isAdminPortal ? <Analytics /> : null} <SpeedInsights endpoint={endpoint} /> </>}But I'm not sure if it works because the official docs is lack of information.