Hide PayPal Insights when WP Debug is set to false. Also allow logging when WP Debug is set to false.

This commit is contained in:
Daniel Dudzic 2024-06-12 22:30:33 +02:00
parent b4e35e2959
commit 8f99aa5f9e
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
2 changed files with 11 additions and 9 deletions

View file

@ -1,7 +1,7 @@
export function log(message, level = 'info') { export function log(message, level = 'info') {
const wpDebug = window.wc_ppcp_axo?.wp_debug; const wpDebug = window.wc_ppcp_axo?.wp_debug;
const endpoint = window.wc_ppcp_axo?.ajax?.frontend_logger?.endpoint; const endpoint = window.wc_ppcp_axo?.ajax?.frontend_logger?.endpoint;
if(!wpDebug || !endpoint) { if (!endpoint) {
return; return;
} }
@ -16,6 +16,7 @@ export function log(message, level = 'info') {
} }
}) })
}).then(() => { }).then(() => {
if (wpDebug) {
switch (level) { switch (level) {
case 'error': case 'error':
console.error(`[AXO] ${message}`); console.error(`[AXO] ${message}`);
@ -23,5 +24,6 @@ export function log(message, level = 'info') {
default: default:
console.log(`[AXO] ${message}`); console.log(`[AXO] ${message}`);
} }
}
}); });
} }

View file

@ -169,7 +169,7 @@ class AxoManager {
'email' => 'render', 'email' => 'render',
), ),
'insights' => array( 'insights' => array(
'enabled' => true, 'enabled' => defined( 'WP_DEBUG' ) && WP_DEBUG,
'client_id' => ( $this->settings->has( 'client_id' ) ? $this->settings->get( 'client_id' ) : null ), 'client_id' => ( $this->settings->has( 'client_id' ) ? $this->settings->get( 'client_id' ) : null ),
'session_id' => 'session_id' =>
substr( substr(