Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the deprecation warning for the googlesitekit_analytics-4_tag_block_on_consent filter #8362

Closed
1 task
techanvil opened this issue Mar 8, 2024 · 4 comments
Labels
P1 Medium priority Squad 2 (Team M) Issues for Squad 2 Type: Enhancement Improvement of an existing feature

Comments

@techanvil
Copy link
Collaborator

techanvil commented Mar 8, 2024

Feature Description

At present, the deprecation warning for the googlesitekit_analytics-4_tag_block_on_consent filter that was introduced in #8275 reads as follows:

PHP Deprecated: Hook googlesitekit_analytics-4_tag_block_on_consent is deprecated since version 1.122.0 with no alternative available.

We should improve the message to help steer users toward the Consent Mode feature as an alternative, for example:

PHP Deprecated: Hook googlesitekit_analytics-4_tag_block_on_consent is deprecated since version 1.122.0 with no alternative available. Please use the Consent Mode feature instead.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • The deprecation warning for the googlesitekit_analytics-4_tag_block_on_consent should read as follows:

PHP Deprecated: Hook googlesitekit_analytics-4_tag_block_on_consent is deprecated since version 1.122.0 with no alternative available. Please use the Consent Mode feature instead.

  • The additional message, "Please use the Consent Mode feature instead.", should be translated as usual.

Implementation Brief

  • Amend the arguments returned by Analytics_4\Web_Tag::get_tag_blocked_on_consent_deprecated_args() to include the translated additional message as per the AC. The second argument should be an empty string.

protected function get_tag_blocked_on_consent_deprecated_args() {
return array(
'1.122.0', // Deprecated in this version.
);
}

Test Coverage

QA Brief

  • Setup Site Kit and connect Analytics.
  • Create a php file inside wp-content/mu-plugins/ directory and add following code to it
<?php
add_filter( 'googlesitekit_analytics-4_tag_block_on_consent', '__return_true' );
  • Make sure you have WP_DEBUG and WP_DEBUG_DISPLAY set to true in wp-config.php file so that we can see the warning on the page.
  • Visit the home page, there must be the following warning displayed on the page.
Deprecated: Hook googlesitekit_analytics-4_tag_block_on_consent is deprecated since version 1.122.0 with no alternative available. Please use the Consent Mode feature instead. in /var/www/html/wp-includes/functions.php on line ----

Screenshot 2024-04-22 at 3.42.34 PM.png

Changelog entry

  • Improve the deprecation warning for the googlesitekit_analytics-4_tag_block_on_consent filter.
@techanvil techanvil added P1 Medium priority Type: Enhancement Improvement of an existing feature labels Mar 8, 2024
@aaemnnosttv
Copy link
Collaborator

I looked at this as well and core wasn't using the message at all from what I found. There is no alternative filter though (as noted in the IB), so I think this is a worthwhile enhancement.

AC + IB ✅

@wpdarren
Copy link
Collaborator

QA Update: ⚠️

@ankitrox in the AC it mentions the text should read:

PHP Deprecated: Hook googlesitekit_analytics-4_tag_block_on_consent is deprecated since version 1.122.0 with no alternative available. Please use the Consent Mode feature instead.

I do not see any reference to PHP in warning notice, is this correct?

Deprecated: Hook googlesitekit_analytics-4_tag_block_on_consent is deprecated since version 1.122.0 with no alternative available. Please use the Consent Mode feature instead

Also, the message reads a little odd because after instead theres a period and then in, So in its entirety it reads Deprecated: Hook googlesitekit_analytics-4_tag_block_on_consent is deprecated since version 1.122.0 with no alternative available. Please use the Consent Mode feature instead. in /s2-sitekit-125/wordpress/wp-includes/functions.php on line 6078

Is that expected?

image

@ankitrox
Copy link
Collaborator

@wpdarren Thank you for testing this.

I think this is correct behaviour because this deprecation warning is generated by apply_filters_deprecated, which in turn calls _deprecated_hook.

If we look at the function, it calls

wp_trigger_error( '', $message, E_USER_DEPRECATED );

So this tells us that this is user generated warning, not the warning generated from PHP itself, thus it will show Deprecated instead of PHP Deprecated.

@wpdarren
Copy link
Collaborator

QA Update: ✅

Verified:

  • Followed instructions in the QAB and depreciation warning notice appears.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 Medium priority Squad 2 (Team M) Issues for Squad 2 Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

5 participants