diff --git a/packages/js/remote-logging/changelog/update-remote-logging-data b/packages/js/remote-logging/changelog/update-remote-logging-data new file mode 100644 index 00000000000..69c8edf57c4 --- /dev/null +++ b/packages/js/remote-logging/changelog/update-remote-logging-data @@ -0,0 +1,4 @@ +Significance: patch +Type: update + +Add request_uri prop to remote logging data diff --git a/packages/js/remote-logging/src/remote-logger.ts b/packages/js/remote-logging/src/remote-logger.ts index 501a546a00f..8808e9f9c59 100644 --- a/packages/js/remote-logging/src/remote-logger.ts +++ b/packages/js/remote-logging/src/remote-logger.ts @@ -103,6 +103,11 @@ export class RemoteLogger { message: error.message, severity: 'error', ...extraData, + properties: { + ...extraData?.properties, + request_uri: + window.location.pathname + window.location.search, + }, } ), trace: this.getFormattedStackFrame( TraceKit.computeStackTrace( error ) @@ -206,6 +211,10 @@ export class RemoteLogger { message: error.message, severity: 'critical', tags: [ 'js-unhandled-error' ], + properties: { + request_uri: + window.location.pathname + window.location.search, + }, } ), trace: this.getFormattedStackFrame( trace ), }; diff --git a/plugins/woocommerce/changelog/update-remote-logging-data b/plugins/woocommerce/changelog/update-remote-logging-data new file mode 100644 index 00000000000..69c8edf57c4 --- /dev/null +++ b/plugins/woocommerce/changelog/update-remote-logging-data @@ -0,0 +1,4 @@ +Significance: patch +Type: update + +Add request_uri prop to remote logging data diff --git a/plugins/woocommerce/src/Internal/Logging/RemoteLogger.php b/plugins/woocommerce/src/Internal/Logging/RemoteLogger.php index 03c0b173679..01e71d40e62 100644 --- a/plugins/woocommerce/src/Internal/Logging/RemoteLogger.php +++ b/plugins/woocommerce/src/Internal/Logging/RemoteLogger.php @@ -71,6 +71,7 @@ class RemoteLogger extends \WC_Log_Handler { 'wc_version' => WC()->version, 'php_version' => phpversion(), 'wp_version' => get_bloginfo( 'version' ), + 'request_uri' => filter_input( INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL ), ), );