Compare commits
4 commits
main
...
feat/telem
Author | SHA1 | Date | |
---|---|---|---|
|
5d1736d020 | ||
|
3de02708a6 | ||
|
49c331fcc9 | ||
|
ba53acdca7 |
7 changed files with 94 additions and 10 deletions
|
@ -34,6 +34,7 @@ import { patches, PMLogger, startAllPlugins } from "./plugins";
|
||||||
import { localStorage } from "./utils/localStorage";
|
import { localStorage } from "./utils/localStorage";
|
||||||
import { relaunch } from "./utils/native";
|
import { relaunch } from "./utils/native";
|
||||||
import { getCloudSettings, putCloudSettings } from "./utils/settingsSync";
|
import { getCloudSettings, putCloudSettings } from "./utils/settingsSync";
|
||||||
|
import { sendTelemetry } from "./utils/telemetry";
|
||||||
import { checkForUpdates, update, UpdateLogger } from "./utils/updater";
|
import { checkForUpdates, update, UpdateLogger } from "./utils/updater";
|
||||||
import { onceReady } from "./webpack";
|
import { onceReady } from "./webpack";
|
||||||
import { SettingsRouter } from "./webpack/common";
|
import { SettingsRouter } from "./webpack/common";
|
||||||
|
@ -83,6 +84,8 @@ async function init() {
|
||||||
|
|
||||||
syncSettings();
|
syncSettings();
|
||||||
|
|
||||||
|
sendTelemetry();
|
||||||
|
|
||||||
if (!IS_WEB) {
|
if (!IS_WEB) {
|
||||||
try {
|
try {
|
||||||
const isOutdated = await checkForUpdates();
|
const isOutdated = await checkForUpdates();
|
||||||
|
|
|
@ -61,6 +61,8 @@ export interface Settings {
|
||||||
settingsSync: boolean;
|
settingsSync: boolean;
|
||||||
settingsSyncVersion: number;
|
settingsSyncVersion: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
telemetry?: boolean; // tri-state, undefined = ask
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefaultSettings: Settings = {
|
const DefaultSettings: Settings = {
|
||||||
|
@ -91,7 +93,9 @@ const DefaultSettings: Settings = {
|
||||||
url: "https://api.vencord.dev/",
|
url: "https://api.vencord.dev/",
|
||||||
settingsSync: false,
|
settingsSync: false,
|
||||||
settingsSyncVersion: 0
|
settingsSyncVersion: 0
|
||||||
}
|
},
|
||||||
|
|
||||||
|
telemetry: undefined
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import { Settings, useSettings } from "@api/Settings";
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import DonateButton from "@components/DonateButton";
|
import DonateButton from "@components/DonateButton";
|
||||||
import { ErrorCard } from "@components/ErrorCard";
|
import { ErrorCard } from "@components/ErrorCard";
|
||||||
|
import { isMac, isWindows } from "@utils/constants";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { identity } from "@utils/misc";
|
import { identity } from "@utils/misc";
|
||||||
import { relaunch, showItemInFolder } from "@utils/native";
|
import { relaunch, showItemInFolder } from "@utils/native";
|
||||||
|
@ -46,9 +47,6 @@ function VencordSettings() {
|
||||||
|
|
||||||
const donateImage = React.useMemo(() => Math.random() > 0.5 ? DEFAULT_DONATE_IMAGE : SHIGGY_DONATE_IMAGE, []);
|
const donateImage = React.useMemo(() => Math.random() > 0.5 ? DEFAULT_DONATE_IMAGE : SHIGGY_DONATE_IMAGE, []);
|
||||||
|
|
||||||
const isWindows = navigator.platform.toLowerCase().startsWith("win");
|
|
||||||
const isMac = navigator.platform.toLowerCase().startsWith("mac");
|
|
||||||
|
|
||||||
const Switches: Array<false | {
|
const Switches: Array<false | {
|
||||||
key: KeysOfType<typeof settings, boolean>;
|
key: KeysOfType<typeof settings, boolean>;
|
||||||
title: string;
|
title: string;
|
||||||
|
@ -93,6 +91,11 @@ function VencordSettings() {
|
||||||
key: "macosTranslucency",
|
key: "macosTranslucency",
|
||||||
title: "Enable translucent window",
|
title: "Enable translucent window",
|
||||||
note: "Requires a full restart"
|
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."
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import { definePluginSettings } from "@api/Settings";
|
import { definePluginSettings } from "@api/Settings";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { ErrorCard } from "@components/ErrorCard";
|
import { ErrorCard } from "@components/ErrorCard";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs, isMac } from "@utils/constants";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
@ -96,9 +96,8 @@ export default definePlugin({
|
||||||
],
|
],
|
||||||
|
|
||||||
settingsAboutComponent: () => {
|
settingsAboutComponent: () => {
|
||||||
const isMacOS = navigator.platform.includes("Mac");
|
const modKey = isMac ? "cmd" : "ctrl";
|
||||||
const modKey = isMacOS ? "cmd" : "ctrl";
|
const altKey = isMac ? "opt" : "alt";
|
||||||
const altKey = isMacOS ? "opt" : "alt";
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Forms.FormTitle tag="h3">More Information</Forms.FormTitle>
|
<Forms.FormTitle tag="h3">More Information</Forms.FormTitle>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { definePluginSettings, Settings } from "@api/Settings";
|
import { definePluginSettings, Settings } from "@api/Settings";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs, isMac } from "@utils/constants";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { ChannelStore, FluxDispatcher as Dispatcher, MessageStore, PermissionsBits, PermissionStore, SelectedChannelStore, UserStore } from "@webpack/common";
|
import { ChannelStore, FluxDispatcher as Dispatcher, MessageStore, PermissionsBits, PermissionStore, SelectedChannelStore, UserStore } from "@webpack/common";
|
||||||
|
@ -25,7 +25,6 @@ import { Message } from "discord-types/general";
|
||||||
|
|
||||||
const Kangaroo = findByPropsLazy("jumpToMessage");
|
const Kangaroo = findByPropsLazy("jumpToMessage");
|
||||||
|
|
||||||
const isMac = navigator.platform.includes("Mac"); // bruh
|
|
||||||
let replyIdx = -1;
|
let replyIdx = -1;
|
||||||
let editIdx = -1;
|
let editIdx = -1;
|
||||||
|
|
||||||
|
|
|
@ -389,3 +389,10 @@ export const DevsById = /* #__PURE__*/ (() =>
|
||||||
.map(([_, v]) => [v.id, v] as const)
|
.map(([_, v]) => [v.id, v] as const)
|
||||||
))
|
))
|
||||||
)() as Record<string, Dev>;
|
)() as Record<string, Dev>;
|
||||||
|
|
||||||
|
|
||||||
|
const { platform } = navigator;
|
||||||
|
|
||||||
|
export const isWindows = platform.startsWith("Win");
|
||||||
|
export const isMac = platform.startsWith("Mac");
|
||||||
|
export const isLinux = platform.startsWith("Linux");
|
||||||
|
|
69
src/utils/telemetry.tsx
Normal file
69
src/utils/telemetry.tsx
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* 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 } from "@webpack/common";
|
||||||
|
|
||||||
|
import { isPluginEnabled } from "../plugins";
|
||||||
|
import { Plugins } from "../Vencord";
|
||||||
|
import { isLinux, isMac, isWindows } from "./constants";
|
||||||
|
|
||||||
|
export function sendTelemetry() {
|
||||||
|
// TODO: READ THIS CHECK BEFORE RELEASING!!
|
||||||
|
// 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, or they haven't agreed at all, DON'T send a
|
||||||
|
// probe now, but tell them and then let them decide if they want to opt in or not.
|
||||||
|
if (Settings.telemetry === undefined) {
|
||||||
|
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. We
|
||||||
|
gather your operating system, the version of Vencord you're using and a list of enabled plugins, and
|
||||||
|
we can use this data to help improve it for yourself and everyone else.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
If you don't want this, that's okay! We haven't sent anything yet. Please decide if you want to allow
|
||||||
|
us to gather a little bit of data. You can change this setting at any time in the future. If you
|
||||||
|
grant consent, we will start sending the data above the next time you reload or restart Discord.
|
||||||
|
</p>
|
||||||
|
</>,
|
||||||
|
confirmText: "Yes, that's fine",
|
||||||
|
cancelText: "No, I don't want that",
|
||||||
|
|
||||||
|
onConfirm() {
|
||||||
|
Settings.telemetry = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
onCancel() {
|
||||||
|
Settings.telemetry = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
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