Repository navigation
feat(reports): add the AI-sourced pipeline section to reports and their PDF - #2270
Merged
gkhngyk merged 10 commits intoNov 10, 2026
Merged
Conversation
… by engine and page HubSpot, part 2 of ansvisor#2140 (stacked on the HubSpot connection): AI Traffic gets an "AI-sourced pipeline" section after "Where AI visitors convert". - 00520: hubspot_ai_contacts and hubspot_ai_deals, the brand's AI-sourced HubSpot contacts and their deals (HubSpot ids, AI source, landing page, amounts and dates; never a name or an email), read by the brand's members. brand_ai_pipeline(brand, since, until) answers the section, checking can_access_brand. - A daily read of each brand's HubSpot (lib/hubspot/pipeline-sync.js), and Sync now on the HubSpot card: the contacts Ansvisor marked for the brand, and HubSpot's own AI Referrals contacts on the brand's domains as a line of their own; their deals, each once, in full, credited to the earliest AI contact (Ansvisor's first). Read-only on HubSpot, with consent to mark contacts, a live sign-in and the plan's crm_integrations. - Won revenue by close date, open pipeline now and unweighted, in the HubSpot account's currency (owner, 2026-11-10). - The section: four KPIs against the period before, by AI engine, by landing page, and its states (locked below Growth, not connected, marking contacts off, first read, nothing yet). - The HubSpot card says when HubSpot was last read, with Sync now. - The demo brand connects no HubSpot account: both tables are skipped in the demo's coverage. - Help: ai-traffic/ai-sourced-pipeline (approved: false); settings/hubspot mentions Sync now. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
The Supabase types gain the pipeline's RPC and its two tables (00520), so the AI Traffic read typechecks; the section's test is formatted. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
# Conflicts: # supabase/schema.sql
…ir PDF HubSpot, part 3 of ansvisor#2140 (stacked on ansvisor#2266): a report can carry HubSpot's AI-sourced contacts, deals and revenue for its period, as AI Traffic shows them. - A new section, "AI-sourced pipeline", in the picker and in the Monthly Executive Report's defaults. It needs the plan's crm_integrations: below Growth it shows off, with the plan it needs, and the server leaves it out. - Gathered with brand_ai_pipeline (00520) for the report's dates; a brand that hasn't connected HubSpot with consent to mark contacts, or whose HubSpot hasn't been read yet, gets no such section (not a missing one). - The report page and its PDF show the four KPIs (contacts and won revenue against the previous period), the top 5 engines and landing pages, and HubSpot's own AI Referrals on a line of their own. - formatMoney and percentChange join lib/format, and AI Traffic's section uses formatMoney. - Help: reports/visibility-reports names the section (approved copy regenerated). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
Brings in upstream/main through ansvisor#2265's branch (the Slack PRs). schema.sql is rebuilt with 00510, 00515 and 00520. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
…t-section Brings in upstream/main (the Slack PRs) through ansvisor#2266's branch. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMf5TZg7yqwaSeMFba9
cihan-gyk
dismissed
gkhngyk’s stale review
November 10, 2026 11:49
The merge-base changed after approval.
…pipeline # Conflicts: # supabase/schema.sql
…hanges account or disconnects Only a successful sync pruned hubspot_ai_contacts and hubspot_ai_deals, so after a brand moved to another HubSpot account AI Traffic showed the old account's contacts, deals and revenue as the new one's until a sync of it succeeded, or forever when it kept failing. The brand's rows now go where its other sign-in reads go (brand-integrations.js): when it uses another account, activates a new login of its own, or disconnects. A sync still reading the old account when that happens writes nothing (account_changed). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMenyNyxsr2Doq4CaQ3
cihan-gyk
dismissed
gkhngyk’s stale review
November 10, 2026 20:23
The merge-base changed after approval.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stacked on #2266 (AI-sourced pipeline in AI Traffic), which is stacked on #2265 (HubSpot connection). Merge after #2266; until then this diff also shows theirs.
HubSpot, part 3 of #2140: a report can include HubSpot's AI-sourced contacts, deals and revenue for its period, as the owner approved in the mockup's Reports screen.
What a person sees
How it works
lib/reports/templates.ts:aiPipelinejoinsReportSection,ALL_REPORT_SECTIONSand the executive summary template.lib/actions/reports.ts:crm_integrations(getOrgPlan), as the shopping section is dropped without Shopping mode.getTrafficAiPipeline(brand_ai_pipeline, 00520) for the report's dates.lib/format.tsgainsformatMoney(whole amounts in the HubSpot account's currency) andpercentChange. The AI Traffic section'smoneynow usesformatMoney.help/reports/visibility-reports.mdnames the section, and has a short "AI-sourced pipeline" part. That article is approved, soapproved-articles.jsonwas regenerated (yarn test -u src/lib/help).Not in this PR
Related issue
Part of #2140
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd web && yarn vitest run "src/app/[locale]/(dashboard)/dashboard/reports" src/lib/format.test.ts "src/app/[locale]/(dashboard)/dashboard/traffic/_ai-pipeline.test.tsx" src/lib/help. In particular:reports/page.test.tsx: the section can be picked on Growth, and is off with "Growth" below it;reports/[id]/page.test.tsx: the card's KPIs, engines, pages and the AI Referrals line, and no card on a report without it;_report-pdf.render.test.tsx: the PDF prints the section.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/) — 0 errors; 9 warnings, all in files this PR doesn't touchyarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)help/(or no user-visible change) — see help/README.mdChecks run on bc439c9 (web only, since the server is unchanged):
yarn format:check,yarn lint(0 errors) andyarn typecheckpass.yarn test: 1,065 files, 11,670 passed, 1 skipped.yarn build(CI's placeholder env) passes.After merging
main(the Slack PRs, through #2265's and #2266's branches): the reports, format and Help tests pass again (7 files, 46 tests), and the branch merges cleanly into currentmain.Generated by Claude Code