Wiring Unity LevelPlay Into Our Revenue Ledger and Bypassing Toss Report Timeouts
How we added Unity LevelPlay v6 reporting with daily USD-to-KRW FX caching to our local ledger, and switched Toss IAA collection to per-app queries with rate-limit backoff after workspace-wide reports started timing out.
한국어로 읽기 수익 장부에 LevelPlay API 붙이고, 토스 IAA 전체 리포트 타임아웃 우회하기
Just days after removing headless AI from our Toss ledger collector, our local revenue-ledger needed two more upgrades: pulling stats from our new Unity LevelPlay mediation account, and fixing persistent timeouts on Toss’s workspace-wide ad report. (As usual, we share the architecture and code patterns without disclosing revenue figures.)
1. levelplay_fetch.py: Pulling LevelPlay v6 Stats Into a KRW Ledger
- Token exchange: Reads gitignored
Secret KeyandRefresh Tokenfromlevelplay_api.jsonand requests a bearer token fromplatform.ironsrc.com/partners/publisher/auth. - 14-day window through yesterday: Calls
mediation/applications/v6/statsup to yesterday so daily totals stay aligned across platforms (today’s in-progress UTC numbers print only to the console unless--todayis passed). - Daily USD → KRW cache: Fetches the USD/KRW rate once per day from
open.er-api.com/v6/latest/USDintofx_usd_krw.json, falling back to the last cached rate or1400.0if offline. - Unified app names: Maps each
appKeyand PlaybundleIdvialevelplay-*.propertiesandapps.csvso Toss and Play rows merge cleanly under one display name.
2. Making Toss Per-App Fetching the Default
As our Toss mini-app count grew, iaa_workspace_dashboard_report_v2 began timing out consistently after 60 seconds. Previously, toss_fetch.py wasted a minute waiting for the workspace report to fail before falling back.
In commit b61159e, we made per-app querying (fetch_per_app) the default and hardened toss_mcp.py:
- Lowered default concurrency (
TOSS_MCP_PARALLEL) from 4 to 2. - Classified JSON-RPC rate-limit phrases (
Too Many Requests,rate limit, Korean equivalents) asTransientErrorinstead of fatalRpcError. - Bumped retries from 3 to 4 with
(2, 5, 10)-second backoff.
3. Refreshing Every Platform With One Command
Now a single update.cmd run refreshes Toss IAA, Unity LevelPlay, promotions, reviews, and the HTML dashboard without manual intervention. Adapting to a new ad network only required swapping in one collector module rather than rebuilding the pipeline.
