Skip to content

Commit

Permalink
Optional analytics #209
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed May 4, 2022
1 parent 55fa585 commit c993dd5
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 21 deletions.
31 changes: 22 additions & 9 deletions app/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,19 @@ <h4 data-loc>Uses GPU for smoother experience. Enable this option if you experie
</div>
<hr />
</div>
<div>
<h3 data-loc>Optional analytics</h3>
<h4 data-loc>Send optional analytics, the sent data is completely anonymous. This includes your Authme version and your OS version.</h4>
<div class="mx-auto flex h-[68px] w-72 items-center justify-center rounded-full bg-white">
<a href="#" onclick="optionalAnalytics()">
<div class="pointer-events-none relative mr-2 inline-block w-10 select-none rounded-full border-2 border-gray-900 bg-gray-900 align-middle">
<input tabindex="-1" id="tgl8" type="checkbox" class="toggle" />
<label for="tgl8" class="toggle-bg block h-6 cursor-pointer overflow-hidden rounded-full bg-white"></label></div
></a>
<span id="tgt8" class="text-xl text-black">-</span>
</div>
<hr />
</div>
<h3 data-loc>Language</h3>
<h4 data-loc>Choose which language should Authme use by default. The translations are not perfect and changing the language requires a restart.</h4>
<div class="relative inline-block">
Expand Down Expand Up @@ -193,15 +206,6 @@ <h4 data-loc>Choose which language should Authme use by default. The translation
</div>
</div>
<hr />
<h3 data-loc>Clear data</h3>
<h4 data-loc>Clear password, 2FA codes and all other settings. Be careful.</h4>
<button class="buttoni" onclick="clearData()">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
<span data-loc>Clear data</span>
</button>
<hr />
<h3 data-loc>Logs</h3>
<h4 data-loc>You can view the logs for debugging. You can view all the logs in the settings folder.</h4>
<div class="flex flex-row flex-wrap justify-center gap-3">
Expand All @@ -218,6 +222,15 @@ <h4 data-loc>You can view the logs for debugging. You can view all the logs in t
<span data-loc>Logs folder</span>
</button>
</div>
<hr />
<h3 data-loc>Clear data</h3>
<h4 data-loc>Clear password, 2FA codes and all other settings. Be careful.</h4>
<button class="buttoni" onclick="clearData()">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
<span data-loc>Clear data</span>
</button>
</div>

<!-- codes -->
Expand Down
60 changes: 60 additions & 0 deletions app/settings/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ const tgl6 = document.querySelector("#tgl6")
const tgt6 = document.querySelector("#tgt6")
const tgl7 = document.querySelector("#tgl7")
const tgt7 = document.querySelector("#tgt7")
const tgl8 = document.querySelector("#tgl8")
const tgt8 = document.querySelector("#tgt8")

// launch on startup
let launch_startup_state = settings.settings.launch_on_startup
Expand Down Expand Up @@ -200,6 +202,16 @@ if (hardware_state === false) {
tgl7.checked = true
}

// analytics
let analytics_state = settings.settings.analytics
if (analytics_state === false) {
tgt8.textContent = "Off"
tgl8.checked = false
} else {
tgt8.textContent = "On"
tgl8.checked = true
}

/**
* Launch Authme on system startup
*/
Expand Down Expand Up @@ -483,6 +495,54 @@ const hardwareAcceleration = () => {
})
}

/**
* Optional analytics
*/
const optionalAnalytics = () => {
const toggle = () => {
if (analytics_state === true) {
settings.settings.analytics = false

save()

tgt8.textContent = "Off"
tgl8.checked = false

analytics_state = false
} else {
settings.settings.analytics = true

save()

tgt8.textContent = "On"
tgl8.checked = true

analytics_state = true
}
}

dialog
.showMessageBox({
title: "Authme",
buttons: [lang.button.yes, lang.button.no, lang.button.cancel],
defaultId: 2,
cancelId: 2,
noLink: true,
type: "warning",
message: lang.settings_dialog.restart,
})
.then((result) => {
if (result.response === 0) {
toggle()
restart()
}

if (result.response === 1) {
toggle()
}
})
}

/**
* Sort codes dropdown
*/
Expand Down
8 changes: 5 additions & 3 deletions languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,18 @@ module.exports = {
"Allows screenshots and screen capture. You can record or screenshot the app until you restart Authme.",
"Hardware acceleration",
"Uses GPU for smoother experience. Enable this option if you experience frame drops or lags.",
"Optional analytics",
"Send optional analytics, the sent data is completely anonymous. This includes your Authme version and your OS version.",
"Language",
"Choose which language should Authme use by default. The translations are not perfect and changing the language requires a restart.",
"Default",
"Clear data",
"Clear password, 2FA codes and all other settings. Be careful.",
"Clear data",
"Logs",
"You can view the logs for debugging. You can view all the logs in the settings folder.",
"Latest log",
"Logs folder",
"Clear data",
"Clear password, 2FA codes and all other settings. Be careful.",
"Clear data",
"Sort codes",
"You can choose how to sort the codes. By default codes are sorted by importing order.",
"Default",
Expand Down
8 changes: 5 additions & 3 deletions languages/hu.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,18 @@ module.exports = {
"Képernyőképek és az ablak rögzítésének engedélyezése. Aktív amíg újra nem indítod az Atuhme-t.",
"Hardveres gyorsítás",
"A GPU használata a jobb élmény érdekébe. Kapcsold be ha laggokat vagy akadásokat tapasztalsz.",
"Opcionális telemetria küldése",
"Opcionális telemetria küldése, a küldött telemetria teljesen névtelen. Ebbe beletartozik az Authme verziója és az OP rendszered verziója.",
"Nyelv",
"Válaszd ki a nyelvet amin az Authme megjelenik. A fordítások nem tökéletesek, hibák előfordulhatnak.",
"Alapértelmezett",
"Adatok törlése",
"A jelszavak, a 2FA kódjaid, valamint a beállításaid törlődnek. Légy óvatos.",
"Adatok törlése",
"Logok",
"Megnézheted a logokat ha hibákat tapasztalsz. Az összes logot a log mappába találod.",
"Legújabb log",
"Log mappa",
"Adatok törlése",
"A jelszavak, a 2FA kódjaid, valamint a beállításaid törlődnek. Légy óvatos.",
"Adatok törlése",
"Kódok rendezése",
"Itt tudod kiválasztani milyen sorrendben jelenjenek meg a kódok. Alapértelmezetten a kódok az importálás sorrendjében vannak.",
"Alapértelmezett",
Expand Down
1 change: 1 addition & 0 deletions lib/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @property {boolean} settings.search_filter.description - Filter for description
* @property {null|string} settings.language - Change language
* @property {null|number} settings.sort - Sort codes
* @property {boolean} settings.analytics - Optional analytics
*
* @property {object} [experimental] - Experimental
*
Expand Down
21 changes: 15 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ const settings_file = {
},
language: null,
sort: null,
analytics: true,
},
security: {
require_password: null,
Expand Down Expand Up @@ -289,6 +290,12 @@ if (settings.window === undefined) {
saveSettings()
}

if (settings.settings.analytics === undefined) {
settings.settings.analytics = true

saveSettings()
}

/**
* Force dark mode
*/
Expand Down Expand Up @@ -936,11 +943,13 @@ app.whenReady()
})
}

// analytics
try {
axios.post("https://api.levminer.com/api/v1/authme/analytics/post", { version: authme_version, os: os_version, date: new Date() })
} catch (error) {
logger.error("Failed to post analytics", error)
// Optional analytics
if (settings.settings.analytics === true) {
try {
axios.post("https://api.levminer.com/api/v1/authme/analytics/post", { version: authme_version, os: os_version, date: new Date() })
} catch (error) {
logger.error("Failed to post analytics", error)
}
}

logger.log("App finished loading")
Expand Down Expand Up @@ -1171,7 +1180,7 @@ ipc.on("disableWindowCapture", () => {
*/
ipc.on("enableWindowCapture", () => {
try {
window_security.setContentProtection(true)
window_security.setContentProtection(false)
} catch (error) {}

window_application.setContentProtection(false)
Expand Down

0 comments on commit c993dd5

Please sign in to comment.