simulate-returning-user
它能做什么
这项技能在同一个浏览器会话中发送模拟的多页面访问,并检查每个页面上的 PostHog 事件。适合希望确认访客的活动被正确关联在一起的开发者。
适用场景
- ✓当你想确认页面浏览之间保持同一个用户 ID 的时候。
- ✓当你想检查每个页面而不仅仅是第一个页面都被记录了页面浏览的时候。
- ✓当有人反映同一位访客的活动被拆分到了多个用户的时候。
技能链接
https://github.com/PostHog/posthog/blob/master/tools/traffic-sim/skills/simulate-returning-user/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请模拟一位访客在我们网站上浏览三个页面,并检查 PostHog 是否把这三次页面浏览都关联到同一个用户。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会运行一个在页面浏览之间保留 Cookie 和存储的浏览器会话,使访问过程像真人浏览一样。它会报告事件和用户 ID,然后确认每次页面浏览是否被记录。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Simulate returning-user traffic
Drives a single browser context across N page views (cookies and localStorage persist), navigating between pages and reporting which PostHog events fired. This matches the behavior of a single visitor browsing multiple pages on the same site.
When to use
- Confirm that PostHog reuses the same
distinct_idacross page views in a session (no fresh anonymous IDs per page). - Confirm
$pageviewfires on every page view, not just the first. - Reproduce "session not stitching" or "events split across multiple users" reports.
How to invoke
Call the simulate_returning_user MCP tool with:
url(required) — the page to visit each iteration.page_views(default3) — number of page views in the session.interval(default5.0) — seconds between page views.posthog_host(defaulthttps://us.i.posthog.com).
To exercise multi-page navigation, call the tool once per URL — the cookies
won't carry across calls (each call is a separate Playwright context). For
true multi-page browsing within one session, edit the URL list passed to the
underlying CLI: traffic-sim returning-user --url A --url B --url C.
Interpreting the result
The structured response shape matches simulate_new_user. Key signals:
verified: trueandpageviews >= page_views— the session works.- Same
distinct_idacross all pageviews (visible in PostHog UI under the run_id query param) — session stitching works. - Different
distinct_idper visit — likely a cookie domain or storage-permissions issue. Inspect the rawposthog_requestsfor$session_idvalues to diagnose.
常见问题
它与全新用户测试有何不同?
此测试在页面浏览之间保留 Cookie,因此它检查的是访问如何被关联,而不是首次访问的行为。
它可以在一次会话中访问多个页面吗?
每次调用只使用一个页面地址,因此要访问多个页面,需要修改传给工具的 URL 列表。
这里的已验证是什么意思?
指 PostHog 记录的页面浏览数至少等于所请求的页面浏览数。
详情
作者的原始描述
Send synthetic single-session multi-page traffic to a URL and confirm PostHog $pageview events fire across page views. Use when verifying that cookies persist correctly, that the same distinct_id is reused across navigations, or when debugging session-stitching issues.
repo: PostHog/posthog
热度
- GitHub 星标
- 41k
- 排名
- #6987
- 许可证
- —
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
depot-ci
41k帮你的智能体设置并运行 Depot CI 工作流(GitHub Actions 的替代方案),包括迁移现有工作流和读取运行日志。
depot-container-builds
41k帮你的智能体在 Depot 的远程构建器上构建 Docker 镜像,包括多平台镜像、推送到镜像仓库,以及修复构建失败。
depot-github-runners
41k帮你的智能体把 GitHub Actions 任务迁移到 Depot 托管的运行器上,选择运行器规格和标签,并排查运行器设置问题。
editing-agents-md
41k帮你的智能体判断某条规则应写入 AGENTS.md 还是 CLAUDE.md,并以不会让文件臃肿的方式写下,确保规则真正生效。