OUT-3542: add Sentry context tags, breadcrumbs, and error categorization#215
Open
SandipBajracharya wants to merge 3 commits intomasterfrom
Open
OUT-3542: add Sentry context tags, breadcrumbs, and error categorization#215SandipBajracharya wants to merge 3 commits intomasterfrom
SandipBajracharya wants to merge 3 commits intomasterfrom
Conversation
…orization Enrich Sentry error reports with structured context for easier debugging: - Add portalId, workspaceId, entityType, eventType, errorCategory tags - Add sync breadcrumbs at key decision points (invoice/customer/product/payment flows) - Expand FailedRecordCategoryType with RATE_LIMIT, VALIDATION, QB_API_ERROR, MAPPING_NOT_FOUND - Enhance error source tracking (intuit/copilot) in getMessageAndCodeFromError - Isolate Sentry scope per portal in Trigger.dev cron flow to prevent breadcrumb bleed - Fix ANSI color codes leaking into Vercel/New Relic logs Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…dcrumb capture Move captureMessage from checkAndUpdateAttempt (before processing) to intiateSync (after processing) so breadcrumbs from the actual execution path are included in the Sentry event. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Only fire Sentry threshold report if record is still FAILED after final attempt (prevents spurious alerts on successful last retry) - Use Sentry.withScope in webhook controller to isolate tags per request (prevents portalId contamination in concurrent webhooks) - Skip setting errorSource tag when value is 'unknown' (reduces noise) - Use actual booleans in breadcrumb data instead of string 'true'/'false' Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
priosshrsth
approved these changes
Apr 9, 2026
Collaborator
priosshrsth
left a comment
There was a problem hiding this comment.
@SandipBajracharya couple of comments. But overall good job.
Comment on lines
+31
to
+39
| // check if token is valid or not | ||
| const copilot = new CopilotAPI(token) | ||
| const tokenPayload = await copilot.getTokenPayload() | ||
| CustomLogger.info({ | ||
| obj: { copilotApiCronToken: token, tokenPayload }, | ||
| message: | ||
| 'CronService#_scheduleSinglePortal | Copilot API token and payload', | ||
| }) | ||
| if (!tokenPayload) throw new APIError(500, 'Encoded token is not valid') // this should trigger p-retry and re-run the function |
Collaborator
There was a problem hiding this comment.
What we are doing here seems so wrong. I think we either set process.env.ASSEMBLY_ENV=local before line 32 and unset it after line 32. Or just use endpoints without sdks for cron. But looks like our whole flow is setup to require token. So I guess we are stuck with it.
| info({ message, obj }: { message: string; obj?: any }) { | ||
| const consoleBody = [message] | ||
| if (obj) consoleBody.push(util.inspect(obj, { depth: null, colors: true })) | ||
| if (obj) consoleBody.push(util.inspect(obj, { depth: null, colors: isDev })) |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
portalId,workspaceId,entityType,eventType,errorCategorytags to all Sentry error reports for dashboard filteringFailedRecordCategoryTypewithRATE_LIMIT,VALIDATION,QB_API_ERROR,MAPPING_NOT_FOUNDfor finer error categorizationwithErrorHandlerto capture errors with category and source tags viaSentry.withScopeintuit/copilot) togetMessageAndCodeFromErrorfor accurate QB API error detectionCronService._scheduleSinglePortal) to prevent breadcrumb/tag bleed across portalscaptureMessageincheckAndUpdateAttemptwith full context tags (portalId,entityType,eventType,errorCategory) and extras (invoiceNumber,errorMessage,attempt)[32m/[39m) leaking into Vercel/New Relic logs by disabling colors in non-dev environmentsDB Migration
Adds 4 new values to
failed_record_category_typesPostgreSQL enum:Additive only — existing records and the
othersdefault are unaffected.Test plan
yarn buildpassesSELECT enum_range(NULL::failed_record_category_types)returns all 7 valuesportalIdandentityTypetagscaptureMessageincludes enriched tags/extras🤖 Generated with Claude Code