mirror of
https://github.com/supabase/supabase.git
synced 2026-05-08 18:00:20 -04:00
4a0bb36ca8
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
'use client'
|
|
|
|
import { ErrorDisplay, SupportFormParams } from 'ui-patterns/ErrorDisplay/ErrorDisplay'
|
|
|
|
import { getMappingForError } from './ErrorMatcher.utils'
|
|
import { useTrack } from '@/lib/telemetry/track'
|
|
|
|
interface ErrorMatcherProps {
|
|
title: string
|
|
error: string | { message: string }
|
|
supportFormParams?: SupportFormParams
|
|
className?: string
|
|
}
|
|
|
|
export function ErrorMatcher({ title, error, supportFormParams, className }: ErrorMatcherProps) {
|
|
const track = useTrack()
|
|
|
|
const message = typeof error === 'string' ? error : error.message
|
|
const mapping = getMappingForError(error)
|
|
const Troubleshooting = mapping?.Troubleshooting
|
|
|
|
return (
|
|
<ErrorDisplay
|
|
title={title}
|
|
errorMessage={message}
|
|
supportFormParams={supportFormParams}
|
|
className={className}
|
|
onRender={() => {
|
|
track('dashboard_error_created', {
|
|
source: 'error_display',
|
|
errorType: mapping?.id,
|
|
hasTroubleshooting: !!mapping,
|
|
})
|
|
if (mapping) {
|
|
track('inline_error_troubleshooter_exposed', { errorType: mapping.id })
|
|
}
|
|
}}
|
|
onSupportClick={
|
|
mapping
|
|
? () =>
|
|
track('inline_error_troubleshooter_action_clicked', {
|
|
errorType: mapping.id,
|
|
ctaType: 'contact_support',
|
|
})
|
|
: undefined
|
|
}
|
|
>
|
|
{Troubleshooting && <Troubleshooting />}
|
|
</ErrorDisplay>
|
|
)
|
|
}
|