Enhance Remote Logging to Include `request_uri` (#50671)

Add request_uri prop to remote logging data
This commit is contained in:
Chi-Hsuan Huang 2024-08-15 22:14:53 +08:00 committed by GitHub
parent 1235f4d38a
commit 73f45833b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Add request_uri prop to remote logging data

View File

@ -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 ),
};

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Add request_uri prop to remote logging data

View File

@ -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 ),
),
);