Skip to content

Commit

Permalink
Disable lavamoat browserify (#110)
Browse files Browse the repository at this point in the history
* disable lavamoat browserify

* enable sentry (#111)
  • Loading branch information
brunobar79 authored Nov 22, 2022
1 parent 332618f commit c312d82
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"license": "GPL-3.0-only",
"version": "0.0.1",
"scripts": {
"// Generates a LavaMoat secured build": "",
"build": "yarn build:webpack && yarn build:lavamoat",
"// Generates a build using webpack secured by Lavamoat": "",
"build": "yarn build:webpack",
"// Generates modules via Webpack (without LavaMoat protected modules)": "",
"build:webpack": "lavamoat ./scripts/webpack.js --policy ./lavamoat/build-webpack/policy.json --override ./lavamoat/build-webpack/policy-override.json",
"// Generates LavaMoat secured modules from the Webpack build": "",
Expand All @@ -20,7 +20,7 @@
"ds:build": "cd src/design-system/docs && yarn build",
"ds:generate-symbols": "node -r esbuild-register ./src/design-system/scripts/generateSymbols.ts",
"// Generates LavaMoat policies for everything that is protected w/ LavaMoat": "",
"policy": "yarn policy:build:webpack && yarn policy:build:lavamoat && yarn policy:bundle",
"policy": "yarn policy:build:webpack",
"// Generates a LavaMoat policy for the output of the Webpack bundle": "",
"policy:bundle": "yarn build:webpack && GENERATE_POLICY=true lavamoat ./scripts/lavamoat-browserify.js --policy ./lavamoat/build-lavamoat/policy.json --override ./lavamoat/build-lavamoat/policy-override.json",
"// Generates a LavaMoat policy for the Webpack build script": "",
Expand Down
6 changes: 4 additions & 2 deletions src/core/sentry/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import * as Sentry from '@sentry/browser';
import { BrowserTracing } from '@sentry/tracing';

export function initializeSentry() {
export function initializeSentry(context: 'popup' | 'background') {
if (process.env.NODE_ENV === 'production' && process.env.SENTRY_DSN) {
const integrations = context === 'popup' ? [new BrowserTracing()] : [];
Sentry.init({
dsn: process.env.SENTRY_DSN,
integrations: [new BrowserTracing()],
integrations,
tracesSampleRate: 1.0,
});
console.log('sentry initialized correctly!');
}
}
4 changes: 3 additions & 1 deletion src/entries/background/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { initializeMessenger } from '~/core/messengers';
import { initializeSentry } from '~/core/sentry';
import { syncStores } from '~/core/state';
import { createWagmiClient } from '~/core/wagmi';

Expand All @@ -7,8 +8,9 @@ import { handleProviderRequest } from './handlers/handleProviderRequest';
import { handleSetupInpage } from './handlers/handleSetupInpage';
import { handleWallets } from './handlers/handleWallets';

const messenger = initializeMessenger({ connect: 'popup' });
initializeSentry('background');

const messenger = initializeMessenger({ connect: 'popup' });
createWagmiClient();
handleInstallExtension();
handleProviderRequest({ messenger });
Expand Down
2 changes: 2 additions & 0 deletions src/entries/popup/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { WagmiConfig } from 'wagmi';

import { changeI18nLanguage } from '~/core/languages';
import { persistOptions, queryClient } from '~/core/react-query';
import { initializeSentry } from '~/core/sentry';
import { useCurrentLanguageStore } from '~/core/state';
import { usePendingRequestStore } from '~/core/state/requests';
import { createWagmiClient } from '~/core/wagmi';
Expand All @@ -28,6 +29,7 @@ export function App() {

React.useEffect(() => {
changeI18nLanguage(currentLanguage);
initializeSentry('popup');
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down

0 comments on commit c312d82

Please sign in to comment.