@productpulse/sdk
v0.1.2
Published
ProductPulse analytics SDK — track product usage in minutes
Maintainers
Readme
@productpulse/sdk
One SDK to understand how users actually use your product.
Track events, identify users, capture errors, and view analytics in the ProductPulse dashboard.
Install
npm install @productpulse/sdk
npx @productpulse/sdk initinit creates config files — paste your API key after signup.
Quick start
1. Sign up & get your key
- Create an account
- Enter your app name (becomes your workspace)
- Go to Settings → copy your
pk_...API key
2. Paste key in config
After running npx @productpulse/sdk init, edit productpulse.config.js:
export default {
apiKey: "pk_your_key_here",
endpoint: "https://product-pulse-cloud-api.vercel.app",
debug: false,
};3. Import setup once
// Next.js: app/layout.tsx
// React/Vite: src/main.tsx
import "./productpulse.setup";4. Track events
import { ProductPulse } from "@productpulse/sdk";
ProductPulse.track("Signup Completed", { plan: "Pro" });
ProductPulse.identify("user_123", { email: "[email protected]", plan: "Pro" });
ProductPulse.revenue({ amount: 29, currency: "USD" });
ProductPulse.captureException(error);Files created by init
| File | Purpose |
|------|---------|
| productpulse.config.js | API key + endpoint |
| productpulse.setup.ts | Initializes SDK — import once |
| .env.example | Env var template (optional) |
Framework examples
Next.js (App Router)
app/layout.tsx:
import "../productpulse.setup";React (Vite)
src/main.tsx:
import "./productpulse.setup";Node.js / Express
import { ProductPulse } from "@productpulse/sdk";
ProductPulse.init({
apiKey: process.env.PRODUCTPULSE_API_KEY!,
endpoint: "https://product-pulse-cloud-api.vercel.app",
});
ProductPulse.track("Server Started");Environment variables
The SDK reads these automatically if apiKey is omitted from config:
# Node.js
PRODUCTPULSE_API_KEY=pk_your_key
PRODUCTPULSE_ENDPOINT=https://product-pulse-cloud-api.vercel.app
# Next.js (browser)
NEXT_PUBLIC_PRODUCTPULSE_API_KEY=pk_your_key
NEXT_PUBLIC_PRODUCTPULSE_ENDPOINT=https://product-pulse-cloud-api.vercel.app
# Vite (browser)
VITE_PRODUCTPULSE_API_KEY=pk_your_key
VITE_PRODUCTPULSE_ENDPOINT=https://product-pulse-cloud-api.vercel.appAPI reference
| Method | Description |
|--------|-------------|
| ProductPulse.init(config) | Initialize SDK |
| ProductPulse.track(name, props?) | Track custom event |
| ProductPulse.identify(id, traits?) | Identify user |
| ProductPulse.user.set(traits) | Update user properties |
| ProductPulse.page() | Page view |
| ProductPulse.revenue({ amount, currency }) | Track revenue |
| ProductPulse.captureException(error) | Track errors |
| ProductPulse.performance() | Page performance metrics |
Auto capture
ProductPulse.init({
apiKey: "pk_xxx",
endpoint: "https://product-pulse-cloud-api.vercel.app",
autoCapture: {
pageViews: true,
clicks: false,
formSubmissions: false,
scroll: false,
errors: true,
},
});Config options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| apiKey | string | — | Required. Your project API key |
| endpoint | string | Production API URL | Event ingestion endpoint |
| debug | boolean | false | Log SDK activity to console |
| autoCapture | boolean \| object | true | Auto-track page views, errors, etc. |
| batchSize | number | 10 | Events per batch |
| flushInterval | number | 5000 | Flush interval (ms) |
Links
Note: Use
@productpulse/sdkonly. The separate@productpulse/clipackage is deprecated.
License
MIT © RahimZahid
