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
Show imported icon only when querying imported ranges (#2892)
Vini Brasileb6baa92a38a
diff --git a/assets/js/dashboard/mount.js b/assets/js/dashboard/mount.jsindex c1cac71d90..9c923a88b4 100644--- a/assets/js/dashboard/mount.js+++ b/assets/js/dashboard/mount.js@@ -17,6 +17,7 @@ if (container) {offset: container.dataset.offset,hasGoals: container.dataset.hasGoals === 'true',statsBegin: container.dataset.statsBegin,+ nativeStatsBegin: container.dataset.nativeStatsBegin,embedded: container.dataset.embedded,background: container.dataset.background,isDbip: container.dataset.isDbip === 'true',diff --git a/assets/js/dashboard/stats/graph/visitor-graph.js b/assets/js/dashboard/stats/graph/visitor-graph.jsindex 89b4753cce..36193c672b 100644--- a/assets/js/dashboard/stats/graph/visitor-graph.js+++ b/assets/js/dashboard/stats/graph/visitor-graph.js@@ -13,6 +13,7 @@ import { IntervalPicker, getStoredInterval, storeInterval } from './interval-picimport FadeIn from '../../fade-in';import * as url from '../../util/url'import classNames from 'classnames';+import { parseNaiveDate, isBefore } from '../../util/date'const calculateMaximumY = function(dataset) {const yAxisValues = dataset@@ -284,9 +285,22 @@ class LineGraph extends React.Component {}importedNotice() {- const source = this.props.topStatData && this.props.topStatData.imported_source;+ if (!this.props.topStatData?.imported_source) return- if (source) {+ const isBeforeNativeStats = (date) => {+ if (!date) return false++ const nativeStatsBegin = parseNaiveDate(this.props.site.nativeStatsBegin)+ const parsedDate = parseNaiveDate(date)++ return isBefore(parsedDate, nativeStatsBegin, "day")+ }++ const isQueryingImportedPeriod = isBeforeNativeStats(this.props.topStatData.from)+ const isComparingImportedPeriod = isBeforeNativeStats(this.props.topStatData.comparing_from)++ if (isQueryingImportedPeriod || isComparingImportedPeriod) {+ const source = this.props.topStatData.imported_sourceconst withImported = this.props.topStatData.with_imported;const strike = withImported ? "" : " line-through"const target = url.setQuery('with_imported', !withImported)diff --git a/lib/plausible_web/controllers/stats_controller.ex b/lib/plausible_web/controllers/stats_controller.exindex 58174a3b31..74b4c2d69a 100644--- a/lib/plausible_web/controllers/stats_controller.ex+++ b/lib/plausible_web/controllers/stats_controller.ex@@ -65,6 +65,7 @@ defmodule PlausibleWeb.StatsController dosite: site,has_goals: Plausible.Sites.has_goals?(site),stats_start_date: stats_start_date,+ native_stats_start_date: NaiveDateTime.to_date(site.native_stats_start_at),title: "Plausible · " <> site.domain,offer_email_report: offer_email_report,demo: demo,@@ -296,6 +297,7 @@ defmodule PlausibleWeb.StatsController dosite: shared_link.site,has_goals: Sites.has_goals?(shared_link.site),stats_start_date: shared_link.site.stats_start_date,+ native_stats_start_date: NaiveDateTime.to_date(shared_link.site.native_stats_start_at),title: "Plausible · " <> shared_link.site.domain,offer_email_report: false,demo: false,diff --git a/lib/plausible_web/templates/stats/stats.html.eex b/lib/plausible_web/templates/stats/stats.html.eexindex 98e76cf3da..2d8d4c65c5 100644--- a/lib/plausible_web/templates/stats/stats.html.eex+++ b/lib/plausible_web/templates/stats/stats.html.eex@@ -20,6 +20,7 @@data-has-goals="<%= @has_goals %>"data-logged-in="<%= [email protected][:current_user] %>"data-stats-begin="<%= @stats_start_date %>"+ data-native-stats-begin="<%= @native_stats_start_date %>"data-shared-link-auth="<%= assigns[:shared_link_auth] %>"data-embedded="<%= @conn.assigns[:embedded] %>"data-background="<%= @conn.assigns[:background] %>"