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

Allow testing tags in non-production environments #4774

Closed
aaemnnosttv opened this issue Feb 2, 2022 · 6 comments
Closed

Allow testing tags in non-production environments #4774

aaemnnosttv opened this issue Feb 2, 2022 · 6 comments
Labels
P2 Low priority PHP QA: Eng Requires specialized QA by an engineer Rollover Issues which role over to the next sprint Type: Enhancement Improvement of an existing feature

Comments

@aaemnnosttv
Copy link
Collaborator

aaemnnosttv commented Feb 2, 2022

Feature Description

In #2054, we added a guard to prevent module tags from being placed in non-production environments to tracking page views, displaying ads, etc in such environments. There are however cases where it makes sense for a developer to want these tags to be rendered in a local/development/staging environment in order to test integration with them (e.g. custom Analytics events).

With this in mind, we should allow for a developer to disable/bypass the environment type guard for tags.


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

Acceptance criteria

  • The Tag_Production_Guard tag guard should be replaced with a new Tag_Environment_Type_Guard which works similar to the current production guard, but allows for flexibility in the environments it disables tags for
  • Like today, if the wp_get_environment_type function does not exist, it should continue to return true
  • A new filter should be invoked to allow filtering the allowed environment types:
    • googlesitekit_allowed_tag_environment_types which filters an array of valid environment types which should initially be only production as today
  • The can_activate method should return true if the current environment type is in the filtered array
  • The Tag_Production_Guard class should be removed and its usage replaced with the new Tag_Environment_Type_Guard

Implementation Brief

  • Copy the Tag_Production_Guard class to a new class named Tag_Environment_Type_Guard. It should implement the same Guard_Interface.
  • Within the can_activate() method, use apply_filters() with the hook name to be googlesitekit_allowed_tag_environment_types. Pass an array with the value production as the value to filter.
  • Implement the remaining points within the AC which provide enough detail.

Test Coverage

  • Rework the existing tests within Tag_Production_GuardTest to test the newly created filter.

QA Brief

  • There is nothing specific to be tested for these changes. However, we must ensure that all the tags are added while setting up the modules in the production environment.

QA:Eng

  • Add the following filter and ensure the tags are being added while setting up the modules in the development environment.
add_filter(
	'googlesitekit_allowed_tag_environment_types',
	function ( $allowed_environments ) {
		$allowed_environments[] = 'development';
		return $allowed_environments;
	}
);

Changelog entry

  • Update tag placement functionality to allow using tags in non-production environments.
@aaemnnosttv
Copy link
Collaborator Author

cc: @felixarntz

@aaemnnosttv aaemnnosttv removed their assignment Apr 29, 2022
@jimmymadon jimmymadon assigned jimmymadon and unassigned jimmymadon Jun 10, 2022
@eugene-manuilov eugene-manuilov self-assigned this Jun 11, 2022
@eugene-manuilov
Copy link
Collaborator

IB ✔️

@eugene-manuilov eugene-manuilov removed their assignment Jun 11, 2022
@hussain-t hussain-t self-assigned this Jun 12, 2022
@hussain-t hussain-t removed their assignment Jun 16, 2022
@eclarke1 eclarke1 added the Rollover Issues which role over to the next sprint label Jun 20, 2022
@eugene-manuilov eugene-manuilov removed their assignment Jun 21, 2022
@wpdarren wpdarren self-assigned this Jun 22, 2022
@mohitwp mohitwp assigned mohitwp and unassigned wpdarren Jun 23, 2022
@mohitwp
Copy link
Collaborator

mohitwp commented Jun 27, 2022

QA Update ⚠️

@hussain-t @aaemnnosttv

Can you please provide more information in QAB. Like,where I can find these tags and are you referring to GA tags ?

@hussain-t
Copy link
Collaborator

hussain-t commented Jun 27, 2022

@mohitwp, yes, you have to verify whether the GA and GTM tags are added as how it works today.

@hussain-t hussain-t removed their assignment Jun 27, 2022
@mohitwp
Copy link
Collaborator

mohitwp commented Jun 28, 2022

QA update ✅

Verified:

  • Verified GA, GTM and AdSense tags.
  • Compared the latest release and dev branch.
  • On dev branches, tags are added same as latest release branch.

Note : Added QA:Eng label as mentioned in QAB.

image

image

image

image

image

image

@mohitwp mohitwp removed their assignment Jun 28, 2022
@mohitwp mohitwp added the QA: Eng Requires specialized QA by an engineer label Jun 28, 2022
@jimmymadon
Copy link
Collaborator

jimmymadon commented Jun 28, 2022

QA: Eng ✅

  • Set the WP_ENVIRONMENT_TYPE to 'development'. Verified that no tag snippets (other than AdSense meta tag snippet which is not using the Tag_Environment_Type_Guard) are added to the site.

Screenshot 2022-06-29 at 00 39 09

  • Added the filter as per the QAB to Plugin.php's register() method. Verified that Analytics, GTM and AdSense snippets are inserted.

Screenshot 2022-06-29 at 00 49 42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 Low priority PHP QA: Eng Requires specialized QA by an engineer Rollover Issues which role over to the next sprint Type: Enhancement Improvement of an existing feature
Projects
None yet
Development

No branches or pull requests

8 participants