Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@grafana/agent-integration-react

Package Overview
Dependencies
Maintainers
17
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@grafana/agent-integration-react

Grafana JavaScript Agent package that enables easier integration in projects built with React.

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
17
Weekly downloads
 
Created
Source

@grafana/agent-integration-react

DEPRECATED Project has been moved to @grafana/faro-react

Grafana JavaScript Agent package that enables easier integration in projects built with React.

Warning: currently pre-release and subject to frequent breaking changes. Use at your own risk.

Out of the box, the package provides you the following features:

  • Error Boundary - Provides additional stacktrace for errors
  • Component Profiler - Capture every re-render of a component, the un/mounting time etc.
  • Router (v4-v6) integration - Send events for all route changes
  • SSR support

Installation

import { createRoutesFromChildren, matchRoutes, Routes, useLocation, useNavigationType } from 'react-router-dom';

import {
  getWebInstrumentations,
  initializeGrafanaAgent,
  ReactIntegration,
  ReactRouterVersion,
} from '@grafana/agent-integration-react';
import { TracingInstrumentation } from '@grafana/agent-tracing-web';

initializeGrafanaAgent({
  // ...
  instrumentations: [
    // Load the default Web instrumentations
    ...getWebInstrumentations(),

    // Tracing Instrumentation is needed if you want to use the React Profiler
    new TracingInstrumentation(),

    new ReactIntegration({
      // Only needed if you want to use the React Router instrumentation
      router: {
        version: ReactRouterVersion.V6,
        dependencies: {
          createRoutesFromChildren,
          matchRoutes,
          Routes,
          useLocation,
          useNavigationType,
        },
      },

      // Or if you use react-router v4/v5
      router2: {
        version: ReactRouterVersion.V5, // or ReactRouterVersion.V4,
        dependencies: {
          history, // the history object used by react-router
          Route, // Route component imported from react-router package
        },
      },
    }),
  ],
});

Usage

Error Boundary

import { GrafanaAgentErrorBoundary } from '@grafana/agent-integration-react';

// during render
<GrafanaAgentErrorBoundary>
  <App />
</GrafanaAgentErrorBoundary>;

or

import { withErrorBoundary } from '@grafana/agent-integration-react';

export default withErrorBoundary(App);

Router

V6

import { GrafanaAgentRoutes } from '@grafana/agent-integration-react';

// during render
<GrafanaAgentRoutes>
  <Route path="/" element={<Home />} />
  {/* ... */}
</GrafanaAgentRoutes>;

V4/v5

import { GrafanaAgentRoute } from '@grafana/agent-integration-react';

// during render
<Switch>
  <GrafanaAgentRoute path="/">
    <Home />
  </GrafanaAgentRoute>
  {/* ... */}
</Switch>;

Profiler

import { withGrafanaAgentProfiler } from '@grafana/agent-integration-react';

export default withGrafanaAgentProfiler(App);

FAQs

Package last updated on 31 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc