Skip to content

Commit efd9018

Browse files
committed
refactor: clean up feedback API for production - remove debug logs and optimize code
1 parent 49cae7e commit efd9018

File tree

2 files changed

+4
-61
lines changed

2 files changed

+4
-61
lines changed

apps/dashboard/src/@/lib/supabase.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,3 @@ export const supabase =
88
supabaseUrl && supabaseAnonKey
99
? createClient(supabaseUrl, supabaseAnonKey)
1010
: null;
11-
12-
// Log the status for debugging (both dev and production)
13-
console.log("🔧 Supabase client status:", {
14-
hasUrl: !!supabaseUrl,
15-
hasKey: !!supabaseAnonKey,
16-
clientCreated: !!supabase,
17-
env: process.env.NODE_ENV,
18-
urlLength: supabaseUrl?.length || 0,
19-
keyLength: supabaseAnonKey?.length || 0,
20-
});

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/support/apis/feedback.ts

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,64 +12,18 @@ export async function submitSupportFeedback(
1212
data: FeedbackData,
1313
): Promise<{ success: true } | { error: string }> {
1414
try {
15-
// Enhanced logging for production debugging
16-
console.log("🔍 Debug - Feedback submission attempt:", {
17-
hasSupabase: !!supabase,
18-
data: data,
19-
env: {
20-
hasUrl: !!process.env.NEXT_PUBLIC_SUPABASE_URL,
21-
hasKey: !!process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
22-
urlLength: process.env.NEXT_PUBLIC_SUPABASE_URL?.length || 0,
23-
keyLength: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY?.length || 0,
24-
},
25-
timestamp: new Date().toISOString(),
26-
});
27-
2815
if (!supabase) {
2916
const error =
3017
"Supabase client not initialized. Please check your environment variables.";
3118
console.error("❌ Supabase client error:", error);
3219
throw new Error(error);
3320
}
3421

35-
// Test the connection first with more detailed logging
36-
console.log("🔍 Testing Supabase connection...");
37-
const { data: testData, error: testError } = await supabase
38-
.from("support_feedback")
39-
.select("id")
40-
.limit(1);
41-
42-
console.log("🔍 Debug - Supabase connection test:", {
43-
testData,
44-
testError,
45-
hasTestData: !!testData,
46-
testDataLength: testData?.length || 0,
47-
});
48-
49-
if (testError) {
50-
console.error("❌ Supabase connection test failed:", testError);
51-
return { error: `Connection test failed: ${testError.message}` };
52-
}
53-
54-
// Attempt to insert the feedback
55-
console.log("🔍 Attempting to insert feedback data:", {
22+
// Insert the feedback
23+
const { error } = await supabase.from("support_feedback").insert({
5624
rating: data.rating,
57-
feedbackLength: data.feedback?.length || 0,
58-
ticketId: data.ticketId,
59-
});
60-
61-
const { data: insertData, error } = await supabase
62-
.from("support_feedback")
63-
.insert({
64-
rating: data.rating,
65-
feedback: data.feedback,
66-
ticket_id: data.ticketId,
67-
});
68-
69-
console.log("🔍 Debug - Insert result:", {
70-
insertData,
71-
error,
72-
hasInsertData: !!insertData,
25+
feedback: data.feedback,
26+
ticket_id: data.ticketId,
7327
});
7428

7529
if (error) {
@@ -82,7 +36,6 @@ export async function submitSupportFeedback(
8236
return { error: `Failed to submit feedback: ${error.message}` };
8337
}
8438

85-
console.log("✅ Feedback submitted successfully:", insertData);
8639
return { success: true };
8740
} catch (error) {
8841
console.error("❌ Feedback submission error:", {

0 commit comments

Comments
 (0)