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
@@ -1,3 +1,8 @@
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 {
interface Window {
ANALYTICS_DISABLED?: boolean | string;
SERVER_LOCK?: boolean;
SERVER_NAME?: string;
SERVER_TYPE?: string;
SERVER_URL?: string;
umami?: {
identify(unique_id: string): void;
identify(unique_id: string, data: object): void;