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
Scroll depth flag cleanup (#5195)
RobertJoonasc8ba6d918cad
diff --git a/assets/js/dashboard/site-context.test.tsx b/assets/js/dashboard/site-context.test.tsxindex 3014793430..71309c173f 100644--- a/assets/js/dashboard/site-context.test.tsx+++ b/assets/js/dashboard/site-context.test.tsx@@ -48,7 +48,6 @@ describe('parseSiteFromDataset', () => {revenueGoals: [{ currency: 'USD', display_name: 'Purchase' }],funnels: [{ id: 1, name: 'From homepage to login', steps_count: 3 }],hasProps: true,- scrollDepthVisible: true,statsBegin: '2021-09-07',nativeStatsBegin: '2022-09-02',embedded: false,diff --git a/assets/js/dashboard/site-context.tsx b/assets/js/dashboard/site-context.tsxindex e251ce2322..bd263d94f2 100644--- a/assets/js/dashboard/site-context.tsx+++ b/assets/js/dashboard/site-context.tsx@@ -7,7 +7,6 @@ export function parseSiteFromDataset(dataset: DOMStringMap): PlausibleSite {offset: parseInt(dataset.offset!, 10),hasGoals: dataset.hasGoals === 'true',hasProps: dataset.hasProps === 'true',- scrollDepthVisible: dataset.scrollDepthVisible === 'true',funnelsAvailable: dataset.funnelsAvailable === 'true',propsAvailable: dataset.propsAvailable === 'true',siteSegmentsAvailable: dataset.siteSegmentsAvailable === 'true',@@ -40,7 +39,6 @@ const siteContextDefaultValue = {offset: 0,hasGoals: false,hasProps: false,- scrollDepthVisible: false,funnelsAvailable: false,propsAvailable: false,siteSegmentsAvailable: false,diff --git a/assets/js/dashboard/stats/modals/pages.js b/assets/js/dashboard/stats/modals/pages.jsindex 79485a7946..3204422770 100644--- a/assets/js/dashboard/stats/modals/pages.js+++ b/assets/js/dashboard/stats/modals/pages.js@@ -47,14 +47,13 @@ function PagesModal() {]}- const defaultMetrics = [+ return [metrics.createVisitors({renderLabel: (_query) => "Visitors" }),metrics.createPageviews(),metrics.createBounceRate(),- metrics.createTimeOnPage()+ metrics.createTimeOnPage(),+ metrics.createScrollDepth()]-- return site.scrollDepthVisible ? [...defaultMetrics, metrics.createScrollDepth()] : defaultMetrics}return (diff --git a/assets/test-utils/app-context-providers.tsx b/assets/test-utils/app-context-providers.tsxindex ec0a3cacdf..f5409ac897 100644--- a/assets/test-utils/app-context-providers.tsx+++ b/assets/test-utils/app-context-providers.tsx@@ -36,7 +36,6 @@ export const TestContextProviders = ({offset: 0,hasGoals: false,hasProps: false,- scrollDepthVisible: false,funnelsAvailable: false,propsAvailable: false,siteSegmentsAvailable: false,diff --git a/lib/plausible/exports.ex b/lib/plausible/exports.exindex f9355a1574..91657cd6d5 100644--- a/lib/plausible/exports.ex+++ b/lib/plausible/exports.ex@@ -415,10 +415,7 @@ defmodule Plausible.Exports doenddefp export_pages_q(site_id, current_user_id, timezone, date_range) do- site = Plausible.Repo.get(Plausible.Site, site_id)- current_user = current_user_id && Plausible.Repo.get(Plausible.Auth.User, current_user_id)-- include_scroll_depth? = Plausible.Stats.ScrollDepth.check_feature_visible!(site, current_user)+ _will_be_used_for_time_on_page_flag = current_user_idbase_q =from(e in sampled("events_v2"),@@ -428,51 +425,34 @@ defmodule Plausible.Exports doorder_by: selected_as(:date))- if include_scroll_depth? do- max_scroll_depth_per_session_q =- from(e in "events_v2",- where: ^export_filter(site_id, date_range),- where: e.name == "engagement" and e.scroll_depth <= 100,- select: %{- date: date(e.timestamp, ^timezone),- page: selected_as(e.pathname, :page),- session_id: e.session_id,- max_scroll_depth: max(e.scroll_depth)- },- group_by: [e.session_id, selected_as(:date), selected_as(:page)]- )-- scroll_depth_q =- from(p in subquery(max_scroll_depth_per_session_q),- select: %{- date: p.date,- page: p.page,- total_scroll_depth: fragment("sum(?)", p.max_scroll_depth),- total_scroll_depth_visits: fragment("uniq(?)", p.session_id)- },- group_by: [:date, :page]- )-- from(e in base_q,- left_join: s in subquery(scroll_depth_q),- on: s.date == selected_as(:date) and s.page == selected_as(:page),- select: [- date(e.timestamp, ^timezone),- selected_as(fragment("any(?)", e.hostname), :hostname),- selected_as(e.pathname, :page),- selected_as(- scale_sample(fragment("uniq(?)", e.session_id)),- :visits- ),- visitors(e),- selected_as(scale_sample(fragment("count()")), :pageviews),- selected_as(fragment("any(?)", s.total_scroll_depth), :total_scroll_depth),- selected_as(fragment("any(?)", s.total_scroll_depth_visits), :total_scroll_depth_visits)- ]+ max_scroll_depth_per_session_q =+ from(e in "events_v2",+ where: ^export_filter(site_id, date_range),+ where: e.name == "engagement" and e.scroll_depth <= 100,+ select: %{+ date: date(e.timestamp, ^timezone),+ page: selected_as(e.pathname, :page),+ session_id: e.session_id,+ max_scroll_depth: max(e.scroll_depth)+ },+ group_by: [e.session_id, selected_as(:date), selected_as(:page)])- else- base_q- |> select([e], [++ scroll_depth_q =+ from(p in subquery(max_scroll_depth_per_session_q),+ select: %{+ date: p.date,+ page: p.page,+ total_scroll_depth: fragment("sum(?)", p.max_scroll_depth),+ total_scroll_depth_visits: fragment("uniq(?)", p.session_id)+ },+ group_by: [:date, :page]+ )++ from(e in base_q,+ left_join: s in subquery(scroll_depth_q),+ on: s.date == selected_as(:date) and s.page == selected_as(:page),+ select: [date(e.timestamp, ^timezone),selected_as(fragment("any(?)", e.hostname), :hostname),selected_as(e.pathname, :page),@@ -481,9 +461,11 @@ defmodule Plausible.Exports do:visits),visitors(e),- selected_as(scale_sample(fragment("count()")), :pageviews)- ])- end+ selected_as(scale_sample(fragment("count()")), :pageviews),+ selected_as(fragment("any(?)", s.total_scroll_depth), :total_scroll_depth),+ selected_as(fragment("any(?)", s.total_scroll_depth_visits), :total_scroll_depth_visits)+ ]+ )enddefp export_entry_pages_q(site_id, timezone, date_range) dodiff --git a/lib/plausible/site.ex b/lib/plausible/site.exindex 5e6cdd0281..e3cfa0e7af 100644--- a/lib/plausible/site.ex+++ b/lib/plausible/site.ex@@ -21,7 +21,6 @@ defmodule Plausible.Site dofield :conversions_enabled, :boolean, default: truefield :props_enabled, :boolean, default: truefield :funnels_enabled, :boolean, default: true- field :scroll_depth_visible_at, :naive_datetimefield :ingest_rate_limit_scale_seconds, :integer, default: 60# default is set via changeset/2diff --git a/lib/plausible/sites.ex b/lib/plausible/sites.exindex 1663999dc9..d2080d8aef 100644--- a/lib/plausible/sites.ex+++ b/lib/plausible/sites.ex@@ -311,14 +311,6 @@ defmodule Plausible.Sites do|> Repo.update!()end- def set_scroll_depth_visible_at(site) do- utc_now = NaiveDateTime.utc_now(:second)-- site- |> Ecto.Changeset.change(%{scroll_depth_visible_at: utc_now})- |> Repo.update()- end-def has_goals?(site) doRepo.exists?(from(g in Plausible.Goal,diff --git a/lib/plausible/stats/scroll_depth.ex b/lib/plausible/stats/scroll_depth.exdeleted file mode 100644index e8ce025627..0000000000--- a/lib/plausible/stats/scroll_depth.ex+++ /dev/null@@ -1,63 +0,0 @@-defmodule Plausible.Stats.ScrollDepth do- @moduledoc """- Module to check whether the scroll depth metric is available and visible for a site.- """-- import Ecto.Query- require Logger-- alias Plausible.ClickhouseRepo-- def feature_available?(site, user) do- FunWithFlags.enabled?(:scroll_depth, for: user) ||- FunWithFlags.enabled?(:scroll_depth, for: site)- end-- def feature_visible?(site, user) do- feature_available?(site, user) && not is_nil(site.scroll_depth_visible_at)- end-- @doc """- Checks whether the scroll depth feature is visible for a site and updates the site record if it is.-- Note this function queries ClickHouse and may take a while to complete.- """- def check_feature_visible!(site, user) do- cond do- not feature_available?(site, user) ->- false-- not is_nil(site.scroll_depth_visible_at) ->- true-- is_nil(site.scroll_depth_visible_at) ->- visible? = has_scroll_data_last_30d?(site)-- if visible? do- Plausible.Sites.set_scroll_depth_visible_at(site)- end-- visible?- end- end-- defp has_scroll_data_last_30d?(site) do- try do- ClickhouseRepo.exists?(- from(e in "events_v2",- where:- e.site_id == ^site.id and- e.name == "engagement" and- e.timestamp >= fragment("toStartOfDay(now() - toIntervalDay(30))") and- e.scroll_depth > 0 and e.scroll_depth <= 100- )- )- rescue- # Avoid propagating error to the user, bringing down the site.- error ->- Logger.error("Error checking scroll data for site #{site.id}: #{inspect(error)}")-- false- end- end-enddiff --git a/lib/plausible_web/controllers/api/stats_controller.ex b/lib/plausible_web/controllers/api/stats_controller.exindex 4ceca38a1b..bd8c0adbf0 100644--- a/lib/plausible_web/controllers/api/stats_controller.ex+++ b/lib/plausible_web/controllers/api/stats_controller.ex@@ -397,23 +397,15 @@ defmodule PlausibleWeb.Api.StatsController dopage_filter? =Filters.filtering_on_dimension?(query, "event:page", behavioral_filters: :ignore)- include_scroll_depth? = Plausible.Stats.ScrollDepth.feature_visible?(site, current_user)-metrics = [:visitors, :visits, :pageviews, :sample_percent]metrics =cond do- page_filter? && include_scroll_depth? && query.include_imported ->- metrics ++ [:scroll_depth]-- page_filter? && include_scroll_depth? ->- metrics ++ [:bounce_rate, :scroll_depth, :time_on_page]-page_filter? && query.include_imported ->- metrics+ metrics ++ [:scroll_depth]page_filter? ->- metrics ++ [:bounce_rate, :time_on_page]+ metrics ++ [:bounce_rate, :scroll_depth, :time_on_page]true ->metrics ++ [:views_per_visit, :bounce_rate, :visit_duration]@@ -863,23 +855,15 @@ defmodule PlausibleWeb.Api.StatsController dodef pages(conn, params) dosite = conn.assigns[:site]- current_user = conn.assigns[:current_user]params = Map.put(params, "property", "event:page")query = Query.from(site, params, debug_metadata(conn))- include_scroll_depth? = Plausible.Stats.ScrollDepth.feature_visible?(site, current_user)-extra_metrics =- cond do- params["detailed"] && include_scroll_depth? ->- [:pageviews, :bounce_rate, :time_on_page, :scroll_depth]-- params["detailed"] ->- [:pageviews, :bounce_rate, :time_on_page]-- true ->- []+ if params["detailed"] do+ [:pageviews, :bounce_rate, :time_on_page, :scroll_depth]+ else+ []endmetrics = breakdown_metrics(query, extra_metrics)@@ -897,11 +881,7 @@ defmodule PlausibleWeb.Api.StatsController do|> transform_keys(%{visitors: :conversions})|> to_csv([:name, :conversions, :conversion_rate])else- cols = [:name, :visitors, :pageviews, :bounce_rate, :time_on_page]-- # credo:disable-for-next-line Credo.Check.Refactor.Nesting- cols = if include_scroll_depth?, do: cols ++ [:scroll_depth], else: cols-+ cols = [:name, :visitors, :pageviews, :bounce_rate, :time_on_page, :scroll_depth]pages |> to_csv(cols)endelsediff --git a/lib/plausible_web/controllers/stats_controller.ex b/lib/plausible_web/controllers/stats_controller.exindex c51ee9beef..0f3b4432d8 100644--- a/lib/plausible_web/controllers/stats_controller.ex+++ b/lib/plausible_web/controllers/stats_controller.ex@@ -60,9 +60,6 @@ defmodule PlausibleWeb.StatsController dodogfood_page_path = if demo, do: "/#{site.domain}", else: "/:dashboard"skip_to_dashboard? = conn.params["skip_to_dashboard"] == "true"- scroll_depth_visible? =- Plausible.Stats.ScrollDepth.check_feature_visible!(site, current_user)-{:ok, segments} = Plausible.Segments.get_all_for_site(site, site_role)cond do@@ -78,7 +75,6 @@ defmodule PlausibleWeb.StatsController dorevenue_goals: list_revenue_goals(site),funnels: list_funnels(site),has_props: Plausible.Props.configured?(site),- scroll_depth_visible: scroll_depth_visible?,stats_start_date: stats_start_date,native_stats_start_date: NaiveDateTime.to_date(site.native_stats_start_at),legacy_time_on_page_cutoff: TimeOnPage.legacy_time_on_page_cutoff(),@@ -132,7 +128,7 @@ defmodule PlausibleWeb.StatsController dolimited_params = Map.merge(params, %{"limit" => "100"})csvs = %{- ~c"visitors.csv" => fn -> main_graph_csv(site, query, conn.assigns[:current_user]) end,+ ~c"visitors.csv" => fn -> main_graph_csv(site, query) end,~c"sources.csv" => fn -> Api.StatsController.sources(conn, params) end,~c"channels.csv" => fn -> Api.StatsController.channels(conn, params) end,~c"utm_mediums.csv" => fn -> Api.StatsController.utm_mediums(conn, params) end,@@ -182,8 +178,8 @@ defmodule PlausibleWeb.StatsController doendend- defp main_graph_csv(site, query, current_user) do- {metrics, column_headers} = csv_graph_metrics(query, site, current_user)+ defp main_graph_csv(site, query) do+ {metrics, column_headers} = csv_graph_metrics(query)map_bucket_to_row = fn bucket -> Enum.map([:date | metrics], &bucket[&1]) endprepend_column_headers = fn data -> [column_headers | data] end@@ -195,11 +191,10 @@ defmodule PlausibleWeb.StatsController do|> NimbleCSV.RFC4180.dump_to_iodata()end- defp csv_graph_metrics(query, site, current_user) do+ defp csv_graph_metrics(query) doinclude_scroll_depth? =!query.include_imported &&- Filters.filtering_on_dimension?(query, "event:page", behavioral_filters: :ignore) &&- Plausible.Stats.ScrollDepth.feature_visible?(site, current_user)+ Filters.filtering_on_dimension?(query, "event:page", behavioral_filters: :ignore){metrics, column_headers} =if Filters.filtering_on_dimension?(query, "event:goal", max_depth: 0) do@@ -351,9 +346,6 @@ defmodule PlausibleWeb.StatsController doshared_link = Plausible.Repo.preload(shared_link, site: :owners)stats_start_date = Plausible.Sites.stats_start_date(shared_link.site)- scroll_depth_visible? =- Plausible.Stats.ScrollDepth.check_feature_visible!(shared_link.site, current_user)-flags = get_flags(current_user, shared_link.site){:ok, segments} = Plausible.Segments.get_all_for_site(shared_link.site, site_role)@@ -368,7 +360,6 @@ defmodule PlausibleWeb.StatsController dorevenue_goals: list_revenue_goals(shared_link.site),funnels: list_funnels(shared_link.site),has_props: Plausible.Props.configured?(shared_link.site),- scroll_depth_visible: scroll_depth_visible?,stats_start_date: stats_start_date,native_stats_start_date: NaiveDateTime.to_date(shared_link.site.native_stats_start_at),legacy_time_on_page_cutoff: TimeOnPage.legacy_time_on_page_cutoff(),@@ -403,7 +394,7 @@ defmodule PlausibleWeb.StatsController dodefp get_flags(user, site),do:- [:saved_segments, :saved_segments_fe, :scroll_depth, :new_time_on_page]+ [:saved_segments, :saved_segments_fe, :new_time_on_page]|> Enum.map(fn flag ->{flag, FunWithFlags.enabled?(flag, for: user) || FunWithFlags.enabled?(flag, for: site)}end)diff --git a/lib/plausible_web/live/goal_settings/form.ex b/lib/plausible_web/live/goal_settings/form.exindex 5f6375290c..493a32b54a 100644--- a/lib/plausible_web/live/goal_settings/form.ex+++ b/lib/plausible_web/live/goal_settings/form.ex@@ -476,11 +476,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do<div class="my-2 text-sm w-full flex rounded border border-gray-300 dark:border-gray-500 overflow-hidden"><.custom_events_tab selected?={@selected_tab == "custom_events"} myself={@myself} /><.pageviews_tab selected?={@selected_tab == "pageviews"} myself={@myself} />- <.scroll_tab- :if={Plausible.Stats.ScrollDepth.feature_visible?(@site, @current_user)}- selected?={@selected_tab == "scroll"}- myself={@myself}- />+ <.scroll_tab selected?={@selected_tab == "scroll"} myself={@myself} /></div>"""enddiff --git a/lib/plausible_web/templates/stats/stats.html.heex b/lib/plausible_web/templates/stats/stats.html.heexindex 41d3d15bda..2454b68d63 100644--- a/lib/plausible_web/templates/stats/stats.html.heex+++ b/lib/plausible_web/templates/stats/stats.html.heex@@ -33,7 +33,6 @@data-revenue-goals={Jason.encode!(@revenue_goals)}data-funnels={Jason.encode!(@funnels)}data-has-props={to_string(@has_props)}- data-scroll-depth-visible={to_string(@scroll_depth_visible)}data-logged-in={to_string([email protected][:current_user])}data-stats-begin={@stats_start_date}data-native-stats-begin={@native_stats_start_date}diff --git a/test/plausible/imported/csv_importer_test.exs b/test/plausible/imported/csv_importer_test.exsindex 23730b793e..c2ded3401b 100644--- a/test/plausible/imported/csv_importer_test.exs+++ b/test/plausible/imported/csv_importer_test.exs@@ -1095,9 +1095,6 @@ defmodule Plausible.Imported.CSVImporterTest do|> upload_csvs()|> run_import()- assert %NaiveDateTime{} =- Plausible.Repo.reload!(exported_site).scroll_depth_visible_at-assert %SiteImport{start_date: start_date,end_date: end_date,@@ -1179,42 +1176,6 @@ defmodule Plausible.Imported.CSVImporterTest doassert query_scroll_depth_per_page.(conn, exported_site) == expected_resultsassert query_scroll_depth_per_page.(conn, imported_site) == expected_resultsend-- @tag :tmp_dir- test "does not include scroll depth without existing engagement data", %{- user: user,- tmp_dir: tmp_dir- } do- exported_site = new_site(owner: user)-- populate_stats(exported_site, [build(:pageview, timestamp: ~N[2021-01-01 00:00:00])])-- context = %{- user: user,- tmp_dir: tmp_dir,- exported_site: exported_site,- imported_site: new_site(owner: user)- }-- %{exported_files: exported_files, site_import: site_import} =- context- |> export_archive()- |> download_archive()- |> unzip_archive()- |> upload_csvs()- |> run_import()-- assert %SiteImport{has_scroll_depth: false} = site_import-- imported_pages_content =- exported_files- |> Enum.find(&String.contains?(&1, "imported_pages"))- |> File.read!()-- assert is_nil(Plausible.Repo.reload!(exported_site).scroll_depth_visible_at)-- refute imported_pages_content =~ "scroll_depth"- endenddefp export_archive(%{user: user, exported_site: exported_site} = context) dodiff --git a/test/plausible_web/controllers/api/stats_controller/imported_test.exs b/test/plausible_web/controllers/api/stats_controller/imported_test.exsindex 828a855985..048fc2ccbf 100644--- a/test/plausible_web/controllers/api/stats_controller/imported_test.exs+++ b/test/plausible_web/controllers/api/stats_controller/imported_test.exs@@ -787,8 +787,6 @@ defmodule PlausibleWeb.Api.StatsController.ImportedTest dosite: site,import_id: import_id} do- Plausible.Sites.set_scroll_depth_visible_at(site)-populate_stats(site, [build(:pageview,pathname: "/",diff --git a/test/plausible_web/controllers/api/stats_controller/pages_test.exs b/test/plausible_web/controllers/api/stats_controller/pages_test.exsindex 58a3562927..9b9a931b5b 100644--- a/test/plausible_web/controllers/api/stats_controller/pages_test.exs+++ b/test/plausible_web/controllers/api/stats_controller/pages_test.exs@@ -9,8 +9,7 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do:create_user,:log_in,:create_site,- :create_legacy_site_import,- :set_scroll_depth_visible_at+ :create_legacy_site_import]test "returns top pages by visitors", %{conn: conn, site: site} do@@ -655,27 +654,6 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do]end- test "does not return scroll depth (in detailed mode) when site.scroll_depth_visible_at=nil",- %{conn: conn, user: user} do- site = new_site(owner: user)-- populate_stats(site, [build(:pageview)])-- pages =- conn- |> get("/api/stats/#{site.domain}/pages?detailed=true")- |> json_response(200)- |> Map.get("results")-- assert List.first(pages) == %{- "bounce_rate" => 100,- "name" => "/",- "pageviews" => 1,- "time_on_page" => nil,- "visitors" => 1- }- end-test "calculates scroll_depth from native and imported data combined", %{conn: conn,site: site@@ -1141,8 +1119,6 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest doendtest "returns scroll depth warning code", %{conn: conn, site: site} do- Plausible.Sites.set_scroll_depth_visible_at(site)-conn =get(conn, "/api/stats/#{site.domain}/pages?period=day&detailed=true&with_imported=true")diff --git a/test/plausible_web/controllers/api/stats_controller/top_stats_test.exs b/test/plausible_web/controllers/api/stats_controller/top_stats_test.exsindex 7075108e2c..8668c0b103 100644--- a/test/plausible_web/controllers/api/stats_controller/top_stats_test.exs+++ b/test/plausible_web/controllers/api/stats_controller/top_stats_test.exs@@ -482,8 +482,7 @@ defmodule PlausibleWeb.Api.StatsController.TopStatsTest do:create_user,:log_in,:create_site,- :create_legacy_site_import,- :set_scroll_depth_visible_at+ :create_legacy_site_import]test "puts scroll depth warning code", %{conn: conn, site: site} do@@ -917,7 +916,7 @@ defmodule PlausibleWeb.Api.StatsController.TopStatsTest doenddescribe "GET /api/stats/top-stats - filters" do- setup [:create_user, :log_in, :create_site, :set_scroll_depth_visible_at]+ setup [:create_user, :log_in, :create_site]test "returns graph_metric key for top stats with a page filter", %{conn: conn,@@ -1337,29 +1336,6 @@ defmodule PlausibleWeb.Api.StatsController.TopStatsTest do"top_stats"]end-- test "does not return scroll depth when site.scroll_depth_visible_at=nil", %{- conn: conn,- user: user- } do- site = new_site(owner: user)-- filters = Jason.encode!([[:is, "event:page", ["/"]]])-- top_stats =- conn- |> get("/api/stats/#{site.domain}/top-stats?filters=#{filters}")- |> json_response(200)- |> Map.get("top_stats")-- assert [- %{"name" => "Unique visitors"},- %{"name" => "Total visits"},- %{"name" => "Total pageviews"},- %{"name" => "Bounce rate"},- %{"name" => "Time on page"}- ] = top_stats- endenddescribe "GET /api/stats/top-stats - filtered for goal" dodiff --git a/test/plausible_web/controllers/stats_controller_test.exs b/test/plausible_web/controllers/stats_controller_test.exsindex d546bc5722..fc1489f6b4 100644--- a/test/plausible_web/controllers/stats_controller_test.exs+++ b/test/plausible_web/controllers/stats_controller_test.exs@@ -117,37 +117,6 @@ defmodule PlausibleWeb.StatsControllerTest doconn = get(conn, "/test-site.com")assert html_response(conn, 404) =~ "There's nothing here"end-- test "site.scroll_depth_visible_at gets updated correctly", %{conn: conn} do- site = new_site(public: true)-- populate_stats(site, [build(:pageview)])-- # No engagements yet - `scroll_depth_visible_at` will remain `nil`- html =- conn- |> get("/#{site.domain}")- |> html_response(200)-- assert text_of_attr(html, @react_container, "data-scroll-depth-visible") == "false"-- site = Repo.reload!(site)- assert is_nil(site.scroll_depth_visible_at)-- populate_stats(site, [- build(:pageview, user_id: 123),- build(:engagement, user_id: 123, scroll_depth: 20)- ])-- # engagements exist now - `scroll_depth_visible_at` gets set to `utc_now`- html =- conn- |> get("/#{site.domain}")- |> html_response(200)-- assert text_of_attr(html, @react_container, "data-scroll-depth-visible") == "true"- assert not is_nil(Repo.reload!(site).scroll_depth_visible_at)- endenddescribe "GET /:domain - as a logged in user" do@@ -321,7 +290,7 @@ defmodule PlausibleWeb.StatsControllerTest doenddescribe "GET /:domain/export" do- setup [:create_user, :create_site, :set_scroll_depth_visible_at, :log_in]+ setup [:create_user, :create_site, :log_in]test "exports all the necessary CSV files", %{conn: conn, site: site} doconn = get(conn, "/" <> site.domain <> "/export")@@ -775,7 +744,7 @@ defmodule PlausibleWeb.StatsControllerTest doenddescribe "GET /:domain/export - via shared link" do- setup [:create_user, :create_site, :set_scroll_depth_visible_at]+ setup [:create_user, :create_site]test "exports data in zipped csvs", %{conn: conn, site: site} dolink = insert(:shared_link, site: site)@@ -787,7 +756,7 @@ defmodule PlausibleWeb.StatsControllerTest doenddescribe "GET /:domain/export - for past 6 months" do- setup [:create_user, :create_site, :set_scroll_depth_visible_at, :log_in]+ setup [:create_user, :create_site, :log_in]test "exports 6 months of data in zipped csvs", %{conn: conn, site: site} dopopulate_exported_stats(site)@@ -797,7 +766,7 @@ defmodule PlausibleWeb.StatsControllerTest doenddescribe "GET /:domain/export - with path filter" do- setup [:create_user, :create_site, :set_scroll_depth_visible_at, :log_in]+ setup [:create_user, :create_site, :log_in]test "exports filtered data in zipped csvs", %{conn: conn, site: site} dopopulate_exported_stats(site)@@ -861,34 +830,6 @@ defmodule PlausibleWeb.StatsControllerTest do[""]]end-- test "does not export scroll depth in visitors.csv if site.scroll_depth_visible_at=nil", %{- conn: conn,- user: user- } do- site = new_site(owner: user)-- filters = Jason.encode!([[:is, "event:page", ["/"]]])-- column_headers =- conn- |> get(- "/#{site.domain}/export?period=custom&from=2021-01-01&to=2021-01-02&filters=#{filters}"- )- |> response(200)- |> unzip_and_parse_csv(~c"visitors.csv")- |> List.first()-- assert column_headers == [- "date",- "visitors",- "pageviews",- "visits",- "views_per_visit",- "bounce_rate",- "visit_duration"- ]- endenddescribe "GET /:domain/export - with a custom prop filter" do@@ -1208,36 +1149,6 @@ defmodule PlausibleWeb.StatsControllerTest doassert response(conn, 404) =~ "nothing here"end- test "site.scroll_depth_visible_at gets updated correctly", %{conn: conn} do- site = insert(:site)- link = insert(:shared_link, site: site)-- # No engagements yet - `scroll_depth_visible_at` will remain `nil`- html =- conn- |> get("/share/#{site.domain}/?auth=#{link.slug}")- |> html_response(200)-- assert text_of_attr(html, @react_container, "data-scroll-depth-visible") == "false"-- site = Repo.reload!(site)- assert is_nil(site.scroll_depth_visible_at)-- populate_stats(site, [- build(:pageview, user_id: 123),- build(:engagement, user_id: 123, scroll_depth: 20)- ])-- # engagements exist now - `scroll_depth_visible_at` gets set to `utc_now`- html =- conn- |> get("/share/#{site.domain}/?auth=#{link.slug}")- |> html_response(200)-- assert text_of_attr(html, @react_container, "data-scroll-depth-visible") == "true"- assert not is_nil(Repo.reload!(site).scroll_depth_visible_at)- end-test "all segments (personal or site) are stuffed into dataset, without their owner_id and owner_name",%{conn: conn} douser = new_user()diff --git a/test/plausible_web/live/goal_settings/form_test.exs b/test/plausible_web/live/goal_settings/form_test.exsindex 52bfc4c0f7..e5b5b040f1 100644--- a/test/plausible_web/live/goal_settings/form_test.exs+++ b/test/plausible_web/live/goal_settings/form_test.exs@@ -24,8 +24,6 @@ defmodule PlausibleWeb.Live.GoalSettings.FormTest dotest "can navigate to scroll tab if scroll_depth feature visible for site/user",%{conn: conn, site: site} do- Plausible.Sites.set_scroll_depth_visible_at(site)-lv = get_liveview(conn, site)lv |> element(~s/a#scroll-tab/) |> render_click()html = render(lv)@@ -34,12 +32,6 @@ defmodule PlausibleWeb.Live.GoalSettings.FormTest doassert "goal[page_path]" in input_namesassert "goal[display_name]" in input_namesend-- test "does not render scroll tab if scroll_depth feature not visible for site/user",- %{conn: conn, site: site} do- html = get_liveview(conn, site) |> render()- refute element_exists?(html, ~s/a#scroll-tab/)- endenddescribe "Goal submission" dodiff --git a/test/support/test_utils.ex b/test/support/test_utils.exindex 6e2ad60de8..fc00a9c2e6 100644--- a/test/support/test_utils.ex+++ b/test/support/test_utils.ex@@ -74,11 +74,6 @@ defmodule Plausible.TestUtils do{:ok, site_import: site_import}end- def set_scroll_depth_visible_at(%{site: site}) do- Plausible.Sites.set_scroll_depth_visible_at(site)- :ok- end-def create_api_key(%{user: user}) doapi_key = Factory.insert(:api_key, user: user)