fix(core): runtime control of telemetry (#10663)

This commit is contained in:
forehalo
2025-03-06 09:56:13 +00:00
parent 93920f9895
commit 56b842f2e1
5 changed files with 70 additions and 51 deletions

View File

@@ -1,15 +1,5 @@
import { createStore } from 'jotai';
import { getDefaultStore } from 'jotai';
// global store
let rootStore = createStore();
export function getCurrentStore(): ReturnType<typeof createStore> {
return rootStore;
}
/**
* @internal do not use this function unless you know what you are doing
*/
export function _setCurrentStore(store: ReturnType<typeof createStore>) {
rootStore = store;
export function getCurrentStore() {
return getDefaultStore();
}

View File

@@ -22,15 +22,23 @@ export const windowFrameStyleOptions: AppSetting['windowFrameStyle'][] = [
'NativeTitleBar',
];
const appSettingBaseAtom = atomWithStorage<AppSetting>('affine-settings', {
clientBorder: BUILD_CONFIG.isElectron && !environment.isWindows,
windowFrameStyle: 'frameless',
enableBlurBackground: true,
enableNoisyBackground: true,
autoCheckUpdate: true,
autoDownloadUpdate: true,
enableTelemetry: true,
});
export const APP_SETTINGS_STORAGE_KEY = 'affine-settings';
const appSettingBaseAtom = atomWithStorage<AppSetting>(
APP_SETTINGS_STORAGE_KEY,
{
clientBorder: BUILD_CONFIG.isElectron && !environment.isWindows,
windowFrameStyle: 'frameless',
enableBlurBackground: true,
enableNoisyBackground: true,
autoCheckUpdate: true,
autoDownloadUpdate: true,
enableTelemetry: true,
},
undefined,
{
getOnInit: true,
}
);
type SetStateAction<Value> = Value | ((prev: Value) => Value);