Skip to content

Commit 96d44fc

Browse files
fix: @axiomhq/react example code (#222)
1 parent 6c871d5 commit 96d44fc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

send-data/react.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,24 @@ This page explains how to use the @axiomhq/react library to send data from your
4747
npm install --save @axiomhq/logging @axiomhq/react
4848
```
4949

50-
1. Add the following environment variables to your React app:
51-
52-
- `AXIOM_DATASET` is the name of the Axiom dataset where you want to send data.
53-
- `AXIOM_TOKEN` is the Axiom API token you have generated.
54-
55-
1. Create a `Logger` instance and export the utils. The example below uses the `useLogger` and `WebVitals` components.
50+
2. Create a `Logger` instance and export the utils. The example below uses the `useLogger` and `WebVitals` components.
5651

5752
```tsx [expandable]
5853
'use client';
5954

60-
import { Logger, AxiomFetchTransport } from '@axiomhq/logging';
55+
import { Logger, AxiomJSTransport } from '@axiomhq/logging';
56+
import { Axiom } from '@axiomhq/js';
6157
import { createUseLogger, createWebVitalsComponent } from '@axiomhq/react';
6258

59+
const axiomClient = new Axiom({
60+
token: process.env.AXIOM_TOKEN!,
61+
});
62+
6363
export const logger = new Logger({
6464
transports: [
65-
new AxiomFetchTransport({
65+
new AxiomJSTransport({
66+
client: axiomClient,
6667
dataset: process.env.AXIOM_DATASET!,
67-
token: process.env.AXIOM_TOKEN!,
6868
}),
6969
],
7070
});

0 commit comments

Comments
 (0)