
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
@grafana/faro-web-sdk
Advanced tools
@grafana/faro-web-sdk is a JavaScript SDK designed to integrate with Grafana Faro, a platform for observability and monitoring. It provides tools for logging, tracing, and collecting metrics from web applications, helping developers monitor and debug their applications effectively.
Logging
The logging feature allows developers to send log messages to a Faro instance. This can be used to track application behavior and debug issues.
import { initializeFaro } from '@grafana/faro-web-sdk';
const faro = initializeFaro({
url: 'https://your-faro-instance.com',
app: { name: 'my-app', version: '1.0.0' }
});
faro.log('This is a log message');
Tracing
Tracing helps in monitoring the flow of requests and operations within an application. This feature allows developers to trace specific operations and collect contextual data.
import { initializeFaro } from '@grafana/faro-web-sdk';
const faro = initializeFaro({
url: 'https://your-faro-instance.com',
app: { name: 'my-app', version: '1.0.0' }
});
faro.trace('operation-name', { key: 'value' });
Metrics Collection
Metrics collection allows developers to gather quantitative data about their application's performance, such as response times or error rates, which can be visualized in Grafana.
import { initializeFaro } from '@grafana/faro-web-sdk';
const faro = initializeFaro({
url: 'https://your-faro-instance.com',
app: { name: 'my-app', version: '1.0.0' }
});
faro.metric('metric-name', 100);
Sentry is a popular open-source error tracking and performance monitoring tool. It provides similar functionalities to @grafana/faro-web-sdk, such as logging, tracing, and metrics collection, but is more focused on error tracking and performance monitoring across various platforms.
LogRocket is a front-end application monitoring solution that provides session replay, error tracking, and performance monitoring. While it offers similar logging and monitoring capabilities as @grafana/faro-web-sdk, it is particularly strong in session replay and user experience analysis.
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.
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.
console
global object. Only warn
, info
and error
levels by default.default
value for the view metaconsole
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.18.2
fix(user actions): don't attach user action context to http request when in halt mode (#1249)
chore(deps): Updated Node.js version support by removing Node.js 18 (EOL) and adding Node.js 24 LTS (#1259).
FAQs
Faro instrumentations, metas, transports for web.
The npm package @grafana/faro-web-sdk receives a total of 170,175 weekly downloads. As such, @grafana/faro-web-sdk popularity was classified as popular.
We found that @grafana/faro-web-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 23 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.