npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xcelsior/monitoring

v1.0.4

Published

Monitoring Utils

Readme

@xcelsior/monitoring

Application monitoring and error tracking service for Xcelsior applications. Supports both Sentry and Rollbar providers.

Installation

pnpm add @xcelsior/monitoring

Features

Provider Support

Choose between Sentry and Rollbar for error tracking and monitoring:

import { Monitor } from '@xcelsior/monitoring';

// Using Sentry
const sentryMonitor = new Monitor({
  provider: 'sentry',
  service: 'user-service',
  environment: 'production',
  sentry: {
    dsn: process.env.SENTRY_DSN,
    tracesSampleRate: 0.1,
  },
});

// Using Rollbar
const rollbarMonitor = new Monitor({
  provider: 'rollbar',
  service: 'user-service',
  environment: 'production',
  rollbar: {
    accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
  },
});

Error Tracking

Capture and track application errors:

// Capture error
monitor.captureException(new Error('Something went wrong'), {
  user: { id: '123' },
  tags: { component: 'auth' },
});

// Capture message
monitor.captureMessage('Important event occurred', {
  level: 'info',
  extra: { details: 'some details' },
});

Performance Monitoring

Track application performance:

// Track function execution time
const result = await monitor.trackPerformance(
  'database-query',
  async () => {
    return await db.query();
  }
);

// Manual performance tracking
const span = monitor.startSpan('api-request');
try {
  await apiCall();
} finally {
  span.finish();
}

Health Checks

Monitor service health:

const health = monitor.healthCheck({
  database: async () => {
    await db.ping();
    return { status: 'healthy' };
  },
  redis: async () => {
    await redis.ping();
    return { status: 'healthy' };
  },
});

// Get health status
const status = await health.check();

Configuration

Monitor Options

interface MonitoringConfig {
  provider: 'sentry' | 'rollbar';
  service: string;
  environment: string;
  release?: string;
  sampleRate?: number;
  ignoreErrors?: (string | RegExp)[];
  enabled?: boolean;
  
  // Sentry-specific configuration
  sentry?: {
    dsn: string;
    tracesSampleRate?: number;
    profilesSampleRate?: number;
  };
  
  // Rollbar-specific configuration
  rollbar?: {
    accessToken: string;
    captureUncaught?: boolean;
    captureUnhandledRejections?: boolean;
  };
}

Environment Variables

For Sentry:

SENTRY_DSN=your_sentry_dsn_here

For Rollbar:

ROLLBAR_ACCESS_TOKEN=your_rollbar_access_token_here

Integration Options

// Express integration
app.use(monitor.expressHandler());

// Lambda integration
export const handler = monitor.wrapLambda(async (event) => {
  // Your handler logic
});

// Custom integration
monitor.addIntegration({
  name: 'custom',
  setup: (client) => {
    // Setup logic
  },
});

Advanced Usage

Custom Context

Add custom context to all events:

monitor.setContext('user', {
  id: '123',
  email: '[email protected]',
});

monitor.setTag('region', 'us-east-1');
monitor.setExtra('deploymentInfo', {
  version: '1.0.0',
  timestamp: Date.now(),
});

Breadcrumbs

Track application flow:

monitor.addBreadcrumb({
  category: 'auth',
  message: 'User login attempt',
  level: 'info',
  data: { userId: '123' },
});

Transaction Monitoring

Track complex operations:

const transaction = monitor.startTransaction('order-process');

try {
  const span1 = transaction.startSpan('validate-cart');
  await validateCart();
  span1.finish();

  const span2 = transaction.startSpan('process-payment');
  await processPayment();
  span2.finish();

  transaction.finish();
} catch (error) {
  transaction.finish(error);
  throw error;
}

Best Practices

Error Handling

try {
  await riskyOperation();
} catch (error) {
  monitor.captureError(error, {
    tags: { operation: 'riskyOperation' },
    extra: { input: input },
    user: { id: userId },
  });
  throw error;
}

Performance Tracking

const middleware = async (req, res, next) => {
  const transaction = monitor.startTransaction(req.path);
  
  res.on('finish', () => {
    transaction.finish({
      status: res.statusCode,
      duration: Date.now() - req.startTime,
    });
  });

  next();
};

Custom Metrics

monitor.trackMetric('queue_size', 10);
monitor.trackMetric('response_time', 150, {
  tags: { endpoint: '/api/users' },
});

Migration from Legacy API

The package maintains backward compatibility with the legacy captureException function:

// Legacy API (still supported)
import { captureException } from '@xcelsior/monitoring';

captureException({
  err: new Error('Something went wrong'),
  logLevel: 'error',
  tags: { component: 'auth' },
});

However, we recommend migrating to the new Monitor class for better functionality and provider flexibility.

License

MIT