Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves realtime top stats and conversion rate calculation #500

Merged
merged 5 commits into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
- Simple notifications around traffic spikes plausible/analytics#453
- Dark theme option/system setting follow plausible/analytics#467
- "Load More" capability to pages modal plausible/analytics#480
- Unique Visitors (last 30 min) as a top stat in realtime view plausible/analytics#500
- Pinned filter and date selector rows while scrolling plausible/analytics#472

### Changed
Expand All @@ -33,6 +34,7 @@ All notable changes to this project will be documented in this file.
- Prevent picking dates before site insertion plausible/analtics#446
- Fix overly-sticky from and to in query parameters plausible/analytics#495
- Adds support for single-day date selection plausible/analytics#495
- Goal conversion rate in realtime view is now accurate plausible/analytics#500

### Security
- Do not run the plausible Docker container as root plausible/analytics#362
Expand Down
1 change: 1 addition & 0 deletions lib/plausible/stats/clickhouse.ex
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ defmodule Plausible.Stats.Clickhouse do
end

def unique_visitors(site, query) do
query = if query.period == "realtime", do: %Query{query | period: "30m"}, else: query
ClickhouseRepo.one(
from e in base_query_w_sessions(site, query),
select: fragment("uniq(user_id)")
Expand Down
4 changes: 4 additions & 0 deletions lib/plausible_web/controllers/api/stats_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ defmodule PlausibleWeb.Api.StatsController do
name: "Current visitors",
count: Stats.current_visitors(site, query)
},
%{
name: "Unique visitors (last 30 min)",
count: Stats.unique_visitors(site, query)
},
%{
name: "Pageviews (last 30 min)",
count: Stats.total_pageviews(site, query)
Expand Down