Skip to content

Commit 46632cc

Browse files
[MAIN] Logger added in yahoo audiences to track taxonomy (#3710)
* Logger added in yahoo audiences to track taxonomy * Logger added in yahoo audiences to track taxonomy * Changed logger to console log --------- Co-authored-by: Joe Ayoub <[email protected]>
1 parent fc58970 commit 46632cc

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

packages/destination-actions/src/destinations/yahoo-audiences/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const destination: AudienceDestinationDefinition<Settings, AudienceSettings> = {
6464
400
6565
)
6666
} else {
67-
// The last 2 params are undefined because statsContext.statsClient and statsContext.tags are not available testAuthentication()
67+
// The last 3 params are undefined because statsContext.statsClient, statsContext.tags, and logger are not available in testAuthentication()
6868
return await update_taxonomy('', tx_creds, request, body_form_data, undefined, undefined)
6969
}
7070
},

packages/destination-actions/src/destinations/yahoo-audiences/utils-tax.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)