Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

850 B
Raw Blame
import { getExceptionStepsMalformedReason } from './exceptionStepsValidation'
import { ErrorEventProperties } from './types'

export function addExceptionStepsMalformedWarning(eventProperties: ErrorEventProperties): ErrorEventProperties {
    const malformedReason = getExceptionStepsMalformedReason(eventProperties?.$exception_steps)
    if (!malformedReason) {
        return eventProperties
    }

    const warning = `Exception steps malformed: ${malformedReason}`
    const existingWarnings = Array.isArray(eventProperties.$cymbal_errors)
        ? eventProperties.$cymbal_errors.filter((error): error is string => typeof error === 'string')
        : []

    if (existingWarnings.includes(warning)) {
        return eventProperties
    }

    return {
        ...eventProperties,
        $cymbal_errors: [...existingWarnings, warning],
    }
}