-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(core): Record callback_error client reports for throwing user callbacks
#23903
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ import type { Event, EventHint } from '../types/event'; | |
| import type { ClientOptions } from '../types/options'; | ||
| import type { StackParser } from '../types/stacktrace'; | ||
| import { getFilenameToDebugIdMap } from './debug-ids'; | ||
| import { getDataCategoryByType } from './envelope'; | ||
| import { addExceptionMechanismToCapturedException, uuid4 } from './misc'; | ||
| import { normalize } from './normalize'; | ||
| import { applyScopeDataToEvent, applySpanToEvent, getCombinedScopeData } from './scopeData'; | ||
|
|
@@ -36,7 +37,8 @@ export type ExclusiveEventHintOrCaptureContext = | |
| * @param event The original event. | ||
| * @param hint May contain additional information about the original exception. | ||
| * @param scope A scope containing event metadata. | ||
| * @returns A new event with more information. | ||
| * @returns A new event with more information, or `null` if an event processor dropped it (or threw). In that case the | ||
| * drop has already been recorded on the client, so callers must not record it again. | ||
| * @hidden | ||
| */ | ||
| export function prepareEvent( | ||
|
|
@@ -102,19 +104,30 @@ export function prepareEvent( | |
| // Skip event processors for internal exceptions to prevent recursion | ||
| // oxlint-disable-next-line typescript/prefer-optional-chain | ||
| const isInternalException = hint.data && (hint.data as { __sentry__: boolean }).__sentry__ === true; | ||
| const result = isInternalException | ||
| const result: PromiseLike<Event | null> = isInternalException | ||
| ? resolvedSyncPromise(prepared) | ||
| : notifyEventProcessors(eventProcessors, prepared, hint); | ||
| : notifyEventProcessors(eventProcessors, prepared, hint, 0, reason => { | ||
| if (!client) { | ||
| return; | ||
| } | ||
|
|
||
| client.recordDroppedEvent(reason, getDataCategoryByType(event.type)); | ||
| if (reason === 'callback_error' && event.type === 'transaction') { | ||
| client.recordDroppedEvent(reason, 'span', 1 + (event.spans || []).length); | ||
| } | ||
| }); | ||
|
|
||
| return result.then(evt => { | ||
| if (evt) { | ||
| // We apply the debug_meta field only after all event processors have ran, so that if any event processors modified | ||
| // file names (e.g.the RewriteFrames integration) the filename -> debug ID relationship isn't destroyed. | ||
| // This should not cause any PII issues, since we're only moving data that is already on the event and not adding | ||
| // any new data | ||
| applyDebugMeta(evt); | ||
| if (!evt) { | ||
| return null; | ||
| } | ||
|
|
||
| // We apply the debug_meta field only after all event processors have ran, so that if any event processors modified | ||
| // file names (e.g.the RewriteFrames integration) the filename -> debug ID relationship isn't destroyed. | ||
| // This should not cause any PII issues, since we're only moving data that is already on the event and not adding | ||
| // any new data | ||
| applyDebugMeta(evt); | ||
|
Comment on lines
+127
to
+129
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: When a transaction is dropped by an event processor, its spans are not recorded as dropped because the code only checks for the Suggested FixIn Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Lms24 this is true, but preexisting on develop. Just to be sure, I assume we do want to count dropped spans in all cases, right?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, we want to also count spans (which IIUC we already do in most cases). Agree that this is preexisting, so feel free to follow up on separately or do it in this PR. whatever works best |
||
|
|
||
| if (typeof normalizeDepth === 'number' && normalizeDepth > 0) { | ||
| return normalizeEvent(evt, normalizeDepth, normalizeMaxBreadth); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.