diff --git a/.gitignore b/.gitignore index e69896d9..7e8d9883 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,6 @@ dist/ **/.DS_Store # Sentry Config File .env.sentry-build-plugin + +# Sentry Config File +.env.sentry-build-plugin diff --git a/interface/.gitignore b/interface/.gitignore index 7d7c7a5f..8adfcaab 100644 --- a/interface/.gitignore +++ b/interface/.gitignore @@ -1,3 +1,6 @@ # Sentry Config File .env.sentry-build-plugin + +# Sentry Config File +.env.sentry-build-plugin diff --git a/interface/src/SettingsContext.tsx b/interface/src/SettingsContext.tsx index f5b951ef..5c0932c5 100644 --- a/interface/src/SettingsContext.tsx +++ b/interface/src/SettingsContext.tsx @@ -16,6 +16,7 @@ export const SettingsContextProvider: React.FC<{ children: ReactNode }> = ({ chi const [settingsState, setSettingsState] = useState({ notificationCollector: false, lessonAlerts: false, + telemetry: true, animatedBackground: false, animatedBackgroundSpeed: "0", customThemeColor: "rgba(219, 105, 105, 1)", diff --git a/interface/src/hooks/settingsState.ts b/interface/src/hooks/settingsState.ts index 1bbdf309..899eed08 100644 --- a/interface/src/hooks/settingsState.ts +++ b/interface/src/hooks/settingsState.ts @@ -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", diff --git a/interface/src/main.tsx b/interface/src/main.tsx index 18d2bd24..4d069335 100644 --- a/interface/src/main.tsx +++ b/interface/src/main.tsx @@ -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"); diff --git a/interface/src/pages/Settings.tsx b/interface/src/pages/Settings.tsx index fa6840f6..2ab45b17 100644 --- a/interface/src/pages/Settings.tsx +++ b/interface/src/pages/Settings.tsx @@ -35,6 +35,11 @@ const Settings: React.FC = () => { description: "Sends a native browser notification ~5 minutes prior to lessons.", modifyElement: switchChange('lessonAlerts', isOn)} /> }, + { + title: "Telemetry", + description: "Enables/disables error collecting.", + modifyElement: switchChange('telemetry', isOn)} /> + }, { title: "Animated Background", description: "Adds an animated background to BetterSEQTA. (May impact battery life)", diff --git a/interface/src/types/AppProps.ts b/interface/src/types/AppProps.ts index 263bf41e..b31c2a81 100644 --- a/interface/src/types/AppProps.ts +++ b/interface/src/types/AppProps.ts @@ -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[]; diff --git a/interface/vite.config.ts b/interface/vite.config.ts index fd8a9824..91ada8a0 100644 --- a/interface/vite.config.ts +++ b/interface/vite.config.ts @@ -5,7 +5,7 @@ import react from '@vitejs/plugin-react' // https://vitejs.dev/config/ export default defineConfig({ plugins: [react(), sentryVitePlugin({ - org: "personal-771", + org: "betterseqta-plus", project: "betterseqtaplus-popup" })], build: { diff --git a/src/SEQTA.ts b/src/SEQTA.ts index 647098f3..2c38b009 100644 --- a/src/SEQTA.ts +++ b/src/SEQTA.ts @@ -1,27 +1,25 @@ /* eslint-disable no-inner-declarations */ import * as Sentry from "@sentry/browser"; -Sentry.init({ - dsn: "https://54bdb68e80b45182ded22ecf9fe9529c@o4506347383291904.ingest.sentry.io/4506347462393856", - - // Alternatively, use `process.env.npm_package_version` for a dynamic release version - // if your build tool supports it. - release: "betterseqtaplus@3.2.2", - integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()], - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for performance monitoring. - // We recommend adjusting this value in production - tracesSampleRate: 1.0, - - // Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled - tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/], - - // Capture Replay for 10% of all sessions, - // plus for 100% of sessions with an error - replaysSessionSampleRate: 0.1, - replaysOnErrorSampleRate: 1.0, -}); +browser.storage.local.get([ "telemetry" ]).then((telemetry) => { + if (telemetry.telemetry === true) { + Sentry.init({ + dsn: "https://54bdb68e80b45182ded22ecf9fe9529c@o4506347383291904.ingest.sentry.io/4506347462393856", + 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 browser from 'webextension-polyfill'; import { animate, spring, stagger } from 'motion'; import Color from 'color'; diff --git a/src/background.ts b/src/background.ts index e9fc238c..cadce43e 100644 --- a/src/background.ts +++ b/src/background.ts @@ -1,27 +1,25 @@ import * as Sentry from "@sentry/browser"; -Sentry.init({ - dsn: "https://54bdb68e80b45182ded22ecf9fe9529c@o4506347383291904.ingest.sentry.io/4506347462393856", - - // Alternatively, use `process.env.npm_package_version` for a dynamic release version - // if your build tool supports it. - release: "betterseqtaplus@3.2.2", - integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()], - - // Set tracesSampleRate to 1.0 to capture 100% - // of transactions for performance monitoring. - // We recommend adjusting this value in production - tracesSampleRate: 1.0, - - // Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled - tracePropagationTargets: ["localhost", /^https:\/\/yourserver\.io\/api/], - - // Capture Replay for 10% of all sessions, - // plus for 100% of sessions with an error - replaysSessionSampleRate: 0.1, - replaysOnErrorSampleRate: 1.0, -}); +browser.storage.local.get([ "telemetry" ]).then((telemetry) => { + if (telemetry.telemetry === true) { + Sentry.init({ + dsn: "https://54bdb68e80b45182ded22ecf9fe9529c@o4506347383291904.ingest.sentry.io/4506347462393856", + 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 browser from 'webextension-polyfill' import { onError } from './seqta/utils/onError'; export const openDB = () => { diff --git a/webpack.config.js b/webpack.config.js index f7ae2318..d1f3eac7 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -15,7 +15,7 @@ export default { maxEntrypointSize: 512000, maxAssetSize: 512000, }, - devtool: 'cheap-module-source-map', + devtool: 'source-map', entry: { SEQTA: './src/SEQTA.ts', background: './src/background.ts', @@ -80,7 +80,7 @@ export default { }), sentryWebpackPlugin({ authToken: process.env.SENTRY_AUTH_TOKEN, - org: "personal-771", + org: "betterseqta-plus", project: "betterseqtaplus-main", }), ],