This commit is contained in:
Daniel 2025-06-20 10:20:42 +08:00
parent 3631b729ad
commit 3319ffbb18
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
28 changed files with 91 additions and 9172 deletions

View file

@ -11,7 +11,7 @@ import {onWindowsMsg} from "../window/onWindowsMsg";
import {Constants} from "../constants";
import {appearance} from "../config/appearance";
import {fetchPost, fetchSyncPost} from "../util/fetch";
import {addGA, initAssets, setInlineStyle} from "../util/assets";
import {initAssets, setInlineStyle} from "../util/assets";
import {renderSnippet} from "../config/util/snippets";
import {openFile, openFileById} from "../editor/util";
import {exitSiYuan} from "../dialog/processSystem";
@ -87,7 +87,6 @@ export const onGetConfig = (isStart: boolean, app: App) => {
firstResize = true;
}, 200);
});
addGA();
};
const winOnMaxRestore = async () => {

View file

@ -56,14 +56,6 @@ export const about = {
<div class="fn__space"></div>
<input class="b3-switch fn__flex-center" id="downloadInstallPkg" type="checkbox"${window.siyuan.config.system.downloadInstallPkg ? " checked" : ""}>
</label>
<label class="b3-label fn__flex">
<div class="fn__flex-1">
${window.siyuan.languages.googleAnalytics}
<div class="b3-label__text">${window.siyuan.languages.googleAnalyticsTip}</div>
</div>
<div class="fn__space"></div>
<input class="b3-switch fn__flex-center" id="googleAnalytics" type="checkbox"${window.siyuan.config.system.disableGoogleAnalytics ? "" : " checked"}>
</label>
<label class="b3-label fn__flex">
<div class="fn__flex-1">
${window.siyuan.languages.about11}
@ -354,17 +346,6 @@ ${checkUpdateHTML}
window.siyuan.config.system.lockScreenMode = lockScreenModeElement.checked ? 1 : 0;
});
});
const googleAnalyticsElement = about.element.querySelector("#googleAnalytics") as HTMLInputElement;
googleAnalyticsElement.addEventListener("change", () => {
fetchPost("/api/system/setGoogleAnalytics", {googleAnalytics: googleAnalyticsElement.checked}, () => {
exportLayout({
errorExit: false,
cb() {
window.location.reload();
}
});
});
});
const downloadInstallPkgElement = about.element.querySelector("#downloadInstallPkg") as HTMLInputElement;
downloadInstallPkgElement.addEventListener("change", () => {
fetchPost("/api/system/setDownloadInstallPkg", {downloadInstallPkg: downloadInstallPkgElement.checked}, () => {

View file

@ -101,7 +101,7 @@ export const initConfigSearch = (element: HTMLElement, app: App) => {
"systemLog", "importKey", "genKey", "genKeyByPW", "copyKey", "resetRepo", "systemLogTip", "export",
"downloadLatestVer", "safeQuit", "directConnection", "siyuanNote", "key", "password", "copied", "resetRepoTip",
"autoDownloadUpdatePkg", "autoDownloadUpdatePkgTip", "networkProxy", "keyPlaceholder", "initRepoKeyTip",
"googleAnalytics", "googleAnalyticsTip", "dataRepoPurge", "dataRepoPurgeTip", "dataRepoAutoPurgeIndexRetentionDays",
"dataRepoPurge", "dataRepoPurgeTip", "dataRepoAutoPurgeIndexRetentionDays",
"dataRepoAutoPurgeRetentionIndexesDaily"]),
];
const inputElement = element.querySelector(".b3-form__icon input") as HTMLInputElement;

View file

@ -797,7 +797,4 @@ export abstract class Constants {
"inline-math",
"inline-memo",
];
// Google Analytics 事件
public static readonly ANALYTICS_EVT_ON_GET_CONFIG: string = "siyuan.onGetConfig";
}

View file

@ -10,7 +10,7 @@ import {addBaseURL, getIdFromSYProtocol, isSYProtocol, setNoteBook} from "../uti
import {handleTouchEnd, handleTouchMove, handleTouchStart} from "./util/touch";
import {fetchGet, fetchPost} from "../util/fetch";
import {initFramework} from "./util/initFramework";
import {addGA, initAssets, loadAssets} from "../util/assets";
import {initAssets, loadAssets} from "../util/assets";
import {bootSync} from "../dialog/processSystem";
import {initMessage, showMessage} from "../dialog/message";
import {goBack} from "./util/MobileBackFoward";
@ -121,7 +121,6 @@ class App {
});
});
});
addGA();
});
});
document.addEventListener("touchstart", handleTouchStart, false);

View file

@ -1515,10 +1515,6 @@ declare namespace Config {
* The absolute path of the `data` directory of the current workspace
*/
dataDir: string;
/**
* Whether to disable Google Analytics
*/
disableGoogleAnalytics: boolean;
/**
* Whether to automatically download the installation package for the new version
*/

View file

@ -169,49 +169,6 @@ export const initAssets = () => {
});
};
export const addGA = () => {
if (!window.siyuan.config.system.disableGoogleAnalytics) {
addScript("https://www.googletagmanager.com/gtag/js?id=G-L7WEXVQCR9", "gaScript");
window.dataLayer = window.dataLayer || [];
/*eslint-disable */
const gtag = function (...args: any[]) {
window.dataLayer.push(arguments);
};
/*eslint-enable */
gtag("js", new Date());
gtag("config", "G-L7WEXVQCR9", {send_page_view: false});
const para = {
version: Constants.SIYUAN_VERSION,
container: window.siyuan.config.system.container,
os: window.siyuan.config.system.os,
osPlatform: window.siyuan.config.system.osPlatform,
isLoggedIn: false,
subscriptionStatus: -1,
subscriptionPlan: -1,
subscriptionType: -1,
oneTimePayStatus: -1,
syncEnabled: false,
syncProvider: -1,
cTreeCount: window.siyuan.config.stat.cTreeCount,
cBlockCount: window.siyuan.config.stat.cBlockCount,
cDataSize: window.siyuan.config.stat.cDataSize,
cAssetsSize: window.siyuan.config.stat.cAssetsSize,
};
if (window.siyuan.user) {
para.isLoggedIn = true;
para.subscriptionStatus = window.siyuan.user.userSiYuanSubscriptionStatus;
para.subscriptionPlan = window.siyuan.user.userSiYuanSubscriptionPlan;
para.subscriptionType = window.siyuan.user.userSiYuanSubscriptionType;
para.oneTimePayStatus = window.siyuan.user.userSiYuanOneTimePayStatus;
}
if (window.siyuan.config.sync) {
para.syncEnabled = window.siyuan.config.sync.enabled;
para.syncProvider = window.siyuan.config.sync.provider;
}
gtag("event", Constants.ANALYTICS_EVT_ON_GET_CONFIG, para);
}
};
export const setInlineStyle = async (set = true) => {
const height = Math.floor(window.siyuan.config.editor.fontSize * 1.625);
let style;