Skip to content

Fix Google Analytics detection#44

Merged
wauputr4 merged 7 commits into
releasefrom
main
Jul 20, 2026
Merged

Fix Google Analytics detection#44
wauputr4 merged 7 commits into
releasefrom
main

Conversation

@wauputr4

Copy link
Copy Markdown
Member

What changed

  • render the standard Google tag directly in <head>
  • keep the Measurement ID sourced from PUBLIC_GOOGLE_ANALYTICS_ID
  • allow the exact inline bootstrap through a generated SHA-256 CSP hash
  • remove the previous dynamic loader from the footer bundle

Why

The production bundle contained the Measurement ID, but dynamically injecting the tag could prevent Google installation checks from detecting the standard snippet reliably.

Validation

  • npm test (20 passed)
  • npm run check (0 errors, warnings, or hints)
  • PUBLIC_GOOGLE_ANALYTICS_ID=G-KT6W59QLYP npm run build (107 pages)
  • verified the generated tag is inside <head> and its CSP hash matches

github-actions Bot and others added 6 commits July 20, 2026 09:34
* feat: refresh community website content

* docs: align release and contribution guides

* fix: address release review findings

* feat: show blog commit contributors

* feat: link latest article commit

* fix: simplify homepage repository card

* feat: improve SEO analytics and AI discovery

* feat: add draft previews and release polish

* fix: preserve blog commit contributors
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8dce7197-21a9-4064-af90-15761fade64f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch main

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
indopensource-org ab7bc84 Commit Preview URL

Branch Preview URL
Jul 20 2026, 04:53 PM

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request migrates the deployment target from GitHub Pages to Cloudflare Workers Static Assets, updates contribution guidelines and release documentation, and introduces several new pages including a dedicated roadmap, a community directory, and a top users ranking page. Additionally, it integrates Google Analytics and Cloudflare Web Analytics, refactors structured data, and updates the blog sync script to support multiple authors. The review feedback highlights three key areas for improvement: defensively filtering out falsy values in the blog sync script to prevent runtime errors, normalizing line endings in the inline Google Analytics script to avoid CSP hash mismatches on Windows/CI environments, and dynamically resolving the sitemap URL in robots.txt using BASE_URL to support subpath deployments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

I am having trouble creating individual review comments. Click here to see my feedback.

scripts/sync-blog-posts.mjs (264-271)

medium

If resolvedAuthor.author is null or undefined, it will be added as the first element of the resolvedAuthors array, resulting in [null, ...] or [undefined, ...]. This can cause runtime errors when rendering author details in Astro templates. Filtering out falsy values defensively prevents this issue.

  const resolvedAuthors = (resolvedAuthor.fromFrontmatter\n    ? [\n        resolvedAuthor.author,\n        ...commitMeta.authors.filter(\n          (author) => author.name.toLowerCase() !== (resolvedAuthor.author?.name || '').toLowerCase()\n        )\n      ]\n    : commitMeta.authors.length ? commitMeta.authors : [resolvedAuthor.author]\n  ).filter(Boolean);

src/layouts/BaseLayout.astro (53-58)

medium

If the source file is checked out with CRLF line endings (e.g., on Windows or certain CI environments), the template literal for googleAnalyticsScript will contain \r\n. However, the HTML generator/compiler might normalize it to \n when emitting the inline script. This mismatch between the hashed string and the emitted script will cause the CSP SHA-256 hash check to fail and block Google Analytics. Normalizing the line endings to \n before hashing and emitting ensures consistency across all platforms.

const googleAnalyticsScript = googleAnalyticsId\n  ? `window.dataLayer = window.dataLayer || [];\nfunction gtag(){dataLayer.push(arguments);}\ngtag('js', new Date());\ngtag('config', ${JSON.stringify(googleAnalyticsId)});`.replace(/\r\n/g, '\n')\n  : '';

src/pages/robots.txt.ts (10-11)

medium

If the site is configured to be served under a subpath via import.meta.env.BASE_URL, hardcoding /sitemap.xml relative to the origin will point to the root domain instead of the correct subpath sitemap. Using BASE_URL ensures sitemap resolution is correct across all deployment environments.

  const origin = site ?? new URL('https://indopensource.org');\n  const baseUrl = import.meta.env.BASE_URL.replace(/\/?$/, '/');\n  const sitemapUrl = new URL(baseUrl + 'sitemap.xml', origin).toString();

@wauputr4
wauputr4 marked this pull request as ready for review July 20, 2026 16:54
@wauputr4
wauputr4 merged commit 72527b8 into release Jul 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant