Loading...
Loading...
Analyze Pollinations revenue, pack purchases, and tier spending patterns. Query Polar for payment history and Tinybird for usage data.
npx skill4agent add pollinations/pollinations spending-analysisbrew install jqbrew install sopspollinationsenter.pollinations.ai/external_iduser_tiertotal_priceuser_id# From sops-encrypted secrets
export POLAR_ACCESS_TOKEN=$(sops -d enter.pollinations.ai/secrets/prod.vars.json | jq -r '.POLAR_ACCESS_TOKEN')
# Or from .testingtokens (if available)
export POLAR_ACCESS_TOKEN=$(grep POLAR_ACCESS_TOKEN enter.pollinations.ai/.testingtokens | cut -d= -f2)export TINYBIRD_TOKEN=$(sops -d enter.pollinations.ai/secrets/prod.vars.json | jq -r '.TINYBIRD_ACCESS_TOKEN')curl -sL "https://api.polar.sh/v1/products" \
-H "Authorization: Bearer $POLAR_ACCESS_TOKEN" | jq '[.items[] | {name, id, recurring: .is_recurring}]'# 5 pollen pack product 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}]'| 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) | |
.claude/skills/spending-analysis/scripts/weekly-pack-revenue.shcurl -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})'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'.claude/skills/spending-analysis/scripts/weekly-pack-revenue.sh.claude/skills/spending-analysis/scripts/pack-purchases-by-tier.sh| 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 |
| 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 |
external_iduser_idcurl -sL