mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-23 20:18:42 +08:00
refactor(core): adjust sentry config (#10631)
This commit is contained in:
@@ -33,6 +33,7 @@ function main() {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
setTags({
|
setTags({
|
||||||
|
distribution: BUILD_CONFIG.distribution,
|
||||||
appVersion: BUILD_CONFIG.appVersion,
|
appVersion: BUILD_CONFIG.appVersion,
|
||||||
editorVersion: BUILD_CONFIG.editorVersion,
|
editorVersion: BUILD_CONFIG.editorVersion,
|
||||||
});
|
});
|
||||||
@@ -41,7 +42,7 @@ function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mountApp() {
|
function mountApp() {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
const root = document.getElementById('app')!;
|
const root = document.getElementById('app')!;
|
||||||
createRoot(root).render(
|
createRoot(root).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
|
|||||||
@@ -1,12 +1,46 @@
|
|||||||
import './setup';
|
import './setup';
|
||||||
|
|
||||||
import { appConfigProxy } from '@affine/core/components/hooks/use-app-config-storage';
|
import { appConfigProxy } from '@affine/core/components/hooks/use-app-config-storage';
|
||||||
import { StrictMode } from 'react';
|
import {
|
||||||
|
init,
|
||||||
|
reactRouterV6BrowserTracingIntegration,
|
||||||
|
setTags,
|
||||||
|
} from '@sentry/react';
|
||||||
|
import { StrictMode, useEffect } from 'react';
|
||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
|
import {
|
||||||
|
createRoutesFromChildren,
|
||||||
|
matchRoutes,
|
||||||
|
useLocation,
|
||||||
|
useNavigationType,
|
||||||
|
} from 'react-router-dom';
|
||||||
|
|
||||||
import { App } from './app';
|
import { App } from './app';
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
// skip bootstrap setup for desktop onboarding
|
||||||
|
if (BUILD_CONFIG.debug || window.SENTRY_RELEASE) {
|
||||||
|
// https://docs.sentry.io/platforms/javascript/guides/react/#configure
|
||||||
|
init({
|
||||||
|
dsn: process.env.SENTRY_DSN,
|
||||||
|
environment: process.env.BUILD_TYPE ?? 'development',
|
||||||
|
integrations: [
|
||||||
|
reactRouterV6BrowserTracingIntegration({
|
||||||
|
useEffect,
|
||||||
|
useLocation,
|
||||||
|
useNavigationType,
|
||||||
|
createRoutesFromChildren,
|
||||||
|
matchRoutes,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
});
|
||||||
|
setTags({
|
||||||
|
distribution: BUILD_CONFIG.distribution,
|
||||||
|
appVersion: BUILD_CONFIG.appVersion,
|
||||||
|
editorVersion: BUILD_CONFIG.editorVersion,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// load persistent config for electron
|
// load persistent config for electron
|
||||||
// TODO(@Peng): should be sync, but it's not necessary for now
|
// TODO(@Peng): should be sync, but it's not necessary for now
|
||||||
appConfigProxy
|
appConfigProxy
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import { registerEvents } from './events';
|
|||||||
import { registerHandlers } from './handlers';
|
import { registerHandlers } from './handlers';
|
||||||
import { logger } from './logger';
|
import { logger } from './logger';
|
||||||
import { registerProtocol } from './protocol';
|
import { registerProtocol } from './protocol';
|
||||||
import { isOnline } from './ui';
|
|
||||||
import { launch } from './windows-manager/launcher';
|
import { launch } from './windows-manager/launcher';
|
||||||
import { launchStage } from './windows-manager/stage';
|
import { launchStage } from './windows-manager/stage';
|
||||||
|
|
||||||
@@ -38,7 +37,7 @@ if (overrideSession) {
|
|||||||
app.setPath('sessionData', userDataPath);
|
app.setPath('sessionData', userDataPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// oxlint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
if (require('electron-squirrel-startup')) app.quit();
|
if (require('electron-squirrel-startup')) app.quit();
|
||||||
|
|
||||||
if (process.env.SKIP_ONBOARDING) {
|
if (process.env.SKIP_ONBOARDING) {
|
||||||
@@ -97,8 +96,10 @@ if (process.env.SENTRY_RELEASE) {
|
|||||||
transportOptions: {
|
transportOptions: {
|
||||||
maxAgeDays: 30,
|
maxAgeDays: 30,
|
||||||
maxQueueSize: 100,
|
maxQueueSize: 100,
|
||||||
shouldStore: () => !isOnline,
|
|
||||||
shouldSend: () => isOnline,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Sentry.setTags({
|
||||||
|
distribution: 'electron',
|
||||||
|
appVersion: app.getVersion(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ import { getOrCreateCustomThemeWindow } from '../windows-manager/custom-theme-wi
|
|||||||
import { getChallengeResponse } from './challenge';
|
import { getChallengeResponse } from './challenge';
|
||||||
import { uiSubjects } from './subject';
|
import { uiSubjects } from './subject';
|
||||||
|
|
||||||
export let isOnline = true;
|
|
||||||
|
|
||||||
export const uiHandlers = {
|
export const uiHandlers = {
|
||||||
isMaximized: async () => {
|
isMaximized: async () => {
|
||||||
const window = await getMainWindow();
|
const window = await getMainWindow();
|
||||||
@@ -75,9 +73,6 @@ export const uiHandlers = {
|
|||||||
const window = await getMainWindow();
|
const window = await getMainWindow();
|
||||||
window?.hide();
|
window?.hide();
|
||||||
},
|
},
|
||||||
handleNetworkChange: async (_, _isOnline: boolean) => {
|
|
||||||
isOnline = _isOnline;
|
|
||||||
},
|
|
||||||
getChallengeResponse: async (_, challenge: string) => {
|
getChallengeResponse: async (_, challenge: string) => {
|
||||||
return getChallengeResponse(challenge);
|
return getChallengeResponse(challenge);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ function main() {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
setTags({
|
setTags({
|
||||||
|
distribution: BUILD_CONFIG.distribution,
|
||||||
appVersion: BUILD_CONFIG.appVersion,
|
appVersion: BUILD_CONFIG.appVersion,
|
||||||
editorVersion: BUILD_CONFIG.editorVersion,
|
editorVersion: BUILD_CONFIG.editorVersion,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ function main() {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
setTags({
|
setTags({
|
||||||
|
distribution: BUILD_CONFIG.distribution,
|
||||||
appVersion: BUILD_CONFIG.appVersion,
|
appVersion: BUILD_CONFIG.appVersion,
|
||||||
editorVersion: BUILD_CONFIG.editorVersion,
|
editorVersion: BUILD_CONFIG.editorVersion,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ function main() {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
setTags({
|
setTags({
|
||||||
|
distribution: BUILD_CONFIG.distribution,
|
||||||
appVersion: BUILD_CONFIG.appVersion,
|
appVersion: BUILD_CONFIG.appVersion,
|
||||||
editorVersion: BUILD_CONFIG.editorVersion,
|
editorVersion: BUILD_CONFIG.editorVersion,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,19 +1,7 @@
|
|||||||
import { notify } from '@affine/component';
|
import { notify } from '@affine/component';
|
||||||
import { I18n } from '@affine/i18n';
|
import { I18n } from '@affine/i18n';
|
||||||
import {
|
|
||||||
init,
|
|
||||||
reactRouterV6BrowserTracingIntegration,
|
|
||||||
setTags,
|
|
||||||
} from '@sentry/react';
|
|
||||||
import { OnEvent, Service } from '@toeverything/infra';
|
import { OnEvent, Service } from '@toeverything/infra';
|
||||||
import { debounce } from 'lodash-es';
|
import { debounce } from 'lodash-es';
|
||||||
import { useEffect } from 'react';
|
|
||||||
import {
|
|
||||||
createRoutesFromChildren,
|
|
||||||
matchRoutes,
|
|
||||||
useLocation,
|
|
||||||
useNavigationType,
|
|
||||||
} from 'react-router-dom';
|
|
||||||
|
|
||||||
import { AuthService, DefaultServerService, ServersService } from '../../cloud';
|
import { AuthService, DefaultServerService, ServersService } from '../../cloud';
|
||||||
import { ApplicationStarted } from '../../lifecycle';
|
import { ApplicationStarted } from '../../lifecycle';
|
||||||
@@ -45,48 +33,10 @@ export class DesktopApiService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private setupStartListener() {
|
private setupStartListener() {
|
||||||
this.setupSentry();
|
|
||||||
this.setupCommonUIEvents();
|
this.setupCommonUIEvents();
|
||||||
this.setupAuthRequestEvent();
|
this.setupAuthRequestEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupSentry() {
|
|
||||||
if (
|
|
||||||
BUILD_CONFIG.debug ||
|
|
||||||
window.SENTRY_RELEASE ||
|
|
||||||
this.api.appInfo.windowName !== 'main'
|
|
||||||
) {
|
|
||||||
// https://docs.sentry.io/platforms/javascript/guides/electron/
|
|
||||||
init({
|
|
||||||
dsn: process.env.SENTRY_DSN,
|
|
||||||
environment: process.env.BUILD_TYPE ?? 'development',
|
|
||||||
integrations: [
|
|
||||||
reactRouterV6BrowserTracingIntegration({
|
|
||||||
useEffect,
|
|
||||||
useLocation,
|
|
||||||
useNavigationType,
|
|
||||||
createRoutesFromChildren,
|
|
||||||
matchRoutes,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
setTags({
|
|
||||||
appVersion: BUILD_CONFIG.appVersion,
|
|
||||||
editorVersion: BUILD_CONFIG.editorVersion,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.api.handler.ui
|
|
||||||
.handleNetworkChange(navigator.onLine)
|
|
||||||
.catch(console.error);
|
|
||||||
window.addEventListener('offline', () => {
|
|
||||||
this.api.handler.ui.handleNetworkChange(false).catch(console.error);
|
|
||||||
});
|
|
||||||
window.addEventListener('online', () => {
|
|
||||||
this.api.handler.ui.handleNetworkChange(true).catch(console.error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private setupCommonUIEvents() {
|
private setupCommonUIEvents() {
|
||||||
if (this.api.appInfo.windowName !== 'main') {
|
if (this.api.appInfo.windowName !== 'main') {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ function createMixpanel() {
|
|||||||
editorVersion: BUILD_CONFIG.editorVersion,
|
editorVersion: BUILD_CONFIG.editorVersion,
|
||||||
isDesktop: BUILD_CONFIG.isElectron,
|
isDesktop: BUILD_CONFIG.isElectron,
|
||||||
isSelfHosted: environment.isSelfHosted,
|
isSelfHosted: environment.isSelfHosted,
|
||||||
|
distribution: BUILD_CONFIG.distribution,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
reset() {
|
reset() {
|
||||||
|
|||||||
Reference in New Issue
Block a user