diff --git a/.eslintrc.json b/.eslintrc.json
index e5f0cc94..28e542bd 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -4,7 +4,7 @@
"es2020": true,
"node": true
},
- "extends": ["eslint:recommended", "plugin:react/recommended", "prettier", "next"],
+ "extends": ["eslint:recommended", "plugin:prettier/recommended", "next"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
@@ -12,7 +12,6 @@
"ecmaVersion": 11,
"sourceType": "module"
},
- "plugins": ["react"],
"rules": {
"react/display-name": "off",
"react/react-in-jsx-scope": "off",
diff --git a/README.md b/README.md
index 98fe2150..5a72e3c8 100644
--- a/README.md
+++ b/README.md
@@ -102,6 +102,13 @@ npm install
npm run build
```
+To update the Docker image, simply pull the new images and rebuild:
+
+```bash
+docker-compose pull
+docker-compose up --force-recreate
+```
+
## License
MIT
diff --git a/components/metrics/MetricsTable.js b/components/metrics/MetricsTable.js
index d8065fe3..e1fa6891 100644
--- a/components/metrics/MetricsTable.js
+++ b/components/metrics/MetricsTable.js
@@ -30,7 +30,7 @@ export default function MetricsTable({
const {
resolve,
router,
- query: { url },
+ query: { url, referrer },
} = usePageQuery();
const { data, loading, error } = useFetch(
@@ -41,12 +41,13 @@ export default function MetricsTable({
start_at: +startDate,
end_at: +endDate,
url,
+ referrer,
},
onDataLoad,
delay: DEFAULT_ANIMATION_DURATION,
headers: { [TOKEN_HEADER]: shareToken?.token },
},
- [modified],
+ [modified, url, referrer],
);
const filteredData = useMemo(() => {
diff --git a/components/metrics/ReferrersTable.js b/components/metrics/ReferrersTable.js
index c7079e8d..93cdb956 100644
--- a/components/metrics/ReferrersTable.js
+++ b/components/metrics/ReferrersTable.js
@@ -19,7 +19,7 @@ export default function ReferrersTable({ websiteId, websiteDomain, showFilters,
const [filter, setFilter] = useState(FILTER_COMBINED);
const {
resolve,
- query: { ref: currentRef },
+ query: { referrer: currentRef },
} = usePageQuery();
const buttons = [
@@ -37,7 +37,7 @@ export default function ReferrersTable({ websiteId, websiteDomain, showFilters,
const renderLink = ({ w: link, x: label }) => {
return (
-
+
{
@@ -88,7 +88,7 @@ export default function WebsiteChart({
stickyClassName={styles.sticky}
enabled={stickyHeader}
>
-
+
diff --git a/hooks/useCountryNames.js b/hooks/useCountryNames.js
index e631aecd..6dce6cb7 100644
--- a/hooks/useCountryNames.js
+++ b/hooks/useCountryNames.js
@@ -1,7 +1,7 @@
import { useState, useEffect } from 'react';
import { useRouter } from 'next/router';
import { get } from 'lib/web';
-import enUS from 'public/country/en-US.json';
+import enUS from 'public/intl/country/en-US.json';
const countryNames = {
'en-US': enUS,
@@ -12,7 +12,7 @@ export default function useCountryNames(locale) {
const { basePath } = useRouter();
async function loadData(locale) {
- const { ok, data } = await get(`${basePath}/country/${locale}.json`);
+ const { ok, data } = await get(`${basePath}/intl/country/${locale}.json`);
if (ok) {
countryNames[locale] = data;
diff --git a/hooks/useLanguageNames.js b/hooks/useLanguageNames.js
index ef179185..2fc313f2 100644
--- a/hooks/useLanguageNames.js
+++ b/hooks/useLanguageNames.js
@@ -1,7 +1,7 @@
import { useState, useEffect } from 'react';
import { useRouter } from 'next/router';
import { get } from 'lib/web';
-import enUS from 'public/language/en-US.json';
+import enUS from 'public/intl/language/en-US.json';
const languageNames = {
'en-US': enUS,
@@ -12,7 +12,7 @@ export default function useLanguageNames(locale) {
const { basePath } = useRouter();
async function loadData(locale) {
- const { ok, data } = await get(`${basePath}/language/${locale}.json`);
+ const { ok, data } = await get(`${basePath}/intl/language/${locale}.json`);
if (ok) {
languageNames[locale] = data;
diff --git a/hooks/useLocale.js b/hooks/useLocale.js
index 2a878d89..fdce6d91 100644
--- a/hooks/useLocale.js
+++ b/hooks/useLocale.js
@@ -5,7 +5,7 @@ import { LOCALE_CONFIG } from 'lib/constants';
import { getDateLocale, getTextDirection } from 'lib/lang';
import useStore, { setLocale } from 'store/app';
import useForceUpdate from 'hooks/useForceUpdate';
-import enUS from 'public/messages/en-US.json';
+import enUS from 'public/intl/messages/en-US.json';
const messages = {
'en-US': enUS,
@@ -21,7 +21,7 @@ export default function useLocale() {
const dateLocale = getDateLocale(locale);
async function loadMessages(locale) {
- const { ok, data } = await get(`${basePath}/messages/${locale}.json`);
+ const { ok, data } = await get(`${basePath}/intl/messages/${locale}.json`);
if (ok) {
messages[locale] = data;
diff --git a/lang/fr-FR.json b/lang/fr-FR.json
index b7cee440..6698521d 100644
--- a/lang/fr-FR.json
+++ b/lang/fr-FR.json
@@ -28,7 +28,7 @@
"label.enable-share-url": "Activer le partage d'URL",
"label.invalid": "Invalide",
"label.invalid-domain": "Domaine invalide",
- "label.language": "Language",
+ "label.language": "Langage",
"label.last-days": "{x} derniers jours",
"label.last-hours": "{x} dernières heures",
"label.logged-in-as": "Connecté en tant que {username}",
@@ -51,7 +51,7 @@
"label.settings": "Paramètres",
"label.share-url": "Partager l'URL",
"label.single-day": "Journée",
- "label.theme": "Theme",
+ "label.theme": "Thème",
"label.this-month": "Ce mois ci",
"label.this-week": "Cette semaine",
"label.this-year": "Cette année",
diff --git a/lang/pl-PL.json b/lang/pl-PL.json
index 5856ac9c..32798238 100644
--- a/lang/pl-PL.json
+++ b/lang/pl-PL.json
@@ -5,7 +5,7 @@
"label.administrator": "Administrator",
"label.all": "Wszystkie",
"label.all-events": "Wszystkie wydarzenia",
- "label.all-time": "All time",
+ "label.all-time": "Cały czas",
"label.all-websites": "Wszystkie witryny",
"label.back": "Powrót",
"label.cancel": "Anuluj",
@@ -14,7 +14,7 @@
"label.copy-to-clipboard": "Skopiuj do schowka",
"label.current-password": "Aktualne hasło",
"label.custom-range": "Zakres niestandardowy",
- "label.dashboard": "Dashboard",
+ "label.dashboard": "Panel",
"label.date-range": "Zakres dat",
"label.default-date-range": "Domyślny zakres dat",
"label.delete": "Usuń",
@@ -28,7 +28,7 @@
"label.enable-share-url": "Włącz udostępnianie adresu URL",
"label.invalid": "Nieprawidłowy",
"label.invalid-domain": "Nieprawidłowa witryna",
- "label.language": "Language",
+ "label.language": "Język",
"label.last-days": "Ostatnie {x} dni",
"label.last-hours": "Ostatnie {x} godzin",
"label.logged-in-as": "Zalogowano jako {username}",
@@ -37,7 +37,7 @@
"label.more": "Więcej",
"label.name": "Nazwa",
"label.new-password": "Nowe hasło",
- "label.owner": "Owner",
+ "label.owner": "Właściciel",
"label.password": "Hasło",
"label.passwords-dont-match": "Hasła się nie zgadzają",
"label.profile": "Profil",
@@ -46,12 +46,12 @@
"label.refresh": "Odśwież",
"label.required": "Wymagany",
"label.reset": "Zresetuj",
- "label.reset-website": "Reset statistics",
+ "label.reset-website": "Zresetuj statystyki",
"label.save": "Zapisz",
"label.settings": "Ustawienia",
"label.share-url": "Udostępnij adres URL",
"label.single-day": "W tym dniu",
- "label.theme": "Theme",
+ "label.theme": "Motyw",
"label.this-month": "W tym miesiącu",
"label.this-week": "W tym tygodniu",
"label.this-year": "W tym roku",
@@ -64,7 +64,7 @@
"label.websites": "Witryny",
"message.active-users": "{x} aktualnie {x, plural, one {odwiedzający} other {odwiedzających}}",
"message.confirm-delete": "Czy na pewno chcesz usunąć {target}?",
- "message.confirm-reset": "Are your sure you want to reset {target}'s statistics?",
+ "message.confirm-reset": "Czy na pewno chcesz zresetować statystyki {target}?",
"message.copied": "Skopiowano!",
"message.delete-warning": "Wszystkie powiązane dane również zostaną usunięte.",
"message.failure": "Coś poszło nie tak.",
@@ -78,10 +78,10 @@
"message.no-websites-configured": "Nie masz skonfigurowanych żadnych witryn internetowych.",
"message.page-not-found": "Strona nie znaleziona.",
"message.powered-by": "Obsługiwane przez {name}",
- "message.reset-warning": "All statistics for this website will be deleted, but your tracking code will remain intact.",
+ "message.reset-warning": "Wszystkie statystyki tej witryny zostaną usunięte, ale kod śledzenia pozostanie nienaruszony.",
"message.save-success": "Zapisano pomyślnie.",
"message.share-url": "To jest publicznie udostępniany adres URL dla {target}.",
- "message.toggle-charts": "Toggle charts",
+ "message.toggle-charts": "Przełącz wykresy",
"message.track-stats": "Aby śledzić statystyki dla {target}, umieść poniższy kod w sekcji {head} swojej witryny.",
"message.type-delete": "Wpisz {delete} w polu poniżej, aby potwierdzić.",
"message.type-reset": "Wpisz {reset} w polu poniżej, aby potwierdzić.",
@@ -99,7 +99,7 @@
"metrics.filter.combined": "Połączone",
"metrics.filter.domain-only": "Tylko domena",
"metrics.filter.raw": "Surowe dane",
- "metrics.languages": "Languages",
+ "metrics.languages": "Języki",
"metrics.operating-systems": "System operacyjny",
"metrics.page-views": "Wyświetlenia strony",
"metrics.pages": "Strony",
diff --git a/lang/zh-CN.json b/lang/zh-CN.json
index 66127402..506c99b8 100644
--- a/lang/zh-CN.json
+++ b/lang/zh-CN.json
@@ -5,7 +5,7 @@
"label.administrator": "管理员",
"label.all": "所有",
"label.all-events": "所有事件",
- "label.all-time": "所有时间",
+ "label.all-time": "所有时间段",
"label.all-websites": "全部网站",
"label.back": "返回",
"label.cancel": "取消",
@@ -28,7 +28,7 @@
"label.enable-share-url": "启用共享链接",
"label.invalid": "输入无效",
"label.invalid-domain": "无效域名",
- "label.language": "Language",
+ "label.language": "语言",
"label.last-days": "最近 {x} 天",
"label.last-hours": "最近 {x} 小时",
"label.logged-in-as": "登录名: {username}",
@@ -64,7 +64,7 @@
"label.websites": "网站",
"message.active-users": "当前在线 {x} 人",
"message.confirm-delete": "你确定要删除 {target} 吗?",
- "message.confirm-reset": "Are your sure you want to reset {target}'s statistics?",
+ "message.confirm-reset": "您确定要重置 {target} 的数据吗?",
"message.copied": "复制成功!",
"message.delete-warning": "所有相关数据将会被删除。",
"message.failure": "出现错误。",
@@ -99,7 +99,7 @@
"metrics.filter.combined": "总和",
"metrics.filter.domain-only": "只看域名",
"metrics.filter.raw": "原始",
- "metrics.languages": "Languages",
+ "metrics.languages": "语言",
"metrics.operating-systems": "操作系统",
"metrics.page-views": "页面浏览量",
"metrics.pages": "网页",
diff --git a/lib/filters.js b/lib/filters.js
index e9723b42..fb6b435a 100644
--- a/lib/filters.js
+++ b/lib/filters.js
@@ -1,5 +1,5 @@
import { BROWSERS } from './constants';
-import { removeTrailingSlash, removeWWW } from './url';
+import { removeTrailingSlash, removeWWW, getDomainName } from './url';
export const urlFilter = (data, { raw }) => {
const isValidUrl = url => {
@@ -46,11 +46,14 @@ export const urlFilter = (data, { raw }) => {
};
export const refFilter = (data, { domain, domainOnly, raw }) => {
- const regex = new RegExp(`http[s]?://([a-z0-9-]+\\.)*${domain}`);
+ const domainName = getDomainName(domain);
+ const regex = new RegExp(`http[s]?://([a-z0-9-]+\\.)*${domainName}`);
const links = {};
- const isValidRef = ref => {
- return ref !== '' && ref !== null && !ref.startsWith('/') && !ref.startsWith('#');
+ const isValidRef = referrer => {
+ return (
+ referrer !== '' && referrer !== null && !referrer.startsWith('/') && !referrer.startsWith('#')
+ );
};
const cleanUrl = url => {
@@ -71,8 +74,8 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
if (protocol.startsWith('http')) {
const path = removeTrailingSlash(pathname);
- const ref = searchParams.get('ref');
- const query = ref ? `?ref=${ref}` : '';
+ const referrer = searchParams.get('referrer');
+ const query = referrer ? `?referrer=${referrer}` : '';
return removeTrailingSlash(`${removeWWW(hostname)}${path}`) + query;
}
diff --git a/lib/queries.js b/lib/queries.js
index 5bcd18ba..ed644874 100644
--- a/lib/queries.js
+++ b/lib/queries.js
@@ -335,7 +335,7 @@ export async function getEvents(websites, start_at) {
export function getWebsiteStats(website_id, start_at, end_at, filters = {}) {
const params = [website_id, start_at, end_at];
- const { url, ref } = filters;
+ const { url, referrer } = filters;
let urlFilter = '';
let refFilter = '';
@@ -344,9 +344,9 @@ export function getWebsiteStats(website_id, start_at, end_at, filters = {}) {
params.push(decodeURIComponent(url));
}
- if (ref) {
+ if (referrer) {
refFilter = `and referrer like $${params.length + 1}`;
- params.push(`%${decodeURIComponent(ref)}%`);
+ params.push(`%${decodeURIComponent(referrer)}%`);
}
return rawQuery(
@@ -382,7 +382,7 @@ export function getPageviewStats(
filters = {},
) {
const params = [website_id, start_at, end_at];
- const { url, ref } = filters;
+ const { url, referrer } = filters;
let urlFilter = '';
let refFilter = '';
@@ -392,9 +392,9 @@ export function getPageviewStats(
params.push(decodeURIComponent(url));
}
- if (ref) {
+ if (referrer) {
refFilter = `and referrer like $${params.length + 1}`;
- params.push(`%${decodeURIComponent(ref)}%`);
+ params.push(`%${decodeURIComponent(referrer)}%`);
}
return rawQuery(
@@ -444,10 +444,11 @@ export function getSessionMetrics(website_id, start_at, end_at, field, filters =
export function getPageviewMetrics(website_id, start_at, end_at, field, table, filters = {}) {
const params = [website_id, start_at, end_at];
- const { domain, url } = filters;
+ const { domain, url, referrer } = filters;
let domainFilter = '';
let urlFilter = '';
+ let refFilter = '';
if (domain) {
domainFilter = `and referrer not like $${params.length + 1} and referrer not like '/%'`;
@@ -459,6 +460,11 @@ export function getPageviewMetrics(website_id, start_at, end_at, field, table, f
params.push(decodeURIComponent(url));
}
+ if (referrer) {
+ refFilter = `and referrer like $${params.length + 1}`;
+ params.push(`%${decodeURIComponent(referrer)}%`);
+ }
+
return rawQuery(
`
select ${field} x, count(*) y
@@ -467,6 +473,7 @@ export function getPageviewMetrics(website_id, start_at, end_at, field, table, f
and created_at between $2 and $3
${domainFilter}
${urlFilter}
+ ${refFilter}
group by 1
order by 2 desc
`,
diff --git a/lib/response.js b/lib/response.js
index 0e938f90..72525f18 100644
--- a/lib/response.js
+++ b/lib/response.js
@@ -6,7 +6,9 @@ export function json(res, data = {}) {
return res.status(200).json(data);
}
-export function send(res, data) {
+export function send(res, data, type = 'text/plain') {
+ res.setHeader('Content-Type', type);
+
return res.status(200).send(data);
}
diff --git a/lib/session.js b/lib/session.js
index f91545f3..73d02e59 100644
--- a/lib/session.js
+++ b/lib/session.js
@@ -9,7 +9,8 @@ export async function getSession(req) {
throw new Error('Invalid request');
}
- const { website: website_uuid, hostname, screen, language, cache } = payload;
+ const { website: website_uuid, hostname, screen, language } = payload;
+ const cache = req.headers['x-umami-cache'];
if (cache) {
const result = await parseToken(cache);
diff --git a/package.json b/package.json
index 859be4d2..7b6b2ec9 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,8 @@
"scripts": {
"dev": "next dev",
"build": "npm-run-all build-tracker build-geo build-db build-app",
- "start": "next start",
+ "start": "npm-run-all init start-app",
+ "start-app": "next start",
"start-env": "node -r dotenv/config scripts/start-env.js",
"build-app": "next build",
"build-tracker": "rollup -c rollup.tracker.config.js",
@@ -25,19 +26,20 @@
"build-mysql-client": "dotenv prisma generate -- --schema=./prisma/schema.mysql.prisma",
"build-postgresql-schema": "dotenv prisma db pull -- --schema=./prisma/schema.postgresql.prisma",
"build-postgresql-client": "dotenv prisma generate -- --schema=./prisma/schema.postgresql.prisma",
- "postbuild": "node scripts/postbuild.js",
"copy-db-schema": "node scripts/copy-db-schema.js",
"generate-lang": "npm-run-all extract-lang merge-lang",
"extract-lang": "formatjs extract \"{pages,components}/**/*.js\" --out-file build/messages.json",
"merge-lang": "node scripts/merge-lang.js",
"format-lang": "node scripts/format-lang.js",
- "compile-lang": "formatjs compile-folder --ast build public/messages",
+ "compile-lang": "formatjs compile-folder --ast build public/intl/messages",
"check-lang": "node scripts/check-lang.js",
"download-country-names": "node scripts/download-country-names.js",
"download-language-names": "node scripts/download-language-names.js",
"change-password": "node scripts/change-password.js",
"lint": "next lint --quiet",
- "prepare": "husky install"
+ "prepare": "husky install",
+ "postbuild": "node scripts/postbuild.js",
+ "init": "node scripts/prestart.js"
},
"lint-staged": {
"**/*.js": [
@@ -105,10 +107,7 @@
"dotenv-cli": "^4.0.0",
"eslint": "^7.32.0",
"eslint-config-next": "^12.0.1",
- "eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
- "eslint-plugin-react": "^7.29.4",
- "eslint-plugin-react-hooks": "^4.2.0",
"extract-react-intl-messages": "^4.1.1",
"husky": "^7.0.0",
"lint-staged": "^11.0.0",
diff --git a/pages/api/website/[id]/metrics.js b/pages/api/website/[id]/metrics.js
index 5e16e350..675427db 100644
--- a/pages/api/website/[id]/metrics.js
+++ b/pages/api/website/[id]/metrics.js
@@ -30,7 +30,7 @@ export default async (req, res) => {
return unauthorized(res);
}
- const { id, type, start_at, end_at, url } = req.query;
+ const { id, type, start_at, end_at, url, referrer } = req.query;
const websiteId = +id;
const startDate = new Date(+start_at);
@@ -75,6 +75,7 @@ export default async (req, res) => {
{
domain,
url: type !== 'url' && url,
+ referrer,
},
);
diff --git a/pages/api/website/[id]/pageviews.js b/pages/api/website/[id]/pageviews.js
index 22966ca7..e2069f8c 100644
--- a/pages/api/website/[id]/pageviews.js
+++ b/pages/api/website/[id]/pageviews.js
@@ -11,7 +11,7 @@ export default async (req, res) => {
return unauthorized(res);
}
- const { id, start_at, end_at, unit, tz, url, ref } = req.query;
+ const { id, start_at, end_at, unit, tz, url, referrer } = req.query;
const websiteId = +id;
const startDate = new Date(+start_at);
@@ -22,10 +22,10 @@ export default async (req, res) => {
}
const [pageviews, sessions] = await Promise.all([
- getPageviewStats(websiteId, startDate, endDate, tz, unit, '*', { url, ref }),
+ getPageviewStats(websiteId, startDate, endDate, tz, unit, '*', { url, referrer }),
getPageviewStats(websiteId, startDate, endDate, tz, unit, 'distinct session_id', {
url,
- ref,
+ referrer,
}),
]);
diff --git a/pages/api/website/[id]/stats.js b/pages/api/website/[id]/stats.js
index 9dd82361..cdb374e2 100644
--- a/pages/api/website/[id]/stats.js
+++ b/pages/api/website/[id]/stats.js
@@ -8,7 +8,7 @@ export default async (req, res) => {
return unauthorized(res);
}
- const { id, start_at, end_at, url, ref } = req.query;
+ const { id, start_at, end_at, url, referrer } = req.query;
const websiteId = +id;
const startDate = new Date(+start_at);
@@ -18,8 +18,11 @@ export default async (req, res) => {
const prevStartDate = new Date(+start_at - distance);
const prevEndDate = new Date(+end_at - distance);
- const metrics = await getWebsiteStats(websiteId, startDate, endDate, { url, ref });
- const prevPeriod = await getWebsiteStats(websiteId, prevStartDate, prevEndDate, { url, ref });
+ const metrics = await getWebsiteStats(websiteId, startDate, endDate, { url, referrer });
+ const prevPeriod = await getWebsiteStats(websiteId, prevStartDate, prevEndDate, {
+ url,
+ referrer,
+ });
const stats = Object.keys(metrics[0]).reduce((obj, key) => {
obj[key] = {
diff --git a/public/country/ar-SA.json b/public/intl/country/ar-SA.json
similarity index 100%
rename from public/country/ar-SA.json
rename to public/intl/country/ar-SA.json
diff --git a/public/country/ca-ES.json b/public/intl/country/ca-ES.json
similarity index 100%
rename from public/country/ca-ES.json
rename to public/intl/country/ca-ES.json
diff --git a/public/country/cs-CZ.json b/public/intl/country/cs-CZ.json
similarity index 100%
rename from public/country/cs-CZ.json
rename to public/intl/country/cs-CZ.json
diff --git a/public/country/da-DK.json b/public/intl/country/da-DK.json
similarity index 100%
rename from public/country/da-DK.json
rename to public/intl/country/da-DK.json
diff --git a/public/country/de-DE.json b/public/intl/country/de-DE.json
similarity index 100%
rename from public/country/de-DE.json
rename to public/intl/country/de-DE.json
diff --git a/public/country/el-GR.json b/public/intl/country/el-GR.json
similarity index 100%
rename from public/country/el-GR.json
rename to public/intl/country/el-GR.json
diff --git a/public/country/en-GB.json b/public/intl/country/en-GB.json
similarity index 100%
rename from public/country/en-GB.json
rename to public/intl/country/en-GB.json
diff --git a/public/country/en-US.json b/public/intl/country/en-US.json
similarity index 100%
rename from public/country/en-US.json
rename to public/intl/country/en-US.json
diff --git a/public/country/es-MX.json b/public/intl/country/es-MX.json
similarity index 100%
rename from public/country/es-MX.json
rename to public/intl/country/es-MX.json
diff --git a/public/country/fa-IR.json b/public/intl/country/fa-IR.json
similarity index 100%
rename from public/country/fa-IR.json
rename to public/intl/country/fa-IR.json
diff --git a/public/country/fi-FI.json b/public/intl/country/fi-FI.json
similarity index 100%
rename from public/country/fi-FI.json
rename to public/intl/country/fi-FI.json
diff --git a/public/country/fo-FO.json b/public/intl/country/fo-FO.json
similarity index 100%
rename from public/country/fo-FO.json
rename to public/intl/country/fo-FO.json
diff --git a/public/country/fr-FR.json b/public/intl/country/fr-FR.json
similarity index 100%
rename from public/country/fr-FR.json
rename to public/intl/country/fr-FR.json
diff --git a/public/country/he-IL.json b/public/intl/country/he-IL.json
similarity index 100%
rename from public/country/he-IL.json
rename to public/intl/country/he-IL.json
diff --git a/public/country/hi-IN.json b/public/intl/country/hi-IN.json
similarity index 100%
rename from public/country/hi-IN.json
rename to public/intl/country/hi-IN.json
diff --git a/public/country/hu-HU.json b/public/intl/country/hu-HU.json
similarity index 100%
rename from public/country/hu-HU.json
rename to public/intl/country/hu-HU.json
diff --git a/public/country/id-ID.json b/public/intl/country/id-ID.json
similarity index 100%
rename from public/country/id-ID.json
rename to public/intl/country/id-ID.json
diff --git a/public/country/it-IT.json b/public/intl/country/it-IT.json
similarity index 100%
rename from public/country/it-IT.json
rename to public/intl/country/it-IT.json
diff --git a/public/country/ja-JP.json b/public/intl/country/ja-JP.json
similarity index 100%
rename from public/country/ja-JP.json
rename to public/intl/country/ja-JP.json
diff --git a/public/country/ko-KR.json b/public/intl/country/ko-KR.json
similarity index 100%
rename from public/country/ko-KR.json
rename to public/intl/country/ko-KR.json
diff --git a/public/country/lt-LT.json b/public/intl/country/lt-LT.json
similarity index 100%
rename from public/country/lt-LT.json
rename to public/intl/country/lt-LT.json
diff --git a/public/country/mn-MN.json b/public/intl/country/mn-MN.json
similarity index 100%
rename from public/country/mn-MN.json
rename to public/intl/country/mn-MN.json
diff --git a/public/country/ms-MY.json b/public/intl/country/ms-MY.json
similarity index 100%
rename from public/country/ms-MY.json
rename to public/intl/country/ms-MY.json
diff --git a/public/country/nb-NO.json b/public/intl/country/nb-NO.json
similarity index 100%
rename from public/country/nb-NO.json
rename to public/intl/country/nb-NO.json
diff --git a/public/country/nl-NL.json b/public/intl/country/nl-NL.json
similarity index 100%
rename from public/country/nl-NL.json
rename to public/intl/country/nl-NL.json
diff --git a/public/country/pl-PL.json b/public/intl/country/pl-PL.json
similarity index 100%
rename from public/country/pl-PL.json
rename to public/intl/country/pl-PL.json
diff --git a/public/country/pt-BR.json b/public/intl/country/pt-BR.json
similarity index 100%
rename from public/country/pt-BR.json
rename to public/intl/country/pt-BR.json
diff --git a/public/country/pt-PT.json b/public/intl/country/pt-PT.json
similarity index 100%
rename from public/country/pt-PT.json
rename to public/intl/country/pt-PT.json
diff --git a/public/country/ro-RO.json b/public/intl/country/ro-RO.json
similarity index 100%
rename from public/country/ro-RO.json
rename to public/intl/country/ro-RO.json
diff --git a/public/country/ru-RU.json b/public/intl/country/ru-RU.json
similarity index 100%
rename from public/country/ru-RU.json
rename to public/intl/country/ru-RU.json
diff --git a/public/country/sk-SK.json b/public/intl/country/sk-SK.json
similarity index 100%
rename from public/country/sk-SK.json
rename to public/intl/country/sk-SK.json
diff --git a/public/country/sl-SI.json b/public/intl/country/sl-SI.json
similarity index 100%
rename from public/country/sl-SI.json
rename to public/intl/country/sl-SI.json
diff --git a/public/country/sv-SE.json b/public/intl/country/sv-SE.json
similarity index 100%
rename from public/country/sv-SE.json
rename to public/intl/country/sv-SE.json
diff --git a/public/country/ta-IN.json b/public/intl/country/ta-IN.json
similarity index 100%
rename from public/country/ta-IN.json
rename to public/intl/country/ta-IN.json
diff --git a/public/country/tr-TR.json b/public/intl/country/tr-TR.json
similarity index 100%
rename from public/country/tr-TR.json
rename to public/intl/country/tr-TR.json
diff --git a/public/country/uk-UA.json b/public/intl/country/uk-UA.json
similarity index 100%
rename from public/country/uk-UA.json
rename to public/intl/country/uk-UA.json
diff --git a/public/country/ur-PK.json b/public/intl/country/ur-PK.json
similarity index 100%
rename from public/country/ur-PK.json
rename to public/intl/country/ur-PK.json
diff --git a/public/country/vi-VN.json b/public/intl/country/vi-VN.json
similarity index 100%
rename from public/country/vi-VN.json
rename to public/intl/country/vi-VN.json
diff --git a/public/country/zh-CN.json b/public/intl/country/zh-CN.json
similarity index 100%
rename from public/country/zh-CN.json
rename to public/intl/country/zh-CN.json
diff --git a/public/country/zh-TW.json b/public/intl/country/zh-TW.json
similarity index 100%
rename from public/country/zh-TW.json
rename to public/intl/country/zh-TW.json
diff --git a/public/language/ar-SA.json b/public/intl/language/ar-SA.json
similarity index 100%
rename from public/language/ar-SA.json
rename to public/intl/language/ar-SA.json
diff --git a/public/language/ca-ES.json b/public/intl/language/ca-ES.json
similarity index 100%
rename from public/language/ca-ES.json
rename to public/intl/language/ca-ES.json
diff --git a/public/language/cs-CZ.json b/public/intl/language/cs-CZ.json
similarity index 100%
rename from public/language/cs-CZ.json
rename to public/intl/language/cs-CZ.json
diff --git a/public/language/da-DK.json b/public/intl/language/da-DK.json
similarity index 100%
rename from public/language/da-DK.json
rename to public/intl/language/da-DK.json
diff --git a/public/language/de-DE.json b/public/intl/language/de-DE.json
similarity index 100%
rename from public/language/de-DE.json
rename to public/intl/language/de-DE.json
diff --git a/public/language/el-GR.json b/public/intl/language/el-GR.json
similarity index 100%
rename from public/language/el-GR.json
rename to public/intl/language/el-GR.json
diff --git a/public/language/en-GB.json b/public/intl/language/en-GB.json
similarity index 100%
rename from public/language/en-GB.json
rename to public/intl/language/en-GB.json
diff --git a/public/language/en-US.json b/public/intl/language/en-US.json
similarity index 100%
rename from public/language/en-US.json
rename to public/intl/language/en-US.json
diff --git a/public/language/es-MX.json b/public/intl/language/es-MX.json
similarity index 100%
rename from public/language/es-MX.json
rename to public/intl/language/es-MX.json
diff --git a/public/language/fa-IR.json b/public/intl/language/fa-IR.json
similarity index 100%
rename from public/language/fa-IR.json
rename to public/intl/language/fa-IR.json
diff --git a/public/language/fi-FI.json b/public/intl/language/fi-FI.json
similarity index 100%
rename from public/language/fi-FI.json
rename to public/intl/language/fi-FI.json
diff --git a/public/language/fo-FO.json b/public/intl/language/fo-FO.json
similarity index 100%
rename from public/language/fo-FO.json
rename to public/intl/language/fo-FO.json
diff --git a/public/language/fr-FR.json b/public/intl/language/fr-FR.json
similarity index 100%
rename from public/language/fr-FR.json
rename to public/intl/language/fr-FR.json
diff --git a/public/language/he-IL.json b/public/intl/language/he-IL.json
similarity index 100%
rename from public/language/he-IL.json
rename to public/intl/language/he-IL.json
diff --git a/public/language/hi-IN.json b/public/intl/language/hi-IN.json
similarity index 100%
rename from public/language/hi-IN.json
rename to public/intl/language/hi-IN.json
diff --git a/public/language/hu-HU.json b/public/intl/language/hu-HU.json
similarity index 100%
rename from public/language/hu-HU.json
rename to public/intl/language/hu-HU.json
diff --git a/public/language/id-ID.json b/public/intl/language/id-ID.json
similarity index 100%
rename from public/language/id-ID.json
rename to public/intl/language/id-ID.json
diff --git a/public/language/it-IT.json b/public/intl/language/it-IT.json
similarity index 100%
rename from public/language/it-IT.json
rename to public/intl/language/it-IT.json
diff --git a/public/language/ja-JP.json b/public/intl/language/ja-JP.json
similarity index 100%
rename from public/language/ja-JP.json
rename to public/intl/language/ja-JP.json
diff --git a/public/language/ko-KR.json b/public/intl/language/ko-KR.json
similarity index 100%
rename from public/language/ko-KR.json
rename to public/intl/language/ko-KR.json
diff --git a/public/language/lt-LT.json b/public/intl/language/lt-LT.json
similarity index 100%
rename from public/language/lt-LT.json
rename to public/intl/language/lt-LT.json
diff --git a/public/language/mn-MN.json b/public/intl/language/mn-MN.json
similarity index 100%
rename from public/language/mn-MN.json
rename to public/intl/language/mn-MN.json
diff --git a/public/language/ms-MY.json b/public/intl/language/ms-MY.json
similarity index 100%
rename from public/language/ms-MY.json
rename to public/intl/language/ms-MY.json
diff --git a/public/language/nb-NO.json b/public/intl/language/nb-NO.json
similarity index 100%
rename from public/language/nb-NO.json
rename to public/intl/language/nb-NO.json
diff --git a/public/language/nl-NL.json b/public/intl/language/nl-NL.json
similarity index 100%
rename from public/language/nl-NL.json
rename to public/intl/language/nl-NL.json
diff --git a/public/language/pl-PL.json b/public/intl/language/pl-PL.json
similarity index 100%
rename from public/language/pl-PL.json
rename to public/intl/language/pl-PL.json
diff --git a/public/language/pt-BR.json b/public/intl/language/pt-BR.json
similarity index 100%
rename from public/language/pt-BR.json
rename to public/intl/language/pt-BR.json
diff --git a/public/language/pt-PT.json b/public/intl/language/pt-PT.json
similarity index 100%
rename from public/language/pt-PT.json
rename to public/intl/language/pt-PT.json
diff --git a/public/language/ro-RO.json b/public/intl/language/ro-RO.json
similarity index 100%
rename from public/language/ro-RO.json
rename to public/intl/language/ro-RO.json
diff --git a/public/language/ru-RU.json b/public/intl/language/ru-RU.json
similarity index 100%
rename from public/language/ru-RU.json
rename to public/intl/language/ru-RU.json
diff --git a/public/language/sk-SK.json b/public/intl/language/sk-SK.json
similarity index 100%
rename from public/language/sk-SK.json
rename to public/intl/language/sk-SK.json
diff --git a/public/language/sl-SI.json b/public/intl/language/sl-SI.json
similarity index 100%
rename from public/language/sl-SI.json
rename to public/intl/language/sl-SI.json
diff --git a/public/language/sv-SE.json b/public/intl/language/sv-SE.json
similarity index 100%
rename from public/language/sv-SE.json
rename to public/intl/language/sv-SE.json
diff --git a/public/language/ta-IN.json b/public/intl/language/ta-IN.json
similarity index 100%
rename from public/language/ta-IN.json
rename to public/intl/language/ta-IN.json
diff --git a/public/language/tr-TR.json b/public/intl/language/tr-TR.json
similarity index 100%
rename from public/language/tr-TR.json
rename to public/intl/language/tr-TR.json
diff --git a/public/language/uk-UA.json b/public/intl/language/uk-UA.json
similarity index 100%
rename from public/language/uk-UA.json
rename to public/intl/language/uk-UA.json
diff --git a/public/language/ur-PK.json b/public/intl/language/ur-PK.json
similarity index 100%
rename from public/language/ur-PK.json
rename to public/intl/language/ur-PK.json
diff --git a/public/language/vi-VN.json b/public/intl/language/vi-VN.json
similarity index 100%
rename from public/language/vi-VN.json
rename to public/intl/language/vi-VN.json
diff --git a/public/language/zh-CN.json b/public/intl/language/zh-CN.json
similarity index 100%
rename from public/language/zh-CN.json
rename to public/intl/language/zh-CN.json
diff --git a/public/language/zh-TW.json b/public/intl/language/zh-TW.json
similarity index 100%
rename from public/language/zh-TW.json
rename to public/intl/language/zh-TW.json
diff --git a/public/messages/ar-SA.json b/public/intl/messages/ar-SA.json
similarity index 100%
rename from public/messages/ar-SA.json
rename to public/intl/messages/ar-SA.json
diff --git a/public/messages/ca-ES.json b/public/intl/messages/ca-ES.json
similarity index 100%
rename from public/messages/ca-ES.json
rename to public/intl/messages/ca-ES.json
diff --git a/public/messages/cs-CZ.json b/public/intl/messages/cs-CZ.json
similarity index 100%
rename from public/messages/cs-CZ.json
rename to public/intl/messages/cs-CZ.json
diff --git a/public/messages/da-DK.json b/public/intl/messages/da-DK.json
similarity index 100%
rename from public/messages/da-DK.json
rename to public/intl/messages/da-DK.json
diff --git a/public/messages/de-DE.json b/public/intl/messages/de-DE.json
similarity index 100%
rename from public/messages/de-DE.json
rename to public/intl/messages/de-DE.json
diff --git a/public/messages/el-GR.json b/public/intl/messages/el-GR.json
similarity index 100%
rename from public/messages/el-GR.json
rename to public/intl/messages/el-GR.json
diff --git a/public/messages/en-GB.json b/public/intl/messages/en-GB.json
similarity index 100%
rename from public/messages/en-GB.json
rename to public/intl/messages/en-GB.json
diff --git a/public/messages/en-US.json b/public/intl/messages/en-US.json
similarity index 100%
rename from public/messages/en-US.json
rename to public/intl/messages/en-US.json
diff --git a/public/messages/es-MX.json b/public/intl/messages/es-MX.json
similarity index 100%
rename from public/messages/es-MX.json
rename to public/intl/messages/es-MX.json
diff --git a/public/messages/fa-IR.json b/public/intl/messages/fa-IR.json
similarity index 100%
rename from public/messages/fa-IR.json
rename to public/intl/messages/fa-IR.json
diff --git a/public/messages/fi-FI.json b/public/intl/messages/fi-FI.json
similarity index 100%
rename from public/messages/fi-FI.json
rename to public/intl/messages/fi-FI.json
diff --git a/public/messages/fo-FO.json b/public/intl/messages/fo-FO.json
similarity index 100%
rename from public/messages/fo-FO.json
rename to public/intl/messages/fo-FO.json
diff --git a/public/messages/fr-FR.json b/public/intl/messages/fr-FR.json
similarity index 100%
rename from public/messages/fr-FR.json
rename to public/intl/messages/fr-FR.json
diff --git a/public/messages/he-IL.json b/public/intl/messages/he-IL.json
similarity index 100%
rename from public/messages/he-IL.json
rename to public/intl/messages/he-IL.json
diff --git a/public/messages/hi-IN.json b/public/intl/messages/hi-IN.json
similarity index 100%
rename from public/messages/hi-IN.json
rename to public/intl/messages/hi-IN.json
diff --git a/public/messages/hu-HU.json b/public/intl/messages/hu-HU.json
similarity index 100%
rename from public/messages/hu-HU.json
rename to public/intl/messages/hu-HU.json
diff --git a/public/messages/id-ID.json b/public/intl/messages/id-ID.json
similarity index 100%
rename from public/messages/id-ID.json
rename to public/intl/messages/id-ID.json
diff --git a/public/messages/it-IT.json b/public/intl/messages/it-IT.json
similarity index 100%
rename from public/messages/it-IT.json
rename to public/intl/messages/it-IT.json
diff --git a/public/messages/ja-JP.json b/public/intl/messages/ja-JP.json
similarity index 100%
rename from public/messages/ja-JP.json
rename to public/intl/messages/ja-JP.json
diff --git a/public/messages/ko-KR.json b/public/intl/messages/ko-KR.json
similarity index 100%
rename from public/messages/ko-KR.json
rename to public/intl/messages/ko-KR.json
diff --git a/public/messages/lt-LT.json b/public/intl/messages/lt-LT.json
similarity index 100%
rename from public/messages/lt-LT.json
rename to public/intl/messages/lt-LT.json
diff --git a/public/messages/mn-MN.json b/public/intl/messages/mn-MN.json
similarity index 100%
rename from public/messages/mn-MN.json
rename to public/intl/messages/mn-MN.json
diff --git a/public/messages/ms-MY.json b/public/intl/messages/ms-MY.json
similarity index 100%
rename from public/messages/ms-MY.json
rename to public/intl/messages/ms-MY.json
diff --git a/public/messages/nb-NO.json b/public/intl/messages/nb-NO.json
similarity index 100%
rename from public/messages/nb-NO.json
rename to public/intl/messages/nb-NO.json
diff --git a/public/messages/nl-NL.json b/public/intl/messages/nl-NL.json
similarity index 100%
rename from public/messages/nl-NL.json
rename to public/intl/messages/nl-NL.json
diff --git a/public/messages/pl-PL.json b/public/intl/messages/pl-PL.json
similarity index 96%
rename from public/messages/pl-PL.json
rename to public/intl/messages/pl-PL.json
index f627d631..9a8ce376 100644
--- a/public/messages/pl-PL.json
+++ b/public/intl/messages/pl-PL.json
@@ -38,7 +38,7 @@
"label.all-time": [
{
"type": 0,
- "value": "All time"
+ "value": "Cały czas"
}
],
"label.all-websites": [
@@ -92,7 +92,7 @@
"label.dashboard": [
{
"type": 0,
- "value": "Dashboard"
+ "value": "Panel"
}
],
"label.date-range": [
@@ -176,7 +176,7 @@
"label.language": [
{
"type": 0,
- "value": "Language"
+ "value": "Język"
}
],
"label.last-days": [
@@ -250,7 +250,7 @@
"label.owner": [
{
"type": 0,
- "value": "Owner"
+ "value": "Właściciel"
}
],
"label.password": [
@@ -304,7 +304,7 @@
"label.reset-website": [
{
"type": 0,
- "value": "Reset statistics"
+ "value": "Zresetuj statystyki"
}
],
"label.save": [
@@ -334,7 +334,7 @@
"label.theme": [
{
"type": 0,
- "value": "Theme"
+ "value": "Motyw"
}
],
"label.this-month": [
@@ -448,7 +448,7 @@
"message.confirm-reset": [
{
"type": 0,
- "value": "Are your sure you want to reset "
+ "value": "Czy na pewno chcesz zresetować statystyki "
},
{
"type": 1,
@@ -456,7 +456,7 @@
},
{
"type": 0,
- "value": "'s statistics?"
+ "value": "?"
}
],
"message.copied": [
@@ -580,7 +580,7 @@
"message.reset-warning": [
{
"type": 0,
- "value": "All statistics for this website will be deleted, but your tracking code will remain intact."
+ "value": "Wszystkie statystyki tej witryny zostaną usunięte, ale kod śledzenia pozostanie nienaruszony."
}
],
"message.save-success": [
@@ -606,7 +606,7 @@
"message.toggle-charts": [
{
"type": 0,
- "value": "Toggle charts"
+ "value": "Przełącz wykresy"
}
],
"message.track-stats": [
@@ -746,7 +746,7 @@
"metrics.languages": [
{
"type": 0,
- "value": "Languages"
+ "value": "Języki"
}
],
"metrics.operating-systems": [
diff --git a/public/messages/pt-BR.json b/public/intl/messages/pt-BR.json
similarity index 100%
rename from public/messages/pt-BR.json
rename to public/intl/messages/pt-BR.json
diff --git a/public/messages/pt-PT.json b/public/intl/messages/pt-PT.json
similarity index 100%
rename from public/messages/pt-PT.json
rename to public/intl/messages/pt-PT.json
diff --git a/public/messages/ro-RO.json b/public/intl/messages/ro-RO.json
similarity index 100%
rename from public/messages/ro-RO.json
rename to public/intl/messages/ro-RO.json
diff --git a/public/messages/ru-RU.json b/public/intl/messages/ru-RU.json
similarity index 100%
rename from public/messages/ru-RU.json
rename to public/intl/messages/ru-RU.json
diff --git a/public/messages/sk-SK.json b/public/intl/messages/sk-SK.json
similarity index 100%
rename from public/messages/sk-SK.json
rename to public/intl/messages/sk-SK.json
diff --git a/public/messages/sl-SI.json b/public/intl/messages/sl-SI.json
similarity index 100%
rename from public/messages/sl-SI.json
rename to public/intl/messages/sl-SI.json
diff --git a/public/messages/sv-SE.json b/public/intl/messages/sv-SE.json
similarity index 100%
rename from public/messages/sv-SE.json
rename to public/intl/messages/sv-SE.json
diff --git a/public/messages/ta-IN.json b/public/intl/messages/ta-IN.json
similarity index 100%
rename from public/messages/ta-IN.json
rename to public/intl/messages/ta-IN.json
diff --git a/public/messages/tr-TR.json b/public/intl/messages/tr-TR.json
similarity index 100%
rename from public/messages/tr-TR.json
rename to public/intl/messages/tr-TR.json
diff --git a/public/messages/uk-UA.json b/public/intl/messages/uk-UA.json
similarity index 100%
rename from public/messages/uk-UA.json
rename to public/intl/messages/uk-UA.json
diff --git a/public/messages/ur-PK.json b/public/intl/messages/ur-PK.json
similarity index 100%
rename from public/messages/ur-PK.json
rename to public/intl/messages/ur-PK.json
diff --git a/public/messages/vi-VN.json b/public/intl/messages/vi-VN.json
similarity index 100%
rename from public/messages/vi-VN.json
rename to public/intl/messages/vi-VN.json
diff --git a/public/messages/zh-CN.json b/public/intl/messages/zh-CN.json
similarity index 100%
rename from public/messages/zh-CN.json
rename to public/intl/messages/zh-CN.json
diff --git a/public/messages/zh-TW.json b/public/intl/messages/zh-TW.json
similarity index 100%
rename from public/messages/zh-TW.json
rename to public/intl/messages/zh-TW.json
diff --git a/scripts/postbuild.js b/scripts/postbuild.js
index c992884b..89748058 100644
--- a/scripts/postbuild.js
+++ b/scripts/postbuild.js
@@ -1,9 +1,9 @@
require('dotenv').config();
-const sendTelemetry = require('./telemetry');
+const { sendTelemetry } = require('./telemetry');
async function run() {
- if (!process.env.TELEMETRY_DISABLE) {
- await sendTelemetry();
+ if (!process.env.DISABLE_TELEMETRY) {
+ await sendTelemetry('build');
}
}
diff --git a/scripts/prestart.js b/scripts/prestart.js
new file mode 100644
index 00000000..a13af855
--- /dev/null
+++ b/scripts/prestart.js
@@ -0,0 +1,10 @@
+require('dotenv').config();
+const { sendTelemetry } = require('./telemetry');
+
+async function run() {
+ if (!process.env.DISABLE_TELEMETRY) {
+ await sendTelemetry('start');
+ }
+}
+
+run();
diff --git a/scripts/telemetry.js b/scripts/telemetry.js
index 2f3a1aa0..ee44746a 100644
--- a/scripts/telemetry.js
+++ b/scripts/telemetry.js
@@ -8,7 +8,7 @@ const pkg = require('../package.json');
const dest = path.resolve(__dirname, '../.next/cache/umami.json');
const url = 'https://telemetry.umami.is/api/collect';
-async function sendTelemetry() {
+async function sendTelemetry(action) {
await fs.ensureFile(dest);
let json = {};
@@ -19,36 +19,40 @@ async function sendTelemetry() {
// Ignore
}
- if (json.version !== pkg.version) {
- const { default: isDocker } = await import('is-docker');
- const { default: fetch } = await import('node-fetch');
+ await fs.writeJSON(dest, { version: pkg.version });
- await fs.writeJSON(dest, { version: pkg.version });
+ const { default: isDocker } = await import('is-docker');
+ const { default: fetch } = await import('node-fetch');
+ const upgrade = json.version !== undefined && json.version !== pkg.version;
- const payload = {
- umami: pkg.version,
- node: process.version,
- platform: os.platform(),
- arch: os.arch(),
- os: `${os.type()} (${os.version()})`,
- isDocker: isDocker(),
- isCI,
- };
+ const payload = {
+ action,
+ version: pkg.version,
+ node: process.version,
+ platform: os.platform(),
+ arch: os.arch(),
+ os: `${os.type()} (${os.version()})`,
+ docker: isDocker(),
+ ci: isCI,
+ prev: json.version,
+ upgrade,
+ };
- await retry(
- async () => {
- await fetch(url, {
- method: 'post',
- cache: 'no-cache',
- headers: {
- 'Content-Type': 'application/json',
- },
- body: JSON.stringify(payload),
- });
- },
- { minTimeout: 500, retries: 1, factor: 1 },
- ).catch(() => {});
- }
+ await retry(
+ async () => {
+ await fetch(url, {
+ method: 'post',
+ cache: 'no-cache',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify(payload),
+ });
+ },
+ { minTimeout: 500, retries: 1, factor: 1 },
+ ).catch(() => {});
}
-module.exports = sendTelemetry;
+module.exports = {
+ sendTelemetry,
+};
diff --git a/tracker/index.js b/tracker/index.js
index 312632d9..d7ccb86f 100644
--- a/tracker/index.js
+++ b/tracker/index.js
@@ -7,7 +7,6 @@ import { removeTrailingSlash } from '../lib/url';
navigator: { language },
location: { hostname, pathname, search },
localStorage,
- sessionStorage,
document,
history,
} = window;
@@ -21,14 +20,12 @@ import { removeTrailingSlash } from '../lib/url';
const hostUrl = attr('data-host-url');
const autoTrack = attr('data-auto-track') !== 'false';
const dnt = attr('data-do-not-track');
- const useCache = attr('data-cache');
const cssEvents = attr('data-css-events') !== 'false';
const domain = attr('data-domains') || '';
const domains = domain.split(',').map(n => n.trim());
const eventClass = /^umami--([a-z]+)--([\w]+[\w-]*)$/;
const eventSelect = "[class*='umami--']";
- const cacheKey = 'umami.cache';
const trackingDisabled = () =>
(localStorage && localStorage.getItem('umami.disabled')) ||
@@ -42,13 +39,15 @@ import { removeTrailingSlash } from '../lib/url';
const listeners = {};
let currentUrl = `${pathname}${search}`;
let currentRef = document.referrer;
+ let cache;
/* Collect metrics */
const post = (url, data, callback) => {
const req = new XMLHttpRequest();
req.open('POST', url, true);
- req.setRequestHeader('Content-Type', 'text/plain');
+ req.setRequestHeader('Content-Type', 'application/json');
+ if (cache) req.setRequestHeader('x-umami-cache', cache);
req.onreadystatechange = () => {
if (req.readyState === 4) {
@@ -64,7 +63,6 @@ import { removeTrailingSlash } from '../lib/url';
hostname,
screen,
language,
- cache: useCache && sessionStorage.getItem(cacheKey),
url: currentUrl,
});
@@ -84,7 +82,7 @@ import { removeTrailingSlash } from '../lib/url';
type,
payload,
},
- res => useCache && sessionStorage.setItem(cacheKey, res),
+ res => (cache = res),
);
};
diff --git a/yarn.lock b/yarn.lock
index 3df31185..4f8b4e6a 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3006,7 +3006,7 @@ eslint-plugin-prettier@^4.0.0:
dependencies:
prettier-linter-helpers "^1.0.0"
-eslint-plugin-react-hooks@^4.2.0, eslint-plugin-react-hooks@^4.3.0:
+eslint-plugin-react-hooks@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.3.0.tgz#318dbf312e06fab1c835a4abef00121751ac1172"
integrity sha512-XslZy0LnMn+84NEG9jSGR6eGqaZB3133L8xewQo3fQagbQuGt7a63gf+P1NGKZavEYEC3UXaWEAA/AqDkuN6xA==
@@ -3031,26 +3031,6 @@ eslint-plugin-react@^7.27.0:
semver "^6.3.0"
string.prototype.matchall "^4.0.6"
-eslint-plugin-react@^7.29.4:
- version "7.29.4"
- resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.29.4.tgz#4717de5227f55f3801a5fd51a16a4fa22b5914d2"
- integrity sha512-CVCXajliVh509PcZYRFyu/BoUEz452+jtQJq2b3Bae4v3xBUWPLCmtmBM+ZinG4MzwmxJgJ2M5rMqhqLVn7MtQ==
- dependencies:
- array-includes "^3.1.4"
- array.prototype.flatmap "^1.2.5"
- doctrine "^2.1.0"
- estraverse "^5.3.0"
- jsx-ast-utils "^2.4.1 || ^3.0.0"
- minimatch "^3.1.2"
- object.entries "^1.1.5"
- object.fromentries "^2.0.5"
- object.hasown "^1.1.0"
- object.values "^1.1.5"
- prop-types "^15.8.1"
- resolve "^2.0.0-next.3"
- semver "^6.3.0"
- string.prototype.matchall "^4.0.6"
-
eslint-scope@^5.0.0, eslint-scope@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
@@ -4331,9 +4311,9 @@ minimist-options@4.1.0, minimist-options@^4.0.2:
kind-of "^6.0.3"
minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2.5:
- version "1.2.5"
- resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
- integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==
+ version "1.2.6"
+ resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
+ integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
minipass@^3.0.0:
version "3.1.6"