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

@firebuzz/analytics

v1.7.6

Published

Analytics tracking for Firebuzz landing pages

Downloads

77

Readme

@firebuzz/analytics

Analytics tracking for Firebuzz landing pages hosted outside the monorepo.

Installation

# For testing (beta version)
npm install @firebuzz/analytics@beta

# For production (stable version)  
npm install @firebuzz/analytics

Usage

Basic Setup

import { AnalyticsProvider } from '@firebuzz/analytics';

function App() {
  return (
    <AnalyticsProvider
      apiUrl="https://engine.firebuzz.com"
      campaignId="campaign_123"
      workspaceId="workspace_456"
      projectId="project_789"
      landingPageId="landing_abc"
    >
      {/* Your landing page content */}
    </AnalyticsProvider>
  );
}

Manual Event Tracking

import { useAnalytics } from '@firebuzz/analytics';

function MyComponent() {
  const { trackEvent } = useAnalytics();
  
  const handleCustomEvent = async () => {
    const success = await trackEvent({
      event_id: 'custom-action',
      event_type: 'conversion',
      event_value: '25',
      event_value_type: 'static',
      metadata: JSON.stringify({ source: 'button-click' })
    });
    
    console.log('Event tracked:', success);
  };
  
  return <button onClick={handleCustomEvent}>Track Custom Event</button>;
}

Features

Automatic Event Tracking

The analytics package automatically tracks:

  • System Events: Page load, DOM ready
  • Engagement Events: Pageview, scroll (25/50/75/100%), external link clicks with UTM forwarding
  • Conversion Events: Form submissions

Session Management

  • Automatic session initialization from cookies
  • Session renewal when expired
  • AB test data preservation across session renewals
  • Environment detection (preview vs production)

External Link Enhancement

External links are automatically enhanced with:

  • UTM Parameters: Forwards current page's UTM parameters
  • Tracking Tokens: Adds secure JWT tokens for cross-domain attribution
  • Automatic Detection: Only external links are enhanced
<!-- Original link -->
<a href="https://external-site.com">Click here</a>

<!-- Enhanced automatically -->
<a href="https://external-site.com?utm_source=firebuzz&frbzz_token=eyJ...">Click here</a>

Analytics Control

  • Global Disable: Set enabled={false} to disable all tracking
  • Selective Disable: Set enableDefaultEvents={false} to disable automatic events only
  • Debug Mode: Set debug={true} to see console logs

Cookie Integration

Reads campaign-scoped cookies:

  • frbzz_{campaign_id}_session - Session data with AB test info
  • frbzz_{campaign_id}_attribution - Attribution tracking
  • frbzz_uid or frbzz_uid_{campaign_id} - User identification

API Reference

AnalyticsProvider Props

interface AnalyticsProviderProps {
  apiUrl: string;                      // Engine API URL
  campaignId: string;                  // Campaign identifier
  workspaceId: string;                 // Workspace identifier  
  projectId: string;                   // Project identifier
  landingPageId: string;              // Landing page identifier
  customEvents?: CustomEventConfig[]; // Custom event configurations
  cookiePrefix?: string;              // Cookie prefix (default: "frbzz_")
  enableDefaultEvents?: boolean;      // Enable automatic tracking (default: true)
  enabled?: boolean;                  // Enable/disable entire analytics system (default: true)
  debug?: boolean;                    // Enable debug logging (default: false)
  children: React.ReactNode;
}

TrackEvent Parameters

interface TrackEventParams {
  event_id: string;              // Event identifier (e.g., "form-submission")
  event_type: 'conversion' | 'engagement' | 'system';
  event_value?: string;          // Event value as string (e.g., "10")
  event_value_type?: 'static' | 'dynamic';
  
  // Optional event-specific data
  form_id?: string;
  clicked_element?: string;
  clicked_url?: string;
  scroll_percentage?: number;
  time_on_page?: number;
  viewport_width?: number;
  viewport_height?: number;
  metadata?: string;
  page_url?: string;
  referrer_url?: string;
}

useAnalytics Hook

const { trackEvent, sessionId, userId, isInitialized, debug } = useAnalytics();

Event Types

System Events

  • pageload - Page load complete
  • domready - DOM ready

Engagement Events

  • pageview - Page viewed
  • scroll - Scroll milestones (25%, 50%, 75%, 100%)
  • external-link-click - External link clicked
  • time-on-page - Time spent on page

Conversion Events

  • form-submission - Form submitted

Advanced Usage

Cookie Utilities

import { 
  getSessionData, 
  getAbTestData, 
  isSessionValid,
  getAllCookieData 
} from '@firebuzz/analytics';

// Get session information
const sessionData = getSessionData('campaign_123');
const abTest = getAbTestData('campaign_123');
const isValid = isSessionValid(sessionData);

// Debug cookie data
console.log('All cookies:', getAllCookieData('campaign_123'));

Manual API Configuration

import { configureApiClient, trackEvent } from '@firebuzz/analytics';

configureApiClient({
  apiUrl: 'https://engine.firebuzz.com',
  campaignId: 'campaign_123',
  workspaceId: 'workspace_456', 
  projectId: 'project_789',
  landingPageId: 'landing_abc'
});

// Track events without provider
await trackEvent({
  event_id: 'manual-event',
  event_type: 'engagement'
});

Error Handling

The package handles:

  • Session expiry with automatic renewal
  • Missing cookie data
  • Network failures with retries
  • Invalid event data

All errors are logged to console when debug: true is enabled.

Browser Compatibility

  • Modern browsers with ES2020+ support
  • React 18+
  • SSR compatible

License

MIT