Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
last 90 days -> last 91 days (#5301)
RobertJoonas087b6e77bc8a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8ae5b58907..28c951b4c6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,7 +6,7 @@ All notable changes to this project will be documented in this file.### Added- Ability to sort by and compare the `exit_rate` metric in the dashboard Exit Pages > Details report- Add top 3 pages into the traffic spike email-- Two new shorthand time periods `28d` and `90d` available on both dashboard and in public API+- Two new shorthand time periods `28d` and `91d` available on both dashboard and in public API- Average scroll depth metric- Scroll Depth goals- Dashboard shows comparisons for all reportsdiff --git a/assets/js/dashboard/nav-menu/query-periods/query-dates.test.tsx b/assets/js/dashboard/nav-menu/query-periods/query-dates.test.tsxindex f0b3dec87d..c6a543d6ab 100644--- a/assets/js/dashboard/nav-menu/query-periods/query-dates.test.tsx+++ b/assets/js/dashboard/nav-menu/query-periods/query-dates.test.tsx@@ -28,7 +28,7 @@ test('if no period is stored, loads with default value of "Last 28 days", all ex['Realtime', 'R'],['Last 7 Days', 'W'],['Last 28 Days', 'F'],- ['Last 90 Days', 'N'],+ ['Last 91 Days', 'N'],['Month to Date', 'M'],['Last Month', 'P'],['Year to Date', 'Y'],diff --git a/assets/js/dashboard/query-time-periods.ts b/assets/js/dashboard/query-time-periods.tsindex dfaf9cab2e..ba81f45046 100644--- a/assets/js/dashboard/query-time-periods.ts+++ b/assets/js/dashboard/query-time-periods.ts@@ -32,7 +32,7 @@ export enum QueryPeriod {'7d' = '7d','28d' = '28d','30d' = '30d',- '90d' = '90d',+ '91d' = '91d','6mo' = '6mo','12mo' = '12mo','year' = 'year',@@ -361,15 +361,15 @@ export const getDatePeriodGroups = ({}],[- ['Last 90 Days', 'N'],+ ['Last 91 Days', 'N'],{search: (s) => ({...s,...clearedDateSearch,- period: QueryPeriod['90d'],+ period: QueryPeriod['91d'],keybindHint: 'N'}),- isActive: ({ query }) => query.period === QueryPeriod['90d'],+ isActive: ({ query }) => query.period === QueryPeriod['91d'],onEvent}]@@ -611,8 +611,8 @@ export function getCurrentPeriodDisplayName({if (query.period === '30d') {return 'Last 30 days'}- if (query.period === '90d') {- return 'Last 90 days'+ if (query.period === '91d') {+ return 'Last 91 days'}if (query.period === 'month') {if (isThisMonth(site, query.date)) {diff --git a/assets/js/dashboard/site-context.test.tsx b/assets/js/dashboard/site-context.test.tsxindex a73d846cba..8b5f16c3b0 100644--- a/assets/js/dashboard/site-context.test.tsx+++ b/assets/js/dashboard/site-context.test.tsx@@ -30,7 +30,7 @@ describe('parseSiteFromDataset', () => {data-current-user-role="owner"data-current-user-id="1"data-flags="{}"- data-valid-intervals-by-period='{"12mo":["day","week","month"],"7d":["hour","day"],"28d":["day","week"],"30d":["day","week"],"90d":["day","week","month"],"6mo":["day","week","month"],"all":["week","month"],"custom":["day","week","month"],"day":["minute","hour"],"month":["day","week"],"realtime":["minute"],"year":["day","week","month"]}'+ data-valid-intervals-by-period='{"12mo":["day","week","month"],"7d":["hour","day"],"28d":["day","week"],"30d":["day","week"],"91d":["day","week","month"],"6mo":["day","week","month"],"all":["week","month"],"custom":["day","week","month"],"day":["minute","hour"],"month":["day","week"],"realtime":["minute"],"year":["day","week","month"]}'{...attrs}/>)@@ -58,7 +58,7 @@ describe('parseSiteFromDataset', () => {'7d': ['hour', 'day'],'28d': ['day', 'week'],'30d': ['day', 'week'],- '90d': ['day', 'week', 'month'],+ '91d': ['day', 'week', 'month'],'6mo': ['day', 'week', 'month'],all: ['week', 'month'],custom: ['day', 'week', 'month'],diff --git a/assets/js/types/query-api.d.ts b/assets/js/types/query-api.d.tsindex d73fa18153..af690bb85c 100644--- a/assets/js/types/query-api.d.ts+++ b/assets/js/types/query-api.d.ts@@ -24,7 +24,7 @@ export type DateRangeShorthand =| "7d"| "28d"| "30d"- | "90d"+ | "91d"| "month"| "6mo"| "12mo"diff --git a/lib/plausible/stats/interval.ex b/lib/plausible/stats/interval.exindex 3cbfab6f44..34018037fc 100644--- a/lib/plausible/stats/interval.ex+++ b/lib/plausible/stats/interval.ex@@ -31,7 +31,7 @@ defmodule Plausible.Stats.Interval docase period doperiod when period in ["realtime", "30m"] -> "minute""day" -> "hour"- period when period in ["custom", "7d", "28d", "30d", "90d", "month"] -> "day"+ period when period in ["custom", "7d", "28d", "30d", "91d", "month"] -> "day"period when period in ["6mo", "12mo", "year"] -> "month"endend@@ -59,7 +59,7 @@ defmodule Plausible.Stats.Interval do"7d" => ["hour", "day"],"28d" => ["day", "week"],"30d" => ["day", "week"],- "90d" => ["day", "week", "month"],+ "91d" => ["day", "week", "month"],"month" => ["day", "week"],"6mo" => ["day", "week", "month"],"12mo" => ["day", "week", "month"],diff --git a/lib/plausible/stats/legacy/legacy_query_builder.ex b/lib/plausible/stats/legacy/legacy_query_builder.exindex 9ee542650f..f888ea66d0 100644--- a/lib/plausible/stats/legacy/legacy_query_builder.ex+++ b/lib/plausible/stats/legacy/legacy_query_builder.ex@@ -93,7 +93,7 @@ defmodule Plausible.Stats.Legacy.QueryBuilder doenddefp put_period(query, site, %{"period" => period} = params)- when period in ["7d", "28d", "30d", "90d"] do+ when period in ["7d", "28d", "30d", "91d"] do{days, "d"} = Integer.parse(period)end_date = parse_single_date(query, params) |> Date.shift(day: -1)diff --git a/priv/json-schemas/query-api-schema.json b/priv/json-schemas/query-api-schema.jsonindex f0ce373b04..915273e26e 100644--- a/priv/json-schemas/query-api-schema.json+++ b/priv/json-schemas/query-api-schema.json@@ -201,8 +201,8 @@"description": "Last 30 days relative to today"},{- "const": "90d",- "description": "Last 90 days relative to today"+ "const": "91d",+ "description": "Last 91 days relative to today"},{"const": "month",diff --git a/test/plausible/stats/interval_test.exs b/test/plausible/stats/interval_test.exsindex b014d13b5c..204914a531 100644--- a/test/plausible/stats/interval_test.exs+++ b/test/plausible/stats/interval_test.exs@@ -32,7 +32,7 @@ defmodule Plausible.Stats.IntervalTest do"7d" => ["hour", "day"],"28d" => ["day", "week"],"30d" => ["day", "week"],- "90d" => ["day", "week", "month"],+ "91d" => ["day", "week", "month"],"6mo" => ["day", "week", "month"],"12mo" => ["day", "week", "month"],"year" => ["day", "week", "month"],@@ -51,7 +51,7 @@ defmodule Plausible.Stats.IntervalTest do"7d" => ["hour", "day"],"28d" => ["day", "week"],"30d" => ["day", "week"],- "90d" => ["day", "week", "month"],+ "91d" => ["day", "week", "month"],"6mo" => ["day", "week", "month"],"12mo" => ["day", "week", "month"],"year" => ["day", "week", "month"],@@ -71,7 +71,7 @@ defmodule Plausible.Stats.IntervalTest do"7d" => ["hour", "day"],"28d" => ["day", "week"],"30d" => ["day", "week"],- "90d" => ["day", "week", "month"],+ "91d" => ["day", "week", "month"],"6mo" => ["day", "week", "month"],"12mo" => ["day", "week", "month"],"year" => ["day", "week", "month"],diff --git a/test/plausible_web/controllers/api/external_stats_controller/query_comparisons_test.exs b/test/plausible_web/controllers/api/external_stats_controller/query_comparisons_test.exsindex 5ac02c88e7..ed584fcf9b 100644--- a/test/plausible_web/controllers/api/external_stats_controller/query_comparisons_test.exs+++ b/test/plausible_web/controllers/api/external_stats_controller/query_comparisons_test.exs@@ -169,7 +169,7 @@ defmodule PlausibleWeb.Api.ExternalStatsController.QueryComparisonsTest doassert actual_comparison_last_date == expected_comparison_last_dateend- test "timeseries last 90d period in year_over_year comparison", %{+ test "timeseries last 91d period in year_over_year comparison", %{conn: conn,site: site} do@@ -178,19 +178,19 @@ defmodule PlausibleWeb.Api.ExternalStatsController.QueryComparisonsTest dobuild(:pageview, timestamp: ~N[2021-04-01 00:00:00]),build(:pageview, timestamp: ~N[2021-04-05 00:00:00]),build(:pageview, timestamp: ~N[2021-04-05 00:00:00]),- build(:pageview, timestamp: ~N[2021-06-29 00:00:00]),+ build(:pageview, timestamp: ~N[2021-06-30 00:00:00]),build(:pageview, timestamp: ~N[2022-04-01 00:00:00]),build(:pageview, timestamp: ~N[2022-04-05 00:00:00]),- build(:pageview, timestamp: ~N[2022-06-29 00:00:00]),- build(:pageview, timestamp: ~N[2022-06-30 00:00:00])+ build(:pageview, timestamp: ~N[2022-06-30 00:00:00]),+ build(:pageview, timestamp: ~N[2022-07-01 00:00:00])])conn =post(conn, "/api/v2/query-internal-test", %{"site_id" => site.domain,"metrics" => ["visitors"],- "date_range" => "90d",- "date" => "2022-06-30",+ "date_range" => "91d",+ "date" => "2022-07-01","dimensions" => ["time:day"],"include" => %{"time_labels" => true,@@ -205,7 +205,7 @@ defmodule PlausibleWeb.Api.ExternalStatsController.QueryComparisonsTest doassert "2022-04-01" = List.first(time_labels)assert "2022-04-05" = Enum.at(time_labels, 4)- assert "2022-06-29" = List.last(time_labels)+ assert "2022-06-30" = List.last(time_labels)assert %{"dimensions" => ["2022-04-01"],@@ -226,13 +226,13 @@ defmodule PlausibleWeb.Api.ExternalStatsController.QueryComparisonsTest do} = Enum.find(results, &(&1["dimensions"] == ["2022-04-05"]))assert %{- "dimensions" => ["2022-06-29"],+ "dimensions" => ["2022-06-30"],"metrics" => [1],"comparison" => %{- "dimensions" => ["2021-06-29"],+ "dimensions" => ["2021-06-30"],"metrics" => [1]}- } = Enum.find(results, &(&1["dimensions"] == ["2022-06-29"]))+ } = Enum.find(results, &(&1["dimensions"] == ["2022-06-30"]))endtest "dimensional comparison with low limit", %{conn: conn, site: site} dodiff --git a/test/plausible_web/controllers/api/stats_controller/main_graph_test.exs b/test/plausible_web/controllers/api/stats_controller/main_graph_test.exsindex fb070e82fc..e8b7ec75e0 100644--- a/test/plausible_web/controllers/api/stats_controller/main_graph_test.exs+++ b/test/plausible_web/controllers/api/stats_controller/main_graph_test.exs@@ -167,21 +167,21 @@ defmodule PlausibleWeb.Api.StatsController.MainGraphTest doassert Enum.sum(plot) == 2end- test "displays visitors for last 90d", %{conn: conn, site: site} do+ test "displays visitors for last 91d", %{conn: conn, site: site} dopopulate_stats(site, [build(:pageview, timestamp: ~N[2021-01-16 00:00:00]),- build(:pageview, timestamp: ~N[2021-04-15 00:00:00])+ build(:pageview, timestamp: ~N[2021-04-16 00:00:00])])conn =get(conn,- "/api/stats/#{site.domain}/main-graph?period=90d&date=2021-04-16&metric=visitors"+ "/api/stats/#{site.domain}/main-graph?period=91d&date=2021-04-17&metric=visitors")assert %{"plot" => plot} = json_response(conn, 200)- assert Enum.count(plot) == 90+ assert Enum.count(plot) == 91assert List.first(plot) == 1assert List.last(plot) == 1assert Enum.sum(plot) == 2@@ -1276,14 +1276,14 @@ defmodule PlausibleWeb.Api.StatsController.MainGraphTest do}end- test "shows imperfect month-split for last 90d with full month indicators", %{+ test "shows imperfect month-split for last 91d with full month indicators", %{conn: conn,site: site} doconn =get(conn,- "/api/stats/#{site.domain}/main-graph?period=90d&metric=visitors&interval=month&date=2021-12-13"+ "/api/stats/#{site.domain}/main-graph?period=91d&metric=visitors&interval=month&date=2021-12-13")assert %{"labels" => labels, "full_intervals" => full_intervals} = json_response(conn, 200)@@ -1298,14 +1298,14 @@ defmodule PlausibleWeb.Api.StatsController.MainGraphTest do}end- test "shows half-perfect month-split for last 90d with full month indicators", %{+ test "shows perfect month-split for last 91d with full month indicators", %{conn: conn,site: site} doconn =get(conn,- "/api/stats/#{site.domain}/main-graph?period=90d&metric=visitors&interval=month&date=2021-12-01"+ "/api/stats/#{site.domain}/main-graph?period=91d&metric=visitors&interval=month&date=2021-12-01")assert %{"labels" => labels, "full_intervals" => full_intervals} = json_response(conn, 200)@@ -1313,7 +1313,7 @@ defmodule PlausibleWeb.Api.StatsController.MainGraphTest doassert labels == ["2021-09-01", "2021-10-01", "2021-11-01"]assert full_intervals == %{- "2021-09-01" => false,+ "2021-09-01" => true,"2021-10-01" => true,"2021-11-01" => true}@@ -1863,7 +1863,7 @@ defmodule PlausibleWeb.Api.StatsController.MainGraphTest dorefute present_indexend- for period <- ["7d", "28d", "30d", "90d"] do+ for period <- ["7d", "28d", "30d", "91d"] dotest "#{period} period does not include today", %{conn: conn, site: site} dotoday = "2021-01-01"yesterday = "2020-12-31"