Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Updated handling of env vars.
Mike Cao98a0a83ccf92
diff --git a/next.config.js b/next.config.jsindex 8a0c6569b..92b66943d 100644--- a/next.config.js+++ b/next.config.js@@ -3,19 +3,19 @@ require('dotenv').config();const path = require('path');const pkg = require('./package.json');-const basePath = process.env.BASE_PATH || '';-const collectApiEndpoint = process.env.COLLECT_API_ENDPOINT || '';-const cloudMode = process.env.CLOUD_MODE || '';-const cloudUrl = process.env.CLOUD_URL || '';-const defaultLocale = process.env.DEFAULT_LOCALE || '';-const disableLogin = process.env.DISABLE_LOGIN || '';-const disableUI = process.env.DISABLE_UI || '';-const forceSSL = process.env.FORCE_SSL || '';-const frameAncestors = process.env.ALLOWED_FRAME_URLS || '';-const privateMode = process.env.PRIVATE_MODE || '';-const shareUrlHost = process.env.SHARE_HOST_URL || '';-const trackerScriptHost = process.env.TRACKER_SCRIPT_HOST || '';-const trackerScriptName = process.env.TRACKER_SCRIPT_NAME || '';+const basePath = process.env.BASE_PATH;+const collectApiEndpoint = process.env.COLLECT_API_ENDPOINT;+const cloudMode = process.env.CLOUD_MODE;+const cloudUrl = process.env.CLOUD_URL;+const defaultLocale = process.env.DEFAULT_LOCALE;+const disableLogin = process.env.DISABLE_LOGIN;+const disableUI = process.env.DISABLE_UI;+const forceSSL = process.env.FORCE_SSL;+const frameAncestors = process.env.ALLOWED_FRAME_URLS;+const privateMode = process.env.PRIVATE_MODE;+const shareUrlHost = process.env.SHARE_URL_HOST;+const trackerScriptHost = process.env.TRACKER_SCRIPT_HOST;+const trackerScriptName = process.env.TRACKER_SCRIPT_NAME;const contentSecurityPolicy = [`default-src 'self'`,diff --git a/src/app/(main)/App.tsx b/src/app/(main)/App.tsxindex 406c2f164..efb38043a 100644--- a/src/app/(main)/App.tsx+++ b/src/app/(main)/App.tsx@@ -27,7 +27,7 @@ export function App({ children }) {{children}<UpdateNotice user={user} config={config} />{process.env.NODE_ENV === 'production' && !pathname.includes('/share/') && (- <Script src={`${process.env.basePath}/telemetry.js`} />+ <Script src={`${process.env.basePath || ''}/telemetry.js`} />)}</>);diff --git a/src/app/(main)/console/TestConsole.tsx b/src/app/(main)/console/TestConsole.tsxindex 86a4792e3..37075cf98 100644--- a/src/app/(main)/console/TestConsole.tsx+++ b/src/app/(main)/console/TestConsole.tsx@@ -80,7 +80,7 @@ export function TestConsole({ websiteId }: { websiteId: string }) {<Scriptasyncdata-website-id={websiteId}- src={`${process.env.basePath}/script.js`}+ src={`${process.env.basePath || ''}/script.js`}data-cache="true"/><div className={styles.actions}>diff --git a/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx b/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsxindex 506d5733e..2dd69146d 100644--- a/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx+++ b/src/app/(main)/websites/[websiteId]/realtime/RealtimeCountries.tsx@@ -13,7 +13,7 @@ export function RealtimeCountries({ data }) {({ x: code }) => (<span className={classNames(locale, styles.row)}><img- src={`${process.env.basePath}/images/flags/${code?.toLowerCase() || 'xx'}.png`}+ src={`${process.env.basePath || ''}/images/flags/${code?.toLowerCase() || 'xx'}.png`}alt={code}/>{countryNames[code]}diff --git a/src/components/hooks/useCountryNames.ts b/src/components/hooks/useCountryNames.tsindex acfada442..17b594b6f 100644--- a/src/components/hooks/useCountryNames.ts+++ b/src/components/hooks/useCountryNames.ts@@ -10,7 +10,7 @@ export function useCountryNames(locale: string) {const [list, setList] = useState(countryNames[locale] || enUS);async function loadData(locale: string) {- const { data } = await httpGet(`${process.env.basePath}/intl/country/${locale}.json`);+ const { data } = await httpGet(`${process.env.basePath || ''}/intl/country/${locale}.json`);if (data) {countryNames[locale] = data;diff --git a/src/components/hooks/useLanguageNames.ts b/src/components/hooks/useLanguageNames.tsindex d4bfbf2fb..276faa149 100644--- a/src/components/hooks/useLanguageNames.ts+++ b/src/components/hooks/useLanguageNames.ts@@ -10,7 +10,7 @@ export function useLanguageNames(locale) {const [list, setList] = useState(languageNames[locale] || enUS);async function loadData(locale) {- const { data } = await httpGet(`${process.env.basePath}/intl/language/${locale}.json`);+ const { data } = await httpGet(`${process.env.basePath || ''}/intl/language/${locale}.json`);if (data) {languageNames[locale] = data;diff --git a/src/components/hooks/useLocale.ts b/src/components/hooks/useLocale.tsindex 5e4e1ce84..69e7cc417 100644--- a/src/components/hooks/useLocale.ts+++ b/src/components/hooks/useLocale.ts@@ -19,7 +19,9 @@ export function useLocale() {const dateLocale = getDateLocale(locale);async function loadMessages(locale: string) {- const { ok, data } = await httpGet(`${process.env.basePath}/intl/messages/${locale}.json`);+ const { ok, data } = await httpGet(+ `${process.env.basePath || ''}/intl/messages/${locale}.json`,+ );if (ok) {messages[locale] = data;diff --git a/src/components/metrics/BrowsersTable.tsx b/src/components/metrics/BrowsersTable.tsxindex c0c741cf4..004b5e43a 100644--- a/src/components/metrics/BrowsersTable.tsx+++ b/src/components/metrics/BrowsersTable.tsx@@ -11,7 +11,7 @@ export function BrowsersTable(props: MetricsTableProps) {return (<FilterLink id="browser" value={browser} label={formatBrowser(browser)}><img- src={`${process.env.basePath}/images/browsers/${browser || 'unknown'}.png`}+ src={`${process.env.basePath || ''}/images/browsers/${browser || 'unknown'}.png`}alt={browser}width={16}height={16}diff --git a/src/components/metrics/CitiesTable.tsx b/src/components/metrics/CitiesTable.tsxindex d275e6504..ee2d10051 100644--- a/src/components/metrics/CitiesTable.tsx+++ b/src/components/metrics/CitiesTable.tsx@@ -20,7 +20,7 @@ export function CitiesTable(props: MetricsTableProps) {<FilterLink id="city" value={city} label={renderLabel(city, country)}>{country && (<img- src={`${process.env.basePath}/images/flags/${country?.toLowerCase() || 'xx'}.png`}+ src={`${process.env.basePath || ''}/images/flags/${country?.toLowerCase() || 'xx'}.png`}alt={country}/>)}diff --git a/src/components/metrics/CountriesTable.tsx b/src/components/metrics/CountriesTable.tsxindex e38666bfd..3e7c0af01 100644--- a/src/components/metrics/CountriesTable.tsx+++ b/src/components/metrics/CountriesTable.tsx@@ -27,7 +27,7 @@ export function CountriesTable({label={formatCountry(code)}><img- src={`${process.env.basePath}/images/flags/${code?.toLowerCase() || 'xx'}.png`}+ src={`${process.env.basePath || ''}/images/flags/${code?.toLowerCase() || 'xx'}.png`}alt={code}/></FilterLink>diff --git a/src/components/metrics/DevicesTable.tsx b/src/components/metrics/DevicesTable.tsxindex 4df331a4b..e3db60ea0 100644--- a/src/components/metrics/DevicesTable.tsx+++ b/src/components/metrics/DevicesTable.tsx@@ -11,7 +11,9 @@ export function DevicesTable(props: MetricsTableProps) {return (<FilterLink id="device" value={labels[device] && device} label={formatDevice(device)}><img- src={`${process.env.basePath}/images/device/${device?.toLowerCase() || 'unknown'}.png`}+ src={`${process.env.basePath || ''}/images/device/${+ device?.toLowerCase() || 'unknown'+ }.png`}alt={device}width={16}height={16}diff --git a/src/components/metrics/RegionsTable.tsx b/src/components/metrics/RegionsTable.tsxindex 65c91f211..6e6d7d96d 100644--- a/src/components/metrics/RegionsTable.tsx+++ b/src/components/metrics/RegionsTable.tsx@@ -20,7 +20,7 @@ export function RegionsTable(props: MetricsTableProps) {return (<FilterLink id="region" className={locale} value={code} label={renderLabel(code, country)}><img- src={`${process.env.basePath}/images/flags/${country?.toLowerCase() || 'xx'}.png`}+ src={`${process.env.basePath || ''}/images/flags/${country?.toLowerCase() || 'xx'}.png`}alt={code}/></FilterLink>diff --git a/src/components/metrics/WorldMap.tsx b/src/components/metrics/WorldMap.tsxindex 31d55dd09..27d0f57c0 100644--- a/src/components/metrics/WorldMap.tsx+++ b/src/components/metrics/WorldMap.tsx@@ -54,7 +54,7 @@ export function WorldMap({ data = [], className }: { data?: any[]; className?: s><ComposableMap projection="geoMercator"><ZoomableGroup zoom={0.8} minZoom={0.7} center={[0, 40]}>- <Geographies geography={`${process.env.basePath}${MAP_FILE}`}>+ <Geographies geography={`${process.env.basePath || ''}${MAP_FILE}`}>{({ geographies }) => {return geographies.map(geo => {const code = ISO_COUNTRIES[geo.id];