|
1 | | -import { captureException, setContext, setUser } from "@sentry/node"; |
| 1 | +import { captureException, setContext, setUser, withScope } from "@sentry/node"; |
2 | 2 | import { Mutex } from "async-mutex"; |
3 | 3 | import { eq, inArray, ne } from "drizzle-orm"; |
4 | 4 | import { Hono } from "hono"; |
@@ -221,16 +221,23 @@ function decrypt(base64Secret: string, base64Iv: string, secretKey: string): str |
221 | 221 | if (!issue) throw error; |
222 | 222 | const shouldCapture = issue.type === "NotFoundError" || status === "ACTIVE"; |
223 | 223 | if (shouldCapture) { |
224 | | - captureException(issue.error, { |
225 | | - level: "warning", |
226 | | - extra: { |
227 | | - cardId: id, |
228 | | - credentialId, |
229 | | - pandaId: credential.pandaId, |
230 | | - status, |
231 | | - shouldCapture, |
232 | | - userIssue: issue.type, |
233 | | - }, |
| 224 | + withScope((scope) => { |
| 225 | + scope.addEventProcessor((event) => { |
| 226 | + if (event.exception?.values?.[0]) event.exception.values[0].type = issue.type; |
| 227 | + return event; |
| 228 | + }); |
| 229 | + captureException(issue.error, { |
| 230 | + level: "warning", |
| 231 | + fingerprint: ["{{ default }}", issue.type], |
| 232 | + extra: { |
| 233 | + cardId: id, |
| 234 | + credentialId, |
| 235 | + pandaId: credential.pandaId, |
| 236 | + status, |
| 237 | + shouldCapture, |
| 238 | + userIssue: issue.type, |
| 239 | + }, |
| 240 | + }); |
234 | 241 | }); |
235 | 242 | } |
236 | 243 | return null; |
@@ -386,15 +393,22 @@ function decrypt(base64Secret: string, base64Iv: string, secretKey: string): str |
386 | 393 | const hasCardHistory = credential.cards.length > 0; |
387 | 394 | const shouldCapture = issue.type === "NotFoundError" || hasCardHistory; |
388 | 395 | if (shouldCapture) { |
389 | | - captureException(issue.error, { |
390 | | - level: "warning", |
391 | | - extra: { |
392 | | - credentialId, |
393 | | - hasCardHistory, |
394 | | - pandaId: credential.pandaId, |
395 | | - statuses: credential.cards.map(({ status }) => status), |
396 | | - userIssue: issue.type, |
397 | | - }, |
| 396 | + withScope((scope) => { |
| 397 | + scope.addEventProcessor((event) => { |
| 398 | + if (event.exception?.values?.[0]) event.exception.values[0].type = issue.type; |
| 399 | + return event; |
| 400 | + }); |
| 401 | + captureException(issue.error, { |
| 402 | + level: "warning", |
| 403 | + fingerprint: ["{{ default }}", issue.type], |
| 404 | + extra: { |
| 405 | + credentialId, |
| 406 | + hasCardHistory, |
| 407 | + pandaId: credential.pandaId, |
| 408 | + statuses: credential.cards.map(({ status }) => status), |
| 409 | + userIssue: issue.type, |
| 410 | + }, |
| 411 | + }); |
398 | 412 | }); |
399 | 413 | } |
400 | 414 | return c.json({ code: "no panda" }, 403); |
@@ -588,8 +602,22 @@ function handlePlatinumUpgrade(credentialId: string, account: InferOutput<typeof |
588 | 602 | }) |
589 | 603 | .catch((error: unknown) => { |
590 | 604 | const isPaxConfigError = error instanceof Error && error.message.includes("missing pax"); |
| 605 | + if (isPaxConfigError) { |
| 606 | + withScope((scope) => { |
| 607 | + scope.addEventProcessor((event) => { |
| 608 | + if (event.exception?.values?.[0]) event.exception.values[0].type = "missing pax"; |
| 609 | + return event; |
| 610 | + }); |
| 611 | + captureException(error, { |
| 612 | + level: "warning", |
| 613 | + fingerprint: ["{{ default }}", "missing pax"], |
| 614 | + extra: { credentialId, account, productId: SIGNATURE_PRODUCT_ID, scope: "basic", isPaxConfigError }, |
| 615 | + }); |
| 616 | + }); |
| 617 | + return; |
| 618 | + } |
591 | 619 | captureException(error, { |
592 | | - level: isPaxConfigError ? "warning" : "error", |
| 620 | + level: "error", |
593 | 621 | extra: { credentialId, account, productId: SIGNATURE_PRODUCT_ID, scope: "basic", isPaxConfigError }, |
594 | 622 | }); |
595 | 623 | }); |
|
0 commit comments