Skip to content

Commit

Permalink
Ask for diagnostic reporting on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyRonning committed Jun 6, 2024
1 parent d87d1c9 commit 26ab58c
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 37 deletions.
29 changes: 28 additions & 1 deletion src/routes/setup/Root.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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);
Expand Down Expand Up @@ -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>
);
Expand Down
81 changes: 45 additions & 36 deletions src/state/megaStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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://[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
});
}

// Not actually a shared worker, but it's the same code
const sw = new ComlinkWorker<typeof import("../workers/walletWorker")>(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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://[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
});
}

// handle lsp settings
if (searchParams.lsps) {
settings.lsp = "";
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 26ab58c

Please sign in to comment.