@@ -55,7 +63,7 @@ export default function Referrers({ source, site, query }) {
afterFetchData={afterFetchReferrers}
getFilterFor={getFilterFor}
keyLabel="Referrer"
- metrics={maybeWithCR([VISITORS_METRIC], query)}
+ metrics={chooseMetrics()}
detailsLink={url.sitePath(`referrers/${encodeURIComponent(source)}`)}
query={query}
externalLinkDest={externalLinkDest}
diff --git a/assets/js/dashboard/stats/sources/source-list.js b/assets/js/dashboard/stats/sources/source-list.js
index 806dfc819..adfe5645d 100644
--- a/assets/js/dashboard/stats/sources/source-list.js
+++ b/assets/js/dashboard/stats/sources/source-list.js
@@ -4,7 +4,8 @@ import * as storage from '../../util/storage'
import * as url from '../../util/url'
import * as api from '../../api'
import ListReport from '../reports/list'
-import { VISITORS_METRIC, maybeWithCR } from '../reports/metrics';
+import * as metrics from '../reports/metrics';
+import { hasGoalFilter } from "../../util/filters"
import { Menu, Transition } from '@headlessui/react'
import { ChevronDownIcon } from '@heroicons/react/20/solid'
import classNames from 'classnames'
@@ -41,13 +42,20 @@ function AllSources(props) {
)
}
+ function chooseMetrics() {
+ return [
+ metrics.createVisitors({meta: {plot: true}}),
+ hasGoalFilter(query) && metrics.createConversionRate(),
+ ].filter(metric => !!metric)
+ }
+
return (
!!metric)
+ }
+
return (
"2"})
page1_html = html_response(conn1, 200)
- assert page1_html =~ s1.domain
+ assert page1_html =~ s3.domain
assert page1_html =~ s2.domain
- refute page1_html =~ s3.domain
+ refute page1_html =~ s1.domain
conn2 = get(conn, "/crm/sites/site", %{"page" => "2", "limit" => "2"})
page2_html = html_response(conn2, 200)
- refute page2_html =~ s1.domain
+ refute page2_html =~ s3.domain
refute page2_html =~ s2.domain
- assert page2_html =~ s3.domain
+ assert page2_html =~ s1.domain
end
end
diff --git a/test/plausible_web/controllers/api/external_stats_controller/query_test.exs b/test/plausible_web/controllers/api/external_stats_controller/query_test.exs
index 8bcd82a1a..5af0f7043 100644
--- a/test/plausible_web/controllers/api/external_stats_controller/query_test.exs
+++ b/test/plausible_web/controllers/api/external_stats_controller/query_test.exs
@@ -2385,10 +2385,11 @@ defmodule PlausibleWeb.Api.ExternalStatsController.QueryTest do
]
})
- assert json_response(conn, 200)["results"] == [
- %{"dimensions" => ["/plausible.io"], "metrics" => [100]},
- %{"dimensions" => ["/important-page"], "metrics" => [100]}
- ]
+ results = json_response(conn, 200)["results"]
+
+ assert length(results) == 2
+ assert %{"dimensions" => ["/plausible.io"], "metrics" => [100]} in results
+ assert %{"dimensions" => ["/important-page"], "metrics" => [100]} in results
end
test "IN filter for event:name", %{conn: conn, site: site} do