Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sentry double init #1208

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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://[email protected]/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://[email protected]/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://[email protected]/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://[email protected]/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
Loading