finnear
v0.1.3
Published
Official Node.js SDK for Finnear - Push notification platform for founders & developers
Maintainers
Readme
Finnear Node.js SDK
Official Node.js SDK for Finnear - Push notification platform for founders & developers.
Installation
npm install finnearQuick Start
import { Finnear } from 'finnear';
const finnear = new Finnear({ apiKey: 'pk_...' });
await finnear.track({
channel: 'signups',
title: 'New user signed up',
description: '[email protected]',
emoji: '🙋',
metadata: { plan: 'pro' },
});API
new Finnear(config)
| Option | Type | Required | Description |
| -------- | -------- | -------- | -------------------- |
| apiKey | string | Yes | Your Finnear API key |
finnear.track(event)
Send an event to Finnear. Returns a Promise<{ eventId: string }>.
| Field | Type | Required | Description |
| ------------- | ------------------------ | -------- | ------------------ |
| channel | string | Yes | Event channel |
| title | string | Yes | Event title |
| description | string | No | Event description |
| emoji | string | No | Event emoji icon |
| userId | string | No | Associated user ID |
| metadata | Record<string, string> | No | Key-value metadata |
Error Handling
import { AuthenticationError, ValidationError, ApiError } from 'finnear';
try {
await finnear.track({ ... });
} catch (error) {
if (error instanceof AuthenticationError) {
// Invalid API key (401)
} else if (error instanceof ValidationError) {
// Invalid payload (400)
} else if (error instanceof ApiError) {
// Other HTTP error
console.error(error.status, error.message);
}
}Requirements
- Node.js 18+ (uses native
fetch)
License
MIT
