Migrate research provider to SongStats
Merged
SI
5mo ago+1353+1353+0123456789012345678901234567890123456789-2300-2300-0123456789012345678901234567890123456789
Summary
- Make SongStats the default research provider via a provider router while preserving Chartmetric behind
RESEARCH_PROVIDER=chartmetric. - Add SongStats Enterprise API fetcher and compatibility mapper for supported artist, track, search, lookup, stats, audience, catalog, activities, and playlist paths.
- Keep unsupported Chartmetric-only paths explicit with a 501 compatibility response instead of fabricating unavailable SongStats data.
Verification
pnpm test lib/research lib/songstats lib/chartmetricpassed: 42 files, 195 tests.pnpm lint:checkpassed with two unrelated warnings in generated Workflow route files.env STRIPE_SK=sk_test_dummy SLACK_BOT_TOKEN=dummy SLACK_SIGNING_SECRET=dummy SLACK_CHAT_BOT_TOKEN=dummy SLACK_CHAT_SIGNING_SECRET=dummy pnpm buildpassed.pnpm buildwithout dummy env fails because local required runtime env vars are absent (STRIPE_SK, Slack bot/signing vars).pnpm exec tsc --noEmitstill fails on existing repo-wide fixture/type drift outside research files.
Summary by cubic
Switch research to SongStats as the sole provider and remove Chartmetric. Routes use a SongStats mapping layer; metrics and playlists call provider endpoints directly with longer timeouts.
-
New Features
- Added
fetchSongstats(Enterprise API withapikey, 10s default timeout; 50s for slowstats/historic_statsandartists/top_playlists; graceful 500/504) andfetchSongstatsResearchto map research paths and normalize results. - Metrics via
getResearchMetrics(resolve artist or useid, call/artist/:id/stat/:source, deduct credits);/api/research/metricssetsmaxDuration=60. - Playlists use SongStats
artists/top_playlistswithstatus→scopemapping and flattened placements;/api/research/playlistssetsmaxDuration=60. - Search hits SongStats and returns normalized artists/tracks/labels and related artists; dropped
betaandplatforms. - Validation accepts provider IDs: artist endpoints also accept
id;/research/lookupaccepts a Spotify artist URL orspotifyId. - Metric sources map to SongStats IDs and include
radioandsxm. Track ID extraction simplified inresolveTrack.
- Added
-
Migration
- Set
SONGSTATS_API_KEY(legacySongStats_APIis not supported). Removed all Chartmetric env, code, and tests. - Removed routes not supported by SongStats:
/research/charts,/cities,/curator,/discover,/festivals,/genres,/instagram-posts,/playlist,/radio,/venues,/rank. - Update clients: use provider IDs (non‑numeric allowed) for artists/tracks; pass
artistoridon artist-scoped endpoints; use SongStats search; stop sendingbeta/platforms; drop Chartmetric-only playlist filters (keepplatform,status,limit).
- Set
Summary by CodeRabbit
-
Removed Features
- Removed research endpoints: /api/research/charts, /cities, /curator, /discover, /festivals, /genres, /instagram-posts, /playlist, /radio, /rank, /venues.
-
Modified Features
- Research identifiers are provider-agnostic (non-numeric) and artist lookups accept Spotify URL or direct Spotify ID.
- Search results now surface labels and suggestions when primary categories are absent.
- Metrics and Playlists routes allow extended timeouts.
- Metrics sources expanded to include radio and sxm.