<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Róbert N</title>
    <description>The latest articles on DEV Community by Róbert N (@nautahakk).</description>
    <link>https://dev.to/nautahakk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4281511%2Fc94988ea-3d31-41b4-b425-522d7e996158.jpg</url>
      <title>DEV Community: Róbert N</title>
      <link>https://dev.to/nautahakk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nautahakk"/>
    <language>en</language>
    <item>
      <title>How to build a Spotify Wrapped-style year in review for your app</title>
      <dc:creator>Róbert N</dc:creator>
      <pubDate>Fri, 04 Dec 2026 00:14:55 +0000</pubDate>
      <link>https://dev.to/nautahakk/how-to-build-a-spotify-wrapped-style-year-in-review-for-your-app-3g86</link>
      <guid>https://dev.to/nautahakk/how-to-build-a-spotify-wrapped-style-year-in-review-for-your-app-3g86</guid>
      <description>&lt;p&gt;Spotify Wrapped works because every user gets a story about themselves: a few big numbers, one card at a time, and a picture worth posting. You can build the same thing for your own app. This post walks through every part it takes, the bits that quietly eat the time, and how long it really is.&lt;/p&gt;

&lt;h2&gt;
  
  
  The six parts
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;One row of stats per user.&lt;/strong&gt; A query over a year of events.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The slides.&lt;/strong&gt; The words around each number, for every kind of user.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A story player.&lt;/strong&gt; Tap forward and back, progress bars, hold to pause.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A private link per user,&lt;/strong&gt; plus hosting and link previews.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A share picture&lt;/strong&gt; sized for Instagram and TikTok stories.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sending it:&lt;/strong&gt; the link on the button of an email or push.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Part 1 is the same no matter how you do the rest, so here it is in full.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. One row of stats per user
&lt;/h2&gt;

&lt;p&gt;Everything downstream gets simpler if the data is one flat table: one row per user, one column per stat. This Postgres query works on a plain &lt;code&gt;events&lt;/code&gt; table with a user, a timestamp and a duration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;ev&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;duration_seconds&lt;/span&gt;
  &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;events&lt;/span&gt;
  &lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="s1"&gt;'2026-01-01'&lt;/span&gt; &lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="s1"&gt;'2027-01-01'&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;totals&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;duration_seconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;minutes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="cm"&gt;(*) as sessions
  from ev group by user_id
),
days as (select distinct user_id, created_at::date as d from ev),
-- Consecutive days share the same (date minus row number), so each run of days is one group.
runs as (
  select user_id, d - (row_number() over (partition by user_id order by d))::int as grp
  from days
),
streaks as (
  select user_id, max(n) as streak
  from (select user_id, count(*)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;runs&lt;/span&gt; &lt;span class="k"&gt;group&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;grp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;
  &lt;span class="k"&gt;group&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;top_day&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="k"&gt;distinct&lt;/span&gt; &lt;span class="k"&gt;on&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;to_char&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;created_at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Day'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;top_day&lt;/span&gt;
  &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;ev&lt;/span&gt; &lt;span class="k"&gt;group&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;to_char&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;created_at&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'Day'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;order&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="n"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="cm"&gt;(*) desc
)
select t.user_id, t.minutes, t.sessions, s.streak, d.top_day,
       greatest(1, ceil((1 - percent_rank() over (order by t.minutes)) * 100))::int as percentile
from totals t
join streaks s using (user_id)
join top_day d using (user_id);
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The streak uses a classic trick. Number each active day in order, subtract that number from the date, and every run of consecutive days lands on the same value. Group by that value and the biggest group is the longest streak.&lt;/p&gt;

&lt;p&gt;The percentile line gives each user a "top X%" number, with 1 as the floor so nobody is told they're in the top 0%.&lt;/p&gt;

&lt;p&gt;Export the result as CSV and it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user_id,minutes,sessions,streak,top_day,percentile
u_1001,4820,212,31,Sunday,3
u_1002,1310,88,9,Tuesday,41
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I tested the query against a sample events table in PGlite (Postgres 16.4). If your events live in Mixpanel, Amplitude or PostHog instead, export one row per user from there and you end up with the same file.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The slides
&lt;/h2&gt;

&lt;p&gt;Five to eight slides, one number each, the biggest thing on the screen. Writing them for your best user is easy. The work is everyone else:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The user with 2 minutes all year needs a slide that doesn't read like a scolding.&lt;/li&gt;
&lt;li&gt;A "top 3%" slide only for the people it flatters, and something else for the rest.&lt;/li&gt;
&lt;li&gt;"1 days", names with emoji, app names that wrap onto three lines, numbers in the millions.&lt;/li&gt;
&lt;li&gt;Every slide checked against real rows, not the three test users you made up.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. The story player
&lt;/h2&gt;

&lt;p&gt;People already know how stories work, so it has to behave exactly like the ones on their phone: tap right for next and left for back, progress bars that fill, hold to pause, stop on the last slide. Then come the parts nobody plans for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Phone browsers change height when the address bar slides away, and cut off your bottom line. Use &lt;code&gt;100dvh&lt;/code&gt;, not &lt;code&gt;100vh&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The tap that ends a long press also skips a slide unless you catch it.&lt;/li&gt;
&lt;li&gt;Fonts that load late make the first slide flash in the wrong typeface.&lt;/li&gt;
&lt;li&gt;Reduced motion, screen readers, keyboard arrows, and old Android phones.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The progress bars are the easy part. A CSS animation per bar, paused with one class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.bars&lt;/span&gt; &lt;span class="nc"&gt;.now&lt;/span&gt; &lt;span class="nt"&gt;i&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;fill&lt;/span&gt; &lt;span class="nf"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;--dur&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;linear&lt;/span&gt; &lt;span class="n"&gt;forwards&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.story.paused&lt;/span&gt; &lt;span class="nc"&gt;.bars&lt;/span&gt; &lt;span class="nc"&gt;.now&lt;/span&gt; &lt;span class="nt"&gt;i&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;animation-play-state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;paused&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="nt"&gt;fill&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. A private link for every user
&lt;/h2&gt;

&lt;p&gt;Don't put the user ID in the URL, or anyone can change one digit and read a stranger's year. Each link needs to be unguessable. Each page also needs hosting, a &lt;code&gt;noindex&lt;/code&gt; tag so it stays out of search results, and its own link preview so it looks right when someone drops it into a group chat.&lt;/p&gt;

&lt;p&gt;For 10,000 users, that's 10,000 pages and 10,000 preview images.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. The share picture
&lt;/h2&gt;

&lt;p&gt;The share is where the recap spreads, so it has to be a real picture, not a link: 1080 by 1920 pixels, the size of an Instagram or TikTok story. Where it gets fiddly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only some phone browsers can hand a picture straight to the share sheet. The rest need a download.&lt;/li&gt;
&lt;li&gt;Links opened inside Instagram, Gmail or Slack open in their own browsers, which often block both.&lt;/li&gt;
&lt;li&gt;Fonts and emoji have to be drawn into the picture, and they render differently on each phone.&lt;/li&gt;
&lt;li&gt;Leave off anything that would embarrass someone in public, like money spent or late-night usage.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. Send it
&lt;/h2&gt;

&lt;p&gt;Your build should spit out one file with each user's ID and link. Import it into your email or push tool (OneSignal, Customer.io, Braze, whatever you use) as a custom field, and put the link on the button of a short December email.&lt;/p&gt;

&lt;h2&gt;
  
  
  How long it really takes
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Build it yourself&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Your work&lt;/td&gt;
&lt;td&gt;The query, the slides, the player, links, hosting, share pictures, link previews, sending, and testing it all on real phones&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Time&lt;/td&gt;
&lt;td&gt;A week or more for a plain web version. 3 to 6 weeks for a designed one that holds up on every phone&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost&lt;/td&gt;
&lt;td&gt;Developer time in your busiest month, plus hosting&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Building makes sense when the story has to live inside your native app and you have a developer free in December.&lt;/p&gt;

&lt;p&gt;If you'd rather skip parts 2 to 5, that's what I made &lt;a href="https://yearcap.co" rel="noopener noreferrer"&gt;Yearcap&lt;/a&gt; for. You bring the CSV from part 1 and get a designed story, a private link, a preview and a share picture for every user. It's free up to 500 users.&lt;/p&gt;

&lt;p&gt;Either way, the query above is the hard-to-get-right part, so feel free to take it.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>postgres</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
