Conversation
Contributor
Author
Owner
|
相关修改,可以尽量使用虚拟骨架实现,而不是直接修改 |
新增 web.runtime.network.telemetry-guard 后,仓库里 6 个测试文件把修改点总数与 host/前缀分布硬编码为 103,需要同步为 104(browser 37→38、web.runtime. 37→38)。同时移除 zh-CN 语言包里多余的新增 key:该文件此前不承载任何 runtimeCompatibility.point.* 文案(中文以 catalog.ts 的描述为准),保留会破坏既有约定。
新增 web.runtime.network.telemetry-guard 落在 web-network 组,分组分布断言该组计数 3 -> 4。 compatibility-service 中"合并一个外部插件点后的快照长度"断言基数随之从 104 变为 105。
按骨架约定补齐四处接线与规范缺口: 1. check-modification-boundaries 仍把点数硬编码为 103。它是 build:gateway 的 pretest 环节,新增点让 dist 变成 104 项后,全新构建会在编译阶段直接抛错, CI 与本地干净构建都会失败(实测 pnpm run build:gateway 退出码 1)。 2. 逐文件回退加载路径漏装该 Provider:官方 bundle 含 eager script 或存在外部插件时 canBundleRuntimeBootstrap 为 false,Provider 根本不加载,修改点会在 locate 阶段被判 unsupported。补进与 tooltip-dismiss 同样的 runtimeScript 序列。 3. Provider 在 installer 末尾无条件 emit,违反 docs/MODIFICATION_SKELETON.md 的 "安装完成只代表 ready""不得在 installer 完成时上报 hit"。改为在 send/sendBeacon 真正吞掉遥测时逐次上报,调试页由此反映真实流量;测试同步断言安装后 emits 为 0、 透传流量不计数、每条被吞请求计一次。 4. 新测试断言 zh-CN 也必须给点描述,与仓库现状冲突:zh-CN 语言包不含任何 runtimeCompatibility.point.* 键(中文由 catalog.ts 描述经 metadataText 回退)。 改为断言该约定,并顺手把测试文件登记进 package.json 的 test 脚本, 否则 pnpm test 永远不会执行它。
yorkane
force-pushed
the
codex/statsig-telemetry
branch
from
September 17, 2026 04:37
809edf5 to
f629b2f
Compare
Contributor
Author
#56 已 force-push 换成骨架版 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
改动:改为虚拟修改骨架实现(本 PR 已 force-push 重写)
原实现(f986aa4 + 2d8beac)直接在上游文件 codex-bridge-polyfill.js 里给 XMLHttpRequest.prototype 与 navigator.sendBeacon 打猴补丁。按仓库自身的架构约定,这类行为应作为虚拟修改骨架的独立 Provider 提供,上游文件保持零改动。本版按此重写。
判据:codex-bridge-polyfill.js 相对 main 的 diff 为空,并新增测试断言该文件不得再出现 XMLHttpRequest.prototype.open / sendBeacon / 两个旧补丁标记。
实现
保留的关键细节(原 PR 第二个提交修的那个缺陷):XHR 的 status / statusText / response / responseText / readyState 是原型上的只读 IDL getter,直接赋值会被静默忽略,SDK 读到的仍是 readyState=0,因此用 Object.defineProperty 只覆盖实例、不污染原型;测试用带只读 getter 的假 XHR 复现该形状来守住这点。
骨架规范落点:
配套的必要改动
新增修改点会打破仓库里硬编码的点计数,已一并同步(与主题同属一个原子变更:拆开会让任一提交都无法通过构建):
zh-CN 语言包没有新增键:该文件按仓库现状不承载任何 runtimeCompatibility.point.* 文案(中文取 catalog.ts 的中文描述经 metadataText 回退),测试已断言并守住该约定。
验证
独立克隆 + 全新构建下跑 pnpm test:448 tests / 442 pass / 6 fail,build:gateway 退出码 0。6 条失败与基线(f6fd79c 全新构建)逐字相同,均与本改动无关:3 条 official-desktop-compat 是测试机装有官方 ChatGPT Desktop 被扫到 app.asar;static-assets、runtime-compatibility-page、plugin-config 各 1 条是上游 1f07656 改了 i18n 标题与 effort 取值却没同步测试期望。
新增 8 条用例全绿,覆盖:拦截并模拟成功(200 / readyState 4 / responseText 可读 / load 与 loadend 各一次 / 只覆盖实例不污染原型)、相似域名与外域不误拦、Beacon 命中返回 true 且未触达原生、同代次二次加载幂等、own() 的 dispose 还原原型后透传恢复、点只声明一次且绑定一次。
与其他 PR 的关系
本 PR 拦 renderer 侧的 XHR/Beacon 通道。无出口机器上还有一条走 Electron 主进程 net.fetch 的 Statsig 控制面通道,本 Provider 覆盖不到,由 #58 处理;两者互补不冲突。#58 目前基于 #57,#57 合并后可 rebase。