From 6fec2b06a3379f209792c4b8e6cafeaeecbeb8f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bego=C3=B1a=20=C3=81lvarez=20de=20la=20Cruz?= Date: Tue, 12 Nov 2024 10:50:28 +0100 Subject: [PATCH] feat(tooling): add sentry and amplitude analytics to wallet and explorer (#3945) * feat: enable sentry for testnet tracking * feat: add sentry envs and webpack configurations * refactor: localnet network name * feat: add production configurations * feat(tooling-sdk): Add a default env value empty for SENTRY_AUTH_TOKEN * feat: update nightlhy wallet build to use dev and not sentry * feat: configure sentry in explorer * feat: add amplitude support in the wallet * feat(tooling-wallet): Restore the lib path in wallet/ampli.json * feat(tooling-wallet): Fix wrong branch in wallet/ampli.json * feat(tooling-explorer): Update explorer ampli.json * feat(tooling-explorer): Update explorer amplitude types config * feat(tooling-wallet): Format ampli.json * feat(tooling-wallet): Remove SENTRY token env from wallet_rc workflow * refactor(ci): Add nightly-only type of build * fmt * feat(wallet): Update sentry DSNs to EU * feat(wallet): Update org for sentry plugin source maps upload * feat(explorer):Update sentry DSNs to EU * fix: nightly envs --------- Co-authored-by: Mario Sarcevic Co-authored-by: marc2332 --- .../workflows/apps_wallet_nightly_build.yml | 2 +- .github/workflows/apps_wallet_prod_build.yml | 1 + apps/explorer/.env.example | 4 -- apps/explorer/ampli.json | 14 +++--- .../src/components/activity/Activity.tsx | 2 +- apps/explorer/src/hooks/useEnhancedRpc.ts | 2 +- .../src/lib/utils/analytics/ampli/index.ts | 7 +-- .../src/lib/utils/api/defaultRpcClient.ts | 2 +- apps/explorer/src/lib/utils/sentry.ts | 12 ++--- apps/wallet/ampli.json | 14 +++--- .../configs/webpack/webpack.config.common.ts | 14 ++++-- apps/wallet/package.json | 3 +- apps/wallet/src/background/index.ts | 4 +- .../src/shared/analytics/ampli/index.ts | 19 ++++---- apps/wallet/src/shared/analytics/amplitude.ts | 8 ++-- apps/wallet/src/shared/iota-client.ts | 2 +- apps/wallet/src/shared/sentry-config.ts | 10 ++-- .../menu/content/WalletSettingsMenuList.tsx | 3 +- .../ui/app/pages/home/transfer-coin/index.tsx | 30 ++++++------ .../src/ui/app/staking/stake/StakingCard.tsx | 47 ++++++++++--------- apps/wallet/src/ui/index.tsx | 8 ++-- apps/wallet/webpack.config.ts | 1 + pnpm-lock.yaml | 2 +- sdk/.env.defaults | 1 + sdk/build-scripts/src/utils/buildPackage.ts | 1 + .../src/components/IotaClientProvider.tsx | 2 +- sdk/typescript/src/client/network.ts | 2 +- turbo.json | 3 +- 28 files changed, 115 insertions(+), 105 deletions(-) diff --git a/.github/workflows/apps_wallet_nightly_build.yml b/.github/workflows/apps_wallet_nightly_build.yml index 3a0a6230cc6..267b940df18 100644 --- a/.github/workflows/apps_wallet_nightly_build.yml +++ b/.github/workflows/apps_wallet_nightly_build.yml @@ -43,7 +43,7 @@ jobs: restore-keys: | turbo-${{ runner.os }}- - name: Build Wallet - run: pnpm wallet build + run: pnpm wallet build:nightly - name: Upload artifacts uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # pin@v4 with: diff --git a/.github/workflows/apps_wallet_prod_build.yml b/.github/workflows/apps_wallet_prod_build.yml index 24c4cecc424..964ee7d1411 100644 --- a/.github/workflows/apps_wallet_prod_build.yml +++ b/.github/workflows/apps_wallet_prod_build.yml @@ -9,6 +9,7 @@ env: DEFAULT_NETWORK: ${{ secrets.WALLET_PROD_DEFAULT_NETWORK }} IOTA_NETWORKS: ${{ secrets.WALLET_PROD_IOTA_NETWORKS }} APPS_BACKEND: ${{ secrets.WALLET_PROD_APPS_BACKEND }} + SENTRY_AUTH_TOKEN: ${{ secrets.TOOLING_SENTRY_AUTH_TOKEN }} jobs: wallet-prod-build: diff --git a/apps/explorer/.env.example b/apps/explorer/.env.example index 937e87f2502..bc49b982b26 100644 --- a/apps/explorer/.env.example +++ b/apps/explorer/.env.example @@ -1,5 +1 @@ VITE_SENTRY_SAMPLE_RATE=xxxxxxx -VITE_PROD_SENTRY_DSN=xxxxxxx -VITE_DEV_SENTRY_DSN=xxxxxxx -VITE_AMPLI_PROD_API_KEY=xxxxxxx -VITE_AMPLI_DEV_API_KEY=xxxxxxx diff --git a/apps/explorer/ampli.json b/apps/explorer/ampli.json index fbbe29cec6a..1a49df1166b 100644 --- a/apps/explorer/ampli.json +++ b/apps/explorer/ampli.json @@ -1,14 +1,14 @@ { - "Zone": "us", - "OrgId": "216883", - "WorkspaceId": "cee48712-5b35-403d-af7e-a46bf71ee2c7", - "SourceId": "f2439a98-2bcd-4e46-a2a5-38662eda6d51", + "Zone": "eu", + "OrgId": "100007351", + "WorkspaceId": "141ec983-01d0-4494-a140-3463d0a8ce27", + "SourceId": "ba177631-4a93-48e1-91f4-c45b3ac4d63f", + "Branch": "main", + "Version": "1.0.0", + "VersionId": "81db59d9-e06e-4c91-be42-e1b536a9f68a", "Runtime": "browser:typescript-ampli-v2", "Platform": "Browser", "Language": "TypeScript", "SDK": "@amplitude/analytics-browser@^1.0", - "Branch": "main", - "Version": "1.0.0", - "VersionId": "e04b8300-7375-4e37-a47e-7eb097e55c65", "Path": "./src/utils/analytics/ampli" } diff --git a/apps/explorer/src/components/activity/Activity.tsx b/apps/explorer/src/components/activity/Activity.tsx index d636538800d..9b324a3e8a8 100644 --- a/apps/explorer/src/components/activity/Activity.tsx +++ b/apps/explorer/src/components/activity/Activity.tsx @@ -72,7 +72,7 @@ export function Activity({ initialLimit, disablePagination }: ActivityProps): JS const refetchInterval = paused || !pollingTxnTableEnabled ? undefined : REFETCH_INTERVAL; // TODO remove network check when querying transactions with TransactionKind filter is fixed on devnet and testnet /*const [network] = useNetwork(); - const isTransactionKindFilterEnabled = Network.MAINNET === network || Network.LOCAL === network; + const isTransactionKindFilterEnabled = Network.Mainnet === network || Network.Localnet === network; const [showSystemTransactions, setShowSystemTransaction] = useState( !isTransactionKindFilterEnabled, ); diff --git a/apps/explorer/src/hooks/useEnhancedRpc.ts b/apps/explorer/src/hooks/useEnhancedRpc.ts index 7951f6fa2db..66a925e25e8 100644 --- a/apps/explorer/src/hooks/useEnhancedRpc.ts +++ b/apps/explorer/src/hooks/useEnhancedRpc.ts @@ -12,7 +12,7 @@ export function useEnhancedRpcClient(): IotaClient { const [network] = useNetwork(); const client = useIotaClient(); const enhancedRpc = useMemo(() => { - if (network === Network.Local) { + if (network === Network.Localnet) { return new IotaClient({ url: 'http://localhost:9124' }); } diff --git a/apps/explorer/src/lib/utils/analytics/ampli/index.ts b/apps/explorer/src/lib/utils/analytics/ampli/index.ts index 7b6f54c343e..b9ff9f6d2f4 100644 --- a/apps/explorer/src/lib/utils/analytics/ampli/index.ts +++ b/apps/explorer/src/lib/utils/analytics/ampli/index.ts @@ -26,8 +26,8 @@ import * as amplitude from '@amplitude/analytics-browser'; type Environment = 'production' | 'development'; export const ApiKey: Record = { - production: import.meta.env.VITE_AMPLI_PROD_API_KEY, - development: import.meta.env.VITE_AMPLI_DEV_API_KEY, + production: '896b9073219c06800d9bf0aecf1b6f80', + development: '253fa1582d8ed913d8c5957f601df3fe', }; /** @@ -38,7 +38,7 @@ export const DefaultConfiguration: BrowserOptions = { version: '1', branch: 'main', source: 'web', - versionId: 'e04b8300-7375-4e37-a47e-7eb097e55c65', + versionId: '81db59d9-e06e-4c91-be42-e1b536a9f68a', }, ...{ ingestionMetadata: { @@ -46,6 +46,7 @@ export const DefaultConfiguration: BrowserOptions = { sourceVersion: '2.0.0', }, }, + serverZone: amplitude.Types.ServerZone.EU, }; interface LoadOptionsBase { diff --git a/apps/explorer/src/lib/utils/api/defaultRpcClient.ts b/apps/explorer/src/lib/utils/api/defaultRpcClient.ts index 35d35f5cf1c..6ff779f0a50 100644 --- a/apps/explorer/src/lib/utils/api/defaultRpcClient.ts +++ b/apps/explorer/src/lib/utils/api/defaultRpcClient.ts @@ -29,7 +29,7 @@ export const createIotaClient = (network: NetworkId): IotaClient => { const client = new IotaClient({ transport: - supportedNetwork && network === Network.Mainnet + supportedNetwork && network === Network.Testnet // Sentry dev hint: change this to eg [Network.Localnet] ? new SentryHttpTransport(networkUrl) : new IotaHTTPTransport({ url: networkUrl }), }); diff --git a/apps/explorer/src/lib/utils/sentry.ts b/apps/explorer/src/lib/utils/sentry.ts index 95320908fca..e8c3f689aab 100644 --- a/apps/explorer/src/lib/utils/sentry.ts +++ b/apps/explorer/src/lib/utils/sentry.ts @@ -14,14 +14,14 @@ import { const SENTRY_ENABLED = import.meta.env.PROD; const SENTRY_SAMPLE_RATE = import.meta.env.VITE_SENTRY_SAMPLE_RATE ? parseFloat(import.meta.env.VITE_SENTRY_SAMPLE_RATE) - : 1; + : 0; export function initSentry() { Sentry.init({ enabled: SENTRY_ENABLED, dsn: import.meta.env.PROD - ? import.meta.env.VITE_PROD_SENTRY_DSN - : import.meta.env.VITE_DEV_SENTRY_DSN, + ? 'https://ce107602e4d122f0639332c7c43fdc08@o4508279186718720.ingest.de.sentry.io/4508279962140752' + : 'https://c8085701fa2650fb2a090ed6aba6bc62@o4508279186718720.ingest.de.sentry.io/4508279963320400', environment: import.meta.env.VITE_VERCEL_ENV, integrations: [ new Sentry.BrowserTracing({ @@ -56,10 +56,6 @@ export function initSentry() { /^chrome(?:-extension)?:\/\//i, //, ], - allowUrls: [ - /.*\.iota\.org/i, - /.*-iota-foundation\.vercel\.app/i, - 'explorer-topaz.vercel.app', - ], + allowUrls: [/.*\.iota\.org/i, /.*\.iota\.cafe/i, /.*\.iotaledger\.net/i], }); } diff --git a/apps/wallet/ampli.json b/apps/wallet/ampli.json index 8bc88266999..cfc15209913 100644 --- a/apps/wallet/ampli.json +++ b/apps/wallet/ampli.json @@ -1,14 +1,14 @@ { - "Zone": "us", - "OrgId": "216883", - "WorkspaceId": "d08bae31-a74f-45c2-985d-2f5dc943b2ea", - "SourceId": "409326bd-fc3f-453e-9275-0bab406831d2", - "Branch": "main", - "Version": "3.0.0", - "VersionId": "e417ca76-bc93-4e57-b900-d5cd7c4b033c", + "Zone": "eu", + "OrgId": "100007351", + "WorkspaceId": "114d6e91-e23e-4185-9235-5d8bf8fac617", + "SourceId": "0bdd0a01-5a4b-4659-86b6-9413d1341b4e", "Runtime": "browser:typescript-ampli-v2", "Platform": "Browser", "Language": "TypeScript", "SDK": "@amplitude/analytics-browser@^1.0", + "Branch": "main", + "Version": "1.0.0", + "VersionId": "bc7a9c07-e259-439c-b48c-026b16a8a548", "Path": "./src/shared/analytics/ampli" } diff --git a/apps/wallet/configs/webpack/webpack.config.common.ts b/apps/wallet/configs/webpack/webpack.config.common.ts index 1131e6c99d1..fc6a86ceeb8 100644 --- a/apps/wallet/configs/webpack/webpack.config.common.ts +++ b/apps/wallet/configs/webpack/webpack.config.common.ts @@ -25,10 +25,17 @@ const CONFIGS_ROOT = resolve(PROJECT_ROOT, 'configs'); const SRC_ROOT = resolve(PROJECT_ROOT, 'src'); const OUTPUT_ROOT = resolve(PROJECT_ROOT, 'dist'); const TS_CONFIGS_ROOT = resolve(CONFIGS_ROOT, 'ts'); +const IS_NIGHTLY = process.env.NODE_ENV === 'nightly'; const IS_DEV = process.env.NODE_ENV === 'development'; const IS_PROD = process.env.NODE_ENV === 'production'; const TS_CONFIG_FILE = resolve(TS_CONFIGS_ROOT, `tsconfig.${IS_DEV ? 'dev' : 'prod'}.json`); -const APP_NAME = WALLET_RC ? 'IOTA Wallet (RC)' : IS_DEV ? 'IOTA Wallet (DEV)' : 'IOTA Wallet'; +const APP_NAME = WALLET_RC + ? 'IOTA Wallet (RC)' + : IS_DEV + ? 'IOTA Wallet (DEV)' + : IS_NIGHTLY + ? 'IOTA Wallet (Nightly)' + : 'IOTA Wallet'; dotenv.config({ path: [resolve(SDK_ROOT, '.env'), resolve(SDK_ROOT, '.env.defaults')], @@ -227,13 +234,14 @@ const commonConfig: () => Promise = async () => { 'process.env.DEFAULT_NETWORK': JSON.stringify(process.env.DEFAULT_NETWORK), 'process.env.IOTA_NETWORKS': JSON.stringify(process.env.IOTA_NETWORKS), 'process.env.APPS_BACKEND': JSON.stringify(process.env.APPS_BACKEND), + 'process.env.SENTRY_AUTH_TOKEN': JSON.stringify(process.env.SENTRY_AUTH_TOKEN), }), new ProvidePlugin({ Buffer: ['buffer', 'Buffer'], }), new SentryWebpackPlugin({ - org: 'iota-foundation', - project: 'wallet', + org: 'iota-foundation-eu', + project: 'iota-wallet', // Sentry dev hint: use 'iota-wallet-dev' project for testing include: OUTPUT_ROOT, dryRun: !IS_PROD || !sentryAuthToken, authToken: sentryAuthToken, diff --git a/apps/wallet/package.json b/apps/wallet/package.json index e07146dcca0..06e3d0ec6d4 100644 --- a/apps/wallet/package.json +++ b/apps/wallet/package.json @@ -9,6 +9,7 @@ "build:prod": "cross-env NODE_ENV=\"production\" TS_NODE_PROJECT=\"./configs/ts/tsconfig.webpack.json\" webpack --progress", "build:dev": "cross-env NODE_ENV=\"development\" TS_NODE_PROJECT=\"./configs/ts/tsconfig.webpack.json\" webpack --progress", "build:rc": "cross-env WALLET_RC=true NODE_ENV=\"production\" TS_NODE_PROJECT=\"./configs/ts/tsconfig.webpack.json\" webpack --progress", + "build:nightly": "cross-env NODE_ENV=\"nightly\" TS_NODE_PROJECT=\"./configs/ts/tsconfig.webpack.json\" webpack --progress", "prettier:check": "prettier -c --ignore-unknown --ignore-path=../../.prettierignore --ignore-path=.prettierignore .", "prettier:fix": "prettier -w --ignore-unknown --ignore-path=../../.prettierignore --ignore-path=.prettierignore .", "prettier:fix:watch": "onchange '**' -i -f add -f change -j 5 -- prettier -w --ignore-unknown --ignore-path=../../.prettierignore --ignore-path=.prettierignore {{file}}", @@ -43,7 +44,7 @@ "@amplitude/analytics-types": "^0.20.0", "@playwright/test": "^1.46.1", "@sentry/react": "^7.59.2", - "@sentry/webpack-plugin": "^1.20.0", + "@sentry/webpack-plugin": "^1.21.0", "@svgr/webpack": "^7.0.0", "@types/git-rev-sync": "^2.0.0", "@types/node": "^20.14.10", diff --git a/apps/wallet/src/background/index.ts b/apps/wallet/src/background/index.ts index 11beed3f9cc..338679105f2 100644 --- a/apps/wallet/src/background/index.ts +++ b/apps/wallet/src/background/index.ts @@ -15,13 +15,13 @@ import Alarms, { AUTO_LOCK_ALARM_NAME, CLEAN_UP_ALARM_NAME } from './Alarms'; import { Connections } from './connections'; import NetworkEnv from './NetworkEnv'; import Permissions from './Permissions'; -// import { initSentry } from './sentry'; +import { initSentry } from './sentry'; import Transactions from './Transactions'; growthbook.loadFeatures().catch(() => { // silence the error }); -// initSentry(); +initSentry(); Browser.runtime.onInstalled.addListener(async ({ reason, previousVersion }) => { // Skip automatically opening the onboarding in end-to-end tests. diff --git a/apps/wallet/src/shared/analytics/ampli/index.ts b/apps/wallet/src/shared/analytics/ampli/index.ts index 95be5cc179e..d3df2009344 100644 --- a/apps/wallet/src/shared/analytics/ampli/index.ts +++ b/apps/wallet/src/shared/analytics/ampli/index.ts @@ -26,8 +26,8 @@ import * as amplitude from '@amplitude/analytics-browser'; export type Environment = 'production' | 'development'; const API_KEY: Record = { - production: '05c63856469c4e1d4aa9a6c1b2298d3b', - development: '938968357fcb3bf031d27b5049f62449', + production: '2a5d35822a1bab41835813f0223f319e', + development: '30a15c4ef8ae0e10ce5d2ed4f0023de3', }; /** @@ -35,10 +35,10 @@ const API_KEY: Record = { */ const DEFAULT_CONFIGURATION: BrowserOptions = { plan: { - version: '3', + version: '1', branch: 'main', source: 'web', - versionId: 'e417ca76-bc93-4e57-b900-d5cd7c4b033c', + versionId: 'ca799820-3dab-4797-bf37-22ff7cc67e78', }, ...{ ingestionMetadata: { @@ -46,6 +46,7 @@ const DEFAULT_CONFIGURATION: BrowserOptions = { sourceVersion: '2.0.0', }, }, + serverZone: amplitude.Types.ServerZone.EU, }; export interface LoadOptionsBase { @@ -635,11 +636,11 @@ export class Ampli { } private isInitializedAndEnabled(): boolean { - // if (!this.amplitude) { - // console.error('ERROR: Ampli is not yet initialized. Have you called ampli.load() on app start?'); - // return false; - // } - return false; + if (!this.amplitude) { + console.error('ERROR: Ampli is not yet initialized. Have you called ampli.load() on app start?'); + return false; + } + return !this.disabled; } /** diff --git a/apps/wallet/src/shared/analytics/amplitude.ts b/apps/wallet/src/shared/analytics/amplitude.ts index c6ed6da31e4..601371ab517 100644 --- a/apps/wallet/src/shared/analytics/amplitude.ts +++ b/apps/wallet/src/shared/analytics/amplitude.ts @@ -32,9 +32,9 @@ export async function initAmplitude() { } export function getUrlWithDeviceId(url: URL) { - // const amplitudeDeviceId = ampli.client.getDeviceId(); - // if (amplitudeDeviceId) { - // url.searchParams.append('deviceId', amplitudeDeviceId); - // } + const amplitudeDeviceId = ampli.client.getDeviceId(); + if (amplitudeDeviceId) { + url.searchParams.append('deviceId', amplitudeDeviceId); + } return url; } diff --git a/apps/wallet/src/shared/iota-client.ts b/apps/wallet/src/shared/iota-client.ts index 85904c928ec..fc698db5364 100644 --- a/apps/wallet/src/shared/iota-client.ts +++ b/apps/wallet/src/shared/iota-client.ts @@ -8,7 +8,7 @@ import { SentryHttpTransport } from '@iota/core'; import { getNetwork, Network, IotaClient, IotaHTTPTransport } from '@iota/iota-sdk/client'; const iotaClientPerNetwork = new Map(); -const SENTRY_MONITORED_ENVS = [Network.Custom]; +const SENTRY_MONITORED_ENVS = [Network.Testnet]; // Sentry dev hint: change this to eg [Network.Localnet] export function getIotaClient({ network, customRpcUrl }: NetworkEnvType): IotaClient { const key = `${network}_${customRpcUrl}`; diff --git a/apps/wallet/src/shared/sentry-config.ts b/apps/wallet/src/shared/sentry-config.ts index 3705ead4aa8..8e5bd57deb2 100644 --- a/apps/wallet/src/shared/sentry-config.ts +++ b/apps/wallet/src/shared/sentry-config.ts @@ -8,12 +8,12 @@ import Browser from 'webextension-polyfill'; const WALLET_VERSION = Browser.runtime.getManifest().version; const IS_PROD = process.env.NODE_ENV === 'production'; -// NOTE: If you want to enable sentry in dev, you can tweak this value: +// Sentry dev hint: If you want to enable sentry in dev, you can tweak this value: const ENABLE_SENTRY = IS_PROD; const SENTRY_DSN = IS_PROD - ? 'https://e52a4e5c90224fe0800cc96aa2570581@o1314142.ingest.sentry.io/6761112' - : 'https://d1022411f6284cab9660146f3aa514d2@o1314142.ingest.sentry.io/4504697974751232'; + ? 'https://36e3e3c59a2e842034b2fc624103b72a@o4508279186718720.ingest.de.sentry.io/4508279958536272' + : 'https://36c25e34e606cac787b1536348101976@o4508279186718720.ingest.de.sentry.io/4508279960895568'; export function getSentryConfig({ integrations, @@ -27,8 +27,8 @@ export function getSentryConfig({ tracesSampler: IS_PROD ? tracesSampler : () => 1, allowUrls: IS_PROD ? [ - 'ehndjpedolgphielnhnpnkomdhgpaaei', // chrome beta - 'opcgpfmipidbgpenhmajoajpbobppdil', // chrome prod + 'nlmllpflpelpannpijhhnbhekpbpejch', // chrome rc + 'iidjkmdceolghepehaaddojmnjnkkija', // chrome prod ] : undefined, }; diff --git a/apps/wallet/src/ui/app/components/menu/content/WalletSettingsMenuList.tsx b/apps/wallet/src/ui/app/components/menu/content/WalletSettingsMenuList.tsx index dc706541a6d..75410062488 100644 --- a/apps/wallet/src/ui/app/components/menu/content/WalletSettingsMenuList.tsx +++ b/apps/wallet/src/ui/app/components/menu/content/WalletSettingsMenuList.tsx @@ -28,6 +28,7 @@ import { CardType, ImageType, } from '@iota/apps-ui-kit'; +import { ampli } from '_src/shared/analytics/ampli'; function MenuList() { const navigate = useNavigate(); @@ -46,7 +47,7 @@ function MenuList() { const logoutMutation = useMutation({ mutationKey: ['logout', 'clear wallet'], mutationFn: async () => { - // ampli.client.reset(); + ampli.client.reset(); queryClient.cancelQueries(); queryClient.clear(); await persister.removeClient(); diff --git a/apps/wallet/src/ui/app/pages/home/transfer-coin/index.tsx b/apps/wallet/src/ui/app/pages/home/transfer-coin/index.tsx index 111017d0bb0..2a7cea08f5f 100644 --- a/apps/wallet/src/ui/app/pages/home/transfer-coin/index.tsx +++ b/apps/wallet/src/ui/app/pages/home/transfer-coin/index.tsx @@ -14,7 +14,7 @@ import { useCoinMetadata, useFormatCoin, } from '@iota/core'; -// import * as Sentry from '@sentry/react'; +import * as Sentry from '@sentry/react'; import { useMutation, useQueryClient } from '@tanstack/react-query'; import { useMemo, useState } from 'react'; import { toast } from 'react-hot-toast'; @@ -56,22 +56,22 @@ function TransferCoinPage() { if (!transaction || !signer) { throw new Error('Missing data'); } - - // const sentryTransaction = Sentry.startTransaction({ - // name: 'send-tokens', - // }); - return signer.signAndExecuteTransaction({ - transactionBlock: transaction, - options: { - showInput: true, - showEffects: true, - showEvents: true, - }, + const sentryTransaction = Sentry.startTransaction({ + name: 'send-tokens', }); - // finally { - // sentryTransaction.finish(); - // } + try { + return signer.signAndExecuteTransaction({ + transactionBlock: transaction, + options: { + showInput: true, + showEffects: true, + showEvents: true, + }, + }); + } finally { + sentryTransaction.finish(); + } }, onSuccess: (response) => { queryClient.invalidateQueries({ queryKey: ['get-coins'] }); diff --git a/apps/wallet/src/ui/app/staking/stake/StakingCard.tsx b/apps/wallet/src/ui/app/staking/stake/StakingCard.tsx index fb57a73e846..4505b554303 100644 --- a/apps/wallet/src/ui/app/staking/stake/StakingCard.tsx +++ b/apps/wallet/src/ui/app/staking/stake/StakingCard.tsx @@ -19,7 +19,7 @@ import { import { useIotaClientQuery } from '@iota/dapp-kit'; import type { StakeObject } from '@iota/iota-sdk/client'; import { NANOS_PER_IOTA, IOTA_TYPE_ARG } from '@iota/iota-sdk/utils'; -// import * as Sentry from '@sentry/react'; +import * as Sentry from '@sentry/react'; import { useMutation, useQueryClient } from '@tanstack/react-query'; import { Formik } from 'formik'; import type { FormikHelpers } from 'formik'; @@ -117,9 +117,9 @@ function StakingCard() { throw new Error('Failed, missing required field'); } - // const sentryTransaction = Sentry.startTransaction({ - // name: 'stake', - // }); + const sentryTransaction = Sentry.startTransaction({ + name: 'stake', + }); try { const transactionBlock = createStakeTransaction(amount, validatorAddress); const tx = await signer.signAndExecuteTransaction({ @@ -135,7 +135,7 @@ function StakingCard() { }); return tx; } finally { - // sentryTransaction.finish(); + sentryTransaction.finish(); } }, onSuccess: (_, { amount, validatorAddress }) => { @@ -153,25 +153,26 @@ function StakingCard() { throw new Error('Failed, missing required field.'); } - // const sentryTransaction = Sentry.startTransaction({ - // name: 'stake', - // }); - const transactionBlock = createUnstakeTransaction(stakedIotaId); - const tx = await signer.signAndExecuteTransaction({ - transactionBlock, - options: { - showInput: true, - showEffects: true, - showEvents: true, - }, - }); - await signer.client.waitForTransaction({ - digest: tx.digest, + const sentryTransaction = Sentry.startTransaction({ + name: 'stake', }); - return tx; - // finally { - // sentryTransaction.finish(); - // } + try { + const transactionBlock = createUnstakeTransaction(stakedIotaId); + const tx = await signer.signAndExecuteTransaction({ + transactionBlock, + options: { + showInput: true, + showEffects: true, + showEvents: true, + }, + }); + await signer.client.waitForTransaction({ + digest: tx.digest, + }); + return tx; + } finally { + sentryTransaction.finish(); + } }, onSuccess: () => { ampli.unstakedIota({ diff --git a/apps/wallet/src/ui/index.tsx b/apps/wallet/src/ui/index.tsx index 8f5d321ecac..49dff3a6b7d 100644 --- a/apps/wallet/src/ui/index.tsx +++ b/apps/wallet/src/ui/index.tsx @@ -8,9 +8,9 @@ import '@fontsource-variable/red-hat-mono'; import { ErrorBoundary } from '_components'; import { initAppType } from '_redux/slices/app'; import { AppType, getFromLocationSearch } from '_redux/slices/app/AppType'; -// import { initAmplitude } from '_src/shared/analytics/amplitude'; +import { initAmplitude } from '_src/shared/analytics/amplitude'; import { setAttributes } from '_src/shared/experimentation/features'; -// import initSentry from '_src/ui/app/helpers/sentry'; +import initSentry from '_src/ui/app/helpers/sentry'; import store from '_store'; import { thunkExtras } from '_store/thunk-extras'; import { KioskClientProvider } from '@iota/core'; @@ -123,7 +123,7 @@ function AppWrapper() { (async () => { await init(); - // initSentry(); - // initAmplitude(); + initSentry(); + initAmplitude(); renderApp(); })(); diff --git a/apps/wallet/webpack.config.ts b/apps/wallet/webpack.config.ts index c7221ee324e..aefc092fdb5 100644 --- a/apps/wallet/webpack.config.ts +++ b/apps/wallet/webpack.config.ts @@ -10,6 +10,7 @@ import configProd from './configs/webpack/webpack.config.prod'; const configMap: Record Promise> = { development: configDev, production: configProd, + nightly: configProd, }; const nodeEnv: string = process.env.NODE_ENV || ''; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 13aeddf218c..8255e037e8d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -866,7 +866,7 @@ importers: specifier: ^7.59.2 version: 7.119.0(react@18.3.1) '@sentry/webpack-plugin': - specifier: ^1.20.0 + specifier: ^1.21.0 version: 1.21.0 '@svgr/webpack': specifier: ^7.0.0 diff --git a/sdk/.env.defaults b/sdk/.env.defaults index 4b1dd6b6ee6..420be36c64d 100644 --- a/sdk/.env.defaults +++ b/sdk/.env.defaults @@ -1,5 +1,6 @@ DEFAULT_NETWORK = 'localnet' APPS_BACKEND = 'http://localhost:3003' +SENTRY_AUTH_TOKEN= IOTA_NETWORKS = ' { diff --git a/sdk/build-scripts/src/utils/buildPackage.ts b/sdk/build-scripts/src/utils/buildPackage.ts index 006627c013e..84c7d386c1b 100755 --- a/sdk/build-scripts/src/utils/buildPackage.ts +++ b/sdk/build-scripts/src/utils/buildPackage.ts @@ -62,6 +62,7 @@ async function embedIOTAEnvVars() { 'process.env.DEFAULT_NETWORK': JSON.stringify(process.env['DEFAULT_NETWORK']), 'process.env.IOTA_NETWORKS': JSON.stringify(process.env['IOTA_NETWORKS']), 'process.env.APPS_BACKEND': JSON.stringify(process.env['APPS_BACKEND']), + 'process.env.SENTRY_AUTH_TOKEN': JSON.stringify(process.env['SENTRY_AUTH_TOKEN']), }; } diff --git a/sdk/dapp-kit/src/components/IotaClientProvider.tsx b/sdk/dapp-kit/src/components/IotaClientProvider.tsx index 4f9d149dbbc..3f53437956f 100644 --- a/sdk/dapp-kit/src/components/IotaClientProvider.tsx +++ b/sdk/dapp-kit/src/components/IotaClientProvider.tsx @@ -40,7 +40,7 @@ export type IotaClientProviderProps = { ); const DEFAULT_NETWORKS = { - localnet: { url: getNetwork(Network.Local).url }, + localnet: { url: getNetwork(Network.Localnet).url }, }; const DEFAULT_CREATE_CLIENT = function createClient( diff --git a/sdk/typescript/src/client/network.ts b/sdk/typescript/src/client/network.ts index 74050ea72af..cbe06abc203 100644 --- a/sdk/typescript/src/client/network.ts +++ b/sdk/typescript/src/client/network.ts @@ -6,7 +6,7 @@ export enum Network { Mainnet = 'mainnet', Devnet = 'devnet', Testnet = 'testnet', - Local = 'local', + Localnet = 'localnet', Custom = 'custom', } diff --git a/turbo.json b/turbo.json index 0035645487c..6a6c3592c3d 100644 --- a/turbo.json +++ b/turbo.json @@ -50,7 +50,8 @@ "DEFAULT_NETWORK", "IOTA_NETWORKS", "RC_VERSION", - "APPS_BACKEND" + "APPS_BACKEND", + "SENTRY_AUTH_TOKEN" ], "globalDependencies": [ ".eslintrc.js",