Skip to content

Commit

Permalink
chore(docs): add missing imports to router instrumentation docs (#625)
Browse files Browse the repository at this point in the history
  • Loading branch information
codecapitano authored Jun 20, 2024
1 parent 2f73bef commit 8b75c18
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions packages/react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ additional React specific functionality like router instrumentation, a custom Er
### Router v6 with Data Router

```ts
import {
initializeFaro,
createReactRouterV6DataOptions,
ReactIntegration,
getWebInstrumentations,
} from '@grafana/faro-react';

import { matchRoutes } from 'react-router-dom';

initializeFaro({
// ...

Expand All @@ -90,6 +99,8 @@ In the file you create your data router, often the App.\* file pass your data ro
function `withFaroRouterInstrumentation` to wrap all your routes and apply Faro auto instrumentation:

```ts
import { createBrowserRouter } from '@grafana/faro-react';

const reactBrowserRouter = createBrowserRouter([
// your routes...
]);
Expand All @@ -105,7 +116,13 @@ In the file you define your router, import `createRoutesFromChildren`, `matchRou
```ts
import { createRoutesFromChildren, matchRoutes, Routes, useLocation, useNavigationType } from 'react-router-dom';

import { getWebInstrumentations, initializeFaro, ReactIntegration, ReactRouterVersion } from '@grafana/faro-react';
import {
createReactRouterV6Options,
getWebInstrumentations,
initializeFaro,
ReactIntegration,
ReactRouterVersion,
} from '@grafana/faro-react';

initializeFaro({
// Mandatory, the URL of the Grafana collector
Expand Down Expand Up @@ -159,7 +176,14 @@ The final result should look similar like this example:
import { createBrowserHistory } from 'history';
import { Route } from 'react-router-dom';

import { getWebInstrumentations, initializeFaro, ReactIntegration, ReactRouterVersion } from '@grafana/faro-react';
import {
// or createReactRouterV4Options
createReactRouterV5Options,
getWebInstrumentations,
initializeFaro,
ReactIntegration,
ReactRouterVersion,
} from '@grafana/faro-react';

const history = createBrowserHistory();

Expand Down

0 comments on commit 8b75c18

Please sign in to comment.