From 1395b0503882520600e4823908441aa9f75dbaa1 Mon Sep 17 00:00:00 2001 From: Josh Moore Date: Thu, 17 Mar 2022 13:51:24 -0600 Subject: [PATCH 01/21] Added Docker updating notes --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) 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 From 0bd589df65a0b7adc6aeda35d0ce83128088fdf9 Mon Sep 17 00:00:00 2001 From: RikoDEV <18230443+RikoDEV@users.noreply.github.com> Date: Fri, 18 Mar 2022 16:55:45 +0100 Subject: [PATCH 02/21] Update pl-PL.json --- lang/pl-PL.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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", From 934914d2490f9924e505559d4cd6d641be6de76a Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 18 Mar 2022 19:02:06 -0700 Subject: [PATCH 03/21] Cleaned up eslint config. --- .eslintrc.json | 3 +-- package.json | 3 --- yarn.lock | 22 +--------------------- 3 files changed, 2 insertions(+), 26 deletions(-) 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/package.json b/package.json index 859be4d2..7ee5675d 100644 --- a/package.json +++ b/package.json @@ -105,10 +105,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/yarn.lock b/yarn.lock index 3df31185..ea41b0d0 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" From 281671b792eb6df3fa979ed8fc8b3d7b902cf738 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 18 Mar 2022 19:02:23 -0700 Subject: [PATCH 04/21] Fixed XML error in Firefox. Renamed telemetry env var. --- scripts/postbuild.js | 2 +- tracker/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/postbuild.js b/scripts/postbuild.js index c992884b..6372bd65 100644 --- a/scripts/postbuild.js +++ b/scripts/postbuild.js @@ -2,7 +2,7 @@ require('dotenv').config(); const sendTelemetry = require('./telemetry'); async function run() { - if (!process.env.TELEMETRY_DISABLE) { + if (!process.env.DISABLE_TELEMETRY) { await sendTelemetry(); } } diff --git a/tracker/index.js b/tracker/index.js index 312632d9..a5012b71 100644 --- a/tracker/index.js +++ b/tracker/index.js @@ -48,7 +48,7 @@ import { removeTrailingSlash } from '../lib/url'; 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'); req.onreadystatechange = () => { if (req.readyState === 4) { From f24696de5aadbc26584068e6ec437788a633d2ee Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 18 Mar 2022 19:17:23 -0700 Subject: [PATCH 05/21] Refactored localization files. --- hooks/useCountryNames.js | 4 ++-- hooks/useLanguageNames.js | 4 ++-- hooks/useLocale.js | 4 ++-- package.json | 2 +- public/{ => intl}/country/ar-SA.json | 0 public/{ => intl}/country/ca-ES.json | 0 public/{ => intl}/country/cs-CZ.json | 0 public/{ => intl}/country/da-DK.json | 0 public/{ => intl}/country/de-DE.json | 0 public/{ => intl}/country/el-GR.json | 0 public/{ => intl}/country/en-GB.json | 0 public/{ => intl}/country/en-US.json | 0 public/{ => intl}/country/es-MX.json | 0 public/{ => intl}/country/fa-IR.json | 0 public/{ => intl}/country/fi-FI.json | 0 public/{ => intl}/country/fo-FO.json | 0 public/{ => intl}/country/fr-FR.json | 0 public/{ => intl}/country/he-IL.json | 0 public/{ => intl}/country/hi-IN.json | 0 public/{ => intl}/country/hu-HU.json | 0 public/{ => intl}/country/id-ID.json | 0 public/{ => intl}/country/it-IT.json | 0 public/{ => intl}/country/ja-JP.json | 0 public/{ => intl}/country/ko-KR.json | 0 public/{ => intl}/country/lt-LT.json | 0 public/{ => intl}/country/mn-MN.json | 0 public/{ => intl}/country/ms-MY.json | 0 public/{ => intl}/country/nb-NO.json | 0 public/{ => intl}/country/nl-NL.json | 0 public/{ => intl}/country/pl-PL.json | 0 public/{ => intl}/country/pt-BR.json | 0 public/{ => intl}/country/pt-PT.json | 0 public/{ => intl}/country/ro-RO.json | 0 public/{ => intl}/country/ru-RU.json | 0 public/{ => intl}/country/sk-SK.json | 0 public/{ => intl}/country/sl-SI.json | 0 public/{ => intl}/country/sv-SE.json | 0 public/{ => intl}/country/ta-IN.json | 0 public/{ => intl}/country/tr-TR.json | 0 public/{ => intl}/country/uk-UA.json | 0 public/{ => intl}/country/ur-PK.json | 0 public/{ => intl}/country/vi-VN.json | 0 public/{ => intl}/country/zh-CN.json | 0 public/{ => intl}/country/zh-TW.json | 0 public/{ => intl}/language/ar-SA.json | 0 public/{ => intl}/language/ca-ES.json | 0 public/{ => intl}/language/cs-CZ.json | 0 public/{ => intl}/language/da-DK.json | 0 public/{ => intl}/language/de-DE.json | 0 public/{ => intl}/language/el-GR.json | 0 public/{ => intl}/language/en-GB.json | 0 public/{ => intl}/language/en-US.json | 0 public/{ => intl}/language/es-MX.json | 0 public/{ => intl}/language/fa-IR.json | 0 public/{ => intl}/language/fi-FI.json | 0 public/{ => intl}/language/fo-FO.json | 0 public/{ => intl}/language/fr-FR.json | 0 public/{ => intl}/language/he-IL.json | 0 public/{ => intl}/language/hi-IN.json | 0 public/{ => intl}/language/hu-HU.json | 0 public/{ => intl}/language/id-ID.json | 0 public/{ => intl}/language/it-IT.json | 0 public/{ => intl}/language/ja-JP.json | 0 public/{ => intl}/language/ko-KR.json | 0 public/{ => intl}/language/lt-LT.json | 0 public/{ => intl}/language/mn-MN.json | 0 public/{ => intl}/language/ms-MY.json | 0 public/{ => intl}/language/nb-NO.json | 0 public/{ => intl}/language/nl-NL.json | 0 public/{ => intl}/language/pl-PL.json | 0 public/{ => intl}/language/pt-BR.json | 0 public/{ => intl}/language/pt-PT.json | 0 public/{ => intl}/language/ro-RO.json | 0 public/{ => intl}/language/ru-RU.json | 0 public/{ => intl}/language/sk-SK.json | 0 public/{ => intl}/language/sl-SI.json | 0 public/{ => intl}/language/sv-SE.json | 0 public/{ => intl}/language/ta-IN.json | 0 public/{ => intl}/language/tr-TR.json | 0 public/{ => intl}/language/uk-UA.json | 0 public/{ => intl}/language/ur-PK.json | 0 public/{ => intl}/language/vi-VN.json | 0 public/{ => intl}/language/zh-CN.json | 0 public/{ => intl}/language/zh-TW.json | 0 public/{ => intl}/messages/ar-SA.json | 0 public/{ => intl}/messages/ca-ES.json | 0 public/{ => intl}/messages/cs-CZ.json | 0 public/{ => intl}/messages/da-DK.json | 0 public/{ => intl}/messages/de-DE.json | 0 public/{ => intl}/messages/el-GR.json | 0 public/{ => intl}/messages/en-GB.json | 0 public/{ => intl}/messages/en-US.json | 0 public/{ => intl}/messages/es-MX.json | 0 public/{ => intl}/messages/fa-IR.json | 0 public/{ => intl}/messages/fi-FI.json | 0 public/{ => intl}/messages/fo-FO.json | 0 public/{ => intl}/messages/fr-FR.json | 0 public/{ => intl}/messages/he-IL.json | 0 public/{ => intl}/messages/hi-IN.json | 0 public/{ => intl}/messages/hu-HU.json | 0 public/{ => intl}/messages/id-ID.json | 0 public/{ => intl}/messages/it-IT.json | 0 public/{ => intl}/messages/ja-JP.json | 0 public/{ => intl}/messages/ko-KR.json | 0 public/{ => intl}/messages/lt-LT.json | 0 public/{ => intl}/messages/mn-MN.json | 0 public/{ => intl}/messages/ms-MY.json | 0 public/{ => intl}/messages/nb-NO.json | 0 public/{ => intl}/messages/nl-NL.json | 0 public/{ => intl}/messages/pl-PL.json | 22 +++++++++++----------- public/{ => intl}/messages/pt-BR.json | 0 public/{ => intl}/messages/pt-PT.json | 0 public/{ => intl}/messages/ro-RO.json | 0 public/{ => intl}/messages/ru-RU.json | 0 public/{ => intl}/messages/sk-SK.json | 0 public/{ => intl}/messages/sl-SI.json | 0 public/{ => intl}/messages/sv-SE.json | 0 public/{ => intl}/messages/ta-IN.json | 0 public/{ => intl}/messages/tr-TR.json | 0 public/{ => intl}/messages/uk-UA.json | 0 public/{ => intl}/messages/ur-PK.json | 0 public/{ => intl}/messages/vi-VN.json | 0 public/{ => intl}/messages/zh-CN.json | 0 public/{ => intl}/messages/zh-TW.json | 0 124 files changed, 18 insertions(+), 18 deletions(-) rename public/{ => intl}/country/ar-SA.json (100%) rename public/{ => intl}/country/ca-ES.json (100%) rename public/{ => intl}/country/cs-CZ.json (100%) rename public/{ => intl}/country/da-DK.json (100%) rename public/{ => intl}/country/de-DE.json (100%) rename public/{ => intl}/country/el-GR.json (100%) rename public/{ => intl}/country/en-GB.json (100%) rename public/{ => intl}/country/en-US.json (100%) rename public/{ => intl}/country/es-MX.json (100%) rename public/{ => intl}/country/fa-IR.json (100%) rename public/{ => intl}/country/fi-FI.json (100%) rename public/{ => intl}/country/fo-FO.json (100%) rename public/{ => intl}/country/fr-FR.json (100%) rename public/{ => intl}/country/he-IL.json (100%) rename public/{ => intl}/country/hi-IN.json (100%) rename public/{ => intl}/country/hu-HU.json (100%) rename public/{ => intl}/country/id-ID.json (100%) rename public/{ => intl}/country/it-IT.json (100%) rename public/{ => intl}/country/ja-JP.json (100%) rename public/{ => intl}/country/ko-KR.json (100%) rename public/{ => intl}/country/lt-LT.json (100%) rename public/{ => intl}/country/mn-MN.json (100%) rename public/{ => intl}/country/ms-MY.json (100%) rename public/{ => intl}/country/nb-NO.json (100%) rename public/{ => intl}/country/nl-NL.json (100%) rename public/{ => intl}/country/pl-PL.json (100%) rename public/{ => intl}/country/pt-BR.json (100%) rename public/{ => intl}/country/pt-PT.json (100%) rename public/{ => intl}/country/ro-RO.json (100%) rename public/{ => intl}/country/ru-RU.json (100%) rename public/{ => intl}/country/sk-SK.json (100%) rename public/{ => intl}/country/sl-SI.json (100%) rename public/{ => intl}/country/sv-SE.json (100%) rename public/{ => intl}/country/ta-IN.json (100%) rename public/{ => intl}/country/tr-TR.json (100%) rename public/{ => intl}/country/uk-UA.json (100%) rename public/{ => intl}/country/ur-PK.json (100%) rename public/{ => intl}/country/vi-VN.json (100%) rename public/{ => intl}/country/zh-CN.json (100%) rename public/{ => intl}/country/zh-TW.json (100%) rename public/{ => intl}/language/ar-SA.json (100%) rename public/{ => intl}/language/ca-ES.json (100%) rename public/{ => intl}/language/cs-CZ.json (100%) rename public/{ => intl}/language/da-DK.json (100%) rename public/{ => intl}/language/de-DE.json (100%) rename public/{ => intl}/language/el-GR.json (100%) rename public/{ => intl}/language/en-GB.json (100%) rename public/{ => intl}/language/en-US.json (100%) rename public/{ => intl}/language/es-MX.json (100%) rename public/{ => intl}/language/fa-IR.json (100%) rename public/{ => intl}/language/fi-FI.json (100%) rename public/{ => intl}/language/fo-FO.json (100%) rename public/{ => intl}/language/fr-FR.json (100%) rename public/{ => intl}/language/he-IL.json (100%) rename public/{ => intl}/language/hi-IN.json (100%) rename public/{ => intl}/language/hu-HU.json (100%) rename public/{ => intl}/language/id-ID.json (100%) rename public/{ => intl}/language/it-IT.json (100%) rename public/{ => intl}/language/ja-JP.json (100%) rename public/{ => intl}/language/ko-KR.json (100%) rename public/{ => intl}/language/lt-LT.json (100%) rename public/{ => intl}/language/mn-MN.json (100%) rename public/{ => intl}/language/ms-MY.json (100%) rename public/{ => intl}/language/nb-NO.json (100%) rename public/{ => intl}/language/nl-NL.json (100%) rename public/{ => intl}/language/pl-PL.json (100%) rename public/{ => intl}/language/pt-BR.json (100%) rename public/{ => intl}/language/pt-PT.json (100%) rename public/{ => intl}/language/ro-RO.json (100%) rename public/{ => intl}/language/ru-RU.json (100%) rename public/{ => intl}/language/sk-SK.json (100%) rename public/{ => intl}/language/sl-SI.json (100%) rename public/{ => intl}/language/sv-SE.json (100%) rename public/{ => intl}/language/ta-IN.json (100%) rename public/{ => intl}/language/tr-TR.json (100%) rename public/{ => intl}/language/uk-UA.json (100%) rename public/{ => intl}/language/ur-PK.json (100%) rename public/{ => intl}/language/vi-VN.json (100%) rename public/{ => intl}/language/zh-CN.json (100%) rename public/{ => intl}/language/zh-TW.json (100%) rename public/{ => intl}/messages/ar-SA.json (100%) rename public/{ => intl}/messages/ca-ES.json (100%) rename public/{ => intl}/messages/cs-CZ.json (100%) rename public/{ => intl}/messages/da-DK.json (100%) rename public/{ => intl}/messages/de-DE.json (100%) rename public/{ => intl}/messages/el-GR.json (100%) rename public/{ => intl}/messages/en-GB.json (100%) rename public/{ => intl}/messages/en-US.json (100%) rename public/{ => intl}/messages/es-MX.json (100%) rename public/{ => intl}/messages/fa-IR.json (100%) rename public/{ => intl}/messages/fi-FI.json (100%) rename public/{ => intl}/messages/fo-FO.json (100%) rename public/{ => intl}/messages/fr-FR.json (100%) rename public/{ => intl}/messages/he-IL.json (100%) rename public/{ => intl}/messages/hi-IN.json (100%) rename public/{ => intl}/messages/hu-HU.json (100%) rename public/{ => intl}/messages/id-ID.json (100%) rename public/{ => intl}/messages/it-IT.json (100%) rename public/{ => intl}/messages/ja-JP.json (100%) rename public/{ => intl}/messages/ko-KR.json (100%) rename public/{ => intl}/messages/lt-LT.json (100%) rename public/{ => intl}/messages/mn-MN.json (100%) rename public/{ => intl}/messages/ms-MY.json (100%) rename public/{ => intl}/messages/nb-NO.json (100%) rename public/{ => intl}/messages/nl-NL.json (100%) rename public/{ => intl}/messages/pl-PL.json (96%) rename public/{ => intl}/messages/pt-BR.json (100%) rename public/{ => intl}/messages/pt-PT.json (100%) rename public/{ => intl}/messages/ro-RO.json (100%) rename public/{ => intl}/messages/ru-RU.json (100%) rename public/{ => intl}/messages/sk-SK.json (100%) rename public/{ => intl}/messages/sl-SI.json (100%) rename public/{ => intl}/messages/sv-SE.json (100%) rename public/{ => intl}/messages/ta-IN.json (100%) rename public/{ => intl}/messages/tr-TR.json (100%) rename public/{ => intl}/messages/uk-UA.json (100%) rename public/{ => intl}/messages/ur-PK.json (100%) rename public/{ => intl}/messages/vi-VN.json (100%) rename public/{ => intl}/messages/zh-CN.json (100%) rename public/{ => intl}/messages/zh-TW.json (100%) 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/package.json b/package.json index 7ee5675d..5ee12ac8 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "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", 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 From 63bfa616f1ea8278d3cbaf33b947cbf841eea6e9 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 18 Mar 2022 21:01:32 -0700 Subject: [PATCH 06/21] Set content type for responses. --- lib/response.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/response.js b/lib/response.js index 0e938f90..796c23eb 100644 --- a/lib/response.js +++ b/lib/response.js @@ -6,14 +6,12 @@ export function json(res, data = {}) { return res.status(200).json(data); } -export function send(res, data) { - return res.status(200).send(data); +export function send(res, data, type = 'text-plain') { + return res.status(200).setHeader('Content-Type', type).send(data); } export function redirect(res, url) { - res.setHeader('Location', url); - - return res.status(303).end(); + return res.status(303).setHeader('Location', url).end(); } export function badRequest(res, msg = '400 Bad Request') { From ffb091c1bcfa6a108f4b43329388b91f174ba6cd Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 18 Mar 2022 21:21:43 -0700 Subject: [PATCH 07/21] Updated telemetry payload. --- package.json | 6 ++++-- scripts/postbuild.js | 10 ---------- scripts/telemetry.js | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 scripts/postbuild.js diff --git a/package.json b/package.json index 5ee12ac8..74b95081 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 telemetry 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,7 +26,7 @@ "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", + "init": "node scripts/init.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", @@ -36,6 +37,7 @@ "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", + "telemetry": "node scripts/telemetry.js", "lint": "next lint --quiet", "prepare": "husky install" }, diff --git a/scripts/postbuild.js b/scripts/postbuild.js deleted file mode 100644 index 6372bd65..00000000 --- a/scripts/postbuild.js +++ /dev/null @@ -1,10 +0,0 @@ -require('dotenv').config(); -const sendTelemetry = require('./telemetry'); - -async function run() { - if (!process.env.DISABLE_TELEMETRY) { - await sendTelemetry(); - } -} - -run(); diff --git a/scripts/telemetry.js b/scripts/telemetry.js index 2f3a1aa0..3714ff35 100644 --- a/scripts/telemetry.js +++ b/scripts/telemetry.js @@ -1,3 +1,4 @@ +require('dotenv').config(); const fs = require('fs-extra'); const path = require('path'); const os = require('os'); @@ -26,13 +27,14 @@ async function sendTelemetry() { await fs.writeJSON(dest, { version: pkg.version }); const payload = { - umami: pkg.version, + version: pkg.version, node: process.version, platform: os.platform(), arch: os.arch(), os: `${os.type()} (${os.version()})`, - isDocker: isDocker(), - isCI, + docker: isDocker(), + ci: isCI, + upgrade: json.version || false, }; await retry( @@ -51,4 +53,10 @@ async function sendTelemetry() { } } -module.exports = sendTelemetry; +async function run() { + if (!process.env.DISABLE_TELEMETRY) { + await sendTelemetry(); + } +} + +run(); From de3bf23e4c8bcff02ab62c53292ac850998f5ad4 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 18 Mar 2022 21:24:46 -0700 Subject: [PATCH 08/21] Fix 500 error in response. --- lib/response.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/response.js b/lib/response.js index 796c23eb..a982f3d4 100644 --- a/lib/response.js +++ b/lib/response.js @@ -7,11 +7,15 @@ export function json(res, data = {}) { } export function send(res, data, type = 'text-plain') { - return res.status(200).setHeader('Content-Type', type).send(data); + res.setHeader('Content-Type', type); + + return res.status(200).send(data); } export function redirect(res, url) { - return res.status(303).setHeader('Location', url).end(); + res.setHeader('Location', url); + + return res.status(303).end(); } export function badRequest(res, msg = '400 Bad Request') { From 777dfeac0e42876ee0aa6690971e53cb9af4735f Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 18 Mar 2022 21:57:58 -0700 Subject: [PATCH 09/21] Added prestart script. --- lib/response.js | 2 +- package.json | 8 ++++---- scripts/postbuild.js | 10 ++++++++++ scripts/prestart.js | 10 ++++++++++ scripts/telemetry.js | 11 +++-------- 5 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 scripts/postbuild.js create mode 100644 scripts/prestart.js diff --git a/lib/response.js b/lib/response.js index a982f3d4..72525f18 100644 --- a/lib/response.js +++ b/lib/response.js @@ -6,7 +6,7 @@ export function json(res, data = {}) { return res.status(200).json(data); } -export function send(res, data, type = 'text-plain') { +export function send(res, data, type = 'text/plain') { res.setHeader('Content-Type', type); return res.status(200).send(data); diff --git a/package.json b/package.json index 74b95081..7b6b2ec9 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "scripts": { "dev": "next dev", "build": "npm-run-all build-tracker build-geo build-db build-app", - "start": "npm-run-all telemetry start-app", + "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", @@ -26,7 +26,6 @@ "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", - "init": "node scripts/init.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", @@ -37,9 +36,10 @@ "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", - "telemetry": "node scripts/telemetry.js", "lint": "next lint --quiet", - "prepare": "husky install" + "prepare": "husky install", + "postbuild": "node scripts/postbuild.js", + "init": "node scripts/prestart.js" }, "lint-staged": { "**/*.js": [ diff --git a/scripts/postbuild.js b/scripts/postbuild.js new file mode 100644 index 00000000..55414dcf --- /dev/null +++ b/scripts/postbuild.js @@ -0,0 +1,10 @@ +require('dotenv').config(); +const { sendTelemetry } = require('./telemetry'); + +async function run() { + if (!process.env.DISABLE_TELEMETRY) { + await sendTelemetry(); + } +} + +run(); diff --git a/scripts/prestart.js b/scripts/prestart.js new file mode 100644 index 00000000..55414dcf --- /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(); + } +} + +run(); diff --git a/scripts/telemetry.js b/scripts/telemetry.js index 3714ff35..6dbc586e 100644 --- a/scripts/telemetry.js +++ b/scripts/telemetry.js @@ -1,4 +1,3 @@ -require('dotenv').config(); const fs = require('fs-extra'); const path = require('path'); const os = require('os'); @@ -53,10 +52,6 @@ async function sendTelemetry() { } } -async function run() { - if (!process.env.DISABLE_TELEMETRY) { - await sendTelemetry(); - } -} - -run(); +module.exports = { + sendTelemetry, +}; From 7cf0927741f08643b7b959eba84d888ab70533a8 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 18 Mar 2022 22:26:23 -0700 Subject: [PATCH 10/21] Enabling caching in tracker script. --- lib/session.js | 3 ++- tracker/index.js | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) 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/tracker/index.js b/tracker/index.js index a5012b71..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,6 +39,7 @@ import { removeTrailingSlash } from '../lib/url'; const listeners = {}; let currentUrl = `${pathname}${search}`; let currentRef = document.referrer; + let cache; /* Collect metrics */ @@ -49,6 +47,7 @@ import { removeTrailingSlash } from '../lib/url'; const req = new XMLHttpRequest(); req.open('POST', url, true); 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), ); }; From 5b1eb8bec2766d2e54e8ef1b39060ab9fe511fe3 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 18 Mar 2022 22:39:39 -0700 Subject: [PATCH 11/21] Added action to telemetry payload. --- scripts/postbuild.js | 2 +- scripts/prestart.js | 2 +- scripts/telemetry.js | 57 ++++++++++++++++++++++---------------------- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/scripts/postbuild.js b/scripts/postbuild.js index 55414dcf..89748058 100644 --- a/scripts/postbuild.js +++ b/scripts/postbuild.js @@ -3,7 +3,7 @@ const { sendTelemetry } = require('./telemetry'); async function run() { if (!process.env.DISABLE_TELEMETRY) { - await sendTelemetry(); + await sendTelemetry('build'); } } diff --git a/scripts/prestart.js b/scripts/prestart.js index 55414dcf..a13af855 100644 --- a/scripts/prestart.js +++ b/scripts/prestart.js @@ -3,7 +3,7 @@ const { sendTelemetry } = require('./telemetry'); async function run() { if (!process.env.DISABLE_TELEMETRY) { - await sendTelemetry(); + await sendTelemetry('start'); } } diff --git a/scripts/telemetry.js b/scripts/telemetry.js index 6dbc586e..d938c88b 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,37 +19,36 @@ 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 payload = { - version: pkg.version, - node: process.version, - platform: os.platform(), - arch: os.arch(), - os: `${os.type()} (${os.version()})`, - docker: isDocker(), - ci: isCI, - upgrade: json.version || false, - }; + const payload = { + action, + version: pkg.version, + node: process.version, + platform: os.platform(), + arch: os.arch(), + os: `${os.type()} (${os.version()})`, + docker: isDocker(), + ci: isCI, + upgrade: json.version || false, + }; - 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 = { From f9f3a5bcabefc00021ce565648c228f10327cddb Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 18 Mar 2022 22:44:02 -0700 Subject: [PATCH 12/21] Fix upgrade logic. --- scripts/telemetry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/telemetry.js b/scripts/telemetry.js index d938c88b..8f504b88 100644 --- a/scripts/telemetry.js +++ b/scripts/telemetry.js @@ -33,7 +33,7 @@ async function sendTelemetry(action) { os: `${os.type()} (${os.version()})`, docker: isDocker(), ci: isCI, - upgrade: json.version || false, + upgrade: json.version !== undefined && json.version !== pkg.version, }; await retry( From 46174f652caac57c87c52b788db78a684470c6e9 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Fri, 18 Mar 2022 22:52:42 -0700 Subject: [PATCH 13/21] Added previous version to payload. --- scripts/telemetry.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/telemetry.js b/scripts/telemetry.js index 8f504b88..ee44746a 100644 --- a/scripts/telemetry.js +++ b/scripts/telemetry.js @@ -23,6 +23,7 @@ async function sendTelemetry(action) { 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 = { action, @@ -33,7 +34,8 @@ async function sendTelemetry(action) { os: `${os.type()} (${os.version()})`, docker: isDocker(), ci: isCI, - upgrade: json.version !== undefined && json.version !== pkg.version, + prev: json.version, + upgrade, }; await retry( From ecfc7ea68e0661f0e5c64d965c9f82549480d395 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 20 Mar 2022 22:10:41 +0100 Subject: [PATCH 14/21] Rename ref to prevent collision with react elements It seems that, at least in dev mode, 'ref' may incorrectly refer to react elements. Signed-off-by: Kevin Decherf --- components/metrics/ReferrersTable.js | 4 ++-- components/metrics/WebsiteChart.js | 8 ++++---- lib/filters.js | 10 ++++++---- lib/queries.js | 12 ++++++------ pages/api/website/[id]/pageviews.js | 6 +++--- pages/api/website/[id]/stats.js | 9 ++++++--- 6 files changed, 27 insertions(+), 22 deletions(-) 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/lib/filters.js b/lib/filters.js index e9723b42..9f00d529 100644 --- a/lib/filters.js +++ b/lib/filters.js @@ -49,8 +49,10 @@ export const refFilter = (data, { domain, domainOnly, raw }) => { const regex = new RegExp(`http[s]?://([a-z0-9-]+\\.)*${domain}`); 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 +73,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('ref'); + const query = referrer ? `?referrer=${referrer}` : ''; return removeTrailingSlash(`${removeWWW(hostname)}${path}`) + query; } diff --git a/lib/queries.js b/lib/queries.js index 5bcd18ba..6b3c6c4e 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( 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] = { From bb7d26d19f56b6eb21785c7babef9ece2c2b71cc Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 20 Mar 2022 22:12:40 +0100 Subject: [PATCH 15/21] Fix referrer filter 7530de87d233b04d88f1fefd425c822bdf7502f4 introduced a regression: the domain parameter in refFilter() contains 'https://', which bypass the new regex; thus we readd the call to getDomainName(). Signed-off-by: Kevin Decherf --- lib/filters.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/filters.js b/lib/filters.js index 9f00d529..945a6011 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,7 +46,8 @@ 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 = referrer => { From 35f9c7ef6cb73289e553a705a955fe38d40199ad Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sun, 20 Mar 2022 22:14:54 +0100 Subject: [PATCH 16/21] Update metric tables when filtering on referrer Signed-off-by: Kevin Decherf --- components/metrics/MetricsTable.js | 5 +++-- lib/queries.js | 9 ++++++++- pages/api/website/[id]/metrics.js | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) 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/lib/queries.js b/lib/queries.js index 6b3c6c4e..ed644874 100644 --- a/lib/queries.js +++ b/lib/queries.js @@ -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/pages/api/website/[id]/metrics.js b/pages/api/website/[id]/metrics.js index 5e16e350..941b99ca 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: referrer, }, ); From 67c3f3743f6a3e44cf27870c7608c295272d8767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=B2=97?= Date: Thu, 24 Mar 2022 11:22:24 +0800 Subject: [PATCH 17/21] Update zh-CN.json --- lang/zh-CN.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lang/zh-CN.json b/lang/zh-CN.json index 2efe028c..fbdba128 100644 --- a/lang/zh-CN.json +++ b/lang/zh-CN.json @@ -4,8 +4,8 @@ "label.add-website": "添加网站", "label.administrator": "管理员", "label.all": "所有", - "label.all-events": "All events", - "label.all-time": "All time", + "label.all-events": "所有事件", + "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}", @@ -37,7 +37,7 @@ "label.more": "更多", "label.name": "名字", "label.new-password": "新密码", - "label.owner": "Owner", + "label.owner": "拥有者", "label.password": "密码", "label.passwords-dont-match": "密码不一致", "label.profile": "个人资料", @@ -46,7 +46,7 @@ "label.refresh": "刷新", "label.required": "必填", "label.reset": "重置", - "label.reset-website": "Reset statistics", + "label.reset-website": "重置数据", "label.save": "保存", "label.settings": "设置", "label.share-url": "共享链接", @@ -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": "出现错误。", @@ -78,10 +78,10 @@ "message.no-websites-configured": "你还没有设置任何网站。", "message.page-not-found": "网页未找到。", "message.powered-by": "由 {name} 提供支持", - "message.reset-warning": "All statistics for this website will be deleted, but your tracking code will remain intact.", + "message.reset-warning": "除了跟踪代码,此网站的所有数据将会删除.", "message.save-success": "保存成功。", "message.share-url": "这是 {target} 的共享链接。", - "message.toggle-charts": "Toggle charts", + "message.toggle-charts": "切换图表", "message.track-stats": "把以下代码放到你的网站的 {head} 部分来收集 {target} 的数据。", "message.type-delete": "在下方输入框输入 {delete} 以确认删除。", "message.type-reset": "在下方输入框输入 {reset} 以确认删除。", @@ -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": "网页", From 5d799a327bbe0ac43a76fcdc1aff65d5401a4ad1 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Thu, 24 Mar 2022 23:20:06 +0100 Subject: [PATCH 18/21] fixup! Rename ref to prevent collision with react elements Signed-off-by: Kevin Decherf --- lib/filters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/filters.js b/lib/filters.js index 945a6011..fb6b435a 100644 --- a/lib/filters.js +++ b/lib/filters.js @@ -74,7 +74,7 @@ export const refFilter = (data, { domain, domainOnly, raw }) => { if (protocol.startsWith('http')) { const path = removeTrailingSlash(pathname); - const referrer = searchParams.get('ref'); + const referrer = searchParams.get('referrer'); const query = referrer ? `?referrer=${referrer}` : ''; return removeTrailingSlash(`${removeWWW(hostname)}${path}`) + query; From 1269bea870c02635a4bb8d7651deed9a6aab63e9 Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Thu, 24 Mar 2022 23:20:19 +0100 Subject: [PATCH 19/21] fixup! Update metric tables when filtering on referrer Signed-off-by: Kevin Decherf --- pages/api/website/[id]/metrics.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/api/website/[id]/metrics.js b/pages/api/website/[id]/metrics.js index 941b99ca..675427db 100644 --- a/pages/api/website/[id]/metrics.js +++ b/pages/api/website/[id]/metrics.js @@ -75,7 +75,7 @@ export default async (req, res) => { { domain, url: type !== 'url' && url, - referrer: referrer, + referrer, }, ); From 9aac74c25667ff673f4ce5834b338851fb15c311 Mon Sep 17 00:00:00 2001 From: Jerem Dlcn <44464165+JeremDlcn@users.noreply.github.com> Date: Sat, 26 Mar 2022 22:02:19 +0100 Subject: [PATCH 20/21] Update fr-FR.json translated the right file this time --- lang/fr-FR.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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", From d4fe64acc0e7c932003f82cc96849284ae133bc9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 27 Mar 2022 04:27:37 +0000 Subject: [PATCH 21/21] build(deps): bump minimist from 1.2.5 to 1.2.6 Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. - [Release notes](https://github.com/substack/minimist/releases) - [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6) --- updated-dependencies: - dependency-name: minimist dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 3df31185..c13da537 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4331,9 +4331,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"