Skip to content

修复 GA4 初始化前的隐私配置并补真实 SDK 契约 - #123

Merged
Frees-Ling merged 12 commits into
mainfrom
gemini/blog-consent-ads-hardening-20261018
Nov 10, 2026
Merged

Frees-Ling merged 12 commits into
mainfrom
gemini/blog-consent-ads-hardening-20261018

Conversation

@Frees-Ling

@Frees-Ling Frees-Ling commented Nov 7, 2026 •

Copy link
Copy Markdown
Owner

真实 Google SDK 在读者同意后发出的 page_view 仍含查询参数,并使用了通用 _ga Cookie;原先的 SDK 夹具没有发现这项初始化顺序问题。本 PR 将完整隐私参数提前到 SDK 初始化前,保留显式同意、广告拒绝与单次手动浏览事件,并补清理本衡量 ID 的旧专用 Cookie,保留其他站点的通用 Cookie。

新增手动隔离真实 SDK 检查:所有收集请求在发送前拦截,不写入正式统计;核验干净地址、来源域、Cookie 主机/期限及撤回。默认完整 Visual 和 Quality 门禁保留,调查模式单独标记,不能当作生产验收。

验证:最终精确提交 cd40424 的完整 Quality 42752697364、完整 Visual 42752713276、精确隔离 SDK 契约 42752717274 全部通过。四张 390/1280 明暗主题中文截图已实际查看,文字正常、按钮完整、未见溢出。历史真实生产诊断 42749020765 / 42749812594 的失败保留,GA4 后台入库和 AdSense 审核没有通过证据。

生产仍是此前单独批准的 PR122。此 PR 已包含生产脚本变更,必须等待所有者对最终精确提交的独立发布批准;不发布 Hub,不启用广告或付费推广,不提交 AdSense 复审。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T03:58:19.910355Z cd40424 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f53087b71

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +111 to +113
page.on('framenavigated', (frame) => {
if (frame === page.mainFrame()) phase = 'after-withdrawal-reload';
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Start withdrawal monitoring before clicking deny

If the loaded SDK sends a collection request during withdrawal or the ensuing unload, before the replacement document commits, it is still labeled after-explicit-consent. The later assertion filters only after-withdrawal-reload, so this diagnostic can report withdrawal: PASS despite transmitting after consent was withdrawn. Replaying the registered handlers with a collection request followed by main-frame navigation confirms that the assertion passes. Set the withdrawal phase immediately before clicking deny and check all Google requests from that point onward, including the reload transition.

Useful? React with 👍 / 👎.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Deploying frees-ling-github-io with  Cloudflare Pages  Cloudflare Pages

Latest commit: cd40424
Status: ✅  Deploy successful!
Preview URL: https://b6d620f8.frees-ling-github-io.pages.dev
Branch Preview URL: https://gemini-blog-consent-ads-hard.frees-ling-github-io.pages.dev

View logs

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 198f5faed2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +177 to +181
assert.ok(
(await context.cookies()).some((cookie) =>
cookie.name.startsWith('fl_blog_ga'),
),
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Save collection evidence before asserting cookie presence

When the SDK acknowledges a page view but creates no fl_blog_ga cookie—the production failure already recorded in docs/execution/STATE.md—this assertion throws before collectionHttpStatus and sanitizedPageView are saved. Consequently, evidence.json loses the actual network page-location value needed to investigate the queue/network discrepancy, and withdrawal is never exercised. Replaying that response with an empty cookie list confirms both evidence fields are absent. Persist the receipt and observed page view immediately, then defer the cookie assertion until after gathering withdrawal evidence while retaining the overall failure.

Useful? React with 👍 / 👎.

@Frees-Ling Frees-Ling changed the title 核验已上线博客的真实GA4请求与撤回行为 修复 GA4 初始化前的隐私配置并补真实 SDK 契约 Nov 10, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 702b5471bf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread public/blog-analytics.js
Comment on lines +250 to 252
Object.keys(configuration).forEach(function (key) {
gtag('set', key, configuration[key]);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Update the consent test for the new set-command shape

Changing gtag('set', {...}) to individual three-argument calls breaks the existing consent regression test: src/utils/blog-analytics.test.mjs:430–437 selects the first set entry and still reads setCall[1].page_location and .page_referrer, but setCall[1] is now the string send_page_view. Running node --test src/utils/blog-analytics.test.mjs reproduces the failure (12 pass, 1 fail). Since .github/workflows/quality.yml runs this test through npm test, the required quality job cannot pass. Update the assertions to inspect the individual parameter calls while preserving the URL-sanitization checks.

Useful? React with 👍 / 👎.

@Frees-Ling
Frees-Ling merged commit c3ba094 into main Nov 10, 2026
9 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