Skip to content

Conversation

@colinmurphy
Copy link
Member

@colinmurphy colinmurphy commented Sep 22, 2025

Description

This pull request introduces a comprehensive "Data Management" feature set for the WPGraphQL Logging plugin, focusing on automated log cleanup, data retention, and data sanitization. It adds a new settings tab in the admin interface, backend logic for retention and sanitization configuration, UI/UX improvements, and supporting code for scheduled cleanup and privacy compliance.

Major new features and changes:

1. Data Management Tab & Settings (Admin UI & Backend)

  • Added a new Data Management tab to the plugin settings, allowing admins to configure log retention (number of days), enable/disable data deletion, and set up data sanitization options, including custom field handling. (plugins/wpgraphql-logging/src/Admin/Settings/Fields/Tab/Data_Management_Tab.php, plugins/wpgraphql-logging/src/Admin/Settings/Fields/Settings_Field_Collection.php, plugins/wpgraphql-logging/README.md) [1] [2] [3]

2. Data Sanitization & Retention Logic

  • Introduced a new Text_Integer_Field for integer settings in the admin UI, used for specifying retention days. (plugins/wpgraphql-logging/src/Admin/Settings/Fields/Field/Text_Integer_Field.php)
  • Added a DataSanitizationProcessor to the logging pipeline to sanitize sensitive fields based on admin configuration. (plugins/wpgraphql-logging/src/Logger/LoggerService.php) [1] [2]

3. Automated & Manual Log Cleanup

  • Added backend logic to delete log entries older than a specified date, supporting both scheduled and manual cleanup. (plugins/wpgraphql-logging/src/Logger/Database/LogsRepository.php)
  • Updated the documentation and settings UI to reflect new cleanup and retention features. (plugins/wpgraphql-logging/README.md, plugins/wpgraphql-logging/src/Admin/Settings/Templates/admin.php) [1] [2]

4. UI/UX Improvements for Settings

  • Improved the settings UI: added conditional display of custom sanitization fields (shown only when "Custom" is selected), and enhanced input styling for number fields. (plugins/wpgraphql-logging/assets/js/settings/wp-graphql-logging-settings.js, plugins/wpgraphql-logging/assets/css/settings/wp-graphql-logging-settings.css) [1] [2] [3]
  • Updated feature lists and documentation links for clarity and accuracy. (plugins/wpgraphql-logging/src/Admin/Settings/Templates/admin.php, plugins/wpgraphql-logging/README.md) [1] [2]

5. Miscellaneous Improvements

  • Standardized request logging by encoding requests as JSON before logging, ensuring consistent and safe data handling. (plugins/wpgraphql-logging/src/Events/QueryActionLogger.php, plugins/wpgraphql-logging/src/Events/QueryFilterLogger.php) [1] [2]
  • Refactored directory structure to clarify the distinction between logging logic, rules, and scheduling. (plugins/wpgraphql-logging/README.md)

Related Issue

Fixes #355

Dependant PRs

Type of Change

  • ✅ Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactoring (no functional changes)
  • 📄 Example update (no functional changes)
  • 📝 Documentation update
  • 🔍 Performance improvement
  • 🧪 Test update

How Has This Been Tested?

Screenshots

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the project's coding standards
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • Any dependent changes have been highlighted, merged or published

Introduces a new data sanitization method selection in the settings, allowing users to choose between recommended and custom methods. Adds fields for specifying custom fields to anonymize, remove, or truncate. Includes supporting JavaScript and CSS for dynamic UI behavior, and minor code cleanup in LogsRepository.
@changeset-bot
Copy link

changeset-bot bot commented Sep 22, 2025

🦋 Changeset detected

Latest commit: 228692e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@wpengine/wpgraphql-logging-wordpress-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link

github-actions bot commented Sep 22, 2025

📦 Plugin Artifacts Ready!

Download from GitHub Actions run

Available plugins:

  • ✅ wpgraphql-logging.zip

See the "Artifacts" section at the bottom of the Actions run page

@colinmurphy colinmurphy changed the title chore DRAFT WPGraphQL Logging Data Management chore: DRAFT WPGraphQL Logging Data Management Sep 22, 2025
Introduces DataSanitizationProcessor to sanitize sensitive data in log records based on configurable rules. Updates QueryActionLogger and QueryFilterLogger to encode requests as arrays for improved processing. Registers the new processor in LoggerService to enhance privacy and compliance.
@colinmurphy colinmurphy marked this pull request as ready for review September 23, 2025 13:50
@colinmurphy colinmurphy requested a review from a team as a code owner September 23, 2025 13:50
@colinmurphy colinmurphy requested a review from Copilot September 23, 2025 14:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces comprehensive data management capabilities for the WPGraphQL Logging plugin, focusing on automated log cleanup, data retention policies, and data sanitization for privacy compliance.

Key Changes

  • Added a new Data Management tab with configurable retention periods and deletion settings
  • Implemented data sanitization processor with recommended and custom field filtering
  • Created automated daily cleanup scheduler with manual cleanup options

Reviewed Changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Plugin.php Initialize data deletion scheduler and handle plugin deactivation cleanup
DataDeletionScheduler.php New scheduler class for automated daily log cleanup based on retention settings
DataSanitizationProcessor.php New processor for sanitizing sensitive fields in log records
LoggerService.php Added data sanitization processor to the logging pipeline
LogsRepository.php Added method to delete logs older than specified date
QueryFilterLogger.php Encode request data as JSON before logging
QueryActionLogger.php Encode request data as JSON before logging
Data_Management_Tab.php New admin settings tab for data management configuration
Settings_Field_Collection.php Register the new data management tab
Text_Integer_Field.php New field type for integer input with number validation
JavaScript/CSS files UI enhancements for conditional field display and styling
README.md Comprehensive documentation for data sanitization features

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Introduces a ConfigurationHelper class to provide cached, singleton-based access to WPGraphQL Logging configuration. Refactors settings and config retrieval throughout the plugin to use this helper, improving performance, consistency, and cache management. Updates related classes and documentation to use the new approach and initializes automatic cache invalidation in the main plugin setup.
@colinmurphy colinmurphy requested a review from Copilot September 23, 2025 16:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 47 out of 48 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@colinmurphy colinmurphy changed the title chore: DRAFT WPGraphQL Logging Data Management chore: WPGraphQL Logging Data Management Sep 23, 2025
@theodesp theodesp requested a review from Copilot September 29, 2025 09:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 47 out of 48 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

plugins/wpgraphql-logging/src/Logger/Processors/DataSanitizationProcessor.php:1

  • This code appears to be in the wrong file. The sanitize_text_field and intval logic should be in TextIntegerField.php, not in DataSanitizationProcessor.php.
<?php

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@colinmurphy colinmurphy added this pull request to the merge queue Sep 29, 2025
Merged via the queue into main with commit 31101f8 Sep 29, 2025
21 checks passed
@colinmurphy colinmurphy deleted the chore-wpgraphql-logging-data-management branch September 29, 2025 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WPGraphQL Logging - Data Deletion and Sanitisation

3 participants