📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
added periods for other dates
kruzhambus365327a2e228
diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsxindex 716cdb8ad..fd99bbb79 100644--- a/src/pages/Project/View/ViewProject.jsx+++ b/src/pages/Project/View/ViewProject.jsx@@ -598,7 +598,8 @@ const ViewProject = ({// eslint-disable-next-line no-restricted-syntaxfor (const index in timeBucketToDays) {if (timeBucketToDays[index].lt >= days) {- if (!onRender) {+ console.log('onrender', onRender)+ if (!onRender && !_includes(timeBucketToDays[index].tb, timeBucket)) {url.searchParams.delete('timeBucket')url.searchParams.append('timeBucket', timeBucketToDays[index].tb[0])const { pathname, search } = url@@ -609,7 +610,6 @@ const ViewProject = ({scrollToTopDisable: true,},})- console.log('timeBucketToDays[index].tb[0]', timeBucketToDays[index].tb[0])setTimebucket(timeBucketToDays[index].tb[0])}url.searchParams.delete('period')@@ -634,48 +634,6 @@ const ViewProject = ({}}- useEffect(() => {- try {- const url = new URL(window.location)- const { searchParams } = url- const intialTimeBucket = searchParams.get('period')- if (!_includes(validPeriods, intialTimeBucket)) {- return- }-- if (intialTimeBucket === 'custom') {- const from = new Date(searchParams.get('from'))- const to = new Date(searchParams.get('to'))- if (from.getDate && to.getDate) {- onRangeDateChange([from, to], true)- setRangeDate([from, to])- // const days = Math.ceil(Math.abs(to.getTime() - from.getTime()) / (1000 * 3600 * 24))-- // // eslint-disable-next-line no-restricted-syntax- // for (const index in timeBucketToDays) {- // if (timeBucketToDays[index].lt >= days) {- // if (!(areTimeBucketParsed && _includes(timeBucketToDays[index].tb, timeBucket))) {- // console.log(_includes(timeBucketToDays[index].tb, timeBucket))- // setTimebucket(timeBucketToDays[index].tb[0])- // setProjectViewPrefs(id, 'custom', timeBucketToDays[index].tb[0], [from, to])- // } else {- // setProjectViewPrefs(id, 'custom', timeBucket, [from, to])- // }- // setPeriodPairs(tbPeriodPairs(t, timeBucketToDays[index].tb, [from, to]))- // setPeriod('custom')- // break- // }- // }- }- }-- // setTimebucket(intialTimeBucket)- } finally {- setArePeriodParsed(true)- }- // eslint-disable-next-line react-hooks/exhaustive-deps- }, [])-useEffect(() => {if (areFiltersParsed && areTimeBucketParsed && arePeriodParsed) {loadAnalytics()@@ -683,10 +641,10 @@ const ViewProject = ({}, [project, period, timeBucket, periodPairs, areFiltersParsed, areTimeBucketParsed, arePeriodParsed, t]) // eslint-disable-lineuseEffect(() => {- if (rangeDate) {+ if (rangeDate && arePeriodParsed) {onRangeDateChange(rangeDate)}- }, [rangeDate, t]) // eslint-disable-line+ }, [rangeDate, t, arePeriodParsed]) // eslint-disable-lineuseEffect(() => {const updateLiveVisitors = async () => {@@ -740,28 +698,32 @@ const ViewProject = ({const updatePeriod = (newPeriod) => {const newPeriodFull = _find(periodPairs, (el) => el.period === newPeriod.period)let tb = timeBucket+ const url = new URL(window.location)if (_isEmpty(newPeriodFull)) returnif (!_includes(newPeriodFull.tbs, timeBucket)) {tb = _last(newPeriodFull.tbs)- const url = new URL(window.location)url.searchParams.delete('timeBucket')url.searchParams.append('timeBucket', tb)- const { pathname, search } = url- history.push({- pathname,- search,- state: {- scrollToTopDisable: true,- },- })setTimebucket(tb)}if (newPeriod.period !== 'custom') {+ url.searchParams.delete('period')+ url.searchParams.delete('from')+ url.searchParams.delete('to')+ url.searchParams.append('period', newPeriod.period)setProjectViewPrefs(id, newPeriod.period, tb)setPeriod(newPeriod.period)}+ const { pathname, search } = url+ history.push({+ pathname,+ search,+ state: {+ scrollToTopDisable: true,+ },+ })}const updateTimebucket = (newTimebucket) => {@@ -797,6 +759,34 @@ const ViewProject = ({}}+ useEffect(() => {+ try {+ const url = new URL(window.location)+ const { searchParams } = url+ const intialPeriod = searchParams.get('period')+ if (!_includes(validPeriods, intialPeriod)) {+ return+ }++ if (intialPeriod === 'custom') {+ const from = new Date(searchParams.get('from'))+ const to = new Date(searchParams.get('to'))+ if (from.getDate && to.getDate) {+ onRangeDateChange([from, to], true)+ setRangeDate([from, to])+ }+ return+ }++ setPeriodPairs(tbPeriodPairs(t))+ setRangeDate(null)+ updatePeriod({ period: intialPeriod })+ } finally {+ setArePeriodParsed(true)+ }+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [])+const exportTypes = [{ label: t('project.asImage'), onClick: exportAsImageHandler },{ label: t('project.asCSV'), onClick: () => onCSVExportClick(panelsData, id, tnMapping, language) },