Sentry support
This commit is contained in:
parent
94e9d5ea75
commit
12d5c02203
3 changed files with 37 additions and 1 deletions
28
README.md
28
README.md
|
@ -8,6 +8,7 @@ An anonymous chat application built with Flask.
|
|||
- Admin dashboard to manage inquiries
|
||||
- Customizable site title
|
||||
- Redis-based session storage for improved scalability
|
||||
- Integrated error tracking with Sentry
|
||||
|
||||
## Development Approach
|
||||
|
||||
|
@ -34,6 +35,7 @@ AnonChat can be configured using environment variables:
|
|||
- `RATELIMIT_STORAGE_URL`: Storage backend for rate limiting (defaults to memory storage)
|
||||
- `REDIS_URL`: Redis connection URL for session storage (defaults to "redis://localhost:6379/0")
|
||||
- `AUTO_DELETE_HOURS`: Number of hours after which closed inquiries are automatically deleted (defaults to 48)
|
||||
- `SENTRY_DSN`: Sentry Data Source Name for error tracking and monitoring (optional)
|
||||
|
||||
You can set these variables in a `.env` file:
|
||||
|
||||
|
@ -45,6 +47,7 @@ SITE_TITLE=My Custom Chat
|
|||
BEHIND_PROXY=true
|
||||
REDIS_URL=redis://redis:6379/0
|
||||
AUTO_DELETE_HOURS=72
|
||||
SENTRY_DSN=https://your-sentry-dsn
|
||||
```
|
||||
|
||||
## Reverse Proxy Configuration
|
||||
|
@ -70,6 +73,31 @@ server {
|
|||
}
|
||||
```
|
||||
|
||||
## Error Tracking with Sentry
|
||||
|
||||
AnonChat includes integration with Sentry for error tracking and performance monitoring. This helps identify and diagnose issues in production environments.
|
||||
|
||||
### Features
|
||||
|
||||
- Automatic error capturing and reporting
|
||||
- Performance monitoring
|
||||
- Contextual information for better debugging
|
||||
- Real-time alerts for critical issues
|
||||
|
||||
### Configuration
|
||||
|
||||
To enable Sentry integration:
|
||||
|
||||
1. Sign up for a free Sentry account at [sentry.io](https://sentry.io)
|
||||
2. Create a new project and get your DSN (Data Source Name)
|
||||
3. Set the `SENTRY_DSN` environment variable in your `.env` file or deployment environment:
|
||||
|
||||
```
|
||||
SENTRY_DSN=https://your-sentry-project-key@sentry.io/your-project-id
|
||||
```
|
||||
|
||||
When the `SENTRY_DSN` variable is set, error tracking will be automatically enabled when the application starts.
|
||||
|
||||
## Installation
|
||||
|
||||
1. Clone the repository
|
||||
|
|
|
@ -20,7 +20,8 @@ dependencies = [
|
|||
"redis (>=5.0.0,<6.0.0)",
|
||||
"flask-session (>=0.5.0,<1.0.0)",
|
||||
"argon2-cffi (>=23.0.0,<24.0.0)",
|
||||
"flask-apscheduler (>=1.13.1,<2.0.0)"
|
||||
"flask-apscheduler (>=1.13.1,<2.0.0)",
|
||||
"sentry-sdk (>=2.25.1,<3.0.0)"
|
||||
]
|
||||
|
||||
[tool.poetry]
|
||||
|
|
|
@ -56,6 +56,13 @@ app.config['SCHEDULER_TIMEZONE'] = 'UTC'
|
|||
if app.config['BEHIND_PROXY']:
|
||||
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=2)
|
||||
|
||||
if os.environ.get('SENTRY_DSN'):
|
||||
import sentry_sdk
|
||||
|
||||
sentry_sdk.init(
|
||||
dsn=os.environ.get('SENTRY_DSN')
|
||||
)
|
||||
|
||||
# Initialize password hasher
|
||||
# Parameters source: https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#argon2id
|
||||
password_hasher = PasswordHasher(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue