Repository navigation
Conversation
When `offline: true`, the mini-program SDK no longer creates a debug room, reuses the cached room, or registers the onAppShow reconnect, and the socket store is marked as offline (`connectable = false`, `isOffline = true`), mirroring the browser SDK. Data collection and DataHarbor upload are unaffected since they rely on `public-data` events, not the socket. Ref: HuolalaTech/page-spy-web#415 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes HuolalaTech/page-spy-web#415
背景
浏览器 SDK 支持
offline: true:开启后不建调试房间、不连 WebSocket,只在本地采集,配合 DataHarbor 上传日志做回放。小程序 SDK 目前不支持(文档中config.offline也只标注了浏览器平台),初始化即创建房间并连接 WebSocket。给真实用户开启离线录制时,每个用户都会在服务端挂一个实时调试房间,详见上面关联的 issue。改动(
packages/page-spy-mp-base/src/index.ts)与浏览器 SDK 保持一致:
updateConfiguration():socketStore.connectable = !offline,并设置socketStore.isOffline = offline(离线时不再为调试端缓存消息)。init():仅在config.offline === false时建立或复用连接,并注册onAppShow重连。数据采集走
public-data事件,小程序 DataHarbor 监听的正是这个事件,与 socket 无关,所以离线模式下采集与upload()不受影响。offline默认值仍为false,未设置的现有用户行为不变。测试
packages/page-spy-mp-base/tests/init.test.ts新增Offline mode一组 5 条:createNewConnection/useOldConnection,也不写房间缓存;onAppShow重连;socketStore.connectable === false、isOffline === true;onAppShow、connectable === true。本地
yarn lerna run build后运行npx jest:32 个套件、182 条全部通过;改动文件 eslint、prettier 通过。我们在自己的微信小程序里用等价做法(初始化前置空两个建连方法)实测过:服务端不再建房间、没有 WebSocket 连接,采集正常,
upload()照常上传。文档
合并后,
page-spy-web文档中config.offline的平台标注需要补上小程序。需要的话我们可以另提一个 PR。🤖 Generated with Claude Code