Ask for diagnostic reporting on startup

This commit is contained in:
Tony Giorgio
2024-06-06 16:16:26 -05:00
committed by Tony Giorgio
parent 59bcd6296d
commit c955626206
2 changed files with 73 additions and 37 deletions

View File

@@ -1,5 +1,5 @@
import { useNavigate } from "@solidjs/router";
import { createSignal } from "solid-js";
import { createEffect, createSignal } from "solid-js";
import logo from "~/assets/mutiny-pixel-logo.png";
import { Button, DefaultMain, NiceP } from "~/components";
@@ -9,8 +9,22 @@ export function Setup() {
const [_state, actions] = useMegaStore();
const [isCreatingNewWallet, setIsCreatingNewWallet] = createSignal(false);
const [isDiagnosticReportingEnabled, setIsDiagnosticReportingEnabled] =
createSignal(true);
const navigate = useNavigate();
// default is to set reporting
actions.setReportDiagnostics();
// set up a listener that toggles it
createEffect(() => {
if (isDiagnosticReportingEnabled()) {
actions.setReportDiagnostics();
} else {
actions.disableReportDiagnostics();
}
});
async function handleNewWallet() {
try {
setIsCreatingNewWallet(true);
@@ -67,6 +81,19 @@ export function Setup() {
</Button>
</div>
<div class="flex-1" />
<p class="max-w-[15rem] text-center text-xs font-light text-m-grey-400">
<input
type="checkbox"
checked={isDiagnosticReportingEnabled()}
onChange={() =>
setIsDiagnosticReportingEnabled(
!isDiagnosticReportingEnabled()
)
}
/>
Allow anonymous error reporting to help us improve the app.
You can opt out at any time.
</p>
</div>
</DefaultMain>
);

View File

@@ -48,41 +48,6 @@ const sentryenv = import.meta.env.VITE_SENTRY_ENVIRONMENT || (DEV ? "dev" : "");
export const makeMegaStoreContext = () => {
const [searchParams] = useSearchParams();
const navigate = useNavigate();
const reportDiagnostics =
localStorage.getItem("report_diagnostics") === "true";
// 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.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
});
}
// Not actually a shared worker, but it's the same code
const sw = new ComlinkWorker<typeof import("../workers/walletWorker")>(
@@ -123,7 +88,8 @@ export const makeMegaStoreContext = () => {
lang: localStorage.getItem("i18nexLng") || undefined,
preferredInvoiceType: "unified" as "unified" | "lightning" | "onchain",
should_zap_hodl: localStorage.getItem("should_zap_hodl") === "true",
report_diagnostics: reportDiagnostics,
report_diagnostics:
localStorage.getItem("report_diagnostics") === "true",
testflightPromptDismissed:
localStorage.getItem("testflightPromptDismissed") === "true",
federations: undefined as MutinyFederationIdentity[] | undefined,
@@ -208,6 +174,41 @@ export const makeMegaStoreContext = () => {
const settings = await getSettings();
setState({ load_stage: "setup" });
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
});
}
// handle lsp settings
if (searchParams.lsps) {
settings.lsp = "";
@@ -559,6 +560,14 @@ export const makeMegaStoreContext = () => {
);
setState({ report_diagnostics });
},
setReportDiagnostics() {
localStorage.setItem("report_diagnostics", "true");
setState({ report_diagnostics: true });
},
disableReportDiagnostics() {
localStorage.setItem("report_diagnostics", "false");
setState({ report_diagnostics: false });
},
async refreshFederations() {
const federations = await sw.list_federations();