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

@pixels-online/pixels-analytics-node-sdk

v1.86.0

Published

Pixels Analytics Node.js SDK

Readme

Pixels Analytics Node.js SDK

A TypeScript SDK for batching and sending analytics events to the Pixels event tracking API, with built-in retry, batching, and graceful shutdown support.

Features

  • Batching: Events are queued and sent in batches (default: 100, configurable).
  • Automatic Flushing: Events are sent every 5 seconds or when the batch size is reached.
  • Exponential Backoff: Retries failed requests with exponential backoff (default: 3 retries).
  • Graceful Shutdown: Flushes the queue on process exit or termination signals.
  • Strong Typing: TypeScript types for all supported event payloads.
  • Supports Test and Live Environments.
  • Native fetch: Requires Node.js 18+ (uses global fetch, no axios dependency).

Installation

npm install @pixels-online/pixels-analytics-node-sdk

Usage

import PixelsAnalytics from '@pixels-online/pixels-analytics-node-sdk';

const analytics = new PixelsAnalytics({
  apiKey: 'YOUR_API_KEY',
  clientId: 'YOUR_CLIENT_ID',
  env: 'test', // or 'live'
});

// Track a sign-in event
analytics.signIn('playerId123', {
  platform: 'email',
  platform_identifier: '[email protected]',
});

// Track a custom event (snake_case event name is enforced)
analytics.custom('custom_event', 'playerId123', { foo: 'bar' });

Event Tracking Methods

  • gainAchievement(playerId, payload, timestamp?)
  • loseAchievement(playerId, payload, timestamp?)
  • referUser(payload, timestamp?)
  • addTags(payload, timestamp?)
  • removeTags(payload, timestamp?)
  • signIn(playerId, payload, timestamp?)
  • signUp(playerId, payload, timestamp?)
  • trustScore(playerId, payload, timestamp?)
  • identifierLink(playerId, payload, timestamp?)
  • gainMembership(playerId, payload, timestamp?)
  • renewMembership(playerId, payload, timestamp?)
  • loseMembership(playerId, payload, timestamp?)
  • spendCurrency(playerId, payload, timestamp?)
  • earnCurrency(playerId, payload, timestamp?)
  • withdrawCurrency(playerId, payload, timestamp?)
  • depositCurrency(playerId, payload, timestamp?)
  • gainItem(playerId, payload, timestamp?)
  • gainManyItems(playerId, payload, timestamp?)
  • loseItem(playerId, payload, timestamp?)
  • loseManyItems(playerId, payload, timestamp?)
  • playerToPlayerTrade(payload, timestamp?)
  • funnelStart(playerId, payload, timestamp?)
  • funnelProgression(playerId, payload, timestamp?)
  • funnelEnd(playerId, payload, timestamp?)
  • questStart(playerId, payload, timestamp?)
  • questProgression(playerId, payload, timestamp?)
  • questEnd(playerId, payload, timestamp?)
  • levelUp(playerId, payload, timestamp?)
  • custom(eventName, playerId, payload, timestamp?) — Track a custom event (eventName is always converted to lower snake_case)

Offer Methods

fetchPlayerCampaigns(playerId, options?) This method refreshes a player's offers and then returns their current list of in-game offers.

claimRewards({kind: 'offer', instanceId, playerId}) This method allows you to claim an offer for a given player. By calling this method, it will mark the offer as "claimed" and then it will return an array of rewards which you will need to handle in your server.

See src/types.ts for detailed payload structures and type definitions.

Configuration Options

Pass an options object to the PixelsAnalytics constructor:

{
  apiKey: string;
  clientId: string;
  env: 'test' | 'live';
  maxBatchSize?: number; // default 100
  flushInterval?: number; // ms, default 5000
  maxRetries?: number; // default 3
}

Graceful Shutdown

The SDK automatically flushes the event queue on SIGINT, SIGTERM, or process exit.

Requirements

  • Node.js 18+ (for native fetch support)
  • TypeScript (for type safety, optional for JS usage)

Migration Notes

  • v2: Uses native fetch, not axios. No axios dependency required.
  • Event name normalization: The generic/custom method always converts event names to lower snake_case.

License

AGPLv3