diff --git a/components/layout/Footer.js b/components/layout/Footer.js
index f9c2ba87..c8035fef 100644
--- a/components/layout/Footer.js
+++ b/components/layout/Footer.js
@@ -4,11 +4,9 @@ import classNames from 'classnames';
import { FormattedMessage } from 'react-intl';
import Link from 'components/common/Link';
import styles from './Footer.module.css';
-import useStore from 'store/version';
-import { HOMEPAGE_URL, REPO_URL } from 'lib/constants';
+import { CURRENT_VERSION, HOMEPAGE_URL, REPO_URL } from 'lib/constants';
export default function Footer() {
- const { current } = useStore();
const { pathname } = useRouter();
return (
@@ -28,9 +26,9 @@ export default function Footer() {
/>
- {`v${current}`}
+ {`v${CURRENT_VERSION}`}
- {!pathname.includes('/share/') && }
+ {!pathname.includes('/share/') && }
);
}
diff --git a/lib/constants.js b/lib/constants.js
index b81bcabd..ccf980c4 100644
--- a/lib/constants.js
+++ b/lib/constants.js
@@ -1,3 +1,4 @@
+export const CURRENT_VERSION = process.env.currentVersion;
export const AUTH_TOKEN = 'umami.auth';
export const LOCALE_CONFIG = 'umami.locale';
export const TIMEZONE_CONFIG = 'umami.timezone';
diff --git a/pages/api/scripts/telemetry.js b/pages/api/scripts/telemetry.js
index f264a1fe..954d5058 100644
--- a/pages/api/scripts/telemetry.js
+++ b/pages/api/scripts/telemetry.js
@@ -1,18 +1,18 @@
-import { TELEMETRY_PIXEL } from 'lib/constants';
+import { CURRENT_VERSION, TELEMETRY_PIXEL } from 'lib/constants';
export default function handler(req, res) {
- const { v } = req.query;
+ res.setHeader('content-type', 'text/javascript');
+
+ if (process.env.DISABLE_TELEMETRY) {
+ return res.send('/* telemetry disabled */');
+ }
+
const script = `
(()=>{const i=document.createElement('img');
- i.setAttribute('src','${TELEMETRY_PIXEL}?v=${v}');
+ i.setAttribute('src','${TELEMETRY_PIXEL}?v=${CURRENT_VERSION}');
i.setAttribute('style','width:0;height:0;position:absolute;pointer-events:none;');
document.body.appendChild(i);})();
`;
- res.setHeader('content-type', 'text/javascript');
- if (process.env.DISABLE_TELEMETRY) {
- res.send('/* telemetry disabled */');
- } else {
- res.send(script.replace(/\s\s+/g, ''));
- }
+ return res.send(script.replace(/\s\s+/g, ''));
}
diff --git a/store/version.js b/store/version.js
index c809aa88..ef8f3e48 100644
--- a/store/version.js
+++ b/store/version.js
@@ -1,11 +1,11 @@
import create from 'zustand';
import produce from 'immer';
import semver from 'semver';
-import { VERSION_CHECK, UPDATES_URL } from 'lib/constants';
+import { CURRENT_VERSION, VERSION_CHECK, UPDATES_URL } from 'lib/constants';
import { getItem } from 'lib/web';
const initialState = {
- current: process.env.currentVersion,
+ current: CURRENT_VERSION,
latest: null,
hasUpdate: false,
checked: false,