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

@bklit/sdk

v0.3.0

Published

A lightweight analytics SDK for tracking page views, sessions, and user behavior.

Readme

Bklit Analytics SDK

A lightweight analytics SDK for tracking page views, sessions, and user behavior.

Installation

npm install @bklit/sdk
# or
pnpm add @bklit/sdk

Quick Start

Vanilla JavaScript / React

import { initBklit } from "@bklit/sdk";

// Initialize the SDK
initBklit({
  projectId: "your-project-id",
  apiKey: "your-api-key",
  debug: true, // Optional - enables console logging
});

Next.js

For Next.js applications, use the BklitComponent:

import { BklitComponent } from "@bklit/sdk/nextjs";

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html>
      <body>
        <BklitComponent
          projectId="your-project-id"
          apiKey="your-api-key"
          debug={process.env.NODE_ENV === "development"}
        />
        {children}
      </body>
    </html>
  );
}

Get your projectId and apiKey from your Bklit Dashboard.

Configuration Options

BklitComponent (Next.js)

Props:

  • projectId (string, required) - Your unique project identifier
  • apiKey (string, optional) - Your API authentication token
  • apiHost (string, optional) - API endpoint URL. Defaults to https://app.bklit.com/api/track
  • environment (string, optional) - Environment mode: "development" or "production". Defaults to "production"
  • debug (boolean, optional) - Enable debug logging. Defaults to false

initBklit(options)

Required Parameters:

  • projectId (string) - Your unique project identifier from the Bklit dashboard
  • apiKey (string) - Your API authentication token from the Bklit dashboard

Optional Parameters:

  • apiHost (string) - API endpoint URL. Defaults to https://app.bklit.com/api/track
  • environment (string) - Set to "development" for local testing. Defaults to "production"
  • debug (boolean) - Enable detailed console logging. Defaults to false

Example with All Options

initBklit({
  projectId: "your-project-id",
  apiKey: "your-api-key",
  apiHost: "https://app.bklit.com/api/track", // Optional
  environment: "production", // Optional
  debug: false, // Optional
});

Console Logging

When debug: true is enabled, the SDK provides detailed console logs to help you monitor tracking events.

Note: Error messages (using console.error and console.warn) will always appear regardless of the debug setting.

Example Debug Output

🎯 Bklit SDK: Initializing with configuration {
  projectId: "your-project-id",
  apiHost: "https://app.bklit.com/api/track",
  environment: "production",
  debug: true
}

🆔 Bklit SDK: New session created {
  sessionId: "1703123456789-abc123def456"
}

🚀 Bklit SDK: Tracking page view... {
  url: "https://yoursite.com/page",
  sessionId: "1703123456789-abc123def456",
  projectId: "your-project-id"
}

✅ Bklit SDK: Page view tracked successfully!

Features

Automatic Tracking

  • Page View Tracking - Automatically tracks when pages load
  • Session Management - Creates and manages user sessions across page visits
  • SPA Support - Detects route changes in single-page applications
  • Session Ending - Automatically ends sessions when users close the tab

Event Tracking

Track user interactions automatically with data attributes or IDs:

<!-- Using data attribute -->
<button data-bklit-event="cta-signup">Sign Up</button>

<!-- Using ID -->
<button id="bklit-event-cta-login">Login</button>

The SDK automatically tracks:

  • Click events - When users click the element
  • View events - When the element becomes visible (50% threshold)
  • Hover events - When users hover for 500ms

Manual Tracking

Track Page Views

window.trackPageView();

Useful for custom routing or manual page tracking.

Track Custom Events

window.trackEvent(
  "purchase-button", // trackingId
  "click", // eventType: "click", "view", "hover", or custom
  {
    // metadata (optional)
    product: "Pro Plan",
    price: 29.99,
  },
  "manual", // triggerMethod: "automatic" or "manual"
);

UTM Parameter Tracking

The SDK automatically captures UTM parameters from the URL:

  • utm_source
  • utm_medium
  • utm_campaign
  • utm_term
  • utm_content

These are included with every page view event.

API Reference

initBklit(options)

Initialize the Bklit SDK.

Parameters:

  • options.projectId (string, required) - Your unique project identifier
  • options.apiKey (string, required) - Your API authentication token
  • options.apiHost (string, optional) - API endpoint URL. Defaults to https://app.bklit.com/api/track
  • options.environment (string, optional) - Environment mode: "development" or "production". Defaults to "production"
  • options.debug (boolean, optional) - Enable debug logging. Defaults to false

window.trackPageView()

Manually trigger a page view tracking event.

Returns: void

window.trackEvent(trackingId, eventType, metadata?, triggerMethod?)

Manually trigger a custom event.

Parameters:

  • trackingId (string, required) - Unique identifier for the event
  • eventType (string, required) - Type of event: "click", "view", "hover", or custom
  • metadata (object, optional) - Additional data to attach to the event
  • triggerMethod (string, optional) - "automatic" or "manual". Defaults to "manual"

Returns: void

window.clearBklitSession()

Clear the current session (useful for testing).

Returns: void

Support

License

MIT