From 5b4a012f0bfb775fa0227f16af3a82a7d14d145d Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Mon, 14 Sep 2020 08:46:35 -0700 Subject: [PATCH 01/67] Fix 401 on share url. --- components/common/Calendar.module.css | 6 +++++- components/common/LanguageButton.js | 2 +- package.json | 2 +- pages/api/website/[id]/active.js | 3 --- pages/api/website/[id]/events.js | 3 --- pages/api/website/[id]/metrics.js | 3 --- pages/api/website/[id]/pageviews.js | 3 --- pages/api/website/[id]/rankings.js | 3 --- 8 files changed, 7 insertions(+), 18 deletions(-) diff --git a/components/common/Calendar.module.css b/components/common/Calendar.module.css index ee5581bd..b7e56df1 100644 --- a/components/common/Calendar.module.css +++ b/components/common/Calendar.module.css @@ -8,6 +8,7 @@ .calendar table { flex: 1; + border-spacing: 5px; } .calendar td { @@ -18,10 +19,12 @@ height: 40px; min-width: 40px; border-radius: 5px; + border: 1px solid transparent; } .calendar td:hover { - background: var(--gray100); + border: 1px solid var(--gray300); + background: var(--gray75); } .calendar td.faded { @@ -45,6 +48,7 @@ .calendar td.disabled:hover { cursor: default; background: var(--gray75); + border-color: transparent; } .calendar td.faded.disabled { diff --git a/components/common/LanguageButton.js b/components/common/LanguageButton.js index 0581a020..5565b45e 100644 --- a/components/common/LanguageButton.js +++ b/components/common/LanguageButton.js @@ -48,7 +48,7 @@ export default function LanguageButton({ menuPosition = 'bottom', menuAlign = 'l
{showMenu && ( ", "license": "MIT", diff --git a/pages/api/website/[id]/active.js b/pages/api/website/[id]/active.js index 492074a9..8c331c44 100644 --- a/pages/api/website/[id]/active.js +++ b/pages/api/website/[id]/active.js @@ -1,10 +1,7 @@ import { getActiveVisitors } from 'lib/queries'; import { methodNotAllowed, ok } from 'lib/response'; -import { useAuth } from 'lib/middleware'; export default async (req, res) => { - await useAuth(req, res); - if (req.method === 'GET') { const { id } = req.query; const website_id = +id; diff --git a/pages/api/website/[id]/events.js b/pages/api/website/[id]/events.js index 143c745a..9e3b6b51 100644 --- a/pages/api/website/[id]/events.js +++ b/pages/api/website/[id]/events.js @@ -1,13 +1,10 @@ import moment from 'moment-timezone'; import { getEvents } from 'lib/queries'; import { ok, badRequest, methodNotAllowed } from 'lib/response'; -import { useAuth } from 'lib/middleware'; const unitTypes = ['year', 'month', 'hour', 'day']; export default async (req, res) => { - await useAuth(req, res); - if (req.method === 'GET') { const { id, start_at, end_at, unit, tz } = req.query; diff --git a/pages/api/website/[id]/metrics.js b/pages/api/website/[id]/metrics.js index 70a9d1e6..07496b25 100644 --- a/pages/api/website/[id]/metrics.js +++ b/pages/api/website/[id]/metrics.js @@ -1,10 +1,7 @@ import { getMetrics } from 'lib/queries'; import { methodNotAllowed, ok } from 'lib/response'; -import { useAuth } from 'lib/middleware'; export default async (req, res) => { - await useAuth(req, res); - if (req.method === 'GET') { const { id, start_at, end_at } = req.query; const websiteId = +id; diff --git a/pages/api/website/[id]/pageviews.js b/pages/api/website/[id]/pageviews.js index 398e52e4..db5b6c33 100644 --- a/pages/api/website/[id]/pageviews.js +++ b/pages/api/website/[id]/pageviews.js @@ -1,13 +1,10 @@ import moment from 'moment-timezone'; import { getPageviews } from 'lib/queries'; import { ok, badRequest, methodNotAllowed } from 'lib/response'; -import { useAuth } from 'lib/middleware'; const unitTypes = ['year', 'month', 'hour', 'day']; export default async (req, res) => { - await useAuth(req, res); - if (req.method === 'GET') { const { id, start_at, end_at, unit, tz } = req.query; diff --git a/pages/api/website/[id]/rankings.js b/pages/api/website/[id]/rankings.js index 158a4bc2..838aefa3 100644 --- a/pages/api/website/[id]/rankings.js +++ b/pages/api/website/[id]/rankings.js @@ -1,7 +1,6 @@ import { getRankings } from 'lib/queries'; import { ok, badRequest, methodNotAllowed } from 'lib/response'; import { DOMAIN_REGEX } from 'lib/constants'; -import { useAuth } from 'lib/middleware'; const sessionColumns = ['browser', 'os', 'device', 'country']; const pageviewColumns = ['url', 'referrer']; @@ -26,8 +25,6 @@ function getColumn(type) { } export default async (req, res) => { - await useAuth(req, res); - if (req.method === 'GET') { const { id, type, start_at, end_at, domain } = req.query; const websiteId = +id; From e35821a0c3067dae52a4587b7793a4c0099dbc3f Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Mon, 14 Sep 2020 08:47:49 -0700 Subject: [PATCH 02/67] Fix calendar starting day. --- components/common/Calendar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/common/Calendar.js b/components/common/Calendar.js index d9c281d3..9ad1be88 100644 --- a/components/common/Calendar.js +++ b/components/common/Calendar.js @@ -105,7 +105,7 @@ export default function Calendar({ date, minDate, maxDate, onChange }) { const DaySelector = ({ date, minDate, maxDate, locale, onSelect }) => { const startWeek = startOfWeek(date); const startMonth = startOfMonth(date); - const startDay = subDays(startMonth, startMonth.getDay() + 1); + const startDay = subDays(startMonth, startMonth.getDay()); const month = date.getMonth(); const year = date.getFullYear(); From 2ea91aaabfec51de37a1289e040de2792654b72b Mon Sep 17 00:00:00 2001 From: Bartosz Hernas Date: Mon, 14 Sep 2020 18:13:59 +0200 Subject: [PATCH 03/67] Ability to unregister umami --- lib/web.js | 8 +++++--- tracker/index.js | 12 ++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/web.js b/lib/web.js index 4a8578f1..784a9e1e 100644 --- a/lib/web.js +++ b/lib/web.js @@ -39,12 +39,14 @@ export const put = (url, params) => apiRequest('put', url, JSON.stringify(params export const hook = (_this, method, callback) => { const orig = _this[method]; - - return (...args) => { + _this[method] = (...args) => { callback.apply(null, args); - return orig.apply(_this, args); }; + + return () => { + _this[method] = orig; + }; }; export const doNotTrack = () => { diff --git a/tracker/index.js b/tracker/index.js index f7f00927..0b91d4e7 100644 --- a/tracker/index.js +++ b/tracker/index.js @@ -73,8 +73,8 @@ import { removeTrailingSlash } from '../lib/url'; pageView(); }; - history.pushState = hook(history, 'pushState', handlePush); - history.replaceState = hook(history, 'replaceState', handlePush); + const pushStateUnhook = hook(history, 'pushState', handlePush); + const replaceStateUnhook = hook(history, 'replaceState', handlePush); /* Handle events */ @@ -106,4 +106,12 @@ import { removeTrailingSlash } from '../lib/url'; if (!window.umami) { window.umami = event_value => collect('event', { event_type: 'custom', event_value }); } + + if (!window.umamiUnregister) { + window.umamiUnregister = () => { + pushStateUnhook(); + replaceStateUnhook(); + removeEvents(); + }; + } })(window); From 4478dfe5aec1e0b9b78ce79027f76dea4f9aedab Mon Sep 17 00:00:00 2001 From: CamTosh Date: Mon, 14 Sep 2020 18:56:22 +0200 Subject: [PATCH 04/67] Add FR lang --- lang/fr-FR.json | 85 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/lang.js | 6 +++- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 lang/fr-FR.json diff --git a/lang/fr-FR.json b/lang/fr-FR.json new file mode 100644 index 00000000..f333ade5 --- /dev/null +++ b/lang/fr-FR.json @@ -0,0 +1,85 @@ +{ + "active-users.message": "{x} {x, plural, one {visiteur} other {visiteurs}} actuellement", + "button.add-account": "Ajouter un compte", + "button.add-website": "Ajouter un site", + "button.back": "Retour", + "button.cancel": "Annuler", + "button.change-password": "Changer de mot de passse", + "button.copy-to-clipboard": "Copier dans le presse papier", + "button.delete": "Supprimer", + "button.edit": "Modifier", + "button.login": "Connexion", + "button.more": "Plus", + "button.save": "Sauvegarder", + "button.view-details": "Voir les details", + "button.websites": "Sites", + "footer.powered-by": "Propulsé par", + "header.nav.dashboard": "Tableau de bord", + "header.nav.settings": "Paramètres", + "label.administrator": "Administrateur", + "label.confirm-password": "Confirmation du mot de passe", + "label.current-password": "Mot de passe actuel", + "label.custom-range": "Plage personnalisée", + "label.domain": "Domaine", + "label.enable-share-url": "Activer le partage d'URL", + "label.invalid": "Invalide", + "label.invalid-domain": "Domaine invalide", + "label.last-days": "{x} derniers jours", + "label.last-hours": "{x} dernières heures", + "label.logged-in-as": "Connecté en tant que {username}", + "label.logout": "Déconnexion", + "label.name": "Nom", + "label.new-password": "Nouveau mot de passe", + "label.password": "Mot de passe", + "label.passwords-dont-match": "Les mots de passe ne correspondent pas", + "label.required": "Requis", + "label.this-month": "Ce mois ci", + "label.this-week": "Cette semaine", + "label.this-year": "Cette année", + "label.today": "Aujourd'hui", + "label.username": "Nom d'utilisateur", + "message.confirm-delete": "Êtes-vous sur de vouloir supprimer {target}?", + "message.copied": "Copié !", + "message.delete-warning": "Toutes les données associées seront également supprimées.", + "message.failure": "Un problème est survenu.", + "message.incorrect-username-password": "nom d'utilisateurs/mot de passe incorrect.", + "message.no-data-available": "Pas de données disponibles.", + "message.page-not-found": "Page non trouvée.", + "message.save-success": "Enregistré avec succès.", + "message.share-url": "Ceci est l'URL partagée pour {target}.", + "message.track-stats": "Pour suivre les statistiques de {target}, placez le code suivant dans la section {head} de votre site Web.", + "message.type-delete": "Tapez {delete} dans la case ci-dessous pour confirmer.", + "metrics.actions": "Actions", + "metrics.average-visit-time": "Temps de visite moyen", + "metrics.bounce-rate": "Taux de rebond", + "metrics.browsers": "Navigateurs", + "metrics.countries": "Pays", + "metrics.devices": "Appareils", + "metrics.events": "Événements", + "metrics.filter.combined": "Combiné", + "metrics.filter.domain-only": "Domaine uniquement", + "metrics.filter.raw": "Brute", + "metrics.operating-systems": "Systèmes d'exploitation", + "metrics.page-views": "Pages vues", + "metrics.pages": "Pages", + "metrics.referrers": "URL Référentes", + "metrics.unique-visitors": "Visiteurs uniques", + "metrics.views": "Vues", + "metrics.visitors": "Visiteurs", + "placeholder.message.go-to-settings": "Aller aux paramètres", + "placeholder.message.no-websites-configured": "Vous n'avez configuré aucun site Web.", + "settings.accounts": "Comptes", + "settings.profile": "Profile", + "settings.websites": "Sites", + "title.add-account": "Ajouter un compte", + "title.add-website": "Ajouter un site", + "title.change-password": "Changer le mot de passe", + "title.delete-account": "Supprimer le compte", + "title.delete-website": "Suprimer le site", + "title.edit-account": "Modifier le compte", + "title.edit-website": "Modifier le site", + "title.share-url": "Partager l'URL", + "title.tracking-code": "Code de suivi", + "tooltip.get-share-url": "Obtenez l'URL de partage", + "tooltip.get-tracking-code": "Obtenez le code de suivi" +} diff --git a/lib/lang.js b/lib/lang.js index 5132362a..d45d7ce0 100644 --- a/lib/lang.js +++ b/lib/lang.js @@ -1,5 +1,5 @@ import { format } from 'date-fns'; -import { enUS, nl, zhCN, tr, ru, de, ja, es } from 'date-fns/locale'; +import { enUS, nl, zhCN, tr, ru, de, ja, es, fr } from 'date-fns/locale'; import enMessages from 'lang-compiled/en-US.json'; import nlMessages from 'lang-compiled/nl-NL.json'; import zhCNMessages from 'lang-compiled/zh-CN.json'; @@ -8,6 +8,7 @@ import ruRUMessages from 'lang-compiled/ru-RU.json'; import deDEMessages from 'lang-compiled/de-DE.json'; import jaMessages from 'lang-compiled/ja-JP.json'; import esMXMessages from 'lang-compiled/es-MX.json'; +import frMessages from 'lang-compiled/fr-FR.json'; import mnMNMessages from 'lang-compiled/mn-MN.json'; export const messages = { @@ -19,6 +20,7 @@ export const messages = { 'tr-TR': trTRMessages, 'ja-JP': jaMessages, 'es-MX': esMXMessages, + 'fr-FR': frMessages, 'mn-MN': mnMNMessages, }; @@ -31,6 +33,7 @@ export const dateLocales = { 'tr-TR': tr, 'ja-JP': ja, 'es-MX': es, + 'fr-FR': fr, 'mn-MN': enUS, }; @@ -39,6 +42,7 @@ export const menuOptions = [ { label: '中文', value: 'zh-CN', display: 'CN' }, { label: 'Deutsch', value: 'de-DE', display: 'DE' }, { label: 'Español', value: 'es-MX', display: 'ES' }, + { label: 'Français', value: 'fr-FR', display: 'FR' }, { label: '日本語', value: 'ja-JP', display: 'JP' }, { label: 'Монгол', value: 'mn-MN', display: 'MN' }, { label: 'Nederlands', value: 'nl-NL', display: 'NL' }, From d19bcbabe053e6b6eb80138818acaa0bed70ea7a Mon Sep 17 00:00:00 2001 From: Bartosz Hernas Date: Tue, 15 Sep 2020 00:09:09 +0200 Subject: [PATCH 05/67] Different method + fixed lint for tracker + added frame mode for shared URLs --- lib/web.js | 10 +++--- pages/share/[...id].js | 4 +-- tracker/index.js | 69 ++++++++++++++++++++++-------------------- 3 files changed, 42 insertions(+), 41 deletions(-) diff --git a/lib/web.js b/lib/web.js index 784a9e1e..4a8578f1 100644 --- a/lib/web.js +++ b/lib/web.js @@ -39,13 +39,11 @@ export const put = (url, params) => apiRequest('put', url, JSON.stringify(params export const hook = (_this, method, callback) => { const orig = _this[method]; - _this[method] = (...args) => { - callback.apply(null, args); - return orig.apply(_this, args); - }; - return () => { - _this[method] = orig; + return (...args) => { + callback.apply(null, args); + + return orig.apply(_this, args); }; }; diff --git a/pages/share/[...id].js b/pages/share/[...id].js index 1e0897a9..50467bf6 100644 --- a/pages/share/[...id].js +++ b/pages/share/[...id].js @@ -6,7 +6,7 @@ import useFetch from 'hooks/useFetch'; export default function SharePage() { const router = useRouter(); - const { id } = router.query; + const { id, frame } = router.query; const shareId = id?.[0]; const { data } = useFetch(shareId ? `/api/share/${shareId}` : null); @@ -15,7 +15,7 @@ export default function SharePage() { } return ( - + ); diff --git a/tracker/index.js b/tracker/index.js index 0b91d4e7..7bb1b7b3 100644 --- a/tracker/index.js +++ b/tracker/index.js @@ -1,6 +1,6 @@ import 'promise-polyfill/src/polyfill'; import 'unfetch/polyfill'; -import { post, hook, doNotTrack } from '../lib/web'; +import { doNotTrack, hook, post } from '../lib/web'; import { removeTrailingSlash } from '../lib/url'; (window => { @@ -31,25 +31,7 @@ import { removeTrailingSlash } from '../lib/url'; /* Collect metrics */ const collect = (type, params) => { - const payload = { - url: currentUrl, - referrer: currentRef, - website, - hostname, - screen, - language, - }; - - if (params) { - Object.keys(params).forEach(key => { - payload[key] = params[key]; - }); - } - - return post(`${root}/api/collect`, { - type, - payload, - }); + return window.umamiTrack(website, type, params); }; const pageView = () => collect('pageview').then(() => setTimeout(loadEvents, 300)); @@ -73,8 +55,8 @@ import { removeTrailingSlash } from '../lib/url'; pageView(); }; - const pushStateUnhook = hook(history, 'pushState', handlePush); - const replaceStateUnhook = hook(history, 'replaceState', handlePush); + history.pushState = hook(history, 'pushState', handlePush); + history.replaceState = hook(history, 'replaceState', handlePush); /* Handle events */ @@ -86,7 +68,7 @@ import { removeTrailingSlash } from '../lib/url'; }; const loadEvents = () => { - document.querySelectorAll("[class*='umami--']").forEach(element => { + document.querySelectorAll('[class*=\'umami--\']').forEach(element => { element.className.split(' ').forEach(className => { if (/^umami--([a-z]+)--([a-z0-9_]+[a-z0-9-_]+)$/.test(className)) { const [, type, value] = className.split('--'); @@ -99,19 +81,40 @@ import { removeTrailingSlash } from '../lib/url'; }); }; - /* Start */ + if (!window.umamiTrack) { + window.umamiTrack = (type, params, id) => { + if (!id) { + id = website + } + const payload = { + url: currentUrl, + referrer: currentRef, + website: id, + hostname, + screen, + language, + }; - pageView(); + if (params) { + Object.keys(params).forEach(key => { + payload[key] = params[key]; + }); + } + + return post(`${root}/api/collect`, { + type, + payload, + }); + }; + } + + /* Start */ + const skipAuto = new URL(script.src).search.includes('auto=false'); + if (!skipAuto) { + pageView(); + } if (!window.umami) { window.umami = event_value => collect('event', { event_type: 'custom', event_value }); } - - if (!window.umamiUnregister) { - window.umamiUnregister = () => { - pushStateUnhook(); - replaceStateUnhook(); - removeEvents(); - }; - } })(window); From d6d1c68e6dbacdda3aa8b2fac70322a1c873f49e Mon Sep 17 00:00:00 2001 From: Bartosz Hernas Date: Tue, 15 Sep 2020 00:12:09 +0200 Subject: [PATCH 06/67] Fix tracker --- tracker/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tracker/index.js b/tracker/index.js index 7bb1b7b3..9c00a47b 100644 --- a/tracker/index.js +++ b/tracker/index.js @@ -55,9 +55,6 @@ import { removeTrailingSlash } from '../lib/url'; pageView(); }; - history.pushState = hook(history, 'pushState', handlePush); - history.replaceState = hook(history, 'replaceState', handlePush); - /* Handle events */ const removeEvents = () => { @@ -84,7 +81,7 @@ import { removeTrailingSlash } from '../lib/url'; if (!window.umamiTrack) { window.umamiTrack = (type, params, id) => { if (!id) { - id = website + id = website; } const payload = { url: currentUrl, @@ -111,6 +108,8 @@ import { removeTrailingSlash } from '../lib/url'; /* Start */ const skipAuto = new URL(script.src).search.includes('auto=false'); if (!skipAuto) { + history.pushState = hook(history, 'pushState', handlePush); + history.replaceState = hook(history, 'replaceState', handlePush); pageView(); } From d5e49141532455b409310b920e98cdf19b0ed3bb Mon Sep 17 00:00:00 2001 From: Bartosz Hernas Date: Tue, 15 Sep 2020 12:03:34 +0200 Subject: [PATCH 07/67] Comments fixed --- pages/share/[...id].js | 4 ++-- tracker/index.js | 44 +++++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pages/share/[...id].js b/pages/share/[...id].js index 50467bf6..1e0897a9 100644 --- a/pages/share/[...id].js +++ b/pages/share/[...id].js @@ -6,7 +6,7 @@ import useFetch from 'hooks/useFetch'; export default function SharePage() { const router = useRouter(); - const { id, frame } = router.query; + const { id } = router.query; const shareId = id?.[0]; const { data } = useFetch(shareId ? `/api/share/${shareId}` : null); @@ -15,7 +15,7 @@ export default function SharePage() { } return ( - + ); diff --git a/tracker/index.js b/tracker/index.js index 9c00a47b..ff7f0995 100644 --- a/tracker/index.js +++ b/tracker/index.js @@ -19,6 +19,7 @@ import { removeTrailingSlash } from '../lib/url'; const website = script.getAttribute('data-website-id'); const hostUrl = script.getAttribute('data-host-url'); + const skipAuto = script.getAttribute('data-skip-auto'); const root = hostUrl ? removeTrailingSlash(hostUrl) : new URL(script.src).href.split('/').slice(0, -1).join('/'); @@ -29,14 +30,7 @@ import { removeTrailingSlash } from '../lib/url'; let currentRef = document.referrer; /* Collect metrics */ - - const collect = (type, params) => { - return window.umamiTrack(website, type, params); - }; - - const pageView = () => collect('pageview').then(() => setTimeout(loadEvents, 300)); - - const pageEvent = (event_type, event_value) => collect('event', { event_type, event_value }); + const pageViewWithAutoEvents = (url, referrer) => window.umami.pageView(url, referrer).then(() => setTimeout(loadEvents, 300)); /* Handle history */ @@ -52,7 +46,7 @@ import { removeTrailingSlash } from '../lib/url'; currentUrl = newUrl; } - pageView(); + pageViewWithAutoEvents(currentUrl, currentRef); }; /* Handle events */ @@ -69,7 +63,7 @@ import { removeTrailingSlash } from '../lib/url'; element.className.split(' ').forEach(className => { if (/^umami--([a-z]+)--([a-z0-9_]+[a-z0-9-_]+)$/.test(className)) { const [, type, value] = className.split('--'); - const listener = () => pageEvent(type, value); + const listener = () => window.umami.event(type, value); listeners.push([element, type, listener]); element.addEventListener(type, listener, true); @@ -78,14 +72,13 @@ import { removeTrailingSlash } from '../lib/url'; }); }; - if (!window.umamiTrack) { - window.umamiTrack = (type, params, id) => { + if (!window.umami) { + window.umami = event_value => window.umami.event('custom', event_value, currentUrl); + window.umami.collect = (type, params, id) => { if (!id) { id = website; } const payload = { - url: currentUrl, - referrer: currentRef, website: id, hostname, screen, @@ -103,17 +96,24 @@ import { removeTrailingSlash } from '../lib/url'; payload, }); }; + window.umami.pageView = (url = currentUrl, referrer = currentRef) => window.umami.collect('pageview', { + url, + referrer, + }); + window.umami.event = (event_type, event_value, url = currentUrl) => window.umami.collect('event', { + url, + event_type, + event_value, + }); + window.umami.registerAutoEvents = () => { + history.pushState = hook(history, 'pushState', handlePush); + history.replaceState = hook(history, 'replaceState', handlePush); + return pageViewWithAutoEvents(currentUrl, currentRef); + }; } /* Start */ - const skipAuto = new URL(script.src).search.includes('auto=false'); if (!skipAuto) { - history.pushState = hook(history, 'pushState', handlePush); - history.replaceState = hook(history, 'replaceState', handlePush); - pageView(); - } - - if (!window.umami) { - window.umami = event_value => collect('event', { event_type: 'custom', event_value }); + window.umami.registerAutoEvents().catch(e => console.error(e)); } })(window); From 7a71bb1c68256ee611cc6751f9c4295a3714b004 Mon Sep 17 00:00:00 2001 From: Bartosz Hernas Date: Tue, 15 Sep 2020 13:54:35 +0200 Subject: [PATCH 08/67] Better snippet --- .gitignore | 1 + components/forms/TrackingCodeForm.js | 5 +- package.json | 1 + rollup.snippet.config.js | 19 ++++++ tracker/index.js | 87 +++++++++++++++++----------- tracker/snippet.js | 42 ++++++++++++++ 6 files changed, 119 insertions(+), 36 deletions(-) create mode 100644 rollup.snippet.config.js create mode 100644 tracker/snippet.js diff --git a/.gitignore b/.gitignore index ca0f3c4f..8b349dbb 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ # production /build /public/umami.js +/public/snippet.js /lang-compiled /lang-formatted diff --git a/components/forms/TrackingCodeForm.js b/components/forms/TrackingCodeForm.js index a98b471d..36dda30e 100644 --- a/components/forms/TrackingCodeForm.js +++ b/components/forms/TrackingCodeForm.js @@ -17,12 +17,15 @@ export default function TrackingCodeForm({ values, onClose }) { />

+ {/* Run `npm run build-snippet, and copy paste here the content of public/snippet.js */} + {/* TODO: use webpack importing function to import the content of the file here ? */}