SuperAPI AI 工具集

mixpanel-data

数据与分析

查看项目

更新于 10-16 00:04

技能介绍

用途:分析 Mixpanel 分析数据,支持事件、用户画像、漏斗、留存等场景。核心思路是先把 Mixpanel 数据抓取到本地 DuckDB,再用 SQL 反复查询,避免原始 API 响应消耗上下文。

主要能力:提供 Python 库 mixpanel_data 与命令行工具 mp。Workspace 类覆盖发现(events、properties、funnels、cohorts)、数据抓取(fetch_events、fetch_profiles、stream_*)、分析(segmentation、funnel、retention、jql)以及本地 SQL(sql、sql_scalar、sql_rows)和自省(info、tables、sample、summarize)。

使用方式:三条数据路径。实时查询直接调用 API,如 ws.segmentation("Purchase", from_date="2024-01-01", to_date="2024-01-31", on="country") 或 mp query segmentation -e Purchase --from 2024-01-01 --to 2024-01-31 --on country。本地分析先抓取再查询,如 ws.fetch_events("events", from_date="2024-01-01", to_date="2024-03-31", parallel=True) 后执行 ws.sql(...),CLI 对应 mp fetch events --from 2024-01-01 --to 2024-03-31 --parallel 与 mp query sql "..."。流式路径用 mp fetch events --stdout 管道给 jq 等工具。事件与画像属性以 JSON 存储,用 properties->>'$.fieldname' 访问。凭据按环境变量 MP_USERNAME、MP_SECRET、MP_PROJECT_ID、MP_REGION,命名账户或 ~/.mp/config.toml 默认账户解析。

适用场景:脚本、笔记本、数据管道、复杂多步分析、一次性查询、Shell 管道及非 Python 环境。

限制:日期范围超过 7 天建议用 --parallel,超过 100 天必须使用;--jq 仅配合 --format json 或 jsonl;漏斗查询需要已保存的漏斗 ID;常见错误包括表已存在、认证失败、限流、日期范围过大、事件不存在。完整文档见 https://jaredmcfarland.github.io/mixpanel_data/ 及其 llms.txt、llms-full.txt。