web/state/settings: add "disable analytics" option
This commit is contained in:
@@ -9,6 +9,14 @@ import defaultSettings from '../settings/defaults';
|
||||
type PartialSettings = RecursivePartial<CobaltSettings>;
|
||||
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) => {
|
||||
localStorage.setItem(
|
||||
"settings",
|
||||
@@ -69,6 +77,7 @@ export function updateSetting(partial: PartialSettings) {
|
||||
)
|
||||
);
|
||||
|
||||
updatePlausiblePreference(partial);
|
||||
return updated;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user