bb-plane-fork/apps/api/plane/bgtasks
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
..
__init__.py chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30
analytic_plot_export.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
apps.py chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30
cleanup_task.py [WEB-5071] chore: implement webhook logging to MongoDB and fallback to database (#7896) 2025-10-15 14:53:43 +05:30
copy_s3_object.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
deletion_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
dummy_data_task.py fix: state group choices (#8198) 2025-11-28 18:06:00 +05:30
email_notification_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
event_tracking_task.py chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30
export_task.py chore(deps): upgrade psycopg packages to version 3.3.0 (#8222) 2025-12-05 16:06:19 +05:30
exporter_expired_task.py chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30
file_asset_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
forgot_password_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
issue_activities_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
issue_automation_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
issue_description_version_sync.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
issue_description_version_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
issue_version_sync.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
logger_task.py [WEB-5575]feat: enhance APITokenLogMiddleware to support logging to MongoDB (#8241) 2025-12-10 01:01:10 +05:30
magic_link_code_task.py chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30
notification_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
page_transaction_task.py [WIKI-553] chore: improved pages components tracking (#7966) 2025-10-23 00:29:05 +05:30
page_version_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
project_add_user_email_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
project_invitation_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
recent_visited_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
storage_metadata_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
user_activation_email_task.py chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30
user_deactivation_email_task.py chore: rename server to api (#7342) 2025-07-04 15:32:21 +05:30
user_email_update_task.py [WEB-5430] feat: allow users to change email (#8120) 2025-11-24 21:21:52 +05:30
webhook_task.py [WEB-5224] chore: raise warning instead of logging an exception for webhook_send_task (#7996) 2025-10-28 16:49:19 +05:30
work_item_link_task.py [WEB-5228] chore: IssueLink.DoesNotExist on crawl_work_item_link_title (#8003) 2025-10-28 18:18:36 +05:30
workspace_invitation_task.py [WEB-5044] fix: ruff lint and format errors (#7868) 2025-09-29 19:15:32 +05:30
workspace_seed_task.py [WEB-5254] chore: add bot user to create workspace seed data (#8225) 2025-12-05 18:03:58 +05:30