bb-plane-fork/apps/api
Nikhil 491b5bc6cc
[WEB-5575]feat: enhance APITokenLogMiddleware to support logging to MongoDB (#8241)
* feat: enhance APITokenLogMiddleware to support logging to MongoDB

- Added functionality to log external API requests to MongoDB, with a fallback to PostgreSQL if MongoDB is unavailable.
- Implemented error handling for MongoDB connection and logging operations.
- Introduced additional fields for MongoDB logs, including timestamps and user identifiers.
- Refactored request logging logic to streamline the process and improve maintainability.

* fix: improve MongoDB availability checks in APITokenLogMiddleware

- Enhanced the logic for determining MongoDB availability by checking if the collection is not None.
- Added a check for MongoDB configuration before attempting to retrieve the collection.
- Updated error handling to ensure the middleware correctly reflects the state of MongoDB connectivity.

* feat: implement logging functionality in logger_task for API activity

- Added a new logger_task module to handle logging of API activity to MongoDB and PostgreSQL.
- Introduced functions for safely decoding request/response bodies and processing logs based on MongoDB availability.
- Refactored APITokenLogMiddleware to utilize the new logging functions, improving code organization and maintainability.

* refactor: simplify MongoDB logging in logger_task and middleware

- Removed direct dependency on MongoDB collection in log_to_mongo function, now retrieving it internally.
- Updated process_logs to check MongoDB configuration before logging, enhancing error handling.
- Cleaned up logger.py by removing unused imports related to MongoDB.

* feat: add Celery task decorator to process_logs function in logger_task

- Introduced the @shared_task decorator to the process_logs function, enabling asynchronous processing of log data.
- Updated function signature to include a return type of None for clarity.
2025-12-10 01:01:10 +05:30
..
bin [WEB-5592] chore: add static files update settings for static files support (#8251) 2025-12-09 21:05:26 +05:30
plane [WEB-5575]feat: enhance APITokenLogMiddleware to support logging to MongoDB (#8241) 2025-12-10 01:01:10 +05:30
requirements [WEB-5592] chore: add static files update settings for static files support (#8251) 2025-12-09 21:05:26 +05:30
templates [WEB-5430] feat: allow users to change email (#8120) 2025-11-24 21:21:52 +05:30
.coveragerc chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30
.env.example - Add SIGNED_URL_EXPIRATION environment variable (#8136) 2025-12-03 10:52:19 +05:30
.prettierignore fix: eslint (#8185) 2025-12-05 16:03:51 +05:30
Dockerfile.api chore: updated node version to 22 and python version to 3.12.10 (#7343) 2025-07-04 16:28:30 +05:30
Dockerfile.dev chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30
manage.py chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30
package.json chore: update package version 2025-12-09 23:35:52 +05:30
pyproject.toml [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
pytest.ini chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30
requirements.txt chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30
run_tests.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
run_tests.sh chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30