Generated banner for Logfire Frontend
Generated logo for Logfire Frontend

Logfire Frontend

PydanticOfficialPublished by Pydantic

  • Skill
  • Tool integration
  • Software development
  • MIT
  • No issues found

From the author

Set up and troubleshoot Pydantic Logfire frontend observability and session replays in JavaScript/TypeScript browser applications. Use for browser errors, RUM, Web Vitals, replay recording, privacy controls, or reducing browser telemetry volume. Supports browser entrypoints, React/Vite, and the client side of Next.js; use logfire-instrumentation for server-side telemetry.
— the description by Pydantic

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides guidance on configuring Pydantic Logfire for browser-based applications using the @pydantic/logfire-browser and @pydantic/logfire-session-replay SDKs. It covers setup procedures for React, Vite, and Next.js, alongside strategies for managing observability signals, including Web Vitals, error tracking, and session replay recording. The skill emphasizes proper credential usage, privacy controls through data masking, and selecting appropriate capture profiles to balance telemetry volume with diagnostic needs.

What it does

  • Configures frontend observability using Logfire browser SDKs.
  • Implements session replay with configurable privacy masking and input blocking.
  • Supports integration with React, Vite, and Next.js client-side environments.
  • Provides capture profiles for varying levels of instrumentation and performance overhead.
  • Guides the setup of error tracking and Web Vitals monitoring.
  • Offers verification steps to ensure telemetry ingestion and replay playback.

When to use it

  • When you need to monitor browser-side errors and user interactions.
  • When you want to record user sessions for debugging complex frontend issues.
  • When you need to track Web Vitals and performance metrics in a web application.
  • When you need to reduce browser telemetry volume while maintaining critical error visibility.

Advantages

  • Enables end-to-end visibility by linking browser sessions to backend traces.
  • Provides granular control over data privacy through text and input masking.
  • Offers flexible capture profiles to optimize for performance or detail.
  • Integrates seamlessly with modern frontend frameworks like Next.js and React.

Usage examples

“How do I set up basic frontend observability in my React application?”
The agent provides the installation commands for @pydantic/logfire-browser and shows how to initialize the configuration in your main entrypoint before rendering the root component.
“How can I enable session replay while masking sensitive user input?”
The agent guides you to install the session replay package and configure the integration with maskAllInputs: true and blockSelector options to protect sensitive regions.
“I need to reduce the amount of telemetry data my frontend sends. What are my options?”
The agent explains the 'Minimal errors and replays' capture profile, showing how to disable automatic spans and RUM signals while keeping essential error reporting.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/pydantic/logfire-frontend/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip logfire-frontend.zip -d .agents/skills

Documentation by Pydantic

Set Up Frontend Observability and Session Replays

The application uses @pydantic/logfire-browser and, when replay is requested, @pydantic/logfire-session-replay. Configure one browser provider; preserve an existing OpenTelemetry provider, proxy, and application initialization pattern.

Confirm the browser application

Read repository instructions, the application manifest, browser entrypoint, router, and existing instrumentation. For Next.js, distinguish client code from server instrumentation before changing either. Respect dependency constraints; check the installed SDK's types before using a capture or sampling option.

Preserve the exact origin, organization, and project supplied by the user or setup handoff. Browser-only setup does not require a CLI login, a local SDK credential, or an ordinary project write token. Use existing native MCP access for verification when available; otherwise use the Logfire UI.

Create or select the frontend application under Frontend → Applications and use its generated regional URL and restricted frontend token. A normal project write token, server environment variable, or .logfire credential is unsuitable for browser code. The frontend application owns service identity. If no supported public API/tool can manage it, use the UI; do not invent a private endpoint.

Match capture to the request

Read browser setup, then the applicable section of capture profiles:

  • Full frontend observability: automatic page/request/interaction spans and Web Vitals. Add replay only when requested.

  • Errors and replays with automatic instrumentation: retain traces with Logfire error-level events or OpenTelemetry error status, while keeping replay independently enabled. This also retains other spans in a qualifying trace.

  • Minimal errors and replays: disable automatic spans and Web Vitals and explicitly report application errors. Use when the user requires lower browser instrumentation overhead or strictly limits the signals collected.

Preserve existing approved replay rates and masking. Trace sampling, replay sampling, and metric capture are separate decisions. Do not promise that minLevel filters automatic spans, that a trace sampler retains an entire browser session, or that every handled application failure is captured automatically.

Session replay is Early Access; check availability for the target organization and keep an existing application rollout flag. Mask text and inputs, leave console capture off, and block sensitive regions before recording them. Review attributes and URLs separately from visible-text masking. Add normalized route templates and opaque user IDs only when useful; names and emails are optional personal data.

Verify the selected behavior

Use verification and troubleshooting to exercise the real browser application, check the signals retained and omitted, query fresh errors in the exact project, and play the matching recording. For a sampling profile, test successful requests and the failure types the user cares about; inspect actual exported spans rather than assuming how HTTP status maps to error severity.

Run the application's normal typecheck/build and focused tests. Report browser execution, telemetry ingestion, and replay playback separately. A successful build, flush, upload response, or generated link does not prove all three. Return the verified project/application, capture policy, and a clean relevant UI link. If account reads or browser playback are unavailable, mark those parts unverified and state what evidence is missing.

For server-side Node.js or Next.js setup, use application instrumentation.

Files

references/capture-profiles.md

Browser Capture Profiles

Apply one profile to the existing browser configuration from setup. These are alternatives, not successive calls to configureFrontend(). Keep its generated frontendOptions, error capture, identity, and privacy controls. Verify options against the installed SDK; do not silently upgrade beyond the application's dependency constraints.

Full frontend observability

configureFrontend() enables automatic browser instrumentation and Web Vitals metrics by default. Add the optional replay integration when requested. Use this for page loads, performance, request/interaction traces, and error investigation. Replay is separate from those signals and needs its own sampling decision.

Errors and replays with automatic instrumentation

Keep automatic instrumentation and tail-sample qualifying traces. Disable Web Vitals when they are outside the requested signals; trace sampling does not filter metric exports. Import OpenTelemetry's error status from a direct dependency when using this callback:

npm install @opentelemetry/api
import { SpanStatusCode } from '@opentelemetry/api'
import * as logfire from '@pydantic/logfire-browser'
import { sessionReplayIntegration } from '@pydantic/logfire-session-replay/integration'

const frontend = logfire.configureFrontend({
  ...frontendOptions,
  autoInstrumentations: true,
  rum: { webVitals: false, longAnimationFrames: false },
  minLevel: 'error',
  sampling: {
    tail: ({ level, span }) => (level.gte('error') || span.status.code === SpanStatusCode.ERROR ? 1 : 0),
  },
  sessionReplay: sessionReplayIntegration({
    maskAllText: true,
    maskAllInputs: true,
    captureConsole: false,
    blockSelector: '[data-logfire-block]',
  }),
})

This accepts Logfire error/fatal events and spans marked with OpenTelemetry error status. Do not assume that an HTTP response code alone sets that status in every instrumentation/version; test 4xx, 5xx, and rejected network requests that matter to the application. Report an important handled failure explicitly when its instrumentation does not classify it as an error.

Tail sampling retains the entire qualifying trace, including its successful spans. It does not retain every trace from the same browser session or recover unrelated requests that finished before a later error. Global error reports may start a separate trace; replay supplies their shared session context.

This SDK sampler decides browser exports. A backend receiving propagated trace context makes its own decision and may retain spans whose browser parent was dropped; do not promise a complete distributed trace from browser sampling alone.

Leave head sampling at its default of 1 when every qualifying error trace must be eligible. A lower head rate can discard an error trace before its outcome is known. minLevel: 'error' suppresses lower-severity manual logs, not unlevelled spans or auto-instrumentation. It is supplementary to the tail callback.

Instrumentation still runs and tail sampling buffers undecided traces in browser memory. Check a long-running/high-volume application before recommending this profile for lower client overhead. Existing metrics/custom instrumentations may emit additional signals; review them rather than promising that these options silence every provider in the application.

Minimal errors and replays

For lower instrumentation overhead, disable automatic spans and RUM performance signals while keeping replay and explicit error reporting:

const frontend = logfire.configureFrontend({
  ...frontendOptions,
  autoInstrumentations: false,
  rum: { webVitals: false, longAnimationFrames: false },
  minLevel: 'error',
  sessionReplay: sessionReplayIntegration({
    maskAllText: true,
    maskAllInputs: true,
    captureConsole: false,
    blockSelector: '[data-logfire-block]',
  }),
})

Keep the SDK's default global error capture and framework boundary reporting from setup. Remove unwanted explicitly registered instrumentations and manual unlevelled spans if strict signal limits are required. Normal Frontend page-load, performance, and request charts will have little or no data from this configuration. The replay may still contain network/navigation events; those are recorder data, not automatic OTLP request spans.

Browser-session inactivity currently follows span activity, not replay events. With few error spans, an actively used page can therefore rotate its session ID after the idle timeout. Verify long recordings rather than assuming one replay ID lasts for the whole page or login session.

Choose replay sampling separately

Preserve the existing replay policy unless changing it is part of the request. sessionSampleRate controls continuous recording. onErrorSampleRate keeps an in-memory buffer for other eligible sessions and promotes it on uncaught window.error or unhandledrejection events. logfire.reportError() also promotes the buffer through the browser SDK's replay integration. Caught errors and console.error alone do not promote it: report handled failures explicitly from framework boundaries or catch blocks when they should preserve a replay.

For a deterministic local verification recording, use sessionSampleRate: 1 and onErrorSampleRate: 0. That is a test override, not a production rate to apply silently. Replay uploads are independent of the trace sampler. Recordings shorter than minSessionDurationMs are not uploaded; the current default is 10 seconds. Preserve that default outside tests unless shorter recordings are required.

Sources: SDK trace sampling, recorder sampling, and browser replay configuration.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Pydantic
Publisher
Pydantic (Official)
Source
pydantic/skills · skills/logfire-frontend · commit 98f591c
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced
Also distributed in
pydantic/skills

AutoGineer is not affiliated with or endorsed by Pydantic.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download logfire-frontend.zip