mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 06:46:04 +02:00
lazyload sentry preventing unauthorized connections
This commit is contained in:
+2
-1
@@ -15,11 +15,12 @@ import {
|
|||||||
initRouter,
|
initRouter,
|
||||||
initSentry
|
initSentry
|
||||||
} from './plugin';
|
} from './plugin';
|
||||||
import { pinia } from './stores';
|
import { initPiniaPlugins, pinia } from './stores';
|
||||||
|
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
|
|
||||||
await initPlugins();
|
await initPlugins();
|
||||||
|
await initPiniaPlugins();
|
||||||
|
|
||||||
// #region | Hey look it's most of VRCX!
|
// #region | Hey look it's most of VRCX!
|
||||||
|
|
||||||
|
|||||||
@@ -215,8 +215,6 @@
|
|||||||
import { THEME_CONFIG } from '../shared/constants';
|
import { THEME_CONFIG } from '../shared/constants';
|
||||||
import { openExternalLink } from '../shared/utils';
|
import { openExternalLink } from '../shared/utils';
|
||||||
|
|
||||||
import * as Sentry from '@sentry/vue';
|
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@@ -457,8 +455,10 @@
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (!sentryErrorReporting.value) return;
|
if (!sentryErrorReporting.value) return;
|
||||||
try {
|
try {
|
||||||
|
import('@sentry/vue').then((Sentry) => {
|
||||||
const feedback = Sentry.getFeedback();
|
const feedback = Sentry.getFeedback();
|
||||||
feedback?.attachTo(document.getElementById('feedback'));
|
feedback?.attachTo(document.getElementById('feedback'));
|
||||||
|
});
|
||||||
window.addEventListener('keydown', handleKeydown);
|
window.addEventListener('keydown', handleKeydown);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error setting up Sentry feedback:', error);
|
console.error('Error setting up Sentry feedback:', error);
|
||||||
|
|||||||
+12
-4
@@ -2,17 +2,24 @@ import { router } from './router';
|
|||||||
|
|
||||||
import configRepository from '../service/config';
|
import configRepository from '../service/config';
|
||||||
|
|
||||||
import * as Sentry from '@sentry/vue';
|
let version = '';
|
||||||
|
|
||||||
export async function initSentry(app) {
|
export async function isSentryEnabled() {
|
||||||
try {
|
|
||||||
const enabled = await configRepository.getString(
|
const enabled = await configRepository.getString(
|
||||||
'VRCX_SentryEnabled',
|
'VRCX_SentryEnabled',
|
||||||
'false'
|
'false'
|
||||||
);
|
);
|
||||||
const version = await AppApi.GetVersion();
|
version = await AppApi.GetVersion();
|
||||||
const isNightly = version.includes('Nightly');
|
const isNightly = version.includes('Nightly');
|
||||||
if (enabled !== 'true' || !isNightly) {
|
if (enabled !== 'true' || !isNightly) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function initSentry(app) {
|
||||||
|
try {
|
||||||
|
if (!(await isSentryEnabled())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const vrcxId = await configRepository.getString('VRCX_id', '');
|
const vrcxId = await configRepository.getString('VRCX_id', '');
|
||||||
@@ -33,6 +40,7 @@ export async function initSentry(app) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const dsn = atob(response.data);
|
const dsn = atob(response.data);
|
||||||
|
const Sentry = await import('@sentry/vue');
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
app,
|
app,
|
||||||
dsn,
|
dsn,
|
||||||
|
|||||||
+13
-1
@@ -1,6 +1,7 @@
|
|||||||
import { createPinia } from 'pinia';
|
import { createPinia } from 'pinia';
|
||||||
import { createSentryPiniaPlugin } from '@sentry/vue';
|
import { createSentryPiniaPlugin } from '@sentry/vue';
|
||||||
|
|
||||||
|
import { isSentryEnabled } from '../plugin';
|
||||||
import { useAdvancedSettingsStore } from './settings/advanced';
|
import { useAdvancedSettingsStore } from './settings/advanced';
|
||||||
import { useAppearanceSettingsStore } from './settings/appearance';
|
import { useAppearanceSettingsStore } from './settings/appearance';
|
||||||
import { useAuthStore } from './auth';
|
import { useAuthStore } from './auth';
|
||||||
@@ -37,8 +38,14 @@ import { useWristOverlaySettingsStore } from './settings/wristOverlay';
|
|||||||
|
|
||||||
export const pinia = createPinia();
|
export const pinia = createPinia();
|
||||||
|
|
||||||
|
async function registerSentryPiniaPlugin() {
|
||||||
|
if (!(await isSentryEnabled())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Sentry = await import('@sentry/vue');
|
||||||
pinia.use(
|
pinia.use(
|
||||||
createSentryPiniaPlugin({
|
Sentry.createSentryPiniaPlugin({
|
||||||
stateTransformer: (state) => ({
|
stateTransformer: (state) => ({
|
||||||
...state,
|
...state,
|
||||||
Auth: null,
|
Auth: null,
|
||||||
@@ -105,6 +112,11 @@ pinia.use(
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function initPiniaPlugins() {
|
||||||
|
await registerSentryPiniaPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
export function createGlobalStores() {
|
export function createGlobalStores() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user