telemetry toggle

This commit is contained in:
Crazypersonalph
2023-12-07 12:21:59 +08:00
parent 0110475dc2
commit 03ab5f0cdc
11 changed files with 77 additions and 63 deletions
+1
View File
@@ -16,6 +16,7 @@ export const SettingsContextProvider: React.FC<{ children: ReactNode }> = ({ chi
const [settingsState, setSettingsState] = useState<SettingsState>({
notificationCollector: false,
lessonAlerts: false,
telemetry: true,
animatedBackground: false,
animatedBackgroundSpeed: "0",
customThemeColor: "rgba(219, 105, 105, 1)",
+2
View File
@@ -17,6 +17,7 @@ const useSettingsState = ({ settingsState, setSettingsState }: SettingsProps) =>
setSettingsState({
notificationCollector: result.notificationcollector,
lessonAlerts: result.lessonalert,
telemetry: result.telemetry,
animatedBackground: result.animatedbk,
animatedBackgroundSpeed: result.bksliderinput,
customThemeColor: result.selectedColor,
@@ -35,6 +36,7 @@ const useSettingsState = ({ settingsState, setSettingsState }: SettingsProps) =>
const keyToStateMap = useMemo(() => ({
"notificationcollector": "notificationCollector",
"lessonalert": "lessonAlerts",
"telemetry": "telemetry",
"animatedbk": "animatedBackground",
"bksliderinput": "animatedBackgroundSpeed",
"selectedColor": "customThemeColor",
+20 -18
View File
@@ -1,27 +1,29 @@
import * as Sentry from "@sentry/react";
Sentry.init({
dsn: "https://4bc7197431b170218e15daba4095d08b@o4506347383291904.ingest.sentry.io/4506347394105344",
integrations: [
new Sentry.BrowserTracing({
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
}),
new Sentry.Replay(),
],
// Performance Monitoring
tracesSampleRate: 1.0, // Capture 100% of the transactions
// Session Replay
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
});
import React from 'react';
import ReactDOM from 'react-dom/client';
import { HashRouter, Routes, Route } from 'react-router-dom';
import './index.css';
import { SettingsContextProvider } from './SettingsContext.js';
import SettingsPage from './SettingsPage.js';
import browser from 'webextension-polyfill'
import browser from 'webextension-polyfill';
import * as Sentry from "@sentry/react";
browser.storage.local.get([ "telemetry" ]).then((telemetry) => {
if (telemetry.telemetry === true)
Sentry.init({
dsn: "https://4bc7197431b170218e15daba4095d08b@o4506347383291904.ingest.sentry.io/4506347394105344",
integrations: [
new Sentry.BrowserTracing({
// Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/],
}),
new Sentry.Replay(),
],
// Performance Monitoring
tracesSampleRate: 1.0, // Capture 100% of the transactions
// Session Replay
replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
replaysOnErrorSampleRate: 1.0, // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
});
})
const fontURL = browser.runtime.getURL("fonts/IconFamily.woff");
const style = document.createElement("style");
+5
View File
@@ -35,6 +35,11 @@ const Settings: React.FC = () => {
description: "Sends a native browser notification ~5 minutes prior to lessons.",
modifyElement: <Switch state={settingsState.lessonAlerts} onChange={(isOn: boolean) => switchChange('lessonAlerts', isOn)} />
},
{
title: "Telemetry",
description: "Enables/disables error collecting.",
modifyElement: <Switch state={settingsState.telemetry} onChange={(isOn: boolean) => switchChange('telemetry', isOn)} />
},
{
title: "Animated Background",
description: "Adds an animated background to BetterSEQTA. (May impact battery life)",
+2
View File
@@ -1,6 +1,7 @@
export interface SettingsState {
notificationCollector: boolean;
lessonAlerts: boolean;
telemetry: boolean;
animatedBackground: boolean;
animatedBackgroundSpeed: string;
customThemeColor: string;
@@ -52,6 +53,7 @@ export interface MainConfig {
};
menuorder: any[];
notificationcollector: boolean;
telemetry: boolean;
onoff: boolean;
selectedColor: string;
shortcuts: Shortcut[];