@@ -11,18 +11,27 @@ export async function submitSupportFeedback(
1111 data : FeedbackData ,
1212) : Promise < { success : true } | { error : string } > {
1313 try {
14+ // Enhanced logging for production debugging
1415 console . log ( "🔍 Debug - Feedback submission attempt:" , {
1516 hasSupabase : ! ! supabase ,
1617 data : data ,
18+ env : {
19+ hasUrl : ! ! process . env . NEXT_PUBLIC_SUPABASE_URL ,
20+ hasKey : ! ! process . env . NEXT_PUBLIC_SUPABASE_ANON_KEY ,
21+ urlLength : process . env . NEXT_PUBLIC_SUPABASE_URL ?. length || 0 ,
22+ keyLength : process . env . NEXT_PUBLIC_SUPABASE_ANON_KEY ?. length || 0 ,
23+ } ,
24+ timestamp : new Date ( ) . toISOString ( ) ,
1725 } ) ;
1826
1927 if ( ! supabase ) {
20- throw new Error (
21- " Supabase client not initialized. Please check your environment variables." ,
22- ) ;
28+ const error = "Supabase client not initialized. Please check your environment variables." ;
29+ console . error ( "❌ Supabase client error:" , error ) ;
30+ throw new Error ( error ) ;
2331 }
2432
25- // Test the connection first
33+ // Test the connection first with more detailed logging
34+ console . log ( "🔍 Testing Supabase connection..." ) ;
2635 const { data : testData , error : testError } = await supabase
2736 . from ( "support_feedback" )
2837 . select ( "id" )
@@ -31,21 +40,50 @@ export async function submitSupportFeedback(
3140 console . log ( "🔍 Debug - Supabase connection test:" , {
3241 testData,
3342 testError,
43+ hasTestData : ! ! testData ,
44+ testDataLength : testData ?. length || 0 ,
3445 } ) ;
3546
36- const { error } = await supabase . from ( "support_feedback" ) . insert ( {
47+ if ( testError ) {
48+ console . error ( "❌ Supabase connection test failed:" , testError ) ;
49+ return { error : `Connection test failed: ${ testError . message } ` } ;
50+ }
51+
52+ // Attempt to insert the feedback
53+ console . log ( "🔍 Attempting to insert feedback data:" , {
54+ rating : data . rating ,
55+ feedbackLength : data . feedback ?. length || 0 ,
56+ } ) ;
57+
58+ const { data : insertData , error } = await supabase . from ( "support_feedback" ) . insert ( {
3759 rating : data . rating ,
3860 feedback : data . feedback ,
3961 } ) ;
4062
63+ console . log ( "🔍 Debug - Insert result:" , {
64+ insertData,
65+ error,
66+ hasInsertData : ! ! insertData ,
67+ } ) ;
68+
4169 if ( error ) {
42- console . error ( "Supabase error:" , error ) ;
70+ console . error ( "❌ Supabase insert error:" , {
71+ message : error . message ,
72+ details : error . details ,
73+ hint : error . hint ,
74+ code : error . code ,
75+ } ) ;
4376 return { error : `Failed to submit feedback: ${ error . message } ` } ;
4477 }
4578
79+ console . log ( "✅ Feedback submitted successfully:" , insertData ) ;
4680 return { success : true } ;
4781 } catch ( error ) {
48- console . error ( "Feedback submission error:" , error ) ;
82+ console . error ( "❌ Feedback submission error:" , {
83+ error,
84+ message : error instanceof Error ? error . message : "Unknown error" ,
85+ stack : error instanceof Error ? error . stack : undefined ,
86+ } ) ;
4987 return {
5088 error : `Failed to submit feedback: ${ error instanceof Error ? error . message : "Unknown error" } ` ,
5189 } ;
0 commit comments