Skip to content

Conversation

@aerosol
Copy link
Member

@aerosol aerosol commented Nov 4, 2025

Changes

This PR integrates consolidated view life cycle with billing properties.
It relies on two migrations which will be extracted to separate PRs once the review is concluded.

Main changes:

  • new feature flag: :consolidated_views - we no longer display anything based on super_admin role; flag is not setup on production yet, meaning existing consolidated views will disappear (and no CTAs will be shown).
  • new billing feature: ConsolidatedView
  • all existing plans are updated, so that business tier includes the newly added features - either through static definitions or database migration
  • whenever /sites is visited an attempt is made to create consolidated view. If the team is eligible, and the feature flag is raised, the consolidated view card is shown. Otherwise a CTA card is displayed (courtesy of @sanne-san)
    • CTA card has several variants, depending on the context, but eventually leads to upgrade. Once the upgrade is performed, /sites will include the consolidated view card.
    • CTA card can be permanently dismissed per user and team; because local storage and cookies turned out to be very difficult to work with in this setup, the decision was made to introduce a new postgres table capable of storing user preferences in a team context (it's almost a 1:1 copy of the existing site user preferences table)
    • When CTA is dismissed, the "New Site" button becomes a prima drop-down (courtesy of @ukutaht) from which the user may restore it (by selecting "+ New consolidated view" dropdown item)
    • CRM now presents a more elaborate alert on deleting consolidated view, as well as the availability status (whether upgrade is required)
    • some minor improvements BTW:
      • shared links enforce regular sites,
      • accessing a consolidated view via pre-existing URL, while ineligible, redirects to /sites
      • at least 2 sites are now required to create (or even suggest) a consolidated view
      • ConsolidatedView.enabled?/1 has been removed, since enabling doesn't mean availability

TODO:

  • staging preview is currently unavailable due to pending migrations
  • there are visual issues with card plots and overlapping dropdowns
record-2025-11-10-10-29-34-year.node.norm.mp4

Tests

  • Automated tests have been added
  • This PR does not require tests

Changelog

  • Entry has been added to changelog
  • This PR does not make a user-facing change

Documentation

  • Docs have been updated
  • This change does not need a documentation update

Dark mode

  • The UI has been tested both in dark and light mode
  • This PR does not change the UI

@aerosol aerosol force-pushed the consolidated-view-billing branch 2 times, most recently from ea6644d to b1e1b17 Compare November 10, 2025 10:10
@aerosol aerosol force-pushed the consolidated-view-billing branch from 2fa36cd to 1b9decd Compare November 10, 2025 12:40
aerosol and others added 5 commits November 10, 2025 13:46
 - add functions to manipulate user/team options (for CTA)
 - require at least two sites in order to create a consolidated view
 - require billing/plan compliance when computing eligibility
Co-authored-by: Sanne de Vries <[email protected]>
Co-authored-by: Uku Taht <[email protected]>
- require team-wise feature flag instead of super admin role
- redirect to /sites if the team isn't eligible any more
- enforce regular site in shared links controller
@aerosol aerosol force-pushed the consolidated-view-billing branch from 1b9decd to 87e593f Compare November 10, 2025 12:46
@aerosol aerosol force-pushed the consolidated-view-billing branch from 64760be to 2ae4797 Compare November 10, 2025 12:53
@aerosol aerosol changed the title [wip] Consolidated View: billing integration Consolidated View life cycle + billing integration Nov 10, 2025
@aerosol aerosol added preview and removed preview labels Nov 10, 2025
@plausible plausible deleted a comment from github-actions bot Nov 10, 2025
@aerosol aerosol marked this pull request as ready for review November 10, 2025 13:37
Copy link
Contributor

@RobertJoonas RobertJoonas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff, looks great overall! A few comments inline.

Comment on lines 39 to +42
def ok_to_display?(team, user) do
with %Team{} <- team,
%User{} <- user,
true <- Plausible.Auth.is_super_admin?(user),
true <- enabled?(team),
true <- has_sites_to_consolidate?(team) do
true <- flag_enabled?(team),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user argument here is unnecessary I believe. I would like to use this function when checking whether a stats report or traffic spike email should be sent for a consolidated view. There's no user in that context.

phx-click="delete-consolidated-view"
phx-target={@myself}
data-confirm="Are you sure you want to delete this consolidated view?"
data-confirm="Are you sure you want to delete this consolidated view? It will be recreated whenever eligible subscription/trial accesses /sites for that team."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also mention that the configuration gets lost with this action?

Comment on lines +410 to 413
consolidated_view_available? =
on_ee(
do: Plausible.ConsolidatedView.ok_to_display?(shared_link.site.team, current_user),
else: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to just say that this is false for shared links too? Even if I'm logged in and seeing my own shared link, I will not be able to switch to the consolidated view in the site picker, or in fact, even see any of my other sites there. There's a login link at the top right though.

<!-- The `z-49` class is to make the dropdown appear above the site cards and (TODO) below the top-right drop down. -->
<!-- The proper solution is for Prima to render the dropdown menu within a <.portal> element to avoid -->
<!-- any stacking context issues. TODO -->
<PrimaDropdown.dropdown
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dropdown needs a darkmode update:

Image

end

def upgrade_card(assigns) do
def consolidated_view_card_cta(assigns) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a slight UI annoyance I'm seeing locally. Try to hide the CTA card, then navigate to another page, e.g. click on one of the site cards to see a dashboard. Now, hit back in the browser history. The card flickers for a second and then disappears. Same happens when you've hidden it before and then restore it.

We should make sure that hiding/restoring the card also updates the entry in browser history stack.

assert stats =~ "Views per visit 1.33"
end

test "consolidated view does not show up for non-superadmin (temp)", %{conn: conn} do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer necessar I think? Looks like a duplicate of "single site won't show neither CTA or view - team setup"

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.

3 participants