frontend-observability

Implements typed analytics event tracking with consent-gated provider fan-out for React apps.

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill frontend-observability-duccuong159
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: frontend-observability
Source: https://github.com/DucCuong159/Realtime-chatapp/tree/main/.agent/skills/frontend-observability
Command: npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill frontend-observability-duccuong159

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires web-vitals, firebase, @react-native-firebase/analytics.

What problem does it solve? Scattered, stringly-typed analytics calls and fragile third-party provider scripts make frontend telemetry unreliable and risky: a failing vendor script can crash the app, event names drift across the codebase, and telemetry may fire before user consent. This Skill establishes a single typed event taxonomy and a best-effort, non-blocking fan-out so analytics never breaks the app. ## Core Features & Use Cases - Typed Event Taxonomy: Canonical event-name constants with a union type, so typos become compile errors and the catalog is reviewable in one file. - Best-Effort Provider Fan-Out: A single track() entry point dispatches to window-guarded adapters (GA4, Clarity, Firebase web and React Native, PostHog, Sentry), each individually try/caught so one failing provider never affects the app or other providers. - Field Web Vitals & Consent Gating: Real-user LCP/INP/CLS reported through the same fan-out, with consent checked once at the boundary so nothing fires before opt-in. - Use Case: Add analytics to a Next.js or Expo app by creating constants/analytics.ts, a services/analytics module, and an AnalyticsProvider, then track typed events from client components with SSR-safe no-op behavior outside the provider. ## Quick Start Ask the AI to set up typed analytics tracking with a consent-gated provider fan-out in your React app following the frontend-observability skill.

Frequently Asked Questions about frontend-observability

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add typed analytics event tracking to a React app?

Define canonical event names as constants in a constants/analytics.ts file with a union type, then call track() with those constants from client components via a useAnalytics() hook. The union type makes event-name typos a compile error instead of silent data drift.

How do I prevent analytics providers from crashing my app?

Wrap each provider adapter call in its own try/catch inside a single track() fan-out, and guard every adapter against missing window globals or unloaded scripts. A failing or absent provider then no-ops without throwing into the caller or blocking other providers.

Does Firebase Analytics work with both web and React Native?

Yes, one adapter shape covers both platforms because the web firebase/analytics SDK and @react-native-firebase/analytics share the same logEvent(name, params) contract. Resolve the platform variant by file extension so the taxonomy, fan-out, and consent gate stay unchanged.

Can I use analytics tracking in Next.js Server Components?

Server Components cannot use the useAnalytics() hook, so wrap tracked elements in thin client components. The hook returns a no-op outside a provider or on the server, so instrumented components render safely anywhere including SSR trees.

How do I gate analytics on user consent for GDPR compliance?

Check consent once at the track() fan-out boundary rather than at every call site, defaulting consent to false where regulations require. No events, web vitals, or error reports with PII fire before opt-in, and event props should use ids and enums instead of emails or names.

Why report web vitals through the same analytics fan-out?

Reporting real-user LCP, INP, and CLS through the same fan-out closes the lab/field loop with synthetic Lighthouse budgets using identical metrics and thresholds. A lab-green but field-poor result reveals gaps between test conditions and real devices or networks.