fix(meta-ads): include onsite_conversion and app_custom_event subtypes in conversions

The conversion filter was only matching offsite_conversion.* subtypes but
missing onsite_conversion.* and app_custom_event.* subtypes, which the Meta
API commonly returns at the subtype level.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Waleed Latif
2026-03-14 09:10:21 -07:00
parent 478bcc06fe
commit b2bd567b2e

View File

@@ -132,10 +132,14 @@ export const metaAdsGetInsightsTool: ToolConfig<
'onsite_conversion',
'app_custom_event',
])
const conversionPrefixes = ['offsite_conversion.', 'onsite_conversion.', 'app_custom_event.']
const conversions = actions
.filter((a) => {
const actionType = a.action_type as string
return conversionTypes.has(actionType) || actionType?.startsWith('offsite_conversion.')
return (
conversionTypes.has(actionType) ||
conversionPrefixes.some((prefix) => actionType?.startsWith(prefix))
)
})
.reduce((sum, a) => sum + Number(a.value ?? 0), 0)