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 🙏

© 2025 – Pkg Stats / Ryan Hefner

small-wins-sdk

v1.3.1

Published

visualise client click events on a global map

Readme

Small Wins SDK

A lightweight SDK for visualizing client click events on a global map. Track user interactions and events from your web application with ease.

Installation

Install the package using npm:

npm install small-wins-sdk

Or using yarn:

yarn add small-wins-sdk

Or using pnpm:

pnpm add small-wins-sdk

Usage

ES Modules (ESM)

import { Visualize } from 'small-wins-sdk';

// Initialize the SDK with your app ID
const visualize = new Visualize({
  app_id: 'your-app-id-here',
});

// Track an event
visualize.track('button-click');

// Track an event with additional payload data
visualize.track('purchase', {
  productId: '12345',
  amount: 99.99,
  currency: 'USD',
});

CommonJS

const { Visualize } = require('small-wins-sdk');

// Initialize the SDK with your app ID
const visualize = new Visualize({
  app_id: 'your-app-id-here',
});

// Track an event
visualize.track('button-click');

Browser (ESM)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My App</title>
</head>
<body>
    <button id="my-button">Click Me</button>

    <script type="module">
        import { Visualize } from './node_modules/small-wins-sdk/dist/index.js';

        const visualize = new Visualize({
            app_id: 'your-app-id-here',
        });

        document.getElementById('my-button').addEventListener('click', () => {
            visualize.track('button-click', {
                buttonId: 'my-button',
                timestamp: Date.now(),
            });
        });
    </script>
</body>
</html>

API Reference

Visualize Class

Constructor

new Visualize(options: VisualizeOptions)

Options:

  • app_id (string, required): Your application identifier

Example:

const visualize = new Visualize({
  app_id: 'my-app-id'

});

Methods

track(eventName: string, payload?: Record<string, any>)

Tracks an event and sends it to the configured endpoint.

Parameters:

  • eventName (string, required): The name of the event to track
  • payload (object, optional): Additional data to include with the event

Example:

// Simple event tracking
visualize.track('page-view');

// Event tracking with payload
visualize.track('user-signup', {
  userId: 'user-123',
  email: '[email protected]',
  plan: 'premium',
});

TypeScript Support

The package includes TypeScript definitions. Import types as needed:

import { Visualize, VisualizeOptions, EventPayload } from 'small-wins-sdk';

const options: VisualizeOptions = {
  app_id: 'my-app-id',
};

const visualize = new Visualize(options);

Event Data Structure

Events are automatically sent with the following structure:

{
  "eventName": "button-click",
  "payload": {
    "buttonId": "my-button"
  },
  "timestamp": "2024-01-15T10:30:00.000Z"
}

Notes

  • Events are sent asynchronously using the Fetch API
  • The SDK uses keepalive: true to ensure events are sent even if the user navigates away
  • Errors are logged to the console but do not throw exceptions
  • The SDK works in both browser and Node.js environments

License

ISC