Skip to content

Commit

Permalink
chore: use captureTraceMetric and captureTraceFeedback
Browse files Browse the repository at this point in the history
  • Loading branch information
skoob13 committed Feb 25, 2025
1 parent 27db5f7 commit f199c59
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions frontend/src/scenes/max/Thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,28 +347,21 @@ function SuccessActions({ retriable }: { retriable: boolean }): JSX.Element {
const [feedbackInputStatus, setFeedbackInputStatus] = useState<'hidden' | 'pending' | 'submitted'>('hidden')

function submitRating(newRating: 'good' | 'bad'): void {
if (rating) {
if (rating || !traceId) {
return // Already rated
}
setRating(newRating)
posthog.capture('$ai_metric', {
$ai_metric_name: 'quality',
$ai_metric_value: newRating,
$ai_trace_id: traceId,
})
posthog.captureTraceMetric(traceId, 'quality', newRating)
if (newRating === 'bad') {
setFeedbackInputStatus('pending')
}
}

function submitFeedback(): void {
if (!feedback) {
if (!feedback || !traceId) {
return // Input is empty
}
posthog.capture('$ai_feedback', {
$ai_feedback_text: feedback,
$ai_trace_id: traceId,
})
posthog.captureTraceFeedback(traceId, feedback)
setFeedbackInputStatus('submitted')
}

Expand Down

0 comments on commit f199c59

Please sign in to comment.