feat(meta-ads): add meta ads integration for campaign and ad performance queries#3563
feat(meta-ads): add meta ads integration for campaign and ad performance queries#3563waleedlatif1 wants to merge 9 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Introduces supporting infrastructure: new Next.js API routes for selector dropdown data ( Updates docs and UI assets by adding Written by Cursor Bugbot for commit b2bd567. Configure here. |
Greptile SummaryThis PR adds a complete Meta Ads integration with five read-only tools (get account info, list campaigns, list ad sets, list ads, get performance insights), a block UI with cascading account → campaign selectors, and the supporting OAuth provider registration and long-lived token exchange logic. Key changes:
Confidence Score: 5/5Safe to merge — only P2 style findings remain; no functional defects or security issues. All remaining findings are P2 (minor log label inaccuracy and version-string duplication across lib files). The core integration logic — OAuth flow, long-lived token exchange, cascading selectors, tool dispatch, and error handling — is correct and follows established codebase patterns. apps/sim/lib/auth/auth.ts and apps/sim/lib/oauth/oauth.ts contain independently-hardcoded v24.0 version strings; apps/sim/app/api/tools/meta_ads/accounts/route.ts has a misleading log label. Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User/UI
participant B as Meta Ads Block
participant SA as /api/tools/meta_ads/accounts
participant SC as /api/tools/meta_ads/campaigns
participant T as Meta Ads Tool
participant M as graph.facebook.com
U->>B: Connect OAuth (meta-ads)
B-->>M: OAuth authorize (ads_read)
M-->>B: Short-lived token
B->>M: Exchange for long-lived token (fb_exchange_token)
M-->>B: Long-lived token (~60 days)
U->>SA: POST {credential, workflowId}
SA->>M: GET /me/adaccounts
M-->>SA: Account list
SA-->>U: {accounts}
U->>SC: POST {credential, workflowId, accountId}
SC->>M: GET /act_{id}/campaigns
M-->>SC: Campaign list
SC-->>U: {campaigns}
U->>T: Execute tool (get_account / list_* / get_insights)
T->>M: GET /act_{id}/{endpoint}?fields=...
M-->>T: API response
T-->>U: Typed output
Reviews (7): Last reviewed commit: "fix(meta-ads): include onsite_conversion..." | Re-trigger Greptile |
…nce queries - Add 5 tools: get_account, list_campaigns, list_ad_sets, list_ads, get_insights - Add account and campaign selectors with cascading dropdown support - Add OAuth config with ads_read scope - Generate docs
…um date preset to docs - Pass access token via Authorization header instead of URL query param in getUserInfo, matching all other providers - Add missing 'maximum' date preset to tool param description and docs
f11f141 to
bb8b314
Compare
Addressing Review Comments1.
|
|
@greptile |
|
@cursor review |
- Use useId() for MetaAdsIcon SVG gradient IDs to prevent collisions when multiple instances render on the same page - Filter conversions to only count actual conversion action types (offsite_conversion, onsite_conversion, app_custom_event) instead of summing all actions
|
@cursor review |
|
@greptile review |
…rity, account statuses, DELETED filter - Add stripActPrefix() helper to prevent act_ double-prefix bug when users provide prefixed IDs - Clarify totalCount descriptions to indicate response-level count (not total in account) - Show all ad accounts in selector with status badges instead of silently filtering to active only - Add DELETED to status filter dropdown options Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
All 4 issues from the Greptile review have been addressed in b339b48: 1. 2. Misleading 3. Accounts selector silently excludes non-active accounts — Fixed. Now shows all accounts regardless of status. Non-active accounts get a status badge appended to their name (e.g., "My Account (Disabled)", "My Account (Pending Risk Review)"). 4. |
|
@cursor review |
|
@greptile review |
…th connect Meta's auth code flow returns a short-lived token (~1-2h) with no refresh token. Add fb_exchange_token call in account.create.after hook to exchange for a long-lived token (~60 days), following the same pattern as Salesforce's post-connect token handling. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…s 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>
|
@cursor review |
|
@greptile review |
|
@greptile |
Summary
ads_readscope for read-only operationsType of Change
Testing
Tested manually
Checklist