platform-logging
Sentry integration for centralized error tracking and analytics. Provides structured error reporting with context enrichment.
Package: @breadstone/archipel-platform-logging
Quick Start
typescript
import { Module } from '@nestjs/common';
import { LoggerModule } from '@breadstone/archipel-platform-logging';
@Module({
imports: [LoggerModule],
})
export class AppModule {}AnalyticsService
Central service for error and event reporting to Sentry.
typescript
import { AnalyticsService } from '@breadstone/archipel-platform-logging';
@Injectable()
export class PaymentService {
constructor(private readonly _analytics: AnalyticsService) {}
public async processPayment(orderId: string): Promise<void> {
try {
// ... payment logic
} catch (error) {
this._analytics.captureException(error, {
tags: { module: 'payments', orderId },
});
throw error;
}
}
}Environment Variables
| Variable | Description | Required |
|---|---|---|
SENTRY_DSN | Sentry Data Source Name | Yes |
SENTRY_ENVIRONMENT | Environment label (e.g. 'production', 'staging') | No |
SENTRY_TRACES_SAMPLE_RATE | Sampling rate for performance traces (0.0–1.0) | No |
Real-World Example: Global Error Filter
typescript
import { Catch, type ExceptionFilter, type ArgumentsHost } from '@nestjs/common';
import { AnalyticsService } from '@breadstone/archipel-platform-logging';
@Catch()
export class GlobalExceptionFilter implements ExceptionFilter {
constructor(private readonly _analytics: AnalyticsService) {}
public catch(exception: unknown, host: ArgumentsHost): void {
this._analytics.captureException(exception);
const ctx = host.switchToHttp();
const response = ctx.getResponse();
response.status(500).json({ error: 'Internal Server Error' });
}
}Exports Summary
| Export | Type | Description |
|---|---|---|
LoggerModule | NestJS Module | Global Sentry integration |
AnalyticsService | Service | Error capture and event tracking |