Skip to content

Commit 3340f63

Browse files
authored
Merge pull request #7 from CROW-B3/CROW-104-web-vitals-integration-for-rogue-store
2 parents a798cba + 42dbbbe commit 3340f63

File tree

7 files changed

+7273
-2
lines changed

7 files changed

+7273
-2
lines changed

.lighthouse/lighthouse-performance.json

Lines changed: 7249 additions & 0 deletions
Large diffs are not rendered by default.

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ENV NEXT_TELEMETRY_DISABLED=1
1515
ENV DOCKER_BUILD=true
1616
RUN bun run build
1717

18-
FROM node:20-alpine AS runner
18+
FROM oven/bun:1-alpine AS runner
1919
WORKDIR /app
2020

2121
ENV NODE_ENV=production
@@ -35,4 +35,4 @@ EXPOSE 3000
3535
ENV PORT=3000
3636
ENV HOSTNAME=0.0.0.0
3737

38-
CMD ["node", "server.js"]
38+
CMD ["bun", "server.js"]

_components/web-vitals.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"use client";
2+
import { useReportWebVitals } from "next/web-vitals";
3+
import { logWebVitals } from "@/lib/utils";
4+
5+
export const WebVitals = () => {
6+
useReportWebVitals(logWebVitals);
7+
return <div></div>;
8+
};

app/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Header } from "@/components/layout/header";
55
import { Footer } from "@/components/layout/footer";
66
import { CartDrawer } from "@/components/cart/cart-drawer";
77
import { ToastProvider } from "@/components/ui/toast-provider";
8+
import { WebVitals } from "@/_components/web-vitals";
89

910
const inter = Inter({ subsets: ["latin"] });
1011

@@ -35,6 +36,7 @@ export default function RootLayout({
3536
</div>
3637
<CartDrawer />
3738
<ToastProvider />
39+
{process.env.NODE_ENV === "production" ? null : <WebVitals />}
3840
</body>
3941
</html>
4042
);

bun.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,8 @@ export function debounce<T extends (...args: never[]) => unknown>(
5555
timeout = setTimeout(() => func(...args), wait);
5656
};
5757
}
58+
59+
// eslint-disable-next-line
60+
export const logWebVitals = (metric: any) => {
61+
console.log(metric);
62+
};

tailwind.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const config: Config = {
44
content: [
55
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
66
"./components/**/*.{js,ts,jsx,tsx,mdx}",
7+
"./_components/**/*.{js,ts,jsx,tsx,mdx}",
78
"./app/**/*.{js,ts,jsx,tsx,mdx}",
89
],
910
};

0 commit comments

Comments
 (0)