Skip to content

Commit

Permalink
add sentry context + refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ra3orblade committed Apr 26, 2024
1 parent 236c4c3 commit 36989f2
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/ts/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import Routes from 'json/route.json';
const memoryHistory = hs.createMemoryHistory;
const history = memoryHistory();
const electron = UtilCommon.getElectron();
const isPackaged = electron.isPackaged;

interface RouteElement { path: string; };

Expand Down Expand Up @@ -88,7 +89,7 @@ const rootStore = {

window.$ = $;

if (!electron.isPackaged) {
if (!isPackaged) {
window.Anytype = {
Store: rootStore,
Lib: {
Expand Down Expand Up @@ -136,8 +137,8 @@ enableLogging({
*/

Sentry.init({
release: UtilCommon.getElectron().version.app,
environment: UtilCommon.getElectron().isPackaged ? 'production' : 'development',
release: electron.version.app,
environment: isPackaged ? 'production' : 'development',
dsn: Constant.sentry,
maxBreadcrumbs: 0,
beforeSend: (e: any) => {
Expand All @@ -152,6 +153,11 @@ Sentry.init({
],
});

Sentry.setContext('info', {
network: I.NetworkMode[authStore.networkConfig?.mode],
isPackaged: isPackaged,
});

class RoutePage extends React.Component<RouteComponentProps> {
render () {
return (
Expand Down Expand Up @@ -207,7 +213,7 @@ class App extends React.Component<object, State> {
<div id="root-loader" className="loaderWrapper">
<div className="inner">
<div className="logo anim from" />
<div className="version anim from">{UtilCommon.getElectron().version.app}</div>
<div className="version anim from">{electron.version.app}</div>
</div>
</div>
) : ''}
Expand Down Expand Up @@ -237,18 +243,20 @@ class App extends React.Component<object, State> {
};

init () {
const { version, arch, getGlobal } = electron;

UtilRouter.init(history);

dispatcher.init(UtilCommon.getElectron().getGlobal('serverAddress'));
dispatcher.init(getGlobal('serverAddress'));
dispatcher.listenEvents();

keyboard.init();

this.registerIpcEvents();
Renderer.send('appOnLoad');

console.log('[Process] os version:', UtilCommon.getElectron().version.system, 'arch:', UtilCommon.getElectron().arch);
console.log('[App] version:', UtilCommon.getElectron().version.app, 'isPackaged', UtilCommon.getElectron().isPackaged);
console.log('[Process] os version:', version.system, 'arch:', arch);
console.log('[App] version:', version.app, 'isPackaged', isPackaged);
};

initStorage () {
Expand Down Expand Up @@ -480,7 +488,7 @@ class App extends React.Component<object, State> {
icon: 'updated',
bgColor: 'green',
title: translate('popupConfirmUpdateDoneTitle'),
text: UtilCommon.sprintf(translate('popupConfirmUpdateDoneText'), UtilCommon.getElectron().version.app),
text: UtilCommon.sprintf(translate('popupConfirmUpdateDoneText'), electron.version.app),
textConfirm: translate('popupConfirmUpdateDoneOk'),
colorConfirm: 'blank',
canCancel: false,
Expand Down

0 comments on commit 36989f2

Please sign in to comment.