Skip to content

Commit

Permalink
fix sentry double init
Browse files Browse the repository at this point in the history
  • Loading branch information
futurepaul authored and TonyGiorgio committed Jun 11, 2024
1 parent f5c0a83 commit 1379b4a
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 81 deletions.
4 changes: 3 additions & 1 deletion src/components/SetupErrorDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
LargeHeader,
Logs,
NiceP,
SmallHeader
SmallHeader,
ToggleReportDiagnostics
} from "~/components";
import { useI18n } from "~/i18n/context";
import {
Expand Down Expand Up @@ -221,6 +222,7 @@ export function SetupErrorDisplay(props: {
</ExternalLink>
</NiceP>
<ImportExport emergency />
<ToggleReportDiagnostics />
<Logs />
<div class="flex flex-col gap-2 rounded-xl bg-m-red p-4">
<SmallHeader>
Expand Down
4 changes: 0 additions & 4 deletions src/routes/settings/Encrypt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { createMemo, createSignal, Show } from "solid-js";
import {
BackLink,
Button,
ButtonLink,
DefaultMain,
InfoBox,
LargeHeader,
Expand Down Expand Up @@ -162,9 +161,6 @@ export function Encrypt() {
</Button>
</VStack>
</Form>
<ButtonLink href="/" intent="green">
{i18n.t("settings.encrypt.skip")}
</ButtonLink>
</VStack>
</DefaultMain>
<NavBar activeTab="settings" />
Expand Down
65 changes: 35 additions & 30 deletions src/state/megaStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,36 +177,41 @@ export const makeMegaStoreContext = () => {
const reportDiagnostics =
localStorage.getItem("report_diagnostics") === "true";

if (reportDiagnostics && sentryenv !== "") {
Sentry.init({
dsn: "https://192c556849619517322719962a057376@sen.mutinywallet.com/2",
environment: sentryenv,
release: "mutiny-web@" + RELEASE_VERSION,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration()
],

initialScope: {
tags: { component: "main" }
},

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
tracePropagationTargets: [
"localhost",
/^https:\/\/mutinywallet\.com/
],

// Capture Replay for 10% of all sessions,
// plus 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0
});
try {
// If there's a password that means we've already setup sentry the first time
if (reportDiagnostics && sentryenv !== "" && !password) {
Sentry.init({
dsn: "https://192c556849619517322719962a057376@sen.mutinywallet.com/2",
environment: sentryenv,
release: "mutiny-web@" + RELEASE_VERSION,
integrations: [
Sentry.browserTracingIntegration(),
Sentry.replayIntegration()
],

initialScope: {
tags: { component: "main" }
},

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
tracePropagationTargets: [
"localhost",
/^https:\/\/mutinywallet\.com/
],

// Capture Replay for 10% of all sessions,
// plus 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0
});
}
} catch (e) {
console.error("Error initializing sentry", e);
}

// handle lsp settings
Expand Down
103 changes: 57 additions & 46 deletions src/workers/walletWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,52 +102,63 @@ export async function setupMutinyWallet(
nsec?: string
): Promise<boolean> {
// initialize both inside worker and outside
if (reportDiagnostics && sentryenv !== "") {
Sentry.init({
dsn: "https://192c556849619517322719962a057376@sen.mutinywallet.com/2",
environment: sentryenv,
release: "mutiny-web@" + RELEASE_VERSION,
integrations: [
Sentry.captureConsoleIntegration(), // grab all mutiny-node console lines
Sentry.browserTracingIntegration(),
Sentry.replayIntegration()
],

initialScope: {
tags: { component: "worker" }
},

// ignore any hex larger than 20 char
ignoreErrors: [/(?:[0-9a-fA-F]{20,}\b)+/],

// only do a new issue for errors w/ or w/o exceptions, and warnings
beforeSend(event, hint) {
const error = hint.originalException;
if (error && typeof error === "object" && "message" in error) {
return event;
} else if (event.level == "warning" || event.level == "error") {
return event;
} else {
return null;
}
},

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
tracePropagationTargets: [
"localhost",
/^https:\/\/mutinywallet\.com/
],

// Capture Replay for 10% of all sessions,
// plus 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0
});
try {
if (reportDiagnostics && sentryenv !== "") {
Sentry.init({
dsn: "https://192c556849619517322719962a057376@sen.mutinywallet.com/2",
environment: sentryenv,
release: "mutiny-web@" + RELEASE_VERSION,
integrations: [
Sentry.captureConsoleIntegration(), // grab all mutiny-node console lines
Sentry.browserTracingIntegration(),
Sentry.replayIntegration()
],

initialScope: {
tags: { component: "worker" }
},

// ignore any hex larger than 20 char
ignoreErrors: [/(?:[0-9a-fA-F]{20,}\b)+/],

// only do a new issue for errors w/ or w/o exceptions, and warnings
beforeSend(event, hint) {
const error = hint.originalException;
if (
error &&
typeof error === "object" &&
"message" in error
) {
return event;
} else if (
event.level == "warning" ||
event.level == "error"
) {
return event;
} else {
return null;
}
},

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
tracePropagationTargets: [
"localhost",
/^https:\/\/mutinywallet\.com/
],

// Capture Replay for 10% of all sessions,
// plus 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0
});
}
} catch (e) {
console.error("Error initializing sentry", e);
}

console.log("Starting setup...");
Expand Down

0 comments on commit 1379b4a

Please sign in to comment.