-
-
Notifications
You must be signed in to change notification settings - Fork 275
Setup Sentry
Akram El Assas edited this page Jul 4, 2025
·
8 revisions
BookCars supports error monitoring through Sentry (https://sentry.io), which captures runtime exceptions and performance metrics. This is useful for diagnosing backend issues in production or staging environments.
- Create a free account at https://sentry.io.
- Create a new Node.js project in Sentry for the BookCars backend.
- Copy the provided DSN URL.
Sentry integration is optional and controlled by environment variables in the backend.
BC_ENABLE_SENTRY=true
BC_SENTRY_DSN_BACKEND=https://your_dsn@o0.ingest.sentry.io/your_project_id
BC_SENTRY_TRACES_SAMPLE_RATE=0.1
Do not commit the real DSN to version control.
- When
BC_ENABLE_SENTRY=true
andBC_SENTRY_DSN_BACKEND
is defined, the backend initializes Sentry at startup. - Runtime errors (especially in
try/catch
blocks or unhandled routes) are automatically reported to Sentry. - When
BC_SENTRY_TRACES_SAMPLE_RATE
is is greater than 0, transactions will be sent to Sentry. Sentry will capture performance transactions, showing request duration, slow routes, and trace spans. Set to0
to disable tracing. 0.1 means 10% of transactions will be sent to Sentry. 1 means 100% of transactions will be sent to Sentry. We recommend adjusting this value in production. - The integration complements the existing Winston-based logging system.
To verify Sentry is working:
- Temporarily set
BC_ENABLE_SENTRY=true
and use a real DSN. - Trigger an error in a controller:
throw new Error('Test Sentry integration')
- Check your Sentry dashboard under Issues.
- Sentry is only enabled if both:
BC_ENABLE_SENTRY=true
-
BC_SENTRY_DSN_BACKEND
is set
- You can safely use BookCars without Sentry if you prefer other monitoring solutions.
-
backend/src/monitoring/instrument.ts
- Sentry integration and initialization -
backend/src/app.ts
- Sentry Express middleware is attached if enabled -
backend/src/config/logger.ts
- Automatically reports errors to Sentry if enabled
Copyright © Akram El Assas. All rights reserved.
- Overview
- Software Architecture
- Install Guide (Self-hosted)
- Install Guide (Docker)
- Free SSL Setup Guide
- Setup Sentry
- Rental Date and Time Constraints
- Payment Gateways
- Setup Stripe
- Social Login Setup Guide
- Build Mobile App
- Demo Database
- Run from Source
- Run from Source (Docker)
- Run Mobile App
- Fork, Customize, and Sync
- Locations
- Auto‐Notification System
- Price Calculation
- Supplier Contracts
- Add New Language
- Add New Currency
- Logs
- Testing
- FAQ
- Release Notes
- Contribution Guide
- Code of Conduct