Plugin Directory

Changeset 3465485


Ignore:
Timestamp:
02/20/2026 04:21:14 AM (5 weeks ago)
Author:
humanityco
Message:

Enhance debug logging for configuration sync and API responses

Location:
cookie-notice/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cookie-notice/trunk/cookie-notice.php

    r3458232 r3465485  
    33Plugin Name: Cookie Notice & Compliance for GDPR / CCPA
    44Description: Cookie Notice allows you to you elegantly inform users that your site uses cookies and helps you comply with GDPR, CCPA and other data privacy laws.
    5 Version: 2.5.12
     5Version: 2.5.13
    66Author: Hu-manity.co
    77Author URI: https://hu-manity.co/
     
    3030 *
    3131 * @class Cookie_Notice
    32  * @version 2.5.12
     32 * @version 2.5.13
    3333 */
    3434class Cookie_Notice {
     
    153153            'activation_datetime'   => 0
    154154        ],
    155         'version'   => '2.5.12'
     155        'version'   => '2.5.13'
    156156    ];
    157157
  • cookie-notice/trunk/includes/welcome-api.php

    r3458232 r3465485  
    950950                    $blocking = get_option( 'cookie_notice_app_blocking', [] );
    951951
    952                 // set cache purge transient to force widget to refresh
    953                 if ( $network )
    954                     set_site_transient( 'cookie_notice_config_update', time(), DAY_IN_SECONDS );
    955                 else
    956                     set_transient( 'cookie_notice_config_update', time(), DAY_IN_SECONDS );
    957 
    958                 $response = [
    959                     'success' => true,
    960                     'message' => esc_html__( 'Configuration synced successfully.', 'cookie-notice' ),
    961                     'timestamp' => ! empty( $blocking['lastUpdated'] ) ? $blocking['lastUpdated'] : ''
    962                 ];
     952                // debug: include blocking data in response when debug mode is enabled
     953                $debug = $cn->options['general']['debug_mode'] ? [
     954                    'app_id' => $app_id,
     955                    'status_data' => $status_data,
     956                    'blocking' => $blocking,
     957                    'providers_count' => ! empty( $blocking['providers'] ) ? count( $blocking['providers'] ) : 0,
     958                    'patterns_count' => ! empty( $blocking['patterns'] ) ? count( $blocking['patterns'] ) : 0,
     959                ] : null;
     960
     961                // check if sync was successful
     962                if ( ! empty( $status_data ) && is_array( $status_data ) && ! empty( $status_data['status'] ) && $status_data['status'] === 'active' ) {
     963                    // set cache purge transient to force widget to refresh
     964                    if ( $network )
     965                        set_site_transient( 'cookie_notice_config_update', time(), DAY_IN_SECONDS );
     966                    else
     967                        set_transient( 'cookie_notice_config_update', time(), DAY_IN_SECONDS );
     968
     969                    $response = [
     970                        'success' => true,
     971                        'message' => esc_html__( 'Configuration synced successfully.', 'cookie-notice' ),
     972                        'timestamp' => ! empty( $blocking['lastUpdated'] ) ? $blocking['lastUpdated'] : ''
     973                    ];
     974                } else {
     975                    $response = [
     976                        'error' => esc_html__( 'Failed to sync configuration. Please check your app ID and try again.', 'cookie-notice' )
     977                    ];
     978                }
     979
     980                if ( $debug )
     981                    $response['debug'] = $debug;
    963982                break;
    964983        }
     
    12471266            }
    12481267
    1249             if ( $json )
     1268            // for GET requests, append params as query string instead of body
     1269            if ( $api_args['method'] === 'GET' )
     1270                $api_url = add_query_arg( $api_params, $api_url );
     1271            elseif ( $json )
    12501272                $api_args['body'] = wp_json_encode( $api_params );
    12511273            else
     
    15331555            ]
    15341556        );
     1557
     1558        // debug: log raw Designer API response
     1559        if ( $cn->options['general']['debug_mode'] ) {
     1560            error_log( '[Cookie Notice] get_app_config - AppID: ' . $app_id );
     1561            error_log( '[Cookie Notice] get_app_config - Designer API response: ' . wp_json_encode( $response ) );
     1562        }
    15351563
    15361564        // get status data
     
    16471675                update_option( 'cookie_notice_app_blocking', $result, false );
    16481676            }
     1677
     1678            // debug: log what gets stored
     1679            if ( $cn->options['general']['debug_mode'] ) {
     1680                error_log( '[Cookie Notice] get_app_config - Stored providers count: ' . count( $result['providers'] ) );
     1681                error_log( '[Cookie Notice] get_app_config - Stored patterns count: ' . count( $result['patterns'] ) );
     1682                error_log( '[Cookie Notice] get_app_config - Stored blocking data: ' . wp_json_encode( $result ) );
     1683            }
    16491684        } else {
     1685            if ( $cn->options['general']['debug_mode'] ) {
     1686                error_log( '[Cookie Notice] get_app_config - No data in response. Error: ' . ( ! empty( $response->error ) ? $response->error : 'unknown' ) );
     1687            }
     1688
    16501689            if ( ! empty( $response->error ) ) {
    16511690                if ( $response->error == 'App is not puplised yet' )
  • cookie-notice/trunk/js/admin.js

    r3458232 r3465485  
    720720                }
    721721            } ).done( function( response ) {
     722                if ( response && response.debug ) {
     723                    console.log( '[Cookie Notice] sync_config response:', response );
     724                    console.log( '[Cookie Notice] App ID:', response.debug.app_id );
     725                    console.log( '[Cookie Notice] Status data:', response.debug.status_data );
     726                    console.log( '[Cookie Notice] Blocking data:', response.debug.blocking );
     727                    console.log( '[Cookie Notice] Providers count:', response.debug.providers_count );
     728                    console.log( '[Cookie Notice] Patterns count:', response.debug.patterns_count );
     729                }
    722730                if ( response && response.success ) {
    723731                    // update last synced timestamp
  • cookie-notice/trunk/readme.txt

    r3458232 r3465485  
    55Requires PHP: 7.4
    66Tested up to: 6.9
    7 Stable tag: 2.5.12
     7Stable tag: 2.5.13
    88License: MIT License
    99License URI: http://opensource.org/licenses/MIT
Note: See TracChangeset for help on using the changeset viewer.