From 61ebb60e71ab276872647303184aba34d57fe0db Mon Sep 17 00:00:00 2001 From: Robert O'Rourke Date: Wed, 10 May 2023 16:05:59 +0100 Subject: [PATCH] Add support for setting redacted keys via global This solves the issue of the filter not being available for the first trace sent which happens prior to WP bootstrapping. Usage: ``` $xray_redact_keys = [ $_POST => [ key, key ] ]; ``` --- inc/namespace.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/namespace.php b/inc/namespace.php index c47db6c..28ed2af 100644 --- a/inc/namespace.php +++ b/inc/namespace.php @@ -922,8 +922,9 @@ function get_object_cache_stats() : array { * @return array */ function redact_metadata( $metadata ) { + global $xray_redact_keys; - $redact_keys_default = []; + $redact_keys_default = (array) ( $xray_redact_keys ?? [] ); if ( function_exists( 'apply_filters' ) ) { $redact_keys_default = apply_filters( 'aws_xray.redact_metadata_keys', $redact_keys_default ); }