-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet-dashboard): Integrate Sentry (#4820)
* refactor(tooling): Update usage of Sentry deprecated methods * feat(dashboard): Integrate Sentry * attempto to fix * deps * chore: add enabled check * chore: Get sentry traces rate from growthbook * chore: Embedded sentry traces rate * fmt * fix(dashboard): clean debris --------- Co-authored-by: cpl121 <[email protected]> Co-authored-by: cpl121 <[email protected]>
- Loading branch information
1 parent
45ad366
commit b1d8ed3
Showing
12 changed files
with
799 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,6 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
# Sentry Config File | ||
.env.sentry-build-plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
'use client'; | ||
|
||
import '@iota/dapp-kit/dist/index.css'; | ||
import './globals.css'; | ||
import { Inter } from 'next/font/google'; | ||
import { AppProviders } from '@/providers'; | ||
import { FontLinks } from '@/components/FontLinks'; | ||
import { useEffect } from 'react'; | ||
import { captureException } from '@/instrumentation'; | ||
|
||
const inter = Inter({ subsets: ['latin'] }); | ||
|
||
export default function GlobalError({ error }: { error: Error & { digest?: string } }) { | ||
useEffect(() => { | ||
captureException(error); | ||
}, [error]); | ||
|
||
return ( | ||
<html lang="en"> | ||
<body className={inter.className}> | ||
<AppProviders> | ||
<FontLinks /> | ||
<h2>Something went wrong!</h2> | ||
</AppProviders> | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export { captureException } from '@sentry/nextjs'; | ||
|
||
export async function register() { | ||
// Only client is needed | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// Modifications Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { SentryHttpTransport } from '@iota/core'; | ||
import { | ||
IotaClient, | ||
IotaHTTPTransport, | ||
getNetwork, | ||
Network, | ||
type NetworkId, | ||
getAllNetworks, | ||
} from '@iota/iota-sdk/client'; | ||
|
||
export const SupportedNetworks = getAllNetworks(); | ||
|
||
const defaultClientMap: Map<NetworkId, IotaClient> = new Map(); | ||
|
||
// NOTE: This class should not be used directly in React components, prefer to use the useIotaClient() hook instead | ||
export const createIotaClient = (network: NetworkId): IotaClient => { | ||
const existingClient = defaultClientMap.get(network); | ||
if (existingClient) return existingClient; | ||
|
||
const supportedNetwork = getNetwork(network); | ||
// If network is not supported, we use assume we are using a custom RPC | ||
const networkUrl = supportedNetwork?.url ?? network; | ||
|
||
const client = new IotaClient({ | ||
transport: | ||
supportedNetwork && network === Network.Testnet // Sentry dev hint: change this to eg [Network.Localnet] | ||
? new SentryHttpTransport(networkUrl) | ||
: new IotaHTTPTransport({ url: networkUrl }), | ||
}); | ||
defaultClientMap.set(network, client); | ||
return client; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This file configures the initialization of Sentry on the client. | ||
// The config you add here will be used whenever a users loads a page in their browser. | ||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/ | ||
|
||
import * as Sentry from '@sentry/nextjs'; | ||
import { IS_PROD, SENTRY_DSN } from './sentry.common.config.mjs'; | ||
|
||
Sentry.init({ | ||
enabled: IS_PROD, | ||
dsn: SENTRY_DSN, | ||
|
||
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control. | ||
tracesSampleRate: 0.0025, | ||
|
||
// Setting this option to true will print useful information to the console while you're setting up Sentry. | ||
debug: false, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const IS_PROD = process.env.NODE_ENV === 'production'; | ||
|
||
export const SENTRY_DSN = IS_PROD | ||
? 'https://cb83626ca07d6cf66ca2f901cf53c051@o4508279186718720.ingest.de.sentry.io/4508647247249488' | ||
: 'https://ba5d6596291f12e88625e02eb942b742@o4508279186718720.ingest.de.sentry.io/4508647248691280'; | ||
|
||
export const SENTRY_PROJECT_NAME = IS_PROD ? 'iota-wallet-dashboard' : 'iota-wallet-dashboard-dev'; | ||
export const SENTRY_ORG_NAME = 'iota-foundation-eu'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This file configures the initialization of Sentry on the client. | ||
// The config you add here will be used whenever a users loads a page in their browser. | ||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/ | ||
|
||
import * as Sentry from '@sentry/nextjs'; | ||
import { IS_PROD, SENTRY_DSN } from './sentry.common.config.mjs'; | ||
|
||
Sentry.init({ | ||
enabled: IS_PROD, | ||
dsn: SENTRY_DSN, | ||
|
||
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control. | ||
tracesSampleRate: 0, // Server is not traced | ||
|
||
// Setting this option to true will print useful information to the console while you're setting up Sentry. | ||
debug: false, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This file configures the initialization of Sentry on the client. | ||
// The config you add here will be used whenever a users loads a page in their browser. | ||
// https://docs.sentry.io/platforms/javascript/guides/nextjs/ | ||
|
||
import * as Sentry from '@sentry/nextjs'; | ||
import { IS_PROD, SENTRY_DSN } from './sentry.common.config.mjs'; | ||
|
||
Sentry.init({ | ||
enabled: IS_PROD, | ||
dsn: SENTRY_DSN, | ||
|
||
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control. | ||
tracesSampleRate: 0, // Server is not traced | ||
|
||
// Setting this option to true will print useful information to the console while you're setting up Sentry. | ||
debug: false, | ||
}); |
Oops, something went wrong.