Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

add func for setActiveChartMetrics and Parse url

kruzhambusbb93e9ee6edf
diff --git a/src/pages/Captcha/View/ViewCaptcha.jsx b/src/pages/Captcha/View/ViewCaptcha.jsx
index 3a9b61ed0..38587e8fe 100644
--- a/src/pages/Captcha/View/ViewCaptcha.jsx
+++ b/src/pages/Captcha/View/ViewCaptcha.jsx
@@ -172,6 +172,11 @@ const ViewProject = ({
}
}, [t])
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ const switchActiveChartMetric = _debounce((pairID) => {
+ setActiveChartMetrics(prev => ({ ...prev, [pairID]: !prev[pairID] }))
+ })
+
const onErrorLoading = () => {
showError(t('project.noExist'))
history.push(routes.dashboard)
@@ -500,6 +505,32 @@ const ViewProject = ({
setPeriodPairs(tbPeriodPairs(t))
}, [t])
+ // Parsing initial filters from the address bar
+ useEffect(() => {
+ // using try/catch because new URL is not supported by browsers like IE, so at least analytics would work without parsing filters
+ try {
+ const url = new URL(window.location)
+ const { searchParams } = url
+ const initialFilters = []
+ // eslint-disable-next-line lodash/prefer-lodash-method
+ searchParams.forEach((value, key) => {
+ if (!_includes(validFilters, key)) {
+ return
+ }
+
+ const isExclusive = _startsWith(value, '!')
+ initialFilters.push({
+ column: key,
+ filter: isExclusive ? value.substring(1) : value,
+ isExclusive,
+ })
+ })
+ setFilters(initialFilters)
+ } finally {
+ setAreFiltersParsed(true)
+ }
+ }, [])
+
useEffect(() => {
if (arePeriodParsed) {
try {