Skip to content

Commit e6ed8bd

Browse files
committed
Clean up feedback system and fix API endpoints
1 parent 5669e33 commit e6ed8bd

File tree

3 files changed

+5
-169
lines changed

3 files changed

+5
-169
lines changed

apps/dashboard/src/@/analytics/report.ts

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -547,62 +547,3 @@ export function reportChainInfraRpcOmissionAgreed(properties: {
547547
}) {
548548
posthog.capture("chain infra checkout rpc omission agreed", properties);
549549
}
550-
551-
// ----------------------------
552-
// SUPPORT FEEDBACK
553-
// ----------------------------
554-
555-
/**
556-
* ### Why do we need to report this event?
557-
* - To track successful feedback submissions for closed support tickets
558-
* - To understand feedback ratings distribution
559-
* - To measure customer satisfaction with support interactions
560-
*
561-
* ### Who is responsible for this event?
562-
* @gisellechacon
563-
*/
564-
export function reportSupportFeedbackSubmitted(properties: {
565-
ticketId: string;
566-
rating: number;
567-
hasFeedback: boolean;
568-
feedbackLength?: number;
569-
}) {
570-
posthog.capture("support feedback submitted", properties);
571-
}
572-
573-
/**
574-
* ### Why do we need to report this event?
575-
* - To track failed feedback submissions for closed support tickets
576-
* - To identify and debug production issues with feedback system
577-
* - To understand error patterns and improve reliability
578-
*
579-
* ### Who is responsible for this event?
580-
* @gisellechacon
581-
*/
582-
export function reportSupportFeedbackFailed(properties: {
583-
ticketId: string;
584-
rating: number;
585-
hasFeedback: boolean;
586-
feedbackLength?: number;
587-
errorMessage: string;
588-
errorType: "validation" | "network" | "server" | "unknown";
589-
}) {
590-
posthog.capture("support feedback failed", properties);
591-
}
592-
593-
/**
594-
* ### Why do we need to report this event?
595-
* - To track when feedback status checks fail
596-
* - To identify issues with feedback verification system
597-
* - To understand reliability of feedback status API
598-
*
599-
* ### Who is responsible for this event?
600-
* @gisellechacon
601-
*/
602-
export function reportSupportFeedbackStatusCheckFailed(properties: {
603-
ticketId: string;
604-
errorMessage: string;
605-
errorType: "network" | "server" | "unknown";
606-
}) {
607-
posthog.capture("support feedback status check failed", properties);
608-
}

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/support/_components/SupportCaseDetails.tsx

Lines changed: 3 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
44
import { format } from "date-fns";
55
import { ChevronDownIcon, StarIcon, UserIcon } from "lucide-react";
66
import Link from "next/link";
7-
import { Component, type ReactNode, useState } from "react";
7+
import { useState } from "react";
88
import { toast } from "sonner";
9-
import {
10-
reportSupportFeedbackFailed,
11-
reportSupportFeedbackStatusCheckFailed,
12-
reportSupportFeedbackSubmitted,
13-
} from "@/analytics/report";
149
import type { Team } from "@/api/team/get-team";
1510
import { Badge } from "@/components/ui/badge";
1611
import {
@@ -51,27 +46,9 @@ function SupportCaseDetails({ ticket, team }: SupportCaseDetailsProps) {
5146
const [statusCheckFailed, setStatusCheckFailed] = useState(false);
5247

5348
// Helper function to handle status check errors consistently
54-
const handleStatusCheckError = (error: unknown) => {
55-
const errorMessage = error instanceof Error ? error.message : String(error);
56-
const errorType = /network|fetch/i.test(errorMessage)
57-
? "network"
58-
: /API Server error/i.test(errorMessage)
59-
? "server"
60-
: /Internal server error/i.test(errorMessage)
61-
? "server"
62-
: "unknown";
63-
64-
// Report analytics for status check failure
65-
reportSupportFeedbackStatusCheckFailed({
66-
ticketId: ticket.id,
67-
errorMessage,
68-
errorType,
69-
});
70-
49+
const handleStatusCheckError = (_error: unknown) => {
7150
// Set degraded state for warning banner
7251
setStatusCheckFailed(true);
73-
74-
// Don't throw; let the query return a safe fallback to avoid retries and duplicate analytics
7552
return;
7653
};
7754

@@ -127,15 +104,6 @@ function SupportCaseDetails({ ticket, team }: SupportCaseDetailsProps) {
127104
return result;
128105
},
129106
onSuccess: () => {
130-
// Report successful feedback submission
131-
reportSupportFeedbackSubmitted({
132-
ticketId: ticket.id,
133-
rating,
134-
hasFeedback: Boolean(feedback?.trim()),
135-
feedbackLength: feedback?.length || 0,
136-
});
137-
138-
// Clean success notification
139107
toast.success("Thank you for your feedback!");
140108

141109
setRating(0);
@@ -147,32 +115,17 @@ function SupportCaseDetails({ ticket, team }: SupportCaseDetailsProps) {
147115
onError: (err) => {
148116
const msg = err instanceof Error ? err.message : String(err ?? "");
149117
let message = "Failed to submit feedback. Please try again.";
150-
let errorType: "validation" | "network" | "server" | "unknown" =
151-
"unknown";
152118

153119
if (/network|fetch/i.test(msg)) {
154120
message = "Network error. Please check your connection and try again.";
155-
errorType = "network";
156121
} else if (
157122
/validation|Rating must be|Please select a rating/i.test(msg)
158123
) {
159124
message = msg; // show precise user-facing validation error
160-
errorType = "validation";
161125
} else if (/API Server error/i.test(msg)) {
162126
message = "Server error. Please try again later.";
163-
errorType = "server";
164127
}
165128

166-
// Report failed feedback submission
167-
reportSupportFeedbackFailed({
168-
ticketId: ticket.id,
169-
rating,
170-
hasFeedback: Boolean(feedback?.trim()),
171-
feedbackLength: feedback?.length || 0,
172-
errorMessage: msg,
173-
errorType,
174-
});
175-
176129
toast.error(message);
177130
},
178131
});
@@ -530,57 +483,4 @@ function TicketMessage(props: { message: SupportMessage }) {
530483
);
531484
}
532485

533-
// Error boundary for debugging production issues
534-
class FeedbackErrorBoundary extends Component<
535-
{ children: ReactNode; ticketId: string },
536-
{ hasError: boolean; error?: Error }
537-
> {
538-
constructor(props: { children: ReactNode; ticketId: string }) {
539-
super(props);
540-
this.state = { hasError: false };
541-
}
542-
543-
static getDerivedStateFromError(error: Error) {
544-
return { hasError: true, error };
545-
}
546-
547-
componentDidCatch(_error: Error, _errorInfo: { componentStack: string }) {
548-
// Report the error to analytics using status check failure event
549-
// which doesn't include misleading feedback metrics
550-
reportSupportFeedbackStatusCheckFailed({
551-
ticketId: this.props.ticketId,
552-
errorMessage: `Error boundary: ${_error.message}`,
553-
errorType: "unknown",
554-
});
555-
}
556-
557-
render() {
558-
if (this.state.hasError) {
559-
return (
560-
<div className="border-t p-6">
561-
<div className="text-destructive text-sm">
562-
<p className="font-medium">
563-
Something went wrong with the feedback system.
564-
</p>
565-
<p className="text-xs mt-1">
566-
Error: {this.state.error?.message || "Unknown error"}
567-
</p>
568-
</div>
569-
</div>
570-
);
571-
}
572-
573-
return this.props.children;
574-
}
575-
}
576-
577-
// Wrapper component with error boundary
578-
export function SupportCaseDetailsWithErrorBoundary(
579-
props: SupportCaseDetailsProps,
580-
) {
581-
return (
582-
<FeedbackErrorBoundary ticketId={props.ticket.id}>
583-
<SupportCaseDetails {...props} />
584-
</FeedbackErrorBoundary>
585-
);
586-
}
486+
export { SupportCaseDetails };

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/support/cases/[id]/page.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { notFound, redirect } from "next/navigation";
22
import { getAuthToken } from "@/api/auth-token";
33
import { getTeamBySlug } from "@/api/team/get-team";
44
import { tryCatch } from "@/utils/try-catch";
5-
import { SupportCaseDetailsWithErrorBoundary } from "../../_components/SupportCaseDetails";
5+
import { SupportCaseDetails } from "../../_components/SupportCaseDetails";
66
import { getSupportTicket } from "../../apis/tickets";
77

88
export default async function TicketPage(props: {
@@ -34,10 +34,5 @@ export default async function TicketPage(props: {
3434
redirect(`/team/${params.team_slug}/~/support`);
3535
}
3636

37-
return (
38-
<SupportCaseDetailsWithErrorBoundary
39-
team={team}
40-
ticket={ticketResult.data}
41-
/>
42-
);
37+
return <SupportCaseDetails team={team} ticket={ticketResult.data} />;
4338
}

0 commit comments

Comments
 (0)