Yilialinn commented on code in PR #2136:
URL: https://github.com/apache/apisix-website/pull/2136#discussion_r4266586591
##########
next/src/components/Analytics.astro:
##########
@@ -0,0 +1,17 @@
+<!-- Keep production measurement independent of the build/preview environment.
-->
+<script is:inline>
+ (() => {
+ if (window.location.hostname !== 'apisix.apache.org') return;
+
+ window.dataLayer = window.dataLayer || [];
+ window.gtag = window.gtag || function () {
window.dataLayer.push(arguments); };
+ window.gtag('js', new Date());
+ // Scope cookies to this project rather than the shared apache.org domain.
+ window.gtag('config', 'G-WQLBQL6GY3', { cookie_domain: 'apisix.apache.org'
});
+
+ const tag = document.createElement('script');
+ tag.async = true;
+ tag.src = 'https://www.googletagmanager.com/gtag/js?id=G-WQLBQL6GY3';
+ document.head.appendChild(tag);
Review Comment:
Fixed in f8288c7ed3847eb718d2fab0771c7adf1bf71ed1. The Redis regression now
requires exactly the intended inline Analytics bootstrap and continues to
reject module scripts, Astro islands, and any additional executable scripts.
Both English and Chinese Redis pages are checked. Added browser coverage that
serves the generated HTML under simulated production and Netlify hostnames,
verifies the exact async Google tag and scoped configuration only in
production, and intercepts Google requests so the tests send no analytics
traffic.
Validation: 7 analytics behavior tests, syntax/whitespace checks, and
independent review pass. The four desktop/mobile production/preview browser
cases also pass locally against a compiled Analytics HTML fixture; this is not
a full-site build or a substitute for the complete Redis content regression.
The new head has been pushed for both required CI workflows to validate the
actual generated/overlaid site.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]