add pinia action trail to sentry events

This commit is contained in:
pa
2026-01-07 20:28:16 +09:00
committed by Natsumi
parent acbc0ca0fc
commit 7ab3ba959b
4 changed files with 170 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
import { createPinia } from 'pinia';
import { getSentry, isSentryOptedIn } from '../plugin';
import { createPiniaActionTrailPlugin } from '../plugin/piniaActionTrail';
import { useAdvancedSettingsStore } from './settings/advanced';
import { useAppearanceSettingsStore } from './settings/appearance';
import { useAuthStore } from './auth';
@@ -38,11 +39,17 @@ import { useWristOverlaySettingsStore } from './settings/wristOverlay';
export const pinia = createPinia();
function registerPiniaActionTrailPlugin() {
if (!NIGHTLY) return;
pinia.use(createPiniaActionTrailPlugin({ maxEntries: 200 }));
}
async function registerSentryPiniaPlugin() {
if (!NIGHTLY) return;
if (!(await isSentryOptedIn())) return;
const Sentry = await getSentry();
pinia.use(
Sentry.createSentryPiniaPlugin({
stateTransformer: (state) => ({
@@ -114,6 +121,7 @@ async function registerSentryPiniaPlugin() {
}
export async function initPiniaPlugins() {
registerPiniaActionTrailPlugin();
await registerSentryPiniaPlugin();
}

View File

@@ -10,6 +10,7 @@ import { debounce, parseLocation } from '../shared/utils';
import { AppDebug } from '../service/appConfig';
import { database } from '../service/database';
import { failedGetRequests } from '../service/request';
import { getPiniaActionTrail } from '../plugin/piniaActionTrail';
import { refreshCustomScript } from '../shared/utils/base/ui';
import { useAdvancedSettingsStore } from './settings/advanced';
import { useAvatarProviderStore } from './avatarProvider';
@@ -527,12 +528,18 @@ export const useVrcxStore = defineStore('Vrcx', () => {
if (advancedSettingsStore.sentryErrorReporting) {
try {
import('@sentry/vue').then((Sentry) => {
Sentry.captureMessage(
`crash message: ${crashMessage}`,
{
level: 'fatal'
}
);
const trail = getPiniaActionTrail();
Sentry.withScope((scope) => {
scope.setLevel('fatal');
scope.setTag('reason', 'crash-recovery');
scope.setContext('pinia_actions', {
trail,
count: trail.length
});
Sentry.captureMessage(
`crash message: ${crashMessage}`
);
});
});
} catch (error) {
console.error('Error setting up Sentry feedback:', error);