google / site-kit-wp

Site Kit is a one-stop solution for WordPress users to use everything Google has to offer to make them successful on the web.
https://sitekit.withgoogle.com
Apache License 2.0
1.25k stars 290 forks source link

Add messaging or change the behaviour of Site Kit for users who have WP_ENVIRONMENT_TYPE’ of anything other than "Production" #7962

Open jamesozzie opened 10 months ago

jamesozzie commented 10 months ago

Bug Description

At present, if a user has their WP_ENVIRONMENT_TYPE set to local or anything other than the default "Production" value in their configuration file, which can be the case if they migrated a site from a local environment, Site Kit will not place any of the snippets on a users site. The issue here is that many users are not aware that their environment type is set to local, and not aware that their snippets are not placed. Site Kit states the snippets are placed by default.

To improve users awareness, consider one of the following:

  1. A pre-flight warning to inform users that their environment is set to local (and therefore snippets will not be placed). There is no pre flight check for this at present.
  2. A notice within the module settings (similar to what is described in #1292)
  3. A notice when connecting any of the modules
  4. A comment added in place of the snippet (ie. "Snippet not placed due to local environment configuration"

Below you'll see a recording of the experience whereby Site Kit will only place the snippet once WP_ENVIRONMENT_TYPE’, ‘local has been removed https://www.loom.com/share/a24625a64c83454c9037d60d3bcb886d

Impacted support topics

Steps to reproduce

  1. Set up a site using Local by Flywheel, all default configurations (this will include WP_ENVIRONMENT_TYPE’, ‘local defined within wp-config.php)
  2. Migrate this site using Duplicator
  3. Set up Site Kit with Analytics
  4. Check and ensure that the snippets are not placed
  5. Remove the WP_ENVIRONMENT_TYPE’, ‘local reference
  6. The snippets are placed

Alternatively, as opposed to the above, simply defining WP_ENVIRONMENT_TYPE’, ‘local on an existing site within a wp-config.php file may also result in the snippets not being placed

Screenshots

Additional Context


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

Acceptance criteria

Implementation Brief

Test Coverage

QA Brief

Changelog entry

alekstrust commented 2 months ago

I've spent around 8 hours trying to find the issue until I found the WP_ENVIRONMENT_TYPE = false in my wp-config file 🥲