posthog-exploring-autocapture-events
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "posthog-exploring-autocapture-events":https://skillpi.com/zh/skills/deepskill-c22eeb13542f18bb1f3c047ea275298683660fe6710b9d9fb563cf126277a376。安装前核对上游来源和版本:https://skills.sh/posthog/ai-plugin/exploring-autocapture-events。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
skills.sh
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
用于探索由 posthog-js 捕获的 $autocapture 事件的指南与工具。帮助理解用户交互、查找 CSS 选择器(尤其是 data-attr 属性)、评估选择器唯一性、临时查询匹配的点击事件并基于这些事件创建操作。仅适用于使用 posthog-js autocapture 的项目。
介绍来源: third_party · posthog · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 来源文档未说明。
- 输入和输出
- 来源文档未说明。
- 软件、账号及付费要求
- 来源文档未说明。
- 限制与区别
- 来源文档未说明。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: exploring-autocapture-events
description: >
Guides exploration of $autocapture events captured by posthog-js to understand user interactions,
find CSS selectors (especially data-attr attributes), evaluate selector uniqueness, query matching
clicks ad-hoc, and create actions. Use when the user asks about autocapture data, wants to find
what users are clicking, needs to build actions from click events, asks about elements_chain,
wants to build a trend or funnel filtered by clicks or other autocapture interactions, asks which
properties autocapture sends, or asks how to filter $autocapture events. Only applies to projects
using posthog-js autocapture.Exploring autocapture events
if users opt in then posthog-js automatically captures clicks, form submissions, and page changes as $autocapture events.
Each event records the clicked DOM element and its ancestors in the elements_chain column.
$autocapture is intentionally excluded from the posthog:read-data-schema taxonomy
because it is only useful with autocapture-specific filters (selector, tag, text, href).
This skill fills that gap.
Materialized columns
The events table provides fast access to common element fields without parsing the full chain string.
| Column | Type | Description |
|---|---|---|
elements_chain |
String | Full semicolon-separated element chain (see format reference) |
elements_chain_href |
String | Last href value from the chain |
elements_chain_texts |
Array(String) | All text values from elements |
elements_chain_ids |
Array(String) | All id attribute values |
elements_chain_elements |
Array(String) | Useful tag names: a, button, input, select, textarea, label |
Use materialized columns for exploration queries whenever possible — they avoid regex parsing.
Canonical autocapture properties
Every $autocapture event from posthog-js ships with a fixed set of properties.
Do not query the schema to "look them up" — they are these:
| Property | Examples | Notes |
|---|---|---|
$event_type |
click, submit, change |
the kind of interaction |
$el_text |
Sign up, Submit |
text of the clicked element |
$current_url |
https://app.example.com/pricing |
page the interaction happened on |
$elements_chain |
semicolon-separated chain | parsed via the elements_chain* materialized columns above |
Standard event properties ($browser, $os, $device_type, etc.) are also present.
Workflow
1. Confirm autocapture data exists
Run a count query before doing anything else. If the count is zero, autocapture may be disabled. There are two ways this happens:
- Project settings — the team can set
autocapture_opt_outin PostHog project settings - SDK config — the posthog-js
init()call can passautocapture: false
Tell the user if no data is found so they can check both settings.
SELECT count() as cnt
FROM events
WHERE event = '$autocapture'
AND timestamp > now() - INTERVAL 7 DAY
2. Explore what users are interacting with
Start broad using the materialized columns. The goal is to understand what users are clicking before narrowing down.
Useful explorations:
- Top clicked tag names (via
elements_chain_elements) - Top clicked text values (via
elements_chain_texts) - Top clicked hrefs (via
elements_chain_href) - Raw
elements_chainvalues for a specific page (filtered byproperties.$current_url)
See example queries for all patterns.
3. Find candidate selectors
Once the user identifies an interaction they care about, find a CSS selector that identifies it.
Priority order for selector attributes (best first):
- *
data-attror other `data-attributes** — highest specificity, stable across deploys, developer-intended anchors. Search withmatch(elements_chain, 'data-attr=')orextractAll`. - Element ID (
attr_id) — also highly stable, queryable viaelements_chain_ids. - Tag + class combination — moderately stable but classes change with CSS refactors.
- Text content — fragile (changes with copy edits, i18n) but sometimes the only option.
- Tag name alone — too broad on its own, useful as a qualifier.
When a data-attr value is found, construct a selector like [data-attr="value"] or button[data-attr="value"].
4. Evaluate selector uniqueness
A selector is only useful if it matches the intended interaction and not unrelated events.
Run a uniqueness check using elements_chain =~ with the regex pattern for the selector.
Then sample matching events to inspect what the selector actually captures.
Compare the count against total autocapture volume to understand selectivity.
A good selector matches a single logical interaction. If it matches too many distinct elements, refine it in the next step.
5. Refine with additional filters
If the selector alone is not unique enough, layer on additional filters:
- Text filter — match by element text content using
elements_chain_texts - URL filter — restrict to a specific page using
properties.$current_url - Href filter — match by link target using
elements_chain_href
Re-run the uniqueness check after each refinement. Only include filters that are needed — fewer filters means more resilience to minor DOM changes.
6. Filter autocapture inside an insight query
When the user wants a funnel, trend, or other insight, the filter shape is different from HogQL.
Each step in a FunnelsQuery / TrendsQuery is an EventsNode (or ActionsNode) with event: "$autocapture" and a properties array.
Two distinct property type values matter — they are not interchangeable:
type: "element"— keys:selector,tag_name,text,href. Matched against the parsedelements_chain. Operator support is split:selectorandtag_nameonly supportexactandis_not— any other operator is rejected by the query engine and the query errors.textandhrefaccept the full string operator set (exact,is_not,icontains,not_icontains,regex,not_regex,is_set,is_not_set).
type: "event"— keys: any of the canonical autocapture properties ($event_type,$el_text,$current_url) or anything else on the event. Standard event-property operators (exact,icontains,regex, etc.).
Example funnel from clicking one button to clicking another:
{
"kind": "FunnelsQuery",
"series": [
{
"kind": "EventsNode",
"event": "$autocapture",
"properties": [
{
"type": "element",
"key": "selector",
"value": ["[data-attr=\"autocapture-series-save-as-action-banner-shown\"]"],
"operator": "exact"
}
]
},
{
"kind": "EventsNode",
"event": "$autocapture",
"properties": [
{
"type": "element",
"key": "selector",
"value": ["[data-attr=\"autocapture-save-as-action\"]"],
"operator": "exact"
}
]
}
]
}
Two things easy to get wrong:
valueis an array even when matching a single selector- The selector string includes the
[data-attr="..."]wrapper — it is a CSS selector, not a bare attribute value
Decision rule: prefer an action (ActionsNode referencing an existing action — see Step 8) when the interaction will be referenced more than once; inline type: "element" / type: "event" filters when it's a one-off insight; raw HogQL (Step 7) when joining across events or doing custom aggregations.
7. Use in ad-hoc queries
The discovered selector can be used directly in HogQL without creating an action.
Trends — count matching clicks over time:
SELECT
toStartOfDay(timestamp) as day,
count() as clicks
FROM events
WHERE event = '$autocapture'
AND timestamp > now() - INTERVAL 14 DAY
AND elements_chain =~ '(^|;)button.*?data-attr="checkout"'
GROUP BY day
ORDER BY day
Funnel — pageview to click conversion:
SELECT
person_id,
first_pageview,
first_click_after
FROM (
SELECT
p.person_id,
p.pageview_time as first_pageview,
min(c.click_time) as first_click_after
FROM (
SELECT person_id, min(timestamp) as pageview_time
FROM events
WHERE event = '$pageview'
AND timestamp > now() - INTERVAL 14 DAY
AND properties.$current_url ILIKE '%/pricing%'
GROUP BY person_id
) p
INNER JOIN (
SELECT person_id, timestamp as click_time
FROM events
WHERE event = '$autocapture'
AND timestamp > now() - INTERVAL 14 DAY
AND elements_chain =~ '(^|;)button.*?data-attr="signup"'
) c ON p.person_id = c.person_id AND c.click_time > p.pageview_time
GROUP BY p.person_id, p.pageview_time
)
For recurring analysis, prefer creating an action (next step) or using posthog:query-trends / posthog:query-funnel with the action.
8. Create an action
Actions are the durable version of ad-hoc selector queries.
Once the criteria uniquely identify the interaction, create an action using posthog:action-create.
Construct the step with only the filters needed for uniqueness:
{
"name": "Clicked checkout button",
"steps": [
{
"event": "$autocapture",
"selector": "button[data-attr='checkout']",
"text": "Complete Purchase",
"text_matching": "exact",
"url": "/checkout",
"url_matching": "contains"
}
]
}
Available step fields for $autocapture:
selector— CSS selector (e.g.button[data-attr='checkout'])tag_name— HTML tag name (e.g.button,a,input)text/text_matching— element text (exact,contains, orregex)href/href_matching— link href (exact,contains, orregex)url/url_matching— page URL (exact,contains, orregex)
After creation, verify with matchesAction():
SELECT count() as matching_events
FROM events
WHERE matchesAction('Clicked checkout button')
AND timestamp > now() - INTERVAL 7 DAY
Tips
- Always set timestamp filters —
$autocaptureis high volume - Use
LIMITgenerously when samplingelements_chain— the strings can be long - The
elements_chain =~operator matches CSS selectors as regex internally; prefer materialized columns when possible for performance - This workflow only applies to posthog-js — other SDKs do not capture elements
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供完整的 autocapture 事件探索工作流,从数据确认到创建操作,解决用户理解交互和构建操作的核心痛点
- 适用于使用 posthog-js 的项目,场景明确且实用价值高
亮点
- 触发描述覆盖全面,明确列出多种适用场景(如 autocapture 数据、elements_chain、构建操作等),边界清晰
亮点
- 结构清晰,分 8 个步骤详细描述工作流,包含多个端到端示例(SQL 查询、JSON 配置)
- frontmatter 完整,文档组织良好,易于理解和执行
亮点
- 提供具体的 SQL 查询和 JSON 配置示例,工具来源明确,参数正确
- 覆盖主要异常情况(如无数据检查),并给出决策规则,执行可靠性高
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- app.example.com
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
来源文档未说明。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。