@@ -1074,15 +1074,47 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
10741074 }
10751075
10761076 const marketData = await response . json ( ) ;
1077- console . log ( '[Background] Steam data:' , {
1077+
1078+ // Log full response for debugging
1079+ console . log ( '[Background] Steam Market History Response:' , JSON . stringify ( marketData , null , 2 ) ) ;
1080+
1081+ console . log ( '[Background] Steam data summary:' , {
1082+ success : marketData . success ,
10781083 total_count : marketData . total_count ,
1079- events : marketData . events ?. length || 0
1084+ has_assets : ! ! marketData . assets ,
1085+ has_results_html : ! ! marketData . results_html ,
1086+ has_purchases : ! ! marketData . purchases ,
1087+ has_listings : ! ! marketData . listings ,
1088+ pagesize : marketData . pagesize ,
1089+ keys : Object . keys ( marketData )
10801090 } ) ;
10811091
1082- if ( ! marketData . events || marketData . events . length === 0 ) {
1092+ // Validate Steam Market History response
1093+ if ( ! marketData . success ) {
1094+ sendResponse ( {
1095+ success : false ,
1096+ error : 'Steam API returned unsuccessful response. Make sure you\'re logged into Steam.'
1097+ } ) ;
1098+ return ;
1099+ }
1100+
1101+ if ( marketData . total_count === 0 ) {
1102+ sendResponse ( {
1103+ success : false ,
1104+ error : 'No transactions found in your Steam Market history'
1105+ } ) ;
1106+ return ;
1107+ }
1108+
1109+ // Backend requires both assets and results_html for parsing
1110+ if ( ! marketData . assets || ! marketData . results_html ) {
1111+ console . error ( '[Background] Missing required fields:' , {
1112+ has_assets : ! ! marketData . assets ,
1113+ has_results_html : ! ! marketData . results_html
1114+ } ) ;
10831115 sendResponse ( {
10841116 success : false ,
1085- error : 'No transactions found in Steam Market history'
1117+ error : `Missing required data from Steam API. Try navigating to steamcommunity.com/market/myhistory in your browser first, then try syncing again.`
10861118 } ) ;
10871119 return ;
10881120 }
@@ -1106,16 +1138,17 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
11061138 console . log ( '[Background] Import result:' , result ) ;
11071139
11081140 // Store synced transactions count
1141+ const transactionCount = marketData . total_count || ( marketData . events ?. length || 0 ) ;
11091142 await chrome . storage . local . set ( {
11101143 lastTransactionSync : Date . now ( ) ,
1111- syncedTransactions : marketData . events || [ ]
1144+ syncedTransactions : Array ( transactionCount ) . fill ( { synced : true } )
11121145 } ) ;
11131146
11141147 sendResponse ( {
11151148 success : true ,
11161149 added : result . added || 0 ,
11171150 skipped : result . skipped || 0 ,
1118- total_count : marketData . total_count
1151+ total_count : transactionCount
11191152 } ) ;
11201153
11211154 } catch ( error ) {
0 commit comments