spending-analysis
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRequirements
前置要求
Before using this skill, ensure you have:
- curl: For API requests
- jq: (for parsing JSON)
brew install jq - sops: (for decrypting secrets)
brew install sops
Must run from the repo root with access to .
pollinationsenter.pollinations.ai/使用此技能前,请确保你已具备:
- curl:用于API请求
- jq:(用于解析JSON)
brew install jq - sops:(用于解密密钥)
brew install sops
必须在仓库根目录运行,且拥有的访问权限。
pollinationsenter.pollinations.ai/Data Sources
数据源
Polar API
Polar API
- Orders: Payment history for pack purchases
- Products: Tier subscriptions and pollen packs
- Customers: User payment info linked by
external_id
- 订单:套餐购买的支付历史
- 产品:层级订阅和花粉套餐
- 客户:通过关联的用户支付信息
external_id
Tinybird
Tinybird
- generation_event: Usage data with ,
user_tier,total_priceuser_id - Tracks all API requests with pricing and tier info
- generation_event:包含、
user_tier、total_price的使用数据user_id - 追踪所有带定价和层级信息的API请求
Quick Commands
快速命令
Get Polar Access Token
获取Polar访问令牌
bash
undefinedbash
undefinedFrom sops-encrypted secrets
从sops加密的密钥中获取
export POLAR_ACCESS_TOKEN=$(sops -d enter.pollinations.ai/secrets/prod.vars.json | jq -r '.POLAR_ACCESS_TOKEN')
export POLAR_ACCESS_TOKEN=$(sops -d enter.pollinations.ai/secrets/prod.vars.json | jq -r '.POLAR_ACCESS_TOKEN')
Or from .testingtokens (if available)
或从.testingtokens获取(若可用)
export POLAR_ACCESS_TOKEN=$(grep POLAR_ACCESS_TOKEN enter.pollinations.ai/.testingtokens | cut -d= -f2)
undefinedexport POLAR_ACCESS_TOKEN=$(grep POLAR_ACCESS_TOKEN enter.pollinations.ai/.testingtokens | cut -d= -f2)
undefinedGet Tinybird Token
获取Tinybird令牌
bash
export TINYBIRD_TOKEN=$(sops -d enter.pollinations.ai/secrets/prod.vars.json | jq -r '.TINYBIRD_ACCESS_TOKEN')bash
export TINYBIRD_TOKEN=$(sops -d enter.pollinations.ai/secrets/prod.vars.json | jq -r '.TINYBIRD_ACCESS_TOKEN')Polar API Queries
Polar API 查询
List Products (Tiers & Packs)
列出产品(层级与套餐)
bash
curl -sL "https://api.polar.sh/v1/products" \
-H "Authorization: Bearer $POLAR_ACCESS_TOKEN" | jq '[.items[] | {name, id, recurring: .is_recurring}]'bash
curl -sL "https://api.polar.sh/v1/products" \
-H "Authorization: Bearer $POLAR_ACCESS_TOKEN" | jq '[.items[] | {name, id, recurring: .is_recurring}]'Get Pack Purchases (Last 100)
获取套餐购买记录(最近100条)
bash
undefinedbash
undefined5 pollen pack product ID
5花粉套餐产品ID
PRODUCT_ID="bcdde7f7-129e-4ec1-abc3-d4e0c852fa68"
curl -sL "https://api.polar.sh/v1/orders?limit=100&product_id=$PRODUCT_ID"
-H "Authorization: Bearer $POLAR_ACCESS_TOKEN" |
jq '[.items[] | {date: .created_at[0:10], amount: (.total_amount / 100), customer: .customer.email}]'
-H "Authorization: Bearer $POLAR_ACCESS_TOKEN" |
jq '[.items[] | {date: .created_at[0:10], amount: (.total_amount / 100), customer: .customer.email}]'
undefinedPRODUCT_ID="bcdde7f7-129e-4ec1-abc3-d4e0c852fa68"
curl -sL "https://api.polar.sh/v1/orders?limit=100&product_id=$PRODUCT_ID"
-H "Authorization: Bearer $POLAR_ACCESS_TOKEN" |
jq '[.items[] | {date: .created_at[0:10], amount: (.total_amount / 100), customer: .customer.email}]'
-H "Authorization: Bearer $POLAR_ACCESS_TOKEN" |
jq '[.items[] | {date: .created_at[0:10], amount: (.total_amount / 100), customer: .customer.email}]'
undefinedAll Pack Product IDs
所有套餐产品ID
| Pack | Product ID |
|---|---|
| 5 pollen + 5 FREE | |
| 10 pollen + 10 FREE | |
| 20 pollen + 20 FREE | |
| 50 pollen + 50 FREE | |
| 10 pollen (pack) | |
| 20 pollen (pack) | |
| 50 pollen (pack) | |
| 套餐 | 产品ID |
|---|---|
| 5花粉 + 5免费 | |
| 10花粉 + 10免费 | |
| 20花粉 + 20免费 | |
| 50花粉 + 50免费 | |
| 10花粉(套餐) | |
| 20花粉(套餐) | |
| 50花粉(套餐) | |
Weekly Revenue from All Packs
所有套餐的每周收入
bash
.claude/skills/spending-analysis/scripts/weekly-pack-revenue.shbash
.claude/skills/spending-analysis/scripts/weekly-pack-revenue.shTinybird Queries
Tinybird 查询
User Count by Tier
按层级统计用户数量
bash
curl -sL "https://api.europe-west2.gcp.tinybird.co/v0/sql" \
-H "Authorization: Bearer $TINYBIRD_TOKEN" \
--data-urlencode "q=SELECT argMax(user_tier, start_time) as tier, count() as users FROM generation_event WHERE start_time >= now() - INTERVAL 60 DAY AND environment = 'production' AND user_id != 'undefined' GROUP BY user_id FORMAT JSON" | \
jq '.data | group_by(.tier) | map({tier: .[0].tier, users: length})'bash
curl -sL "https://api.europe-west2.gcp.tinybird.co/v0/sql" \
-H "Authorization: Bearer $TINYBIRD_TOKEN" \
--data-urlencode "q=SELECT argMax(user_tier, start_time) as tier, count() as users FROM generation_event WHERE start_time >= now() - INTERVAL 60 DAY AND environment = 'production' AND user_id != 'undefined' GROUP BY user_id FORMAT JSON" | \
jq '.data | group_by(.tier) | map({tier: .[0].tier, users: length})'Weekly Spending by Tier
按层级统计每周消费
bash
curl -sL "https://api.europe-west2.gcp.tinybird.co/v0/sql" \
-H "Authorization: Bearer $TINYBIRD_TOKEN" \
--data-urlencode "q=SELECT toStartOfWeek(start_time) as week, user_tier, sum(total_price) as total_spend, count() as requests FROM generation_event WHERE start_time >= now() - INTERVAL 60 DAY AND environment = 'production' GROUP BY week, user_tier ORDER BY week DESC FORMAT JSON" | jq '.data'bash
curl -sL "https://api.europe-west2.gcp.tinybird.co/v0/sql" \
-H "Authorization: Bearer $TINYBIRD_TOKEN" \
--data-urlencode "q=SELECT toStartOfWeek(start_time) as week, user_tier, sum(total_price) as total_spend, count() as requests FROM generation_event WHERE start_time >= now() - INTERVAL 60 DAY AND environment = 'production' GROUP BY week, user_tier ORDER BY week DESC FORMAT JSON" | jq '.data'Analysis Scripts
分析脚本
Weekly Pack Revenue
每周套餐收入
bash
.claude/skills/spending-analysis/scripts/weekly-pack-revenue.shShows weekly breakdown of actual pack purchases (real revenue, not free tier usage).
bash
.claude/skills/spending-analysis/scripts/weekly-pack-revenue.sh展示每周实际套餐购买的明细(真实收入,非免费层级使用量)。
Pack Purchases by Tier
按层级统计套餐购买情况
bash
.claude/skills/spending-analysis/scripts/pack-purchases-by-tier.shCross-references Polar pack purchasers with Tinybird tier data to show which tiers buy most pollen proportionally.
bash
.claude/skills/spending-analysis/scripts/pack-purchases-by-tier.sh将Polar套餐购买者与Tinybird层级数据进行交叉关联,展示哪些层级的用户购买花粉的比例最高。
Key Findings (Jan 2026 Analysis)
关键发现(2026年1月分析)
Pack Purchases by Tier (Weighted by User Count)
按层级统计套餐购买情况(按用户数量加权)
| Tier | Revenue | Purchasers | Total Users | % Who Buy | $/User |
|---|---|---|---|---|---|
| nectar | $146 | 10 | 23 | 43.5% | $6.37 |
| flower | $564 | 18 | 218 | 8.3% | $2.59 |
| seed | $1,173 | 38 | 575 | 6.6% | $2.04 |
| spore | $1,657 | 106 | 6,757 | 1.6% | $0.25 |
Key Insight: Higher tiers buy MORE pollen proportionally, not less.
| 层级 | 收入 | 购买者数量 | 总用户数 | 购买占比 | 每用户平均消费 |
|---|---|---|---|---|---|
| nectar | $146 | 10 | 23 | 43.5% | $6.37 |
| flower | $564 | 18 | 218 | 8.3% | $2.59 |
| seed | $1,173 | 38 | 575 | 6.6% | $2.04 |
| spore | $1,657 | 106 | 6,757 | 1.6% | $0.25 |
核心洞察:层级越高的用户,购买花粉的比例越高,而非越低。
Revenue Trend (9 Weeks)
收入趋势(9周)
| Week | Orders | Revenue |
|---|---|---|
| Jan 13-19 | 51 | $573 |
| Jan 6-12 | 83 | $928 |
| Dec 30-Jan 5 | 59 | $928 |
| Dec 23-29 | 21 | $432 |
| Dec 16-22 | 22 | $276 |
| Dec 9-15 | 16 | $141 |
| Dec 2-8 | 17 | $293 |
| Nov 25-Dec 1 | 10 | $293 |
| Nov 18-24 | 1 | $10 |
| 周 | 订单数 | 收入 |
|---|---|---|
| 1月13日-19日 | 51 | $573 |
| 1月6日-12日 | 83 | $928 |
| 12月30日-1月5日 | 59 | $928 |
| 12月23日-29日 | 21 | $432 |
| 12月16日-22日 | 22 | $276 |
| 12月9日-15日 | 16 | $141 |
| 12月2日-8日 | 17 | $293 |
| 11月25日-12月1日 | 10 | $293 |
| 11月18日-24日 | 1 | $10 |
Notes
注意事项
- Free tier spending in Tinybird includes daily pollen allocation - not real revenue
- Pack purchases in Polar are actual paid revenue
- Cross-reference by (Polar) =
external_id(Tinybird)user_id - Polar API returns 307 redirects - use to follow
curl -sL
- Tinybird中的免费层级消费包含每日花粉配额,并非真实收入
- Polar中的套餐购买是实际付费收入
- 通过(Polar)=
external_id(Tinybird)进行交叉关联user_id - Polar API会返回307重定向 - 使用跟随重定向
curl -sL