Draft: Add an environment variable for controlling inclusion of analytics scripts
What does this MR do and why?
Adds a method to turn off analytics without making code changes or an MR.
This would've allowed us to resolve problems with the Docs site during the analytics incident more quickly.
Screenshots
Build with analytics | Build without analytics |
---|---|
- Build with:
NANOC_ENV="production" CI_DEFAULT_BRANCH="main" CI_COMMIT_REF_NAME="main" GITLAB_DOCS_ANALYTICS_ENABLED="true" make view
- Build without:
NANOC_ENV="production" CI_DEFAULT_BRANCH="main" CI_COMMIT_REF_NAME="main" make view
- Build without:
NANOC_ENV="production" CI_DEFAULT_BRANCH="main" CI_COMMIT_REF_NAME="main" GITLAB_DOCS_ANALYTICS_DISABLED="hotdog" make view
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
-
Configure a local GitLab Docs environment: https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/doc/setup.md. -
Clear out any previous builds: make clean
-
Run a build with analytics: NANOC_ENV="production" CI_DEFAULT_BRANCH="main" CI_COMMIT_REF_NAME="main" GITLAB_DOCS_ANALYTICS_ENABLED="true" make view
-
View the HTML source of the homepage, the search page, the 404, and a standard interior page (our 4 templates). No analytics scripts or OneTrust should be present. -
Stop the preview env and clear out the build: make clean
-
Run a build without analytics: NANOC_ENV="production" CI_DEFAULT_BRANCH="main" CI_COMMIT_REF_NAME="main" make view
-
Check the same pages as step 4. Pages should not include analytics scripts or OneTrust.
Note that to really test this, we'll need to run a build with the new variable after we merge this.
Check for analytics scripts by searching the HTML source for things like: bizible
googletagmanager
linkedin_analytics
geolocation.onetrust.com
Merge request acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this merge request.
Edited by Achilleas Pipinellis