A lightweight performance monitoring & health tracking library for hyperwiz with Discord alerts, GDPR compliance, and smart request optimization.
Everything you need to monitor your APIs and get instant alerts when things go wrong.
Track performance of individual API requests with detailed timing and error information.
Monitor multiple API endpoints with automatic alerts and status tracking.
Get instant notifications when APIs go down with customizable Discord webhooks.
Works out of the box with sensible defaults. No complex setup required.
Full type safety and IntelliSense support for the best developer experience.
Minimal overhead with smart request optimization and efficient monitoring.
Get up and running with wizinsight in less than 2 minutes.
import { createClient } from 'hyperwiz'
import { initMetricsInterceptor } from 'wizinsight'
// Create your hyperwiz client
const client = createClient('https://api.example.com')
// Enable automatic metrics tracking
initMetricsInterceptor(client)
// All requests are now automatically tracked!
const users = await client.get('/users')
Track the performance of your API requests with detailed timing and error information.
import { createClient } from 'hyperwiz'
import { initMetricsInterceptor } from 'wizinsight'
const client = createClient('https://api.example.com')
initMetricsInterceptor(client)
// Console output:
// ✅ GET /users - 245ms - 200 OK
// ✅ POST /users - 180ms - 201 Created
// ❌ GET /invalid - 1200ms - 404 Not Found
initMetricsInterceptor(client, {
onRequestEnd: (metrics) => {
console.log(`🚀 ${metrics.method} ${metrics.url} took ${metrics.duration}ms`)
},
onRequestError: (metrics) => {
console.error(`💥 ${metrics.method} ${metrics.url} failed: ${metrics.errorMessage}`)
}
})
initMetricsInterceptor(client, {
onRequestEnd: (metrics) => {
// Alert on slow requests
if (metrics.duration > 1000) {
console.warn(`🐌 Slow request: ${metrics.method} ${metrics.url} took ${metrics.duration}ms`)
}
// Alert on errors
if (metrics.status >= 400) {
console.error(`❌ Error: ${metrics.method} ${metrics.url} returned ${metrics.status}`)
}
}
})
Monitor the health of multiple API endpoints with automatic alerts and status tracking.
Discover the key benefits that make health monitoring essential for modern applications
Catch issues before users do with intelligent monitoring that detects problems early
Get notified immediately when APIs go down with real-time Discord notifications
Keep track of API health over time with detailed metrics and historical data
Identify and fix issues quickly before they impact your users and business
import { initHealthMonitor, getHealthStatus } from 'wizinsight'
// Simple health monitoring
initHealthMonitor({
targets: [
{ name: 'User API', url: 'https://api.example.com/users' },
{ name: 'Auth API', url: 'https://auth.example.com/health' },
{ name: 'Database', url: 'https://db.example.com/ping' }
]
})
// Check current health status
const health = getHealthStatus()
console.log(health)
initHealthMonitor({
targets: [
{ name: 'Production API', url: 'https://api.production.com/health' },
{ name: 'Staging API', url: 'https://api.staging.com/health' }
],
interval: 30000, // Check every 30 seconds
discordWebhook: 'https://discord.com/api/webhooks/your-webhook-url',
alertCooldown: 600000 // 10 minutes between alerts
})
See how to use wizinsight in production environments with real API testing examples.
// In your main application file
import { createClient } from 'hyperwiz'
import { initMetricsInterceptor, initHealthMonitor } from 'wizinsight'
// Set up API client with metrics
const client = createClient('https://api.yourcompany.com')
initMetricsInterceptor(client, {
onRequestEnd: (metrics) => {
if (metrics.duration > 1000) {
console.warn(`Slow API call: ${metrics.url}`)
}
}
})
// Set up comprehensive health monitoring
initHealthMonitor({
targets: [
// Basic health check
{ name: 'Main API', url: 'https://api.yourcompany.com/health' },
// Test login
{
name: 'Login Service',
url: 'https://api.yourcompany.com/login',
method: 'POST',
body: { username: 'healthuser', password: 'healthpass' },
expectedStatus: 200
},
// Test registration
{
name: 'Registration',
url: 'https://api.yourcompany.com/register',
method: 'POST',
body: {
email: 'health@test.com',
password: 'testpass',
name: 'Health Test User'
},
expectedStatus: 201
},
// Test protected endpoint
{
name: 'User Profile',
url: 'https://api.yourcompany.com/user/profile',
method: 'GET',
headers: { 'Authorization': 'Bearer your-token-here' },
expectedStatus: 200
}
],
interval: 30000,
discordWebhook: process.env.DISCORD_WEBHOOK_URL
})
{
name: 'GraphQL API',
url: 'https://api.example.com/graphql',
method: 'POST',
body: { query: '{ __typename }' },
expectedStatus: 200
}
{
name: 'Auth API',
url: 'https://api.example.com/auth/verify',
method: 'POST',
body: { token: 'test-token' },
headers: { 'Authorization': 'Bearer test-token' },
expectedStatus: 200
}
{
name: 'File Upload',
url: 'https://api.example.com/upload',
method: 'POST',
body: 'test-data',
headers: { 'Content-Type': 'text/plain' },
expectedStatus: 201
}
{
name: 'Slow API',
url: 'https://api.example.com/slow',
timeout: 5000,
expectedStatus: 200
}
Comprehensive configuration options for all features.
Option | Description | Default |
---|---|---|
onRequestStart | Called when request starts | - |
onRequestEnd | Called when request completes | - |
onRequestError | Called when request fails | - |
collectRequestSize | Track request payload size | false |
collectResponseSize | Track response payload size | false |
Option | Description | Default |
---|---|---|
targets | Array of API endpoints to monitor | Required |
interval | Health check interval in milliseconds | 60000 |
discordWebhook | Discord webhook URL for alerts | - |
alertCooldown | Time between alerts in milliseconds | 900000 |
Start tracking your API performance and health in under 2 minutes.