Skip to content

Commit dab60b9

Browse files
committed
fix(ahrefs): convert remaining cents-to-USD fields, drop unneeded fallback key
Rank Tracker SERP Overview's value field, Competitors Stats' trafficValue, and Competitors Overview's nested competitor value were all left in USD cents while every other monetary field in the integration converts to USD - fixed for consistency with the rest of the integration. Also drops the unverified `data.results` fallback in Batch Analysis; the Ahrefs v3 docs confirm the response key is always `targets`.
1 parent 934dca7 commit dab60b9

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

apps/sim/tools/ahrefs/batch_analysis.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const batchAnalysisTool: ToolConfig<AhrefsBatchAnalysisParams, AhrefsBatc
8888
throw new Error(data.error?.message || data.error || 'Failed to run batch analysis')
8989
}
9090

91-
const results = (data.targets || data.results || []).map((item: any) => ({
91+
const results = (data.targets || []).map((item: any) => ({
9292
url: item.url || '',
9393
index: item.index ?? 0,
9494
domainRating: item.domain_rating ?? null,

apps/sim/tools/ahrefs/rank_tracker_competitors_overview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const rankTrackerCompetitorsOverviewTool: ToolConfig<
9999
position: competitor.position ?? null,
100100
bestPositionKind: competitor.best_position_kind ?? null,
101101
traffic: competitor.traffic ?? null,
102-
value: competitor.value ?? null,
102+
value: typeof competitor.value === 'number' ? competitor.value / 100 : null,
103103
})),
104104
}))
105105

@@ -154,7 +154,7 @@ export const rankTrackerCompetitorsOverviewTool: ToolConfig<
154154
},
155155
value: {
156156
type: 'number',
157-
description: 'Estimated traffic value',
157+
description: 'Estimated traffic value (USD)',
158158
optional: true,
159159
},
160160
},

apps/sim/tools/ahrefs/rank_tracker_competitors_stats.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const rankTrackerCompetitorsStatsTool: ToolConfig<
7979
const competitorsStats = (data['competitors-metrics'] || []).map((item: any) => ({
8080
competitor: item.competitor || '',
8181
traffic: item.traffic ?? null,
82-
trafficValue: item.traffic_value ?? null,
82+
trafficValue: typeof item.traffic_value === 'number' ? item.traffic_value / 100 : null,
8383
averagePosition: item.average_position ?? null,
8484
pos1To3: item.pos_1_3 ?? 0,
8585
pos4To10: item.pos_4_10 ?? 0,
@@ -110,7 +110,7 @@ export const rankTrackerCompetitorsStatsTool: ToolConfig<
110110
},
111111
trafficValue: {
112112
type: 'number',
113-
description: 'Estimated monthly organic traffic value',
113+
description: 'Estimated monthly organic traffic value (USD)',
114114
optional: true,
115115
},
116116
averagePosition: {

apps/sim/tools/ahrefs/rank_tracker_serp_overview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export const rankTrackerSerpOverviewTool: ToolConfig<
109109
backlinks: item.backlinks ?? 0,
110110
refdomains: item.refdomains ?? 0,
111111
traffic: item.traffic ?? 0,
112-
value: item.value ?? null,
112+
value: typeof item.value === 'number' ? item.value / 100 : null,
113113
topKeyword: item.top_keyword ?? null,
114114
topKeywordVolume: item.top_keyword_volume ?? null,
115115
updateDate: item.update_date || '',
@@ -145,7 +145,7 @@ export const rankTrackerSerpOverviewTool: ToolConfig<
145145
traffic: { type: 'number', description: 'Estimated monthly organic search traffic' },
146146
value: {
147147
type: 'number',
148-
description: 'Estimated monthly traffic value in USD cents',
148+
description: 'Estimated monthly traffic value (USD)',
149149
optional: true,
150150
},
151151
topKeyword: {

0 commit comments

Comments
 (0)