nimba
v2.0.1
Published
A TypeScript npm package
Readme
Nimba API Reference
Nimba is a lightweight tracking library that allows you to monitor and increment entity counts with optional metadata.
Installation
npm install nimbayarn add nimbaAPI
trackEntity
Tracks an entity by adding a specified count and associating metadata.
trackEntity(entityName: string, count: number, metadata?: Record<string, any>): voidParameters
entityName(string): The name of the entity to track.count(number): The number to add to the total count of this entity.metadata(optional, object): Additional data to associate with this tracking event.
Example
import { Nimba } from 'nimba';
const nimba = new Nimba(process.env.NIMBA_API_KEY);
// Track a page view
nimba.trackEntity('pageView', 1, { page: '/home', referrer: 'google.com' });
// Track multiple items
nimba.trackEntity('purchase', 3, { productId: 'abc123', category: 'electronics' });increment
Increments the count of an entity by 1.
increment(entityName: string): voidParameters
entityName(string): The name of the entity to increment.
Example
import { Nimba } from 'nimba';
const nimba = new Nimba(process.env.NIMBA_API_KEY);
// Increment user login count
nimba.increment('user-login');
// Increment button click count
nimba.increment('button-click');Usage Notes
- Use
trackEntitywhen you need to track specific counts with additional context. - Use
incrementfor simple counter increments when you don't need to specify a custom count or metadata. - Both functions work with the same underlying entities, so you can use them interchangeably on the same entity names.
TypeScript Support
Nimba includes TypeScript definitions for all its functions.
