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
Implement function for updating current page query
birjolaxew0a565025d2ac
diff --git a/assets/js/dashboard/query.js b/assets/js/dashboard/query.jsindex 00e8b3799e..5c0f607457 100644--- a/assets/js/dashboard/query.js+++ b/assets/js/dashboard/query.js@@ -41,6 +41,27 @@ export function parseQuery(querystring, site) {}}+export function navigateToQuery(history, queryFrom, newData) {+ // if we update any data that we store in localstorage, make sure going back in history will revert them+ if (newData.period && newData.period !== queryFrom.period) {+ const replaceQuery = new URLSearchParams(window.location.search)+ replaceQuery.set('period', queryFrom.period)+ history.replace({ search: replaceQuery.toString() })+ }++ // then push the new query to the history+ const query = new URLSearchParams(window.location.search)+ Object.keys(newData).forEach(key => {+ if (!newData[key]) {+ query.delete(key)+ return+ }++ query.set(key, newData[key])+ })+ history.push({ search: query.toString() })+}+export function toHuman(query) {if (query.period === 'day') {return `on ${formatDay(query.date)}`