Opinionated Next.js instrumentation library.
# npm
npm install @foomo/next-instrumentation
# yarn
yarn add @foomo/next-instrumentation
# pnpm
pnpm install -S @foomo/next-instrumentation
# bun
bun add @foomo/next-instrumentationCopy the patches/next.patch file to your project and use your package manager to apply it.
// package.json
{
"pnpm": {
"patchedDependencies": {
"next": "path/to/next.patch"
}
}
}Create a instrumentation.ts file in your src directory:
// instrumentation.ts
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
// load dependencies
await require('pino');
await require('next-logger');
// register instrumentation
await (await import('@foomo/next-instrumentation/server')).register();
}
}Init faro on your pages:
// src/app/page.tsx
import { useFaro } from '@foomo/next-instrumentation/client';
export default async function Page({ params }: { params: {} }) {
useFaro({
url: "https://faro.example.com/collect",
app: {
name: "your-app",
},
})
return (</>)
}Contributions are welcome! Please read the contributing guide.
Distributed under MIT License, please read the license file for more details.