Skip to content

Commit

Permalink
Merge pull request #29 from ethanniser/proxied-analytics
Browse files Browse the repository at this point in the history
Proxy analytics & speed insights data
  • Loading branch information
ethanniser authored Oct 21, 2024
2 parents fdba504 + 1175434 commit c9799ab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
21 changes: 21 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ const nextConfig = {
},
],
},
async rewrites() {
return [
{
source: "/insights/vitals.js",
destination:
"https://cdn.vercel-insights.com/v1/speed-insights/script.js",
},
{
source: "/insights/events.js",
destination: "https://cdn.vercel-insights.com/v1/script.js",
},
{
source: "/hfi/events/:slug*",
destination: "https://vitals.vercel-insights.com/v1/:slug*",
},
{
source: "/hfi/vitals/:slug*",
destination: "https://vitals.vercel-insights.com/v2/:slug*",
},
];
},
};

export default nextConfig;
5 changes: 2 additions & 3 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ export default async function RootLayout({
<Toaster closeButton />
<WelcomeToast />
</Suspense>

<Analytics />
<SpeedInsights />
<Analytics scriptSrc="/insights/events.js" endpoint="/hfi/events" />
<SpeedInsights scriptSrc="/insights/vitals.js" endpoint="/hfi/vitals" />
</body>
</html>
);
Expand Down

0 comments on commit c9799ab

Please sign in to comment.