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!

providing the timezone string to the api

Blue Mouse35ca088c03b2
diff --git a/src/api/index.js b/src/api/index.js
index e41368e15..cf0d3b8cb 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -210,10 +210,11 @@ export const getProjectData = (
filters = [],
from = '',
to = '',
+ timezone = '',
) =>
api
.get(
- `log?pid=${pid}&timeBucket=${tb}&period=${period}&filters=${JSON.stringify(filters)}&from=${from}&to=${to}`
+ `log?pid=${pid}&timeBucket=${tb}&period=${period}&filters=${JSON.stringify(filters)}&from=${from}&to=${to}&timezone=${timezone}`
)
.then((response) => response.data)
.catch((error) => {
diff --git a/src/pages/Project/View/ViewProject.container.jsx b/src/pages/Project/View/ViewProject.container.jsx
index 7bf1de3c1..36e7a6183 100644
--- a/src/pages/Project/View/ViewProject.container.jsx
+++ b/src/pages/Project/View/ViewProject.container.jsx
@@ -9,6 +9,7 @@ const mapStateToProps = (state) => ({
cache: state.ui.cache.analytics,
projectViewPrefs: state.ui.cache.projectViewPrefs,
authenticated: state.auth.authenticated,
+ timezone: state.auth.user.timezone,
})
const mapDispatchToProps = (dispatch) => ({
diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsx
index 88004a415..b2e5d57bb 100644
--- a/src/pages/Project/View/ViewProject.jsx
+++ b/src/pages/Project/View/ViewProject.jsx
@@ -34,7 +34,7 @@ import PropTypes from 'prop-types'
import Title from 'components/Title'
import EventsRunningOutBanner from 'components/EventsRunningOutBanner'
import {
- tbPeriodPairs, tbsFormatMapper, getProjectCacheKey, LIVE_VISITORS_UPDATE_INTERVAL,
+ tbPeriodPairs, tbsFormatMapper, getProjectCacheKey, LIVE_VISITORS_UPDATE_INTERVAL, DEFAULT_TIMEZONE,
} from 'redux/constants'
import Button from 'ui/Button'
import Loader from 'ui/Loader'
@@ -218,7 +218,7 @@ const Filters = ({ filters, onRemoveFilter, onChangeExclusive, language, t, tnMa
const ViewProject = ({
projects, isLoading: _isLoading, showError, cache, setProjectCache, projectViewPrefs, setProjectViewPrefs, setPublicProject,
- setLiveStatsForProject, authenticated,
+ setLiveStatsForProject, authenticated, timezone,
}) => {
const { t, i18n: { language } } = useTranslation('common')
const periodPairs = tbPeriodPairs(t)
@@ -261,7 +261,7 @@ const ViewProject = ({
if (!forced && !_isEmpty(cache[id]) && !_isEmpty(cache[id][key])) {
data = cache[id][key]
} else {
- data = await getProjectData(id, timeBucket, period, newFilters || filters)
+ data = await getProjectData(id, timeBucket, period, newFilters || filters, '', '', timezone)
setProjectCache(id, period, timeBucket, data || {})
}
@@ -638,6 +638,11 @@ ViewProject.propTypes = {
setPublicProject: PropTypes.func.isRequired,
setLiveStatsForProject: PropTypes.func.isRequired,
authenticated: PropTypes.bool.isRequired,
+ timezone: PropTypes.string,
+}
+
+ViewProject.defaultProps = {
+ timezone: DEFAULT_TIMEZONE,
}
export default memo(ViewProject)
diff --git a/src/redux/constants/index.js b/src/redux/constants/index.js
index 91c239278..99cd549af 100644
--- a/src/redux/constants/index.js
+++ b/src/redux/constants/index.js
@@ -50,6 +50,8 @@ export const TITLE_SUFFIX = '| Swetrix'
export const LS_THEME_SETTING = 'colour-theme'
export const LS_VIEW_PREFS_SETTING = 'proj-view-preferences'
+export const DEFAULT_TIMEZONE = 'Etc/GMT'
+
export const DONATE_URL = 'https://ko-fi.com/andriir'
export const FIREFOX_ADDON_URL = 'https://addons.mozilla.org/en-US/firefox/addon/swetrix/'
export const CHROME_EXTENSION_URL = 'https://chrome.google.com/webstore/detail/swetrix/glbeclfdldjldjonfnpnembfkhphmeld'