Agent Skillspollinations/pollinations › spending-analysis

spending-analysis

GitHub

提供基于 Tinybird 和 Stripe 的生产数据查询脚本,用于分析订阅收入、购买记录及用户消费模式。支持按周统计收入、查看近期购买明细及按客户分组统计花费,助力业务财务数据分析。

.claude/skills/spending-analysis/SKILL.md pollinations/pollinations

Trigger Scenarios

需要查询 Pollinations 平台实时或历史营收数据 分析特定时间段内的包购买趋势 查看高价值客户或用户的消费行为 检查不同计量来源的资源消耗与花费

Install

npx skills add pollinations/pollinations --skill spending-analysis -g -y
More Options

Non-standard path

npx skills add https://github.com/pollinations/pollinations/tree/main/.claude/skills/spending-analysis -g -y

Use without installing

npx skills use pollinations/pollinations@spending-analysis

指定 Agent (Claude Code)

npx skills add pollinations/pollinations --skill spending-analysis -a claude-code -g -y

安装 repo 全部 skill

npx skills add pollinations/pollinations --all -g -y

预览 repo 内 skill

npx skills add pollinations/pollinations --list

SKILL.md

Frontmatter
{
    "name": "spending-analysis",
    "description": "Analyze Pollinations Stripe revenue, pack purchases, and balance-bucket spending patterns with Tinybird production data."
}

Requirements

  • Run from the pollinations repository root.
  • Install curl, jq, and sops.
  • Use the production Tinybird read token. The staging workspace has no real revenue.

Setup

export TINYBIRD_TOKEN=$(sops -d operations/kpi/secrets/env.json | jq -r '.TINYBIRD_READ_TOKEN')

Never print the token. Revenue queries must filter successful Stripe checkout events so asynchronous payment methods are counted exactly once.

Weekly pack revenue

curl -sS "https://api.europe-west2.gcp.tinybird.co/v0/sql" \
  -H "Authorization: Bearer $TINYBIRD_TOKEN" \
  --data-urlencode "q=SELECT toStartOfWeek(timestamp) AS week, round(sum(amount_cents) / 100, 2) AS revenue_usd, count() AS purchases FROM stripe_event WHERE payment_status = 'paid' AND event_type IN ('checkout.session.completed', 'checkout.session.async_payment_succeeded') AND timestamp >= now() - INTERVAL 90 DAY GROUP BY week ORDER BY week DESC FORMAT JSON" \
  | jq '.data'

Recent pack purchases

curl -sS "https://api.europe-west2.gcp.tinybird.co/v0/sql" \
  -H "Authorization: Bearer $TINYBIRD_TOKEN" \
  --data-urlencode "q=SELECT timestamp, user_id, session_id, amount_cents / 100 AS amount, currency, payment_method FROM stripe_event WHERE payment_status = 'paid' AND event_type IN ('checkout.session.completed', 'checkout.session.async_payment_succeeded') ORDER BY timestamp DESC LIMIT 100 FORMAT JSON" \
  | jq '.data'

Revenue by customer

curl -sS "https://api.europe-west2.gcp.tinybird.co/v0/sql" \
  -H "Authorization: Bearer $TINYBIRD_TOKEN" \
  --data-urlencode "q=SELECT user_id, round(sum(amount_cents) / 100, 2) AS revenue_usd, count() AS purchases FROM stripe_event WHERE payment_status = 'paid' AND event_type IN ('checkout.session.completed', 'checkout.session.async_payment_succeeded') AND timestamp >= now() - INTERVAL 30 DAY GROUP BY user_id ORDER BY revenue_usd DESC LIMIT 50 FORMAT JSON" \
  | jq '.data'

Weekly spend by balance bucket

curl -sS "https://api.europe-west2.gcp.tinybird.co/v0/sql" \
  -H "Authorization: Bearer $TINYBIRD_TOKEN" \
  --data-urlencode "q=SELECT toStartOfWeek(start_time) AS week, splitByChar(':', selected_meter_slug)[-1] AS meter_source, sum(total_price) AS total_spend, count() AS requests FROM generation_event_v2 WHERE start_time >= now() - INTERVAL 60 DAY AND environment = 'production' GROUP BY week, meter_source ORDER BY week DESC FORMAT JSON" \
  | jq '.data'

Notes

  • stripe_event is the source of truth for pack-purchase revenue analytics.
  • generation_event_v2 records Pollen consumption, not cash revenue.
  • Both datasets use user_id, so revenue and usage can be joined directly.
  • The dashboard's daily_stripe_revenue pipe applies the same paid-event filter.
  • For pre-migration revenue history, note that Polar was the pre-Stripe merchant of record (Nov 2025–Jan 2026) and is retired. Do not combine historical Polar and Stripe totals without checking the cutoff for overlap.

Version History

  • 8303332 Current 2026-08-20 04:57

    修复了获取 Tinybird 读取令牌时 sops 解密配置文件的路径错误(从 apps/operation/kpi/secrets/env.json 更正为 operations/kpi/secrets/env.json)。

  • 99bce92 2026-07-25 10:39

Same Skill Collection

.claude/skills/abuse-detection/SKILL.md
.claude/skills/candidate-evaluation/SKILL.md
.claude/skills/code-formatting/SKILL.md
.claude/skills/community-leaderboard/SKILL.md
.claude/skills/enter-services/SKILL.md
.claude/skills/issue-maker/SKILL.md
.claude/skills/manage-vast-gpu-fleet/SKILL.md
.claude/skills/model-debugging/SKILL.md
.claude/skills/model-management/SKILL.md
.claude/skills/monitor-services/SKILL.md
.claude/skills/polli-video/SKILL.md
.claude/skills/polli/SKILL.md
.claude/skills/r2-glacier-migration/SKILL.md
.claude/skills/sync-production/SKILL.md
.claude/skills/tinybird-deploy/SKILL.md
.claude/skills/voting-status/SKILL.md
.claude/skills/web-research/SKILL.md
apps/openclaw/skills/founder-meditation/SKILL.md
packages/polli-cli/SKILL.md

Metadata

Files
0
Version
8303332
Hash
ac6ba5dc
Indexed
2026-07-25 10:39

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-21 07:18
浙ICP备14020137号-1 $mapa de visitantes$