← back to blog
quantified self

Every Song, Every Album — How xeve Tracks Your Spotify Listening History

4 min read

Music is one of the strongest environmental signals for productivity. Some people code better with ambient electronic. Others need silence. But without data, you are guessing. xeve tracks your Spotify listening history automatically and shows it alongside your work data so you can see the patterns.

How the Integration Works

You connect Spotify once via OAuth on the settings page. xeve requests the user-read-recently-played and user-read-currently-playing scopes — read-only access to your listening history. No access to your library, playlists, or playback controls.

A Supabase edge function polls the Spotify API every 90 seconds for each connected user. It fetches the currently playing track and recent history, deduplicates against what is already stored, and inserts new entries with the track name, artist, album, album art URL, duration, and timestamp.

The 90-second interval is a balance between data fidelity and API rate limits. Spotify's rate limits are generous but not infinite — with thousands of users, we need to stay well under the ceiling. 90 seconds means you might miss a sub-minute skip, but every real listening session gets captured.

The Music Dashboard

The Music page on the web dashboard shows:

  • Listening timeline — a bar chart showing hours of music per day over your selected date range
  • Total listening time — aggregate hours and minutes for the period
  • Top artists — ranked by listening time, not play count (an artist with three 8-minute tracks outranks one with ten 2-minute tracks)
  • Recent tracks — a scrolling list with album art, track name, artist, and timestamp

Album art makes the Music page the most visually distinctive page in the dashboard. Every track has its cover displayed as a small square, turning the recent history list into a colorful mosaic.

Music × Productivity Correlations

The real value is not the listening history itself — it is what happens when you cross-reference it with other data. The correlation engine computes the relationship between daily listening time and metrics like coding output, focus duration, and app switching frequency.

In my own data, days with 3+ hours of music correlate with 15% more coding time and 20% fewer app switches. The effect disappears above 5 hours — at that point, music becomes background noise rather than a focus aid. Your pattern will be different, and xeve will find it.

Token Refresh

Spotify OAuth tokens expire every hour. The polling function handles refresh automatically — when a token expires, it uses the stored refresh token to get a new access token and updates the database. Users never have to re-authenticate unless they explicitly revoke access.

If a refresh fails (user revoked access, changed password), the integration marks itself as disconnected and the settings page shows a reconnect prompt. No silent failures.

Written by Kevin — builder of xeve

Track your apps, coding, music, and health — all in one place.

try xeve free