Gathering detailed insights and metrics for @civitai/next-axiom
Gathering detailed insights and metrics for @civitai/next-axiom
npm install @civitai/next-axiom
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (99.79%)
Nix (0.21%)
Total Downloads
411
Last Day
3
Last Week
21
Last Month
197
Last Year
411
376 Stars
587 Commits
29 Forks
4 Watching
36 Branches
24 Contributors
Latest Version
0.17.0
Package Id
@civitai/next-axiom@0.17.0
Unpacked Size
362.44 kB
Size
90.92 kB
File Count
57
NPM Version
10.5.0
Node Version
20.12.2
Publised On
18 Sept 2024
Cumulative downloads
Total Downloads
Last day
200%
3
Compared to previous day
Last week
-56.3%
21
Compared to previous week
Last month
101%
197
Compared to previous month
Last year
0%
411
Compared to previous year
1
1
Axiom unlocks observability at any scale.
For more information, check out the official documentation.
Make sure you have the Axiom Vercel integration installed. Once it is done, perform the steps below:
next-axiom
as follows:1npm install --save next-axiom
next.config.js
file, wrap your Next.js config in withAxiom
as follows:1const { withAxiom } = require('next-axiom'); 2 3module.exports = withAxiom({ 4 // ... your existing config 5});
Create an API token in Axiom settings and export it as AXIOM_TOKEN
, as well as the Axiom dataset name as AXIOM_DATASET
. Once it is done, perform the steps below:
next-axiom
as follows:1npm install --save next-axiom
next.config.js
file, wrap your Next.js config in withAxiom
as follows:1const { withAxiom } = require('next-axiom'); 2 3module.exports = withAxiom({ 4 // ... your existing config 5});
:warning: next-axiom
is still experimental for non-Vercel platforms and is subject to change.
:warning: Web-Vitals are not yet supported in Next.js 13 and above. Please use Next.js 12 or below.
Go to pages/_app.js
or pages/_app.ts
and add the following line to report web vitals:
1export { reportWebVitals } from 'next-axiom';
Note: WebVitals are only sent from production deployments.
Wrapping your handlers in withAxiom
will make req.log
available and log
exceptions:
:warning: Nextjs 13.x server side components are not yet supported.
1import { withAxiom, AxiomAPIRequest } from 'next-axiom'; 2 3async function handler(req: AxiomAPIRequest, res: NextApiResponse) { 4 req.log.info('Login function called'); 5 6 // You can create intermediate loggers 7 const log = req.log.with({ scope: 'user' }); 8 log.info('User logged in', { userId: 42 }); 9 10 res.status(200).text('hi'); 11} 12 13export default withAxiom(handler);
Import and use log
in the frontend like this:
1import { log } from `next-axiom`; 2 3// pages/index.js 4function home() { 5 ... 6 log.debug('User logged in', { userId: 42 }) 7 ... 8}
The log level defines the lowest level of logs sent to Axiom.
The default is debug, resulting in all logs being sent.
Available levels are (from lowest to highest): debug
, info
, warn
, error
For example, if you don't want debug logs to be sent to Axiom:
1export AXIOM_LOG_LEVEL=info
You can also disable logging completely by setting the log level to off
:
1export AXIOM_LOG_LEVEL=off
To be able to use next-axiom with getServerSideProps
you need to wrap your function with withAxiomGetServerSideProps
, becasue there is no
way at the moment to automatically detected if getServerSideProps is used.
1import { withAxiomGetServerSideProps } from 'next-axiom' 2export const getServerSideProps = withAxiomGetServerSideProps(async ({ req, log }) => { 3 log.info('Hello, world!'); 4 return { 5 props: { 6 }, 7 } 8}); 9 10 11### License 12 13Distributed under the [MIT License](LICENSE).
No vulnerabilities found.
No security vulnerabilities found.