Add authentication, analytics, error tracking, and payments to your app in minutes. One API key, one SDK, everything you need.
Install the SDK and initialize it with your API key from the Dashboard → Settings.
npm install syntro-sdkimport { Syntro } from 'syntro-sdk';
const syntro = new Syntro('sk_your_api_key');Track custom business events to build analytics dashboards.
// Track a custom event
await syntro.event('CUSTOM', 'cart_add', 'User added product to cart', {
productId: 'prod_123',
category: 'electronics'
});
// Get analytics stats
const stats = await syntro.getStats();
// stats.summary = { custom: 12, error: 3, auth: 8, total: 23 }
// List raw events
const { events, total } = await syntro.listEvents({
type: 'CUSTOM', limit: 20
});Track errors from your application. They appear in the Analytics → Errors tab.
// Track an error
await syntro.sendError('checkout_failed', 'Error loading checkout', {
page: '/checkout',
statusCode: 500,
stack: error.stack
});
// Errors show up in Analytics → Errors tab with count and last seenFull user authentication for your app. Register, login, manage users and metadata.
// Register a new user
const { user, token, error } = await syntro.register(
'johndoe', 'john@email.com', 'password123'
);
// Login
const { user, token } = await syntro.login('johndoe', 'password123');
// Verify JWT token (e.g. in your server middleware)
const { valid, user } = await syntro.verifyToken(token);
// Get user info
const username = await syntro.getUsername(userId);
const email = await syntro.getUserEmail(userId);
const metadata = await syntro.getMetadata(userId);
// Update metadata (merge)
await syntro.updateMetadata(userId, { plan: 'pro', role: 'admin' });
// Delete a user
await syntro.deleteUser(userId);Accept payments with Stripe in 3 steps.
Step 1: Configure Stripe
Go to Settings → Stripe in your Syntro project. Add your Stripe Secret Key and Webhook Secret.
Step 2: Add Webhook in Stripe
In Stripe Dashboard → Developers → Webhooks, create a new endpoint:
URL: https://api.syntro.run/v1/billing/webhook/<PROJECT_ID>
Event: checkout.session.completedStep 3: Create Payment
const { url, error } = await syntro.createPayment('Pro Plan', 999, {
currency: 'usd',
successUrl: 'https://yourapp.com/success',
cancelUrl: 'https://yourapp.com/cancel',
customerEmail: 'customer@email.com'
});
// Redirect to Stripe Checkout
if (url) window.location.href = url;payment_completed event automatically.| Method | Description |
|---|---|
| event(type, name, msg?, meta?) | Track any event |
| sendError(name, msg?, meta?) | Track an ERROR event |
| getStats(type?) | Get analytics stats |
| listEvents(opts?) | List raw events |
| register(user, email, pass) | Register user |
| login(username, password) | Login with username |
| loginWithEmail(email, pass) | Login with email |
| verifyToken(token) | Verify JWT |
| getUser(userId) | Get user by ID |
| getUsername(userId) | Get username |
| getUserEmail(userId) | Get email |
| getMetadata(userId) | Get metadata |
| updateMetadata(userId, data) | Merge-update metadata |
| updateUser(userId, data) | Update user |
| deleteUser(userId) | Delete user |
| listUsers(opts?) | List users |
| createPayment(name, amount) | Create Stripe checkout |
| listTransactions(opts?) | List transactions |