feat: anonymous telemetry
This commit is contained in:
parent
ba53acdca7
commit
49c331fcc9
|
@ -34,6 +34,7 @@ import { patches, PMLogger, startAllPlugins } from "./plugins";
|
|||
import { localStorage } from "./utils/localStorage";
|
||||
import { relaunch } from "./utils/native";
|
||||
import { getCloudSettings, putCloudSettings } from "./utils/settingsSync";
|
||||
import { sendTelemetry } from "./utils/telemetry";
|
||||
import { checkForUpdates, update, UpdateLogger } from "./utils/updater";
|
||||
import { onceReady } from "./webpack";
|
||||
import { SettingsRouter } from "./webpack/common";
|
||||
|
@ -83,6 +84,8 @@ async function init() {
|
|||
|
||||
syncSettings();
|
||||
|
||||
sendTelemetry();
|
||||
|
||||
if (!IS_WEB) {
|
||||
try {
|
||||
const isOutdated = await checkForUpdates();
|
||||
|
|
|
@ -61,6 +61,8 @@ export interface Settings {
|
|||
settingsSync: boolean;
|
||||
settingsSyncVersion: number;
|
||||
};
|
||||
|
||||
telemetry: boolean;
|
||||
}
|
||||
|
||||
const DefaultSettings: Settings = {
|
||||
|
@ -91,7 +93,9 @@ const DefaultSettings: Settings = {
|
|||
url: "https://api.vencord.dev/",
|
||||
settingsSync: false,
|
||||
settingsSyncVersion: 0
|
||||
}
|
||||
},
|
||||
|
||||
telemetry: true
|
||||
};
|
||||
|
||||
try {
|
||||
|
|
|
@ -91,6 +91,11 @@ function VencordSettings() {
|
|||
key: "macosTranslucency",
|
||||
title: "Enable translucent window",
|
||||
note: "Requires a full restart"
|
||||
},
|
||||
{
|
||||
key: "telemetry",
|
||||
title: "Enable Telemetry",
|
||||
note: "We only gather anonymous telemetry data. All data deleted after 3 days if you opt out."
|
||||
}
|
||||
];
|
||||
|
||||
|
|
65
src/utils/telemetry.tsx
Normal file
65
src/utils/telemetry.tsx
Normal file
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2023 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { Settings } from "@api/Settings";
|
||||
import { Alerts, SettingsRouter } from "@webpack/common";
|
||||
|
||||
import { isPluginEnabled } from "../plugins";
|
||||
import { Plugins } from "../Vencord";
|
||||
import { isLinux, isMac, isWindows } from "./constants";
|
||||
import { localStorage } from "./localStorage";
|
||||
|
||||
export function sendTelemetry() {
|
||||
// if (IS_DEV) return; // don't send on devbuilds, usually contains incorrect data
|
||||
|
||||
// if we have not yet told the user about the telemetry's existence, DON'T send
|
||||
// a probe now, but tell them and then let them decide if they want to opt in or
|
||||
// not. this only takes place the next time the mod starts.
|
||||
if (!localStorage.getItem("Vencord_telemetryAcknowledged")) {
|
||||
Alerts.show({
|
||||
title: "Telemetry Notice",
|
||||
body: <>
|
||||
<p>
|
||||
Vencord has a telemetry feature that sends anonymous data to us, which we use to improve the mod.
|
||||
</p>
|
||||
<p>
|
||||
If you don't want this, that's okay! We haven't sent anything yet. You can disable this in the
|
||||
settings at any time, easily. If you choose to do nothing, we'll send some information the next time
|
||||
you reload or restart Discord.
|
||||
</p>
|
||||
</>,
|
||||
confirmText: "Okay",
|
||||
secondaryConfirmText: "Vencord Settings",
|
||||
onConfirmSecondary() {
|
||||
SettingsRouter.open("VencordSettings");
|
||||
},
|
||||
});
|
||||
|
||||
localStorage.setItem("Vencord_telemetryAcknowledged", "1");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// if it's disabled in settings, obviously don't do anything
|
||||
if (!Settings.telemetry) return;
|
||||
|
||||
const activePluginsList = Object.keys(Plugins.plugins)
|
||||
.filter(p => isPluginEnabled(p));
|
||||
|
||||
let operatingSystem = "Unknown";
|
||||
|
||||
if (isWindows) operatingSystem = "Windows";
|
||||
else if (isMac) operatingSystem = "macOS";
|
||||
else if (isLinux) operatingSystem = "Linux";
|
||||
|
||||
const data = {
|
||||
version: VERSION,
|
||||
plugins: activePluginsList,
|
||||
operatingSystem
|
||||
};
|
||||
|
||||
navigator.sendBeacon("https://api.vencord.dev/v1/telemetry", JSON.stringify(data));
|
||||
}
|
Loading…
Reference in a new issue