1.11.0 • Published 30 days ago

@grafana/faro-web-sdk v1.11.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
30 days ago

@grafana/faro-web-sdk

Faro is a SDK that can instrument frontend JavaScript applications to collect telemetry and forward it to the Grafana Alloy (with app agent receiver integration enabled).

Grafana Alloy can then send this data to either Loki or Tempo.

Get started

See quick start for web applications.

Alternatively, you can use the CDN version of the library. See use cdn library for details on how to do so.

Instrumentations

  • console - captures messages logged to console global object. Only warn, info and error levels by default.
  • errors - captures unhandled top level exceptions
  • web-vitals - captures performance metrics reported by web vitals API
  • session - sends session start event
  • view - sends view changed event

Metas

  • browser - captures browser metadata: name, version, etc
  • page - captures current URL
  • view - the web SDK enforces a default value for the view meta

Transports

  • console - logs events to global console
  • fetch - sends events over HTTP to a backend

Example

Basic set up, will automatically report errors and web vitals:

import { initializeFaro } from '@grafana/faro-web-sdk';

const faro = initializeFaro({
  url: 'https://agent.myapp/collect',
  apiKey: 'secret',
  app: {
    name: 'frontend',
    version: '1.0.0',
  },
});

// send a log message
faro.api.pushLog(['hello world']);

// will be captured
throw new Error('oh no');

// push error manually
faro.api.pushError(new Error('oh no'));

With OTel tracing and browser console capture:

import { ConsoleInstrumentation, getWebInstrumentations, initializeFaro } from '@grafana/faro-web-sdk';
import { TracingInstrumentation } from '@grafana/faro-web-tracing';

const faro = initializeFaro({
  url: 'https://agent.myapp/collect',
  apiKey: 'secret',
  instrumentations: [...getWebInstrumentations({ captureConsole: true }), new TracingInstrumentation()],
  app: {
    name: 'frontend',
    version: '1.0.0',
  },
});

// start a span
faro.api
  .getOTEL()
  ?.trace.getTracer('frontend')
  .startActiveSpan('hello world', (span) => {
    // send a log message
    faro.api.pushLog(['hello world']);
    span.end();
  });

// will be captured
throw new Error('oh no');
1.11.0

30 days ago

1.10.2

2 months ago

1.10.1

2 months ago

1.10.0

2 months ago

1.9.1

3 months ago

1.8.2

4 months ago

1.8.1

4 months ago

1.8.0

5 months ago

1.7.3

6 months ago

1.9.0

4 months ago

1.7.2

6 months ago

1.7.1

6 months ago

1.7.0

7 months ago

1.6.0

7 months ago

1.5.1

8 months ago

1.5.0

8 months ago

1.4.2

8 months ago

1.4.1

9 months ago

1.4.0

9 months ago

1.3.9

9 months ago

1.3.8

9 months ago

1.3.7

10 months ago

1.3.6

10 months ago

1.3.5

11 months ago

1.3.4

11 months ago

1.3.2

12 months ago

1.3.1

12 months ago

1.3.0

12 months ago

1.2.0

1 year ago

1.2.8

12 months ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.1.4

1 year ago

1.2.2

1 year ago

1.1.3

1 year ago

1.2.1

1 year ago

1.1.2

1 year ago

1.2.9

12 months ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.0-beta4

2 years ago

1.0.0-beta3

2 years ago

1.0.0-beta2

2 years ago

1.0.0-beta1

2 years ago