LCOV - code coverage report
Current view: top level - src/platform/telemetry - sentryBeforeSend.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 0.0 % 10 0
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { ErrorEvent, EventHint } from '@sentry/vue'
       2              : 
       3              : import { WorkspaceApiError } from '@/platform/remote/ingest/ingestApiError'
       4              : 
       5              : import { tagSentryEvaluatedCommandCaller } from './sentryEvaluatedCommandCaller'
       6              : import {
       7              :   sentryThirdPartyErrorFilter,
       8              :   tagSentryNonFirstPartyOrigin
       9              : } from './thirdPartyErrorNoise'
      10              : import { tagSentryStaleChunkCause } from './sentryStaleChunkCause'
      11              : import { addVueDirectiveDiagnostics } from './vueDirectiveErrorDiagnostics'
      12              : 
      13              : /**
      14              :  * Groups a `WorkspaceApiError` by what failed rather than where it was
      15              :  * caught, so each endpoint and server response gets its own Sentry issue.
      16              :  * Errors without an `operation`, such as SDK operation refusals, keep Sentry's
      17              :  * default grouping.
      18              :  */
      19            0 : function groupWorkspaceApiError(
      20              :   event: ErrorEvent,
      21              :   hint: EventHint
      22              : ): ErrorEvent {
      23            0 :   const error = hint.originalException
      24            0 :   if (!(error instanceof WorkspaceApiError)) return event
      25              : 
      26            0 :   const status = error.status === undefined ? 'none' : String(error.status)
      27            0 :   const code = error.code ?? 'none'
      28            0 :   const { operation } = error
      29              : 
      30            0 :   return {
      31              :     ...event,
      32              :     tags: {
      33              :       ...event.tags,
      34              :       workspace_api_status: status,
      35              :       workspace_api_code: code,
      36              :       ...(operation && { workspace_api_operation: operation })
      37              :     },
      38              :     ...(operation && { fingerprint: [error.name, operation, status, code] })
      39              :   }
      40              : }
      41              : 
      42            0 : export function sentryBeforeSend(
      43              :   event: ErrorEvent,
      44              :   hint: EventHint
      45              : ): ErrorEvent | null {
      46            0 :   const kept = sentryThirdPartyErrorFilter(event, hint)
      47            0 :   return (
      48              :     kept &&
      49              :     groupWorkspaceApiError(
      50              :       tagSentryEvaluatedCommandCaller(
      51              :         tagSentryNonFirstPartyOrigin(
      52              :           tagSentryStaleChunkCause(addVueDirectiveDiagnostics(kept, hint))
      53              :         )
      54              :       ),
      55              :       hint
      56              :     )
      57              :   )
      58              : }
        

Generated by: LCOV version 2.0-1