There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
refactor(core): adjust sentry config (#10631)
EYHN0015bfbaf22c
diff --git a/packages/frontend/apps/android/src/index.tsx b/packages/frontend/apps/android/src/index.tsxindex 4d279a07a5..13db0e77b4 100644--- a/packages/frontend/apps/android/src/index.tsx+++ b/packages/frontend/apps/android/src/index.tsx@@ -33,6 +33,7 @@ function main() {],});setTags({+ distribution: BUILD_CONFIG.distribution,appVersion: BUILD_CONFIG.appVersion,editorVersion: BUILD_CONFIG.editorVersion,});@@ -41,7 +42,7 @@ function main() {}function mountApp() {- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ // oxlint-disable-next-line @typescript-eslint/no-non-null-assertionconst root = document.getElementById('app')!;createRoot(root).render(<StrictMode>diff --git a/packages/frontend/apps/electron-renderer/src/index.tsx b/packages/frontend/apps/electron-renderer/src/index.tsxindex a3230ed65b..898bfe3e3e 100644--- a/packages/frontend/apps/electron-renderer/src/index.tsx+++ b/packages/frontend/apps/electron-renderer/src/index.tsx@@ -1,12 +1,46 @@import './setup';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 {+ createRoutesFromChildren,+ matchRoutes,+ useLocation,+ useNavigationType,+} from 'react-router-dom';import { App } from './app';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// TODO(@Peng): should be sync, but it's not necessary for nowappConfigProxydiff --git a/packages/frontend/apps/electron/src/main/index.ts b/packages/frontend/apps/electron/src/main/index.tsindex afb31b0db8..2015b35dcc 100644--- a/packages/frontend/apps/electron/src/main/index.ts+++ b/packages/frontend/apps/electron/src/main/index.ts@@ -14,7 +14,6 @@ import { registerEvents } from './events';import { registerHandlers } from './handlers';import { logger } from './logger';import { registerProtocol } from './protocol';-import { isOnline } from './ui';import { launch } from './windows-manager/launcher';import { launchStage } from './windows-manager/stage';@@ -38,7 +37,7 @@ if (overrideSession) {app.setPath('sessionData', userDataPath);}-// eslint-disable-next-line @typescript-eslint/no-var-requires+// oxlint-disable-next-line @typescript-eslint/no-var-requiresif (require('electron-squirrel-startup')) app.quit();if (process.env.SKIP_ONBOARDING) {@@ -97,8 +96,10 @@ if (process.env.SENTRY_RELEASE) {transportOptions: {maxAgeDays: 30,maxQueueSize: 100,- shouldStore: () => !isOnline,- shouldSend: () => isOnline,},});+ Sentry.setTags({+ distribution: 'electron',+ appVersion: app.getVersion(),+ });}diff --git a/packages/frontend/apps/electron/src/main/ui/handlers.ts b/packages/frontend/apps/electron/src/main/ui/handlers.tsindex 8ef369f814..7480beb862 100644--- a/packages/frontend/apps/electron/src/main/ui/handlers.ts+++ b/packages/frontend/apps/electron/src/main/ui/handlers.ts@@ -32,8 +32,6 @@ import { getOrCreateCustomThemeWindow } from '../windows-manager/custom-theme-wiimport { getChallengeResponse } from './challenge';import { uiSubjects } from './subject';-export let isOnline = true;-export const uiHandlers = {isMaximized: async () => {const window = await getMainWindow();@@ -75,9 +73,6 @@ export const uiHandlers = {const window = await getMainWindow();window?.hide();},- handleNetworkChange: async (_, _isOnline: boolean) => {- isOnline = _isOnline;- },getChallengeResponse: async (_, challenge: string) => {return getChallengeResponse(challenge);},diff --git a/packages/frontend/apps/ios/src/index.tsx b/packages/frontend/apps/ios/src/index.tsxindex 5b8205ad62..10bceb97aa 100644--- a/packages/frontend/apps/ios/src/index.tsx+++ b/packages/frontend/apps/ios/src/index.tsx@@ -42,6 +42,7 @@ function main() {],});setTags({+ distribution: BUILD_CONFIG.distribution,appVersion: BUILD_CONFIG.appVersion,editorVersion: BUILD_CONFIG.editorVersion,});diff --git a/packages/frontend/apps/mobile/src/index.tsx b/packages/frontend/apps/mobile/src/index.tsxindex df106ac8fe..ede2480107 100644--- a/packages/frontend/apps/mobile/src/index.tsx+++ b/packages/frontend/apps/mobile/src/index.tsx@@ -33,6 +33,7 @@ function main() {],});setTags({+ distribution: BUILD_CONFIG.distribution,appVersion: BUILD_CONFIG.appVersion,editorVersion: BUILD_CONFIG.editorVersion,});diff --git a/packages/frontend/apps/web/src/index.tsx b/packages/frontend/apps/web/src/index.tsxindex 67dcbe2bac..26e98270e0 100644--- a/packages/frontend/apps/web/src/index.tsx+++ b/packages/frontend/apps/web/src/index.tsx@@ -34,6 +34,7 @@ function main() {],});setTags({+ distribution: BUILD_CONFIG.distribution,appVersion: BUILD_CONFIG.appVersion,editorVersion: BUILD_CONFIG.editorVersion,});diff --git a/packages/frontend/core/src/modules/desktop-api/service/desktop-api.ts b/packages/frontend/core/src/modules/desktop-api/service/desktop-api.tsindex 4020872aae..b576be831f 100644--- a/packages/frontend/core/src/modules/desktop-api/service/desktop-api.ts+++ b/packages/frontend/core/src/modules/desktop-api/service/desktop-api.ts@@ -1,19 +1,7 @@import { notify } from '@affine/component';import { I18n } from '@affine/i18n';-import {- init,- reactRouterV6BrowserTracingIntegration,- setTags,-} from '@sentry/react';import { OnEvent, Service } from '@toeverything/infra';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 { ApplicationStarted } from '../../lifecycle';@@ -45,48 +33,10 @@ export class DesktopApiService extends Service {}private setupStartListener() {- this.setupSentry();this.setupCommonUIEvents();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() {if (this.api.appInfo.windowName !== 'main') {return;diff --git a/packages/frontend/track/src/mixpanel.ts b/packages/frontend/track/src/mixpanel.tsindex 6d022a9c18..613b0f50d8 100644--- a/packages/frontend/track/src/mixpanel.ts+++ b/packages/frontend/track/src/mixpanel.ts@@ -36,6 +36,7 @@ function createMixpanel() {editorVersion: BUILD_CONFIG.editorVersion,isDesktop: BUILD_CONFIG.isElectron,isSelfHosted: environment.isSelfHosted,+ distribution: BUILD_CONFIG.distribution,});},reset() {