mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
web/state/settings: add "disable analytics" option
This commit is contained in:
parent
578150e40e
commit
ee9421b831
3 changed files with 18 additions and 1 deletions
|
@ -3,7 +3,7 @@ import { defaultLocale } from "$lib/i18n/translations";
|
||||||
import type { CobaltSettings } from "$lib/types/settings";
|
import type { CobaltSettings } from "$lib/types/settings";
|
||||||
|
|
||||||
const defaultSettings: CobaltSettings = {
|
const defaultSettings: CobaltSettings = {
|
||||||
schemaVersion: 1,
|
schemaVersion: 2,
|
||||||
advanced: {
|
advanced: {
|
||||||
debug: false,
|
debug: false,
|
||||||
},
|
},
|
||||||
|
@ -27,6 +27,9 @@ const defaultSettings: CobaltSettings = {
|
||||||
youtubeVideoCodec: "h264",
|
youtubeVideoCodec: "h264",
|
||||||
youtubeDubBrowserLang: false,
|
youtubeDubBrowserLang: false,
|
||||||
},
|
},
|
||||||
|
privacy: {
|
||||||
|
disableAnalytics: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultSettingsPage = () => {
|
const defaultSettingsPage = () => {
|
||||||
|
|
|
@ -9,6 +9,14 @@ import defaultSettings from '../settings/defaults';
|
||||||
type PartialSettings = RecursivePartial<CobaltSettings>;
|
type PartialSettings = RecursivePartial<CobaltSettings>;
|
||||||
type PartialSettingsWithSchema = RecursivePartial<CobaltSettings> & { schemaVersion: number };
|
type PartialSettingsWithSchema = RecursivePartial<CobaltSettings> & { schemaVersion: number };
|
||||||
|
|
||||||
|
const updatePlausiblePreference = (settings: PartialSettings) => {
|
||||||
|
if (settings.privacy?.disableAnalytics) {
|
||||||
|
localStorage.setItem('plausible_ignore', 'true');
|
||||||
|
} else if (localStorage.getItem('plausible_ignore') !== null) {
|
||||||
|
localStorage.removeItem('plausible_ignore');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const writeToStorage = (settings: PartialSettings) => {
|
const writeToStorage = (settings: PartialSettings) => {
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
"settings",
|
"settings",
|
||||||
|
@ -69,6 +77,7 @@ export function updateSetting(partial: PartialSettings) {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
updatePlausiblePreference(partial);
|
||||||
return updated;
|
return updated;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,10 @@ type CobaltSettingsAdvanced = {
|
||||||
debug: boolean,
|
debug: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type CobaltSettingsPrivacy = {
|
||||||
|
disableAnalytics: boolean
|
||||||
|
};
|
||||||
|
|
||||||
type CobaltSettingsSave = {
|
type CobaltSettingsSave = {
|
||||||
audioFormat: typeof audioFormatOptions[number],
|
audioFormat: typeof audioFormatOptions[number],
|
||||||
disableMetadata: boolean,
|
disableMetadata: boolean,
|
||||||
|
@ -38,6 +42,7 @@ export type CobaltSettings = {
|
||||||
advanced: CobaltSettingsAdvanced,
|
advanced: CobaltSettingsAdvanced,
|
||||||
appearance: CobaltSettingsAppearance,
|
appearance: CobaltSettingsAppearance,
|
||||||
save: CobaltSettingsSave,
|
save: CobaltSettingsSave,
|
||||||
|
privacy: CobaltSettingsPrivacy
|
||||||
};
|
};
|
||||||
|
|
||||||
export type DownloadModeOption = CobaltSettings['save']['downloadMode'];
|
export type DownloadModeOption = CobaltSettings['save']['downloadMode'];
|
||||||
|
|
Loading…
Reference in a new issue