allow analytics opt out from env (#1454)

This commit is contained in:
jeffvli
2025-12-30 15:40:58 -08:00
parent 4a025f82e4
commit b99ea61115
4 changed files with 15 additions and 2 deletions
+3
View File
@@ -111,6 +111,7 @@ services:
- SERVER_LOCK=true # When true AND name/type/url are set, only username/password can be toggled - SERVER_LOCK=true # When true AND name/type/url are set, only username/password can be toggled
- SERVER_TYPE=jellyfin # the allowed types are: jellyfin, navidrome, subsonic. These values are case insensitive - SERVER_TYPE=jellyfin # the allowed types are: jellyfin, navidrome, subsonic. These values are case insensitive
- SERVER_URL= # http://address:port or https://address:port - SERVER_URL= # http://address:port or https://address:port
- ANALYTICS_DISABLED=true # Set to true to disable Umami analytics tracking
ports: ports:
- 9180:9180 - 9180:9180
# Alternatively, to restrict to only localhost, - 127.0.0.1:9180:8190 # Alternatively, to restrict to only localhost, - 127.0.0.1:9180:8190
@@ -129,6 +130,8 @@ services:
4. _Optional_ - To hard code the server url, pass the following environment variables: `SERVER_NAME`, `SERVER_TYPE` (one of `jellyfin` or `navidrome` or `subsonic`), `SERVER_URL`. To prevent users from changing these settings, pass `SERVER_LOCK=true`. This can only be set if all three of the previous values are set. 4. _Optional_ - To hard code the server url, pass the following environment variables: `SERVER_NAME`, `SERVER_TYPE` (one of `jellyfin` or `navidrome` or `subsonic`), `SERVER_URL`. To prevent users from changing these settings, pass `SERVER_LOCK=true`. This can only be set if all three of the previous values are set.
5. _Optional_ - To disable Umami analytics tracking in the Docker/web version, set the environment variable `ANALYTICS_DISABLED=true`. When enabled, the analytics script will not be loaded and all tracking will be disabled.
## FAQ ## FAQ
### MPV is either not working or is rapidly switching between pause/play states ### MPV is either not working or is rapidly switching between pause/play states
+1 -1
View File
@@ -1 +1 @@
"use strict";window.SERVER_URL="${SERVER_URL}";window.SERVER_NAME="${SERVER_NAME}";window.SERVER_TYPE="${SERVER_TYPE}";window.SERVER_LOCK=${SERVER_LOCK}; "use strict";window.SERVER_URL="${SERVER_URL}";window.SERVER_NAME="${SERVER_NAME}";window.SERVER_TYPE="${SERVER_TYPE}";window.SERVER_LOCK=${SERVER_LOCK};window.ANALYTICS_DISABLED="${ANALYTICS_DISABLED}";
@@ -1,3 +1,8 @@
export const isAnalyticsDisabled = () => { export const isAnalyticsDisabled = () => {
return localStorage.getItem('umami.disabled') === '1' || process.env.NODE_ENV === 'development'; const isSettingOptOut = localStorage.getItem('umami.disabled') === '1';
const isDevMode = process.env.NODE_ENV === 'development';
const isEnvOptOut =
window && (window.ANALYTICS_DISABLED === true || window.ANALYTICS_DISABLED === 'true');
return isSettingOptOut || isDevMode || isEnvOptOut;
}; };
+5
View File
@@ -1,5 +1,10 @@
declare global { declare global {
interface Window { interface Window {
ANALYTICS_DISABLED?: boolean | string;
SERVER_LOCK?: boolean;
SERVER_NAME?: string;
SERVER_TYPE?: string;
SERVER_URL?: string;
umami?: { umami?: {
identify(unique_id: string): void; identify(unique_id: string): void;
identify(unique_id: string, data: object): void; identify(unique_id: string, data: object): void;