Skip to content

Commit

Permalink
Start of sentry integration
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyGiorgio committed Jun 6, 2024
1 parent b098689 commit 5515f62
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 6 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# LOCALHOST REGTEST
VITE_SENTRY_ENVIRONMENT="dev"

# VITE_NETWORK="regtest"
# VITE_PROXY="wss://p.mutinywallet.com"
Expand Down
3 changes: 2 additions & 1 deletion .env.mainnet
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Mainnet
VITE_SENTRY_ENVIRONMENT="dev"

VITE_NETWORK="bitcoin"
VITE_PROXY="wss://p.mutinywallet.com"
Expand All @@ -13,4 +14,4 @@ VITE_FEEDBACK="https://feedback.mutinywallet.com"
VITE_SCORER="https://scorer.mutinywallet.com"
VITE_PRIMAL="https://primal-cache.mutinywallet.com/api"
VITE_BLIND_AUTH="https://blind-auth.mutinywallet.com"
VITE_HERMES="https://mutiny.plus"
VITE_HERMES="https://mutiny.plus"
1 change: 1 addition & 0 deletions .env.signet
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#SIGNET
VITE_SENTRY_ENVIRONMENT="dev"

VITE_NETWORK="signet"
VITE_PROXY="wss://p.mutinywallet.com"
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
"tailwindcss": "^3.4.1",
"typescript": "^5.4.5",
"vite": "^5.2.10",
"vite-plugin-comlink": "^4.0.3",
"vite-plugin-pwa": "^0.19.8",
"vite-plugin-solid": "^2.10.2",
"vite-plugin-wasm": "^3.3.0",
"workbox-window": "^7.0.0",
"vite-plugin-comlink": "^4.0.3"
"workbox-window": "^7.0.0"
},
"dependencies": {
"@capacitor-mlkit/barcode-scanning": "^6.0.0",
Expand All @@ -55,21 +55,23 @@
"@capacitor/toast": "^6.0.0",
"@kobalte/core": "^0.12.6",
"@kobalte/tailwindcss": "^0.9.0",
"@mutinywallet/mutiny-wasm": "1.7.4",
"@modular-forms/solid": "^0.20.0",
"@mutinywallet/mutiny-wasm": "1.7.4",
"@sentry/browser": "^8.7.0",
"@sentry/wasm": "^8.7.0",
"@solid-primitives/upload": "^0.0.117",
"@solidjs/meta": "^0.29.3",
"@solidjs/router": "^0.13.1",
"capacitor-secure-storage-plugin": "^0.9.0",
"comlink": "^4.4.1",
"i18next": "^23.10.1",
"i18next-browser-languagedetector": "^7.2.0",
"i18next-http-backend": "^2.5.0",
"lucide-solid": "^0.363.0",
"qr-scanner": "^1.4.2",
"solid-js": "^1.8.16",
"solid-qr-code": "^0.0.8",
"solid-transition-group": "^0.2.3",
"comlink": "^4.4.1"
"solid-transition-group": "^0.2.3"
},
"engines": {
"node": ">=18"
Expand Down
87 changes: 87 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions src/state/megaStore.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Inspired by https://github.com/solidjs/solid-realworld/blob/main/src/store/index.js
import { MutinyBalance, TagItem } from "@mutinywallet/mutiny-wasm";
import * as Sentry from "@sentry/browser";
import { useNavigate, useSearchParams } from "@solidjs/router";
import { SecureStoragePlugin } from "capacitor-secure-storage-plugin";
import { Remote } from "comlink";
Expand Down Expand Up @@ -41,10 +42,42 @@ type LoadStage =

export type WalletWorker = Remote<typeof import("../workers/walletWorker")>;

const RELEASE_VERSION = import.meta.env.__RELEASE_VERSION__;
const sentryenv = import.meta.env.VITE_SENTRY_ENVIRONMENT || "prod";

export const makeMegaStoreContext = () => {
const [searchParams] = useSearchParams();
const navigate = useNavigate();

// initialize both inside worker and outside
// TODO figure out when to set or not
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")>(
new URL("../workers/walletWorker", import.meta.url),
Expand Down
49 changes: 49 additions & 0 deletions src/workers/walletWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import initMutinyWallet, {
PendingNwcInvoice,
TagItem
} from "@mutinywallet/mutiny-wasm";
import * as Sentry from "@sentry/browser";

import { IActivityItem } from "~/components";
import { MutinyWalletSettingStrings } from "~/logic/mutinyWalletSetup";
Expand All @@ -26,6 +27,9 @@ import {
MutinyFederationIdentity
} from "~/routes/settings";

const RELEASE_VERSION = import.meta.env.__RELEASE_VERSION__;
const sentryenv = import.meta.env.VITE_SENTRY_ENVIRONMENT || "prod";

// For some reason {...invoice } doesn't bring across the paid field
function destructureInvoice(invoice: MutinyInvoice): MutinyInvoice {
return {
Expand Down Expand Up @@ -95,6 +99,51 @@ export async function setupMutinyWallet(
shouldZapHodl?: boolean,
nsec?: string
): Promise<boolean> {
// initialize both inside worker and outside
// TODO figure out when to set or not
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 && error.message) {

Check failure on line 124 in src/workers/walletWorker.ts

View workflow job for this annotation

GitHub Actions / Build APK

Property 'message' does not exist on type '{}'.

Check failure on line 124 in src/workers/walletWorker.ts

View workflow job for this annotation

GitHub Actions / Build iOS

Property 'message' does not exist on type '{}'.

Check failure on line 124 in src/workers/walletWorker.ts

View workflow job for this annotation

GitHub Actions / code_quality

Property 'message' does not exist on type '{}'.
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
});

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

// https://developer.mozilla.org/en-US/docs/Web/API/Storage_API
Expand Down

0 comments on commit 5515f62

Please sign in to comment.