@@ -105,10 +105,21 @@ export async function update_taxonomy(
105105 const tx_client_key = tx_creds . tx_client_key
106106 const url = `https://datax.yahooapis.com/v1/taxonomy/append${ engage_space_id . length > 0 ? '/' + engage_space_id : '' } `
107107
108+ console . info (
109+ '[update_taxonomy] Starting taxonomy update request' ,
110+ `engage_space_id: ${ engage_space_id } ` ,
111+ `url: ${ url } ` ,
112+ `tx_client_key: ${ tx_client_key ? 'present' : 'missing' } `
113+ )
114+
108115 // Get a short-lived Bearer token using the same JWT client-credentials flow as the Online API
109116 const access_token = await get_taxonomy_access_token ( request , tx_client_key , tx_client_secret )
110117
118+ console . info ( '[update_taxonomy] Access token obtained successfully' )
119+
111120 try {
121+ console . info ( '[update_taxonomy] Sending PUT request to Yahoo Taxonomy API' , `url: ${ url } ` )
122+
112123 const add_segment_node = await request ( url , {
113124 method : 'PUT' ,
114125 body : body_form_data ,
@@ -117,12 +128,34 @@ export async function update_taxonomy(
117128 'Content-Type' : 'multipart/form-data; boundary=SEGMENT-DATA'
118129 }
119130 } )
131+
132+ console . info (
133+ '[update_taxonomy] Received response from Yahoo Taxonomy API' ,
134+ `status: ${ add_segment_node . status } ` ,
135+ `statusText: ${ add_segment_node . statusText } `
136+ )
137+
120138 if ( statsClient && statsTags ) {
121139 statsClient . incr ( 'update_taxonomy.success' , 1 , statsTags )
122140 }
123- return await add_segment_node . json ( )
141+
142+ const responseData = await add_segment_node . json ( )
143+
144+ console . info (
145+ '[update_taxonomy] Response data from Yahoo Taxonomy API' ,
146+ `responseData: ${ JSON . stringify ( responseData ) } `
147+ )
148+
149+ return responseData
124150 } catch ( error ) {
125151 const _error = error as { response : { data : unknown ; status : string } }
152+
153+ console . warn (
154+ '[update_taxonomy] Error occurred during taxonomy update' ,
155+ `status: ${ _error . response ?. status || 'unknown' } ` ,
156+ `responseData: ${ JSON . stringify ( _error . response ?. data || { } ) } `
157+ )
158+
126159 if ( statsClient && statsTags ) {
127160 statsClient . incr ( 'update_taxonomy.error' , 1 , statsTags )
128161 }
0 commit comments