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

vyzora-sdk

v0.2.4

Published

Vyzora Analytics SDK — lightweight, framework-agnostic client-side event tracking

Readme

vyzora-sdk

Lightweight, production-grade analytics SDK for Vyzora. Framework-agnostic, under 7KB minified, zero dependencies, built for reliability.

npm version License Bundle Size


Features

  • Framework Agnostic — Works with Vanilla JS, React, Next.js, Vue, Svelte, and any SPA.
  • Lightweight — < 7KB minified (~2KB gzipped). Zero runtime dependencies.
  • Resilient Batching — Batches events and flushes intelligently. Prevents empty sends, duplicate flushes, and race conditions.
  • Smart Transport — Uses navigator.sendBeacon for unload reliability, with fetch(keepalive) fallback.
  • Auto-Tracking — Collects browser, OS, screen, and language metadata automatically.
  • SPA Navigation — Wraps pushState and replaceState to track all client-side route changes.
  • Persistent Identity — Stable visitorId in localStorage (vyzora_vid). Falls back to in-memory if storage is unavailable.
  • Session Management — 30-minute inactivity-based session rotation. Stored in localStorage (vyzora_sid).
  • Privacy First — Explicit opt-in. Zero listeners and zero timers until enabled: true.
  • Safari Safe — All storage access wrapped in try/catch. Never crashes in private mode.

Installation

npm install vyzora-sdk
# or
yarn add vyzora-sdk
# or
pnpm add vyzora-sdk

Quick Start

import { Vyzora } from 'vyzora-sdk';

const vyzora = new Vyzora({
  apiKey: 'your_project_api_key',
  enabled: true,
});

The SDK starts tracking automatically: visitor ID is generated, session begins, and the initial pageview is recorded on window.load.


Framework Integration

Next.js (App Router)

Create a client component provider and add it to your root layout:

// components/VyzoraProvider.tsx
'use client';

import { useEffect } from 'react';
import { Vyzora } from 'vyzora-sdk';

export default function VyzoraProvider() {
  useEffect(() => {
    new Vyzora({
      apiKey: process.env.NEXT_PUBLIC_VYZORA_KEY!,
      enabled: process.env.NEXT_PUBLIC_VYZORA_ENABLED === 'true',
    });
  }, []);

  return null;
}
// app/layout.tsx
import VyzoraProvider from '@/components/VyzoraProvider';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html>
      <body>
        <VyzoraProvider />
        {children}
      </body>
    </html>
  );
}

React (CRA / Vite)

// src/main.tsx
import { Vyzora } from 'vyzora-sdk';

new Vyzora({
  apiKey: import.meta.env.VITE_VYZORA_KEY,
  enabled: true,
});

Vanilla JS (Script Tag)

<script src="https://cdn.jsdelivr.net/npm/vyzora-sdk/dist/index.mjs" type="module"></script>
<script type="module">
  import { Vyzora } from 'vyzora-sdk';
  new Vyzora({ apiKey: 'your_key', enabled: true });
</script>

Vue 3

// main.ts
import { createApp } from 'vue';
import App from './App.vue';
import { Vyzora } from 'vyzora-sdk';

new Vyzora({ apiKey: 'your_key', enabled: true });
createApp(App).mount('#app');

API Reference

new Vyzora(config)

Instantiates the SDK. No listeners or timers are created unless enabled: true.

const vyzora = new Vyzora({
  apiKey: 'your_project_api_key',  // Required
  enabled: true,
  debug: false,
  endpoint: 'https://api.vyzora.io/api/ingest',
  batchSize: 20,
  flushInterval: 10000,
});

vyzora.track(eventType, metadata?)

Track a custom event with optional metadata.

vyzora.track('button_click', {
  buttonId: 'upgrade-cta',
  plan: 'pro',
});

vyzora.track('purchase_completed', {
  amount: 49.99,
  currency: 'USD',
});

vyzora.pageview(path?)

Manually record a pageview. Path defaults to window.location.pathname + window.location.search. Duplicate paths are deduplicated automatically.

vyzora.pageview('/pricing');
vyzora.pageview(); // uses current URL

vyzora.identify(visitorId)

Link all future events to a known user identity (e.g., after login).

vyzora.identify('user_123456');

vyzora.flush()

Manually flush all queued events immediately.

await vyzora.flush();

vyzora.resetSession()

Force a new session ID on the next tracked event.

vyzora.resetSession();

vyzora.destroy()

Tear down the SDK — clears the flush interval and removes all event listeners.

vyzora.destroy();

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | apiKey | string | Required | Your project's API key from the Vyzora dashboard. | | enabled | boolean | false | Must be true to activate tracking. | | endpoint | string | https://api.vyzora.io/api/ingest | Backend ingest URL. Override for self-hosted deployments. | | batchSize | number | 20 | Max events per batch before an immediate flush is triggered. | | flushInterval | number | 10000 | Auto-flush interval in milliseconds (default: 10 seconds). | | debug | boolean | false | Enables verbose console logging in development. |


Build-Time Endpoint Configuration

For SDK contributors or self-hosted deployments, the default endpoint can be configured at build-time using a .env file:

# runtime-sdk/.env
VYZORA_API_URL=https://your-custom-api.com/api/ingest

Then rebuild:

npm run build

The URL is injected by tsup at compile time — no hardcoded URLs in source code.


Storage Keys

The SDK persists data to localStorage using the following keys:

| Key | Description | |-----|-------------| | vyzora_vid | Stable visitor UUID. Never rotates. | | vyzora_sid | Current session UUID. Rotates after 30 minutes of inactivity. | | vyzora_session_ts | Timestamp of last activity. Updated on every track() call. |

All storage access is wrapped in try/catch. If localStorage is unavailable (e.g., Safari private mode), visitor ID falls back to a stable in-memory value for the page lifetime.


Safety Guarantees

  • Zero global pollution — No window.* mutations, no prototype modifications.
  • No double flush — A flushing lock flag prevents concurrent send calls.
  • No duplicate intervalsstart() checks for an existing timer before creating one.
  • No duplicate pageviewslastTrackedPath (with full pathname + search) deduplicates SPA transitions.
  • No 4xx retries — Only 5xx and network errors trigger a single retry. 401/403/429 are dropped silently.
  • No crash guarantee — Every internal operation is wrapped in try/catch.

License

MIT © Vyzora