expresstechsoftware / connect-memberpress-discord-add-on

This add-on enables connecting your MemberPress enabled website to your discord server. Now you can add/remove MemberPress members directly to your discord server roles, assign roles according to your member levels, unassign roles when they expire, change role when they change membership.
GNU General Public License v2.0
4 stars 1 forks source link

Implement Enhanced API Logging in MemberPress-Discord Integration #151

Open ravisoni6262 opened 6 months ago

ravisoni6262 commented 6 months ago

Objective

Implement a robust logging system in our existing MemberPress-Discord integration plugin to capture detailed information about each API interaction. This includes requests, responses, error details, and user information, storing them in a newly created MySQL table ets_memberpress_discord_api_logs.

Note: do not save client_id, client_secret and bot token to DB.

Requirements:

  1. Database Table Creation

    Create a new MySQL table discord_api_logs with the following columns:
    id (INT AUTO_INCREMENT, PRIMARY KEY)
    api_endpoint (VARCHAR 255) // full url.
    api_endpoint_version (VARCHAR 10) // 
    request_params (LONGTEXT) // serialise. 
    api_response_header (LONGTEXT)
    api_response_body (LONGTEXT)
    api_response_http_code (VARCHAR 5) // / we will add a search feature that will query this colum.
    error_detail_code (VARCHAR 100)
    error_message (TEXT) // we will add a search feature that will query this colum.
    wp_user_id (INT) // / we will add a search feature that will query this colum.
    discord_user_id (LONGINT) // / we will add a search feature that will query this colum.
    datetime (DATETIME, DEFAULT CURRENT_TIMESTAMP) // we will add a search feature that will query this colum.
  2. Logging Functionality:

    • Be capable of handling large data sets for request and response bodies.
    • Serialize complex data structures for storage.
    • Be invoked after every API call made in the plugin.
  3. API Call Modification: Modify the existing API calls in the plugin to include the logging function. Ensure that:

    • Both successful and failed API interactions are logged.
    • Relevant user IDs (WordPress and Discord) are captured, where applicable.

Testing and Validation

Additional Notes

Expected Deliverables: