chore: improve monitoring for fix: guard links open action against invalid absol
Added code-level monitoring for prevented invalid link-open attempts, at warning level, instead of letting them surface as uncaught runtime errors. What changed: - Added `captureInvalidLinksFieldUrlOpenAttempt` utility that reports a Sentry warning (`captureMessage`) with scoped metadata: - `fieldName` - `recordId` - `urlLength` - `hasProtocol` - The LINKS click handler now invokes this monitor when validation fails. Why: - Improves triage for malformed link data patterns without crashing the user flow. - Uses warning-level signal for data-quality/user-input issues instead of noisy uncaught exception noise.
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
type CaptureInvalidLinksFieldUrlOpenAttemptArgs = {
|
||||
fieldName: string;
|
||||
recordId: string;
|
||||
url: string;
|
||||
};
|
||||
|
||||
export const captureInvalidLinksFieldUrlOpenAttempt = async ({
|
||||
fieldName,
|
||||
recordId,
|
||||
url,
|
||||
}: CaptureInvalidLinksFieldUrlOpenAttemptArgs) => {
|
||||
try {
|
||||
const { captureMessage, withScope } = await import('@sentry/react');
|
||||
|
||||
withScope((scope) => {
|
||||
scope.setLevel('warning');
|
||||
scope.setTag('feature', 'record-table-cell-secondary-action');
|
||||
scope.setContext('invalidLinksFieldUrlOpenAttempt', {
|
||||
fieldName,
|
||||
hasProtocol: /^\w+:/.test(url),
|
||||
recordId,
|
||||
urlLength: url.length,
|
||||
});
|
||||
|
||||
captureMessage('Invalid links field URL prevented from opening');
|
||||
|
||||
return scope;
|
||||
});
|
||||
} catch (error) {
|
||||
// oxlint-disable-next-line no-console
|
||||
console.warn('Failed to capture invalid links field URL open attempt:', error);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user