Skip to content

Commit dc28ab4

Browse files
authored
Update Next and Vercel (#108)
1 parent c5c965a commit dc28ab4

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

apps/vercel.mdx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Vercel provides a frictionless developer experience to take care of the hard thi
2222

2323
Vercel makes it easy for frontend teams to develop, preview, and ship delightful user experiences, where performance is the default.
2424

25-
## Sending logs to Axiom
25+
## Send logs to Axiom
2626

2727
Simply install the [Axiom Vercel app from here](https://vercel.com/integrations/axiom) and be streaming logs and web vitals within minutes!
2828

@@ -40,9 +40,11 @@ For function logs, if you call `console.log`, `console.warn` or `console.error`
4040

4141
Axiom supports capturing and analyzing Web Vital data directly from your user’s browser without any sampling and with more data than is available elsewhere. It is perfect to pair with Vercel’s in-built analytics when you want to get really deep into a specific problem or debug issues with a specific audience (user-agent, location, region, etc).
4242

43-
**NOTE: Web Vitals are only currently supported for Next.js websites. Expanded support is coming soon!**
43+
<Note>
44+
Web Vitals are only currently supported for Next.js websites. Expanded support is coming soon.
45+
</Note>
4446

45-
#### Installation
47+
### Installation
4648

4749
Perform the following steps to install Web Vitals:
4850

@@ -74,7 +76,9 @@ export default function RootLayout() {
7476
}
7577
```
7678

77-
**Note:** WebVitals are sent only from production deployments.
79+
<Note>
80+
WebVitals are sent only from production deployments.
81+
</Note>
7882

7983
4. Deploy your site and watch data coming into your Axiom dashboard.
8084

@@ -135,7 +139,7 @@ export const GET = withAxiom((req: AxiomRequest) => {
135139
});
136140
```
137141

138-
## Using Next.js 12 for Web Vitals
142+
## Use Next.js 12 for Web Vitals
139143

140144
If you’re using Next.js version 12, follow the instructions below to integrate Axiom for logging and capturing Web Vitals data.
141145

@@ -145,7 +149,7 @@ In your `pages/_app.js` or `pages/_app.ts` and add the following line:
145149
export { reportWebVitals } from 'next-axiom';
146150
```
147151

148-
## Upgrading to Next.js 13 from Next.js 12
152+
## Upgrade to Next.js 13 from Next.js 12
149153

150154
If you plan on upgrading to Next.js 13, you'll need to make specific changes to ensure compatibility:
151155

@@ -235,7 +239,6 @@ You can **parse** the JSON using the [parse_json function](/apl/scalar-functions
235239

236240
- Check out our [APL Documentation on how to use more functions](/apl/scalar-functions/string-functions) and run your own queries against your Vercel logs.
237241

238-
239242
## Migrate from Vercel app to next-axiom
240243

241244
In May 2024, Vercel [introduced higher costs](https://axiom.co/blog/changes-to-vercel-log-drains) for using Vercel Log Drains. Because the Axiom Vercel app depends on Log Drains, using the next-axiom library can be the cheaper option to analyze telemetry data for higher volume projects.
@@ -260,3 +263,7 @@ module.exports = withAxiom({
260263
```
261264

262265
For more configuration options, see the [documentation in the next-axiom GitHub repository](https://github.com/axiomhq/next-axiom).
266+
267+
## Send logs from Vercel preview deployments
268+
269+
To send logs from Vercel preview deployments to Axiom, enable preview deployments for the environment variable `NEXT_PUBLIC_AXIOM_INGEST_ENDPOINT`. For more information, see the [Vercel documentation](https://vercel.com/docs/projects/environment-variables/managing-environment-variables).

send-data/nextjs.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,11 @@ export default function ErrorPage({
224224
}
225225
```
226226
227+
## Extend logger
228+
229+
To extend the logger, use `log.with` to create an intermediate logger. For example:
230+
231+
```typescript
232+
const logger = userLogger().with({ userId: 42 });
233+
logger.info('Hi'); // will ingest { ..., "message": "Hi", "fields" { "userId": 42 }}
234+
```

0 commit comments

Comments
 (0)