Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Fixes edge case on conversion metric automatic change (#1939)

Vignesh Joglekare82131b2f371
diff --git a/assets/js/dashboard/stats/graph/visitor-graph.js b/assets/js/dashboard/stats/graph/visitor-graph.js
index 6f36780674..88002f8fad 100644
--- a/assets/js/dashboard/stats/graph/visitor-graph.js
+++ b/assets/js/dashboard/stats/graph/visitor-graph.js
@@ -349,14 +349,12 @@ export default class VisitorGraph extends React.Component {
const topStatLabels = topStatData && topStatData.top_stats.map(({ name }) => METRIC_MAPPING[name]).filter(name => name)
const prevTopStatLabels = prevState.topStatData && prevState.topStatData.top_stats.map(({ name }) => METRIC_MAPPING[name]).filter(name => name)
if (topStatLabels && `${topStatLabels}` !== `${prevTopStatLabels}`) {
- if (!topStatLabels.includes(savedMetric) && savedMetric !== "") {
- if (this.props.query.filters.goal && metric !== 'conversions') {
- this.setState({ metric: 'conversions' })
- } else {
- this.setState({ metric: topStatLabels[0] })
- }
- } else {
+ if (this.props.query.filters.goal && metric !== 'conversions') {
+ this.setState({ metric: 'conversions' })
+ } else if (topStatLabels.includes(savedMetric) && savedMetric !== "") {
this.setState({ metric: savedMetric })
+ } else {
+ this.setState({ metric: topStatLabels[0] })
}
}
}