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

datafast

v2.1.2

Published

Analytics SDK for DataFast — Web and React Native

Readme

DataFast logo

datafast

Official DataFast SDK for web apps. Use this if you prefer npm packages over the script tag.

Installation

npm install datafast

Quick Start

Same API as in the DataFast docs: use initDataFast once, then call trackPageview(), track(), identify(), and trackPayment(). All methods are async and return Promises.

import { initDataFast } from 'datafast';

const datafast = await initDataFast({
  websiteId: 'your-website-id',
  domain: 'yourdomain.com', // optional, defaults to current hostname
  autoCapturePageviews: true, // optional: capture initial + SPA route changes
});

// Track page views
datafast.trackPageview();
// Or pass a path (e.g. for SPAs)
datafast.trackPageview('/pricing');

// Track custom events
datafast.track('button_click', { button: 'signup' });

// Identify users
datafast.identify('user_123', { email: '[email protected]', plan: 'pro' });

// Track payments (email-based)
datafast.trackPayment({ email: '[email protected]', amount: 99, currency: 'USD' });

// Or provider-ID based payment tracking
datafast.trackPayment({ stripe_session_id: 'cs_test_123' });

// Reset visitor identity (e.g. on logout)
datafast.reset();

With React / Next.js

// lib/analytics.ts
import { initDataFast } from 'datafast';

let datafast: Awaited<ReturnType<typeof initDataFast>> | null = null;

export async function getAnalytics() {
  if (!datafast) {
    datafast = await initDataFast({
      websiteId: process.env.NEXT_PUBLIC_DATAFAST_WEBSITE_ID!,
      domain: process.env.NEXT_PUBLIC_DATAFAST_DOMAIN,
    });
  }
  return datafast;
}

Then in your app:

import { getAnalytics } from '@/lib/analytics';

export default function SignupButton() {
  const handleSignup = async () => {
    const analytics = await getAnalytics();
    analytics.track('signup', { plan: 'free', source: 'homepage' });
  };

  return <button onClick={handleSignup}>Sign Up</button>;
}

API

initDataFast(config)Promise<DataFastWeb>

Initialize the SDK. Returns a client with trackPageview, track, identify, trackPayment, reset, and flush.

Config (DataFastWebConfig)

{
  websiteId: string;        // Required: Your DataFast website ID
  domain?: string;          // Optional: Defaults to current hostname
  apiUrl?: string;          // Optional: Custom API endpoint
  debug?: boolean;          // Optional: Enable debug logging
  flushInterval?: number;   // Optional: ms between flushes (default: 5000)
  maxQueueSize?: number;    // Optional: max events before flush (default: 10)
  autoCapturePageviews?: boolean | {
    enabled?: boolean;          // Default true when object is provided
    trackHashChanges?: boolean; // Default false
    captureInitialPageview?: boolean; // Default true
    debounceMs?: number;        // Default 100
  };
  allowLocalhost?: boolean;   // Allow tracking on localhost (default: false)
  allowIframe?: boolean;      // Allow tracking inside iframes (default: false)
  allowedHostnames?: string[]; // Hostnames for cross-domain tracking
}

When autoCapturePageviews is enabled, the SDK will:

  • capture one initial pageview after initDataFast
  • capture subsequent pageviews on history.pushState, history.replaceState, and back/forward (popstate)
  • optionally include hash-route changes when trackHashChanges: true

By default, tracking is silently disabled on localhost, file:// protocol, inside iframes, and for bots/headless browsers. Set allowLocalhost: true for local development.

datafast.trackPageview(path?)Promise<void>

Track a page view. Omit path to use window.location.href (full URL including query params, UTMs, and ad click IDs). Pass a path for manual override. Duplicate pageviews for the same URL within 60 seconds are automatically skipped.

datafast.track(eventName, properties?)Promise<void>

Track a custom event. properties is optional and must be Record<string, string | number | boolean>.

await datafast.track('purchase', { product: 'Pro Plan', price: 99 });

datafast.identify(userId, properties?)Promise<void>

Identify a logged-in user.

await datafast.identify('user_123', { name: 'John', email: '[email protected]' });

datafast.trackPayment(data)Promise<void>

Track a payment. data must include one of: email, stripe_session_id, lemonsqueezy_order_id, polar_checkout_id, paddle_transaction_id. amount and currency are optional.

await datafast.trackPayment({ email: '[email protected]', amount: 99, currency: 'USD' });
await datafast.trackPayment({ stripe_session_id: 'cs_test_123' });

datafast.reset()Promise<void>

Reset visitor identity (e.g. on logout). New visitor and session IDs are generated.

datafast.flush()Promise<void>

Flush all queued events immediately.

datafast.getTrackingParams(){ _df_vid: string; _df_sid: string }

Get the current visitor and session IDs for cross-domain tracking.

datafast.buildCrossDomainUrl(url)string

Append visitor/session tracking params to a URL for cross-domain navigation.

const url = datafast.buildCrossDomainUrl('https://other-domain.com/signup');
// => 'https://other-domain.com/signup?_df_vid=abc-123&_df_sid=s456-789'

On the receiving domain, initDataFast automatically picks up the params and restores the visitor/session.

Script Tag Alternative

If you prefer not to use npm, add the script tag instead:

<script src="https://datafa.st/script.js" data-website-id="your-website-id" async defer></script>

License

MIT