Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tooling): Update usage of Sentry deprecated methods #4786

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions apps/core/src/api/SentryHttpTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,30 @@ export class SentryHttpTransport extends IotaHTTPTransport {
}

async withRequest<T>(input: { method: string; params: unknown[] }, handler: () => Promise<T>) {
const transaction = Sentry.startTransaction({
name: input.method,
op: 'http.rpc-request',
data: input.params,
tags: {
url: this.url,
return Sentry.startSpan(
{
name: input.method,
op: 'http.rpc-request',
data: input.params,
tags: {
url: this.url,
},
},
});

try {
const res = await handler();
const status: Sentry.SpanStatusType = 'ok';
transaction.setStatus(status);
return res;
} catch (e) {
const status: Sentry.SpanStatusType = 'internal_error';
transaction.setStatus(status);
throw e;
} finally {
transaction.finish();
}
async (span) => {
try {
const res = await handler();
const status: Sentry.SpanStatusType = 'ok';
span?.setStatus(status);
return res;
} catch (e) {
const status: Sentry.SpanStatusType = 'internal_error';
span?.setStatus(status);
throw e;
} finally {
span?.end();
}
},
);
}

override async request<T>(input: { method: string; params: unknown[] }) {
Expand Down
14 changes: 6 additions & 8 deletions apps/explorer/src/lib/utils/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ export function initSentry() {
: 'https://c8085701fa2650fb2a090ed6aba6bc62@o4508279186718720.ingest.de.sentry.io/4508279963320400',
environment: import.meta.env.VITE_VERCEL_ENV,
integrations: [
new Sentry.BrowserTracing({
routingInstrumentation: Sentry.reactRouterV6Instrumentation(
useEffect,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes,
),
Sentry.reactRouterV6BrowserTracingIntegration({
useEffect,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes,
}),
],
tracesSampleRate: SENTRY_SAMPLE_RATE,
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet/src/ui/app/helpers/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getSentryConfig } from '../../../shared/sentryConfig';
export function initSentry() {
Sentry.init(
getSentryConfig({
integrations: [new Sentry.BrowserTracing()],
integrations: [Sentry.browserTracingIntegration()],
tracesSampler: () => {
return growthbook.getFeatureValue(Feature.WalletSentryTracing, 0);
},
Expand Down
35 changes: 19 additions & 16 deletions apps/wallet/src/ui/app/pages/home/transfer-coin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,25 @@ export function TransferCoinPage() {
if (!transaction || !signer) {
throw new Error('Missing data');
}
const sentryTransaction = Sentry.startTransaction({
name: 'send-tokens',
});

try {
return signer.signAndExecuteTransaction({
transactionBlock: transaction,
options: {
showInput: true,
showEffects: true,
showEvents: true,
},
});
} finally {
sentryTransaction.finish();
}
return Sentry.startSpan(
{
name: 'send-tokens',
},
(span) => {
try {
return signer.signAndExecuteTransaction({
transactionBlock: transaction,
options: {
showInput: true,
showEffects: true,
showEvents: true,
},
});
} finally {
span?.end();
}
},
);
},
onSuccess: (response) => {
queryClient.invalidateQueries({ queryKey: ['get-coins'] });
Expand Down
91 changes: 51 additions & 40 deletions apps/wallet/src/ui/app/staking/stake/StakingCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,26 +120,33 @@ export function StakingCard() {
throw new Error('Failed, missing required field');
}

const sentryTransaction = Sentry.startTransaction({
name: 'stake',
});
try {
const transactionBlock = createStakeTransaction(amount, validatorAddress);
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();
}
return Sentry.startSpan(
{
name: 'stake',
},
async (span) => {
try {
const transactionBlock = createStakeTransaction(
amount,
validatorAddress,
);
const tx = await signer.signAndExecuteTransaction({
transactionBlock,
options: {
showInput: true,
showEffects: true,
showEvents: true,
},
});
await signer.client.waitForTransaction({
digest: tx.digest,
});
return tx;
} finally {
span?.end();
}
},
);
},
onSuccess: (_, { amount, validatorAddress }) => {
ampli.stakedIota({
Expand All @@ -156,26 +163,30 @@ export function StakingCard() {
throw new Error('Failed, missing required field.');
}

const sentryTransaction = Sentry.startTransaction({
name: 'stake',
});
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();
}
return Sentry.startSpan(
{
name: 'stake',
},
async (span) => {
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 {
span?.end();
}
},
);
},
onSuccess: () => {
ampli.unstakedIota({
Expand Down
Loading