npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@flash-analytics/astro

v2.2.0

Published

Analytics and error tracking for Astro apps.

Readme

Flash Analytics Astro SDK

Analytics and error tracking for Astro apps.

Install

npm install @flash-analytics/astro

Quick Start

Add the Flash Analytics component to your Astro layout:

---
import { FlashAnalyticsComponent } from '@flash-analytics/astro';
---

<html>
  <head>
    <FlashAnalyticsComponent
      appId="your-app-id"
      endpoint="https://api.flashanalytics.app"
      capturePageViews
    />
  </head>
  <body>
    <slot />
  </body>
</html>

Auto-Tracked Events

| Event | Trigger | |---|---| | page_view | Every page navigation when capturePageViews is enabled | | js_error | Uncaught JS exceptions when captureErrors is enabled | | unhandled_promise_rejection | Unhandled promise rejections when captureErrors is enabled |

Note: server_error is manual in Astro — you call trackServerError() yourself in middleware or API routes. This contrasts with Express where server_error is captured automatically by the error middleware.

Manual Tracking

import { track, identify } from '@flash-analytics/astro';

// Track a custom event
track('signup_completed', { plan: 'pro' });

// Identify a user
identify({ profileId: 'user-123', email: '[email protected]' });

Session Access

import { getSession } from '@flash-analytics/astro';

const session = getSession();

console.log(session?.id);
console.log(session?.estimatedExpiresAt);
console.log(session?.estimatedTtlMs);

Experiment Assignment

Enable captureVariants on the component for automatic assignment on session start and identify():

<FlashAnalyticsComponent
  appId="your-app-id"
  capturePageViews
  captureVariants
/>

For manual assignment or finer control, use the exported functions:

import { assignExperiment, autoAssignExperiments } from '@flash-analytics/astro';

// Single experiment
const variant = await assignExperiment('checkout-cta');

// All eligible experiments at once
const assignments = await autoAssignExperiments({ modes: ['session'] });

Error Tracking

Enable captureErrors to automatically capture client-side JS errors and unhandled promise rejections as js_error and unhandled_promise_rejection. No extra credentials needed — the component uses the SDK's own appId / secretKey / endpoint:

<FlashAnalyticsComponent
  appId="your-app-id"
  endpoint="https://api.flashanalytics.app"
  capturePageViews
  captureErrors
/>

Server-side errors (Astro middleware, API routes) must be tracked manually using trackServerError():

import { trackServerError } from '@flash-analytics/astro';

// In Astro middleware or an API route:
try {
  await riskyOperation();
} catch (err) {
  await trackServerError(err, {
    clientId: import.meta.env.FLASH_CLIENT_ID,
    clientSecret: import.meta.env.FLASH_CLIENT_SECRET,
    apiUrl: 'https://api.flashanalytics.app/track',
  });
  // optionally pass a custom event name as the third argument (default: 'server_error')
}

trackServerError() sends a server_error event directly from the server, so the secret key never reaches the browser.