Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Commit 1379b4a

Browse files
futurepaulAnthonyRonning
authored andcommitted
fix sentry double init
1 parent f5c0a83 commit 1379b4a

File tree

4 files changed

+95
-81
lines changed

4 files changed

+95
-81
lines changed

src/components/SetupErrorDisplay.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import {
1212
LargeHeader,
1313
Logs,
1414
NiceP,
15-
SmallHeader
15+
SmallHeader,
16+
ToggleReportDiagnostics
1617
} from "~/components";
1718
import { useI18n } from "~/i18n/context";
1819
import {
@@ -221,6 +222,7 @@ export function SetupErrorDisplay(props: {
221222
</ExternalLink>
222223
</NiceP>
223224
<ImportExport emergency />
225+
<ToggleReportDiagnostics />
224226
<Logs />
225227
<div class="flex flex-col gap-2 rounded-xl bg-m-red p-4">
226228
<SmallHeader>

src/routes/settings/Encrypt.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { createMemo, createSignal, Show } from "solid-js";
44
import {
55
BackLink,
66
Button,
7-
ButtonLink,
87
DefaultMain,
98
InfoBox,
109
LargeHeader,
@@ -162,9 +161,6 @@ export function Encrypt() {
162161
</Button>
163162
</VStack>
164163
</Form>
165-
<ButtonLink href="/" intent="green">
166-
{i18n.t("settings.encrypt.skip")}
167-
</ButtonLink>
168164
</VStack>
169165
</DefaultMain>
170166
<NavBar activeTab="settings" />

src/state/megaStore.tsx

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -177,36 +177,41 @@ export const makeMegaStoreContext = () => {
177177
const reportDiagnostics =
178178
localStorage.getItem("report_diagnostics") === "true";
179179

180-
if (reportDiagnostics && sentryenv !== "") {
181-
Sentry.init({
182-
dsn: "https://192c556849619517322719962a057376@sen.mutinywallet.com/2",
183-
environment: sentryenv,
184-
release: "mutiny-web@" + RELEASE_VERSION,
185-
integrations: [
186-
Sentry.browserTracingIntegration(),
187-
Sentry.replayIntegration()
188-
],
189-
190-
initialScope: {
191-
tags: { component: "main" }
192-
},
193-
194-
// Set tracesSampleRate to 1.0 to capture 100%
195-
// of transactions for performance monitoring.
196-
// We recommend adjusting this value in production
197-
tracesSampleRate: 1.0,
198-
199-
// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
200-
tracePropagationTargets: [
201-
"localhost",
202-
/^https:\/\/mutinywallet\.com/
203-
],
204-
205-
// Capture Replay for 10% of all sessions,
206-
// plus 100% of sessions with an error
207-
replaysSessionSampleRate: 0.1,
208-
replaysOnErrorSampleRate: 1.0
209-
});
180+
try {
181+
// If there's a password that means we've already setup sentry the first time
182+
if (reportDiagnostics && sentryenv !== "" && !password) {
183+
Sentry.init({
184+
dsn: "https://192c556849619517322719962a057376@sen.mutinywallet.com/2",
185+
environment: sentryenv,
186+
release: "mutiny-web@" + RELEASE_VERSION,
187+
integrations: [
188+
Sentry.browserTracingIntegration(),
189+
Sentry.replayIntegration()
190+
],
191+
192+
initialScope: {
193+
tags: { component: "main" }
194+
},
195+
196+
// Set tracesSampleRate to 1.0 to capture 100%
197+
// of transactions for performance monitoring.
198+
// We recommend adjusting this value in production
199+
tracesSampleRate: 1.0,
200+
201+
// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
202+
tracePropagationTargets: [
203+
"localhost",
204+
/^https:\/\/mutinywallet\.com/
205+
],
206+
207+
// Capture Replay for 10% of all sessions,
208+
// plus 100% of sessions with an error
209+
replaysSessionSampleRate: 0.1,
210+
replaysOnErrorSampleRate: 1.0
211+
});
212+
}
213+
} catch (e) {
214+
console.error("Error initializing sentry", e);
210215
}
211216

212217
// handle lsp settings

src/workers/walletWorker.ts

Lines changed: 57 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -102,52 +102,63 @@ export async function setupMutinyWallet(
102102
nsec?: string
103103
): Promise<boolean> {
104104
// initialize both inside worker and outside
105-
if (reportDiagnostics && sentryenv !== "") {
106-
Sentry.init({
107-
dsn: "https://192c556849619517322719962a057376@sen.mutinywallet.com/2",
108-
environment: sentryenv,
109-
release: "mutiny-web@" + RELEASE_VERSION,
110-
integrations: [
111-
Sentry.captureConsoleIntegration(), // grab all mutiny-node console lines
112-
Sentry.browserTracingIntegration(),
113-
Sentry.replayIntegration()
114-
],
115-
116-
initialScope: {
117-
tags: { component: "worker" }
118-
},
119-
120-
// ignore any hex larger than 20 char
121-
ignoreErrors: [/(?:[0-9a-fA-F]{20,}\b)+/],
122-
123-
// only do a new issue for errors w/ or w/o exceptions, and warnings
124-
beforeSend(event, hint) {
125-
const error = hint.originalException;
126-
if (error && typeof error === "object" && "message" in error) {
127-
return event;
128-
} else if (event.level == "warning" || event.level == "error") {
129-
return event;
130-
} else {
131-
return null;
132-
}
133-
},
134-
135-
// Set tracesSampleRate to 1.0 to capture 100%
136-
// of transactions for performance monitoring.
137-
// We recommend adjusting this value in production
138-
tracesSampleRate: 1.0,
139-
140-
// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
141-
tracePropagationTargets: [
142-
"localhost",
143-
/^https:\/\/mutinywallet\.com/
144-
],
145-
146-
// Capture Replay for 10% of all sessions,
147-
// plus 100% of sessions with an error
148-
replaysSessionSampleRate: 0.1,
149-
replaysOnErrorSampleRate: 1.0
150-
});
105+
try {
106+
if (reportDiagnostics && sentryenv !== "") {
107+
Sentry.init({
108+
dsn: "https://192c556849619517322719962a057376@sen.mutinywallet.com/2",
109+
environment: sentryenv,
110+
release: "mutiny-web@" + RELEASE_VERSION,
111+
integrations: [
112+
Sentry.captureConsoleIntegration(), // grab all mutiny-node console lines
113+
Sentry.browserTracingIntegration(),
114+
Sentry.replayIntegration()
115+
],
116+
117+
initialScope: {
118+
tags: { component: "worker" }
119+
},
120+
121+
// ignore any hex larger than 20 char
122+
ignoreErrors: [/(?:[0-9a-fA-F]{20,}\b)+/],
123+
124+
// only do a new issue for errors w/ or w/o exceptions, and warnings
125+
beforeSend(event, hint) {
126+
const error = hint.originalException;
127+
if (
128+
error &&
129+
typeof error === "object" &&
130+
"message" in error
131+
) {
132+
return event;
133+
} else if (
134+
event.level == "warning" ||
135+
event.level == "error"
136+
) {
137+
return event;
138+
} else {
139+
return null;
140+
}
141+
},
142+
143+
// Set tracesSampleRate to 1.0 to capture 100%
144+
// of transactions for performance monitoring.
145+
// We recommend adjusting this value in production
146+
tracesSampleRate: 1.0,
147+
148+
// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
149+
tracePropagationTargets: [
150+
"localhost",
151+
/^https:\/\/mutinywallet\.com/
152+
],
153+
154+
// Capture Replay for 10% of all sessions,
155+
// plus 100% of sessions with an error
156+
replaysSessionSampleRate: 0.1,
157+
replaysOnErrorSampleRate: 1.0
158+
});
159+
}
160+
} catch (e) {
161+
console.error("Error initializing sentry", e);
151162
}
152163

153164
console.log("Starting setup...");

0 commit comments

Comments
 (0)