A comprehensive error logging solution providing both database-backed and direct notification approaches for modern applications.
SendErrorMessage is a collection of TypeScript libraries designed to solve different error logging needs:
error-logger-sendSMS
- Direct Discord/Slack notifications without database dependenciessupabase-error-logger
- Database-backed error logging with Supabase integration
Both libraries provide Sentry-style APIs (captureException
/captureMessage
) with different storage strategies to fit various application architectures.
Zero-database error logging with instant Discord/Slack notifications
npm install error-logger-sendsms
Key Features:
- π Zero Database Required - Direct webhook notifications
- π Multiple Providers - Discord and Slack support
- π‘οΈ Data Sanitization - Automatic sensitive data protection
- π Retry Logic - Built-in retry with exponential backoff
- π Environment Aware - Automatic environment detection
- β‘ TypeScript First - Full type safety and IntelliSense
Quick Start:
import { ErrorLogger } from 'error-logger-sendsms';
const logger = new ErrorLogger({
discord: {
webhookUrl: process.env.DISCORD_WEBHOOK_URL!
}
});
// Capture exceptions
try {
throw new Error('Something went wrong!');
} catch (error) {
await logger.captureException(error, { userId: '123' });
}
// Capture messages
await logger.captureMessage('User logged in', 'info', { userId: '123' });
Perfect for:
- Frontend applications (React, Vue, Angular)
- Microservices without centralized logging
- Quick prototyping and MVP development
- Teams using Discord/Slack for communication
Database-backed error logging with Supabase integration
npm install supabase-error-logger @supabase/supabase-js
Key Features:
- ποΈ Persistent Storage - Errors stored in Supabase tables
- π Queryable Data - SQL queries for error analysis
- π Rich Context - User sessions, URLs, metadata
- π― Sentry-like API - Familiar
captureException
/captureMessage
- π§ Runtime Configuration - Update settings without restart
Quick Start:
import { SupabaseErrorLogger } from 'supabase-error-logger';
const logger = new SupabaseErrorLogger({
supabaseUrl: process.env.VITE_SUPABASE_URL!,
supabaseKey: process.env.VITE_SUPABASE_ANON_KEY!,
tableName: 'error_logs'
});
// Set user/session context
logger.setUser('user-123');
logger.setSession('session-abc');
// Capture exceptions
try {
// ...
} catch (err) {
await logger.captureException(err as Error, { status: 500 });
}
// Capture messages
await logger.captureMessage('just info');
await logger.captureMessage('warning!', 'warning', { area: 'checkout' });
Perfect for:
- Production applications requiring error persistence
- Teams needing error analytics and reporting
- Applications with user session tracking
- Long-term error monitoring and analysis
sendErrorMessage/
βββ error-logger-sendSMS/ # Direct notification package
β βββ src/ # Source code
β β βββ index.ts # Main ErrorLogger class
β β βββ providers/ # Discord/Slack providers
β β βββ config/ # Configuration management
β β βββ types/ # TypeScript definitions
β β βββ utils/ # Utilities (sanitization, retry)
β βββ examples/ # Usage examples
β βββ tests/ # Test suite
β βββ README.md # Package documentation
βββ supabase-error-logger/ # Database-backed package
β βββ src/ # Source code
β β βββ index.ts # Main SupabaseErrorLogger class
β β βββ env-utils.ts # Environment utilities
β β βββ types/ # TypeScript definitions
β βββ examples/ # Usage examples
β βββ schema.sql # Database schema
β βββ tests/ # Test suite
β βββ README.md # Package documentation
βββ docs/ # Project documentation
β βββ constitution-feature.md # Project principles
β βββ specify/ # Feature specifications
βββ specs/ # Technical specifications
βββ README.md # This file
- β You want immediate notifications without database setup
- β Your team uses Discord or Slack for communication
- β You need zero infrastructure dependencies
- β You're building frontend applications or microservices
- β You want quick setup and minimal configuration
- β You prefer real-time alerts over historical analysis
- β You need persistent error storage for analysis
- β You want to query and analyze error patterns
- β You're building production applications with user sessions
- β You need long-term error monitoring and reporting
- β You want to correlate errors with user behavior
- β You prefer data-driven debugging over immediate alerts
- Node.js 16+
- TypeScript 5.0+
- npm or yarn
For direct notifications (error-logger-sendSMS):
npm install error-logger-sendsms
For database logging (supabase-error-logger):
npm install supabase-error-logger @supabase/supabase-js
Discord/Slack Notifications:
# Discord
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_TOKEN
DISCORD_USERNAME=ErrorBot
# Slack
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK
SLACK_CHANNEL=#errors
# Global settings
ERROR_LOGGER_ENABLED=true
ERROR_LOGGER_ENVIRONMENT=production
Supabase Database:
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
const logger = new ErrorLogger({
discord: {
webhookUrl: 'https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_TOKEN',
username: 'ErrorBot',
avatarUrl: 'https://example.com/avatar.png'
},
slack: {
webhookUrl: 'https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK',
channel: '#errors',
username: 'ErrorBot'
},
enabled: true,
environment: 'production',
retry: {
maxAttempts: 3,
baseDelay: 1000,
maxDelay: 10000,
jitter: true
},
sanitization: {
enabled: true,
customPatterns: ['password', 'token', 'secret']
}
});
const logger = new SupabaseErrorLogger({
supabaseUrl: process.env.VITE_SUPABASE_URL!,
supabaseKey: process.env.VITE_SUPABASE_ANON_KEY!,
tableName: 'error_logs',
enabled: true
});
// Set user/session context
logger.setUser('user-123');
logger.setSession('session-abc');
create table if not exists error_logs (
id uuid primary key default gen_random_uuid(),
message text not null,
stack text,
level text not null check (level in ('error','warning','info')),
timestamp timestamptz not null,
user_id text,
session_id text,
url text,
user_agent text,
metadata jsonb,
created_at timestamptz not null default now()
);
-- Optional index for performance
create index if not exists error_logs_level_timestamp_idx on error_logs(level, timestamp desc);
# Test error-logger-sendSMS
cd error-logger-sendSMS
npm test
# Test supabase-error-logger
cd supabase-error-logger
npm test
# Coverage for error-logger-sendSMS
cd error-logger-sendSMS
npm run test:coverage
# Coverage for supabase-error-logger
cd supabase-error-logger
npm run test:coverage
# Build error-logger-sendSMS
cd error-logger-sendSMS
npm run build
# Build supabase-error-logger
cd supabase-error-logger
npm run build
# Watch mode for error-logger-sendSMS
cd error-logger-sendSMS
npm run dev
# Watch mode for supabase-error-logger
cd supabase-error-logger
npm run dev
import express from 'express';
import { ErrorLogger } from 'error-logger-sendsms';
const app = express();
const errorLogger = new ErrorLogger();
// Global error handler
app.use(async (err: Error, req: Request, res: Response, next: NextFunction) => {
await errorLogger.captureException(err, {
method: req.method,
url: req.url,
headers: req.headers,
body: req.body,
query: req.query
});
res.status(500).json({ error: 'Internal server error' });
});
// app/root.tsx
import { SupabaseErrorLogger } from 'supabase-error-logger';
const errorLogger = new SupabaseErrorLogger({
supabaseUrl: (globalThis as any).__ENV?.SUPABASE_URL || import.meta.env.VITE_SUPABASE_URL,
supabaseKey: (globalThis as any).__ENV?.SUPABASE_ANON_KEY || import.meta.env.VITE_SUPABASE_ANON_KEY,
});
export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
if (isRouteErrorResponse(error)) {
if (error.status !== 404) {
errorLogger.captureException({
status: error.status,
statusText: error.statusText,
message: String(error)
});
}
} else {
errorLogger.captureException(error as any);
}
// ... existing rendering logic
}
Both packages automatically sanitize sensitive data:
Default Patterns:
password
,token
,key
,secret
auth
,credential
,api_key
access_token
,refresh_token
Custom Patterns:
const logger = new ErrorLogger({
sanitization: {
enabled: true,
customPatterns: ['custom_secret', 'internal_key']
}
});
- Never commit webhook URLs or API keys to version control
- Use environment variables for all sensitive configuration
- Rotate webhook URLs and API keys regularly
- Use different webhooks for different environments
We welcome contributions! Please see our contributing guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes with tests
- Run tests (
npm test
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
# Clone the repository
git clone https://github.com/lshtrade/sendErrorMessage.git
cd sendErrorMessage
# Install dependencies for both packages
cd error-logger-sendSMS && npm install
cd ../supabase-error-logger && npm install
# Run tests
cd ../error-logger-sendSMS && npm test
cd ../supabase-error-logger && npm test
This project is licensed under the MIT License - see the LICENSE file for details.
- π§ GitHub Issues
- π Documentation
- π Homepage
- Additional Providers: Microsoft Teams, Telegram, Email notifications
- Error Aggregation: Group similar errors to reduce noise
- Performance Monitoring: Integration with performance metrics
- Custom Dashboards: Web-based error monitoring interface
- Mobile Support: React Native and Flutter integrations
- v1.0.1 - Initial release with Discord/Slack support
- v1.0.0 - Stable release with comprehensive testing
- v0.9.0 - Beta release with core functionality
Made with β€οΈ for developers who care about error monitoring