mirror of
https://github.com/agam778/MS-365-Electron.git
synced 2026-02-17 09:02:10 +00:00
Introduce Aptabase tracking preference
- Add an option to enable or disable Aptabase tracking for users, in the app menu. - Also give users a prompt on the app's first launch to choose their preference.
This commit is contained in:
@@ -326,6 +326,35 @@ const commonPreferencesSubmenu = [
|
||||
},
|
||||
checked: getValue("discordrpcstatus") === "true",
|
||||
},
|
||||
{
|
||||
label: "Enable Aptabase Tracking",
|
||||
type: "checkbox",
|
||||
click: () => {
|
||||
if (getValue("aptabaseTracking") === true) {
|
||||
setValue("aptabaseTracking", false);
|
||||
dialog.showMessageBoxSync({
|
||||
type: "info",
|
||||
title: "Aptabase Tracking",
|
||||
message: "Aptabase Tracking has been disabled.",
|
||||
buttons: ["OK"],
|
||||
});
|
||||
return;
|
||||
} else if (
|
||||
getValue("aptabaseTracking") === false ||
|
||||
getValue("aptabaseTracking") === undefined
|
||||
) {
|
||||
setValue("aptabaseTracking", true);
|
||||
dialog.showMessageBoxSync({
|
||||
type: "info",
|
||||
title: "Aptabase Tracking",
|
||||
message: "Aptabase Tracking has been enabled.",
|
||||
buttons: ["OK"],
|
||||
});
|
||||
return;
|
||||
}
|
||||
},
|
||||
checked: getValue("aptabaseTracking") === true,
|
||||
},
|
||||
{
|
||||
label: "Enable Auto Updates",
|
||||
type: "checkbox",
|
||||
|
||||
@@ -32,6 +32,7 @@ getValueOrDefault("custompage", "home");
|
||||
getValueOrDefault("windowWidth", 0.71);
|
||||
getValueOrDefault("windowHeight", 0.74);
|
||||
getValueOrDefault("customWindowSize", false);
|
||||
getValueOrDefault("aptabaseTracking", null);
|
||||
|
||||
if (getValue("enterprise-or-normal") === "https://microsoft365.com/?auth=1") {
|
||||
setValue("enterprise-or-normal", "?auth=1");
|
||||
|
||||
33
app/main.js
33
app/main.js
@@ -2,7 +2,7 @@ import { app, Menu, BrowserWindow, dialog, nativeImage, screen } from "electron"
|
||||
import { clearActivity, setActivity, loginToRPC } from "./config/rpc.js";
|
||||
import { initialize, trackEvent } from "@aptabase/electron/main";
|
||||
import { ElectronBlocker } from "@cliqz/adblocker-electron";
|
||||
import { getValue } from "./config/store.js";
|
||||
import { setValue, getValue } from "./config/store.js";
|
||||
import { fileURLToPath } from "url";
|
||||
import { dirname } from "path";
|
||||
import { join } from "path";
|
||||
@@ -27,9 +27,11 @@ transports.file.level = "verbose";
|
||||
console.log = _log;
|
||||
Object.assign(console, functions);
|
||||
|
||||
initialize("A-US-2528580917").catch((error) => {
|
||||
console.error("Error initializing:", error);
|
||||
});
|
||||
if (getValue("aptabaseTracking") === true) {
|
||||
initialize("A-US-2528580917").catch((error) => {
|
||||
console.error("Error initializing:", error);
|
||||
});
|
||||
}
|
||||
|
||||
function createWindow() {
|
||||
const enterpriseOrNormal = getValue("enterprise-or-normal");
|
||||
@@ -67,9 +69,11 @@ function createWindow() {
|
||||
win.webContents.on("did-finish-load", () => {
|
||||
splash.destroy();
|
||||
win.show();
|
||||
trackEvent("app_started").catch((error) => {
|
||||
console.error("Error tracking event:", error);
|
||||
});
|
||||
if (getValue("aptabaseTracking") === true) {
|
||||
trackEvent("app_started").catch((error) => {
|
||||
console.error("Error tracking event:", error);
|
||||
});
|
||||
}
|
||||
if (getValue("discordrpcstatus") === "true") {
|
||||
setActivity(`On "${win.webContents.getTitle()}"`);
|
||||
}
|
||||
@@ -118,6 +122,21 @@ Menu.setApplicationMenu(Menu.buildFromTemplate(menulayout));
|
||||
|
||||
app.on("ready", () => {
|
||||
createWindow();
|
||||
if (getValue("aptabaseTracking") === null) {
|
||||
const aptabasedialog = dialog.showMessageBoxSync({
|
||||
type: "question",
|
||||
buttons: ["Yes", "No"],
|
||||
title: "Enable Aptabase Tracking",
|
||||
message: "Would you like to enable Aptabase Tracking?",
|
||||
detail:
|
||||
"Aptabase Tracking helps us improve the app by collecting anonymous usage data. No personal information is collected.\n\nYou can always enable or disable this in the app menu.",
|
||||
});
|
||||
if (aptabasedialog === 0) {
|
||||
setValue("aptabaseTracking", true);
|
||||
} else {
|
||||
setValue("aptabaseTracking", false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
app.on("web-contents-created", (event, contents) => {
|
||||
|
||||
Reference in New Issue
Block a user