Skip to content

Show a posting activity heatmap on Insights - #528

Open
paulocastellano wants to merge 33 commits into
mainfrom
paulocastellano/insights-activity-heatmap
Open

paulocastellano wants to merge 33 commits into
mainfrom
paulocastellano/insights-activity-heatmap

Conversation

@paulocastellano

@paulocastellano paulocastellano commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Insights now has a Posting activity card: a GitHub-style grid with one square per day over the last 12 months, colored by how many posts went out that day. Next to it are the current streak, the longest streak and the year's total. The goal is engagement: at a glance the user sees whether they're posting every day, and the streak gives them something to keep.

It shows at the end of Workspace Insights (with the channel and label filters) and of Channel Insights (with the label and post type filters). The grid always covers the last 12 months, whatever period the page is showing. That is why it sits last: it is the only card that does not follow the period picker, so it never interrupts the cards that do.

What counts

  • A day is a calendar day in the viewer's time zone, and the rows follow their week start (Sunday or Monday).
  • A post is a publication that went out, whether it was published through TryPost or directly on the network. This is the same base the Posts chart counts (BuildPublicationAnalyticsReport::query()), so the two always agree. LinkedIn, Google Business, Telegram and Discord are excluded, as everywhere else in Insights.
  • Current streak is the number of days in a row with at least one post, ending today. If today has no post yet, it ends yesterday, so the streak doesn't reset in the morning.
  • Longest streak is the longest such run inside the 12 months.

History goes back 365 days on connect (BootstrapAccountAnalytics), so most channels see a full year right away. X stops at its 800 most recent posts.

Changes

  • Data: BuildPostingActivity counts posts per local day with CarbonPeriod and collections, grouping in PHP so it behaves the same on PostgreSQL and MySQL, and works out both streaks. Both controllers send its result as a deferred postingActivity prop in its own group (activity), so the channel's metric series never waits for it.
  • Card: PostingActivityCard puts the three numbers in the card's header, next to the title and the share button, with an InfoTip on each. On a phone they wrap under the title.
  • Grid: PostingActivityHeatmap draws a Unovis VisHeatmap that stretches to the card's width. It uses one violet at four strengths, which reads the same in light and dark.
  • Tooltip: PostingActivityTooltip shows the day's posts and the date.
  • Phones: the grid scrolls and opens on the latest weeks.
  • Import refresh: Workspace Insights reloads the card once an import finishes or the first data arrives.
  • Share as image: the card has the same button as Summary and Followers.
    • It adds a new heatmap card shape, drawn by lib/shareCard/heatmap.ts.
    • The page and the image take the grid's weekday offset and month labels from the same helper, lib/postingActivity.ts.
    • The post text changes with the situation: a streak at its record, a streak below it, or no streak today.
  • Copy: all 17 locales, with the single-line budgets added to single-line-copy.php.

Verification

  • tests/Feature/Analytics/PostingActivityTest.php has 11 cases: local days, the window edges, both streak rules, filters, excluded networks and the empty year. They pass on PostgreSQL and on MySQL.
  • InsightsControllerTest and ChannelInsightsPageTest check the deferred prop and its filters. The full tests/Feature/Analytics folder passes (665).
  • tests/Browser/PostingActivityTest.php has 8 cases: both pages, the post type filter, the refresh after the first data arrives, opening on the latest weeks on a phone, the tooltip, and the share card with each post text. The refresh and phone-scroll tests fail when their fix is removed.
  • The existing InsightsShareChartTest still passes (27). The copy guards, vue-tsc, eslint and pint all pass.

"View post" on the added-to-queue toast

When a post goes to the queue, the toast now says so and links to the post, like Buffer's "View post". The link opens the post's details on the publish page, in the tab that matches its status (Queue, Approvals, …). app.posts.index?post=<id> already picked that tab and opened the dialog.

  • Any toast can carry a link. A controller flashes flash.link (label and url) next to its message, and Toast.vue shows the link right after the text, in a toast as wide as its content. Toasts without a link look the same as before.
  • The server sends the toast. Before, the composer, the recovered draft and the card built "Added to queue" in the browser. Now PostController@store and PostScheduleController flash it through RendersPublishPage::flashPostToast(). The message is a full sentence ("Your post was added to the queue."); "Move to top" says the post went to the top instead; and a post waiting for approval says "Approval requested" (RendersPublishPage::queuedMessage(), which replaces the client's requestsApproval flag).
  • Flash survives partial reloads. HandleInertiaRequests shares flash with Inertia::always(), because "Move to top" reloads only part of the queue page. Without it, no flashed toast shows on a partial reload.
  • Copy: the link reuses posts.actions.view ("View post"), which was in all locales but unused. It now has a single-line budget.

Verification

  • Feature: store and queue next flash the message and the link, and drafts flash nothing (PostQueueTest, PostScheduleActionTest). tests/Feature/Posts: 709 passed. All of Feature and Unit: 11632 passed.
  • Browser: from the composer, the toast's "View post" opens the post's details on /posts?post=… (ComposerQueueTest). "Move to top" shows the toast with its link, and that test fails without Inertia::always() (PublishQueueTest). ComposerQueueTest (15), PublishQueueTest (34), PostApprovalsTest (6) and PublishCardActionsTest (7) all pass.

Review pass

  • Two bugs fixed: "Move to top" said the post was added to the queue, and a member who needs approval was told the same from the composer. Each fix has a test that failed first.
  • Helpers:
    • Backend: BuildPostingActivity uses collections and CarbonPeriod instead of array_*, end and max, and ScheduleAction::addsToQueue() replaces in_array.
    • Front: filled() replaces !x, and formatFullNumber() replaces six hand-written toLocaleString calls.
  • New tests: a viewer ahead of UTC (Tokyo), the first day of the window, where today lands in a Sunday-start and a Monday-start week, and the channel card filling in when the first posts arrive. The last two fail when their code is removed.
  • Full runs: Feature and Unit pass in full (11,636). The full browser suite passes except one board test that is flaky in parallel and passes on its own. The Insights section-order test now includes the new card.

Weekly posting streak in the sidebar

A badge next to the logo, laid out like Buffer's: a flame with the number of weeks in a row the workspace posted. Clicking it opens a popover with the streak, its rank, a nudge, "Schedule post" and a share button. The badge is hidden while there is no streak.

  • What counts: any week with at least one post, in the user's time zone and week start. That means every publication Insights reads (posted through TryPost or directly on the network), plus what TryPost published on the networks Insights does not read (LinkedIn, Google Business, Telegram, Discord). A TryPost post on an Insights network is also one of its publications, so it is counted once. A week without a post yet keeps the streak of the weeks before it.
  • Rank: analytics:rank-posting-streaks runs daily and works out the streak of every workspace with app access, using Monday weeks in UTC, then caches the distribution. The popover shows the smallest "Top X%" out of 1, 5, 10, 25 and 50, and nothing below that.
  • Sidebar: the streak is a shared prop, postingStreak (ShowPostingStreak), cached for 10 minutes per user and workspace. PublishPageTest's N+1 check now flushes the cache before each count, so a warm cache never counts as one query fewer.
  • Share: the button opens the composer with "I've reached a 20-week posting streak with TryPost!" and an image of our own, drawn on a canvas (lib/streakShareImage.ts, in the style of the Insights share cards).
  • Copy: all 17 locales.

Verification

  • PostingStreakTest (feature) has 11 cases: the streak, a week without a post yet, a broken streak, LinkedIn through TryPost, a post that failed, the week start, another workspace, the ranking, and the shared prop with and without a rank. They pass on PostgreSQL and on MySQL.
  • PostingStreakTest (browser) has 5 cases: no badge without a streak, the popover and both nudges, "Schedule post" opening the composer, and sharing opening the composer with the text and the image.
  • Feature and Unit pass in full.

Paulo Castellano added 30 commits November 20, 2026 13:28
A GitHub-style grid of the posts that went out each day over the last 12 months, with the current and longest streak, on Workspace and Channel Insights. It shares as an image like the other Insights cards.
Toasts flashed by the server can carry a link (flash.link: label and url), shown right after the message. Adding a post to the queue, from the composer or a card, now toasts from the server with "View post", which opens the post's details in the tab its status belongs to. Flash is always shared, so it also reaches partial reloads.
- Move to top says the post went to the top; a member who needs approval is told it awaits approval, from the composer too.
- BuildPostingActivity counts with CarbonPeriod and collections; ScheduleAction::addsToQueue() replaces in_array.
- Front uses filled() and formatFullNumber(); the recover save passes its options through.
- The activity loads in its own deferred group, so the channel metrics no longer wait for it.
- The card moves to the end of both Insights pages, its numbers into the header.
- Tests for a viewer ahead of UTC, the first day of the window, a Sunday-start week and the channel card refresh.
The streaks and the posts sit above the grid as headline numbers with their label, the way the Posts and Followers cards print their totals. The header keeps the title and the share button, and the flame is gone so no number stands apart.
Label over value, as the channel Metrics card draws its series, with an icon per number (flame, trophy, send) in the grid's violet where that legend draws a swatch.
Flame in orange for the current streak, crown in amber for the longest, send in the grid's violet for the posts.
Next to the logo, like Buffer's: the weeks in a row the workspace posted, counting every publication Insights reads plus what TryPost published on the networks it does not read. The popover nudges to post this week or next, names the streak's rank among every workspace (Top X%, ranked daily by analytics:rank-posting-streaks), schedules a post, and shares the streak as a post with its own image. Hidden without a streak.
A lighter blob on the left, a darker triangle on the right that reaches the flame's circle, a few confetti dots, and the node share icon.
…psed sidebar

An arrow in the popover's color and border touches the badge, and the popover gets the 1px border in light mode too so both read as one shape. The badge's wrapper carries the collapsed-sidebar hiding, which the popover root could not.
The popover goes back to its standard shadow; the arrow takes the popover's fill, with the border stroke only in dark mode where the popover has one.
The arrow's sides take the 1px ring of --shadow-md (#331f0017), so the popover's edge runs up the arrow and back without a gap.
The popover opens 16px under the badge, centered on it, in the system popover style, as the reference places it.
Hovering Top X% says it is compared to other TryPost users, in all 17 locales, on one line like the reference.
The title leads with the number (104 weeks in a row) and the nudge says what happened before the action its button names, in all 17 locales.
The violet band with its blob, wedge and confetti, the number's circle and the flame's, then the streak title and the TryPost signature, on a square. The image no longer needs its own 'weeks' word.
…band art

The band's violet, blob, wedge and confetti fill the whole 4:5 image; translucent tiles sit over it, three with the activity icons; the number sits in the largest tile, the unit and the line under it, then the TryPost signature.
The darker violet edge waves down the image instead of running straight, the number's tile sits closer to the unit with the side tiles following it, and the signature moves up.
…ry language, and cover the share and toast guards

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant