From 747a6d3afe618d84e7430ed3589ab2acc3bcfd9c Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Tue, 15 Aug 2023 00:03:34 +0800 Subject: [PATCH] perf: reduce entry js size --- .../plugins/com.msgbyte.sentry/src/index.tsx | 32 +------------------ .../plugins/com.msgbyte.sentry/src/lazy.tsx | 31 ++++++++++++++++++ 2 files changed, 32 insertions(+), 31 deletions(-) create mode 100644 client/web/plugins/com.msgbyte.sentry/src/lazy.tsx diff --git a/client/web/plugins/com.msgbyte.sentry/src/index.tsx b/client/web/plugins/com.msgbyte.sentry/src/index.tsx index f9e003fc..5e0c9f6a 100644 --- a/client/web/plugins/com.msgbyte.sentry/src/index.tsx +++ b/client/web/plugins/com.msgbyte.sentry/src/index.tsx @@ -1,31 +1 @@ -import * as Sentry from '@sentry/react'; -import { BrowserTracing } from '@sentry/tracing'; -import { sharedEvent } from '@capital/common'; - -try { - Sentry.init({ - dsn: 'https://177fd98a1e9e4deba84146a769633c32@o4504196236836864.ingest.sentry.io/4504196241293312', - replaysSessionSampleRate: 0, - replaysOnErrorSampleRate: 1.0, - integrations: [new 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: 0.1, // reduce sentry quota usage - - ignoreErrors: ['File Too Large'], - }); - - sharedEvent.on('loginSuccess', (userInfo) => { - Sentry.setUser({ - id: userInfo._id, - email: userInfo.email, - username: `${userInfo.nickname}#${userInfo.discriminator}`, - avatar: userInfo.avatar, - temporary: userInfo.temporary, - }); - }); -} catch (err) { - console.error(err); -} +import('./lazy'); diff --git a/client/web/plugins/com.msgbyte.sentry/src/lazy.tsx b/client/web/plugins/com.msgbyte.sentry/src/lazy.tsx new file mode 100644 index 00000000..f9e003fc --- /dev/null +++ b/client/web/plugins/com.msgbyte.sentry/src/lazy.tsx @@ -0,0 +1,31 @@ +import * as Sentry from '@sentry/react'; +import { BrowserTracing } from '@sentry/tracing'; +import { sharedEvent } from '@capital/common'; + +try { + Sentry.init({ + dsn: 'https://177fd98a1e9e4deba84146a769633c32@o4504196236836864.ingest.sentry.io/4504196241293312', + replaysSessionSampleRate: 0, + replaysOnErrorSampleRate: 1.0, + integrations: [new 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: 0.1, // reduce sentry quota usage + + ignoreErrors: ['File Too Large'], + }); + + sharedEvent.on('loginSuccess', (userInfo) => { + Sentry.setUser({ + id: userInfo._id, + email: userInfo.email, + username: `${userInfo.nickname}#${userInfo.discriminator}`, + avatar: userInfo.avatar, + temporary: userInfo.temporary, + }); + }); +} catch (err) { + console.error(err); +}