Repository navigation
feat(prompts): suggest prompts from the pages analytics says are worth it - #720
Merged
Merged
Conversation
…h it Suggestions came from LLM generation, heuristics and Search Console demand. Search Console answers what people type into a search box; the traffic pipeline answers two questions it structurally cannot, because they describe behaviour rather than search volume. Revenue blind spots are pages that earn and that nothing tracked would surface in an AI answer — a commercial gap stated in the customer's own numbers. AI momentum is the inverse: pages an engine already refers visitors to, which proves the topic is answerable and the brand is already a candidate source for it. The two are complements, so the candidate list interleaves them; concatenating would let a shop with real revenue fill every slot and leave no room for what is already working, and a brand without ecommerce would produce nothing from the revenue side at all. Revenue ranks on money where the property reports it and on key events where it does not, which is what makes this work without ecommerce tracking. The prompt is derived from the page, not from its URL or product name. A model number is not something anyone asks an assistant about; the answerable question sits at the category and need level, and reading the page is how we get there — which is also why this needs no product catalogue. A page that cannot be read is dropped rather than passed on as a slug for the model to guess from. Transactional pages are excluded by path segment, not by substring: a GA4 purchase fires on the confirmation page, so without the filter the highest-revenue "page" in most shops is the checkout, while a substring match would quietly delete /cartography-guides along with /cart. Provenance follows the Search Console pattern — a suggestion is 'ga' only when its sourcePage matches a candidate we actually offered, so a fabricated one degrades to a plain 'llm' row instead of carrying invented figures. Search Console wins a tie: it is proven demand for a phrasing, while the page is an inference about what would lead there. Verified against a live connected property: three candidates in six seconds, each carrying the engines that referred it and the page's own words. That property reports no conversions, so it exercised the momentum path and the no-ecommerce fallback; the coverage filter changed nothing there because no tracked prompt overlapped those pages. Closes #705
…module `lib/actions/prompt-suggestions.ts` is `'use server'`, where every runtime export has to be an async server action. The two synchronous narrowing helpers added with the Analytics source therefore failed the production build with "export gscSourceData was not found" — while tsc, eslint and prettier all passed, because none of them run the Next build. The types and their guards now live in a plain module and the server-action file imports the types alone.
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
Prompt suggestions came from LLM generation, heuristics and Search Console demand. Search Console answers what are people typing into a search box; the traffic pipeline (#704) answers two questions it structurally cannot, because they describe behaviour rather than search volume.
revenue_blind_spotai_momentumThe first finds what is missing, the second what is already working. The candidate list interleaves them rather than concatenating: a combined sort would let a shop with real revenue fill every slot and leave no room for momentum, and a brand without ecommerce would produce nothing from the revenue side at all. Revenue ranks on money where the property reports it and on key events where it does not — which is what makes this work without ecommerce tracking, one of the acceptance criteria.
The prompt is derived from the page, not from its URL or product name. A model number is not something anyone asks an assistant about; the answerable question sits at the category and need level, and reading the page is how we get there — which is also why this needs no product catalogue. The model receives the page's own title, h1, description and headings. A page that cannot be read is dropped rather than passed on as a slug for the model to guess from.
Transactional pages are excluded by path segment, not substring. A GA4 purchase fires on the confirmation page, so without the filter the highest-revenue "page" in most shops is
/checkout; a substring match would quietly delete/cartography-guidesalong with/cart.Provenance follows the Search Console pattern. A suggestion is
'ga'only when itssourcePagematches a candidate actually offered, so a fabricated one degrades to a plain'llm'row instead of carrying invented figures. Search Console wins a tie — it is proven demand for a phrasing, while the page is an inference about what would lead there.The card shows the evidence alongside the suggestion (
Analytics · /pricing,#2 by revenueorAI traffic · 25 sessions), with the reasoning in the tooltip. As with Search Console rows, the modelled~X/moestimate is hidden on measured rows — showing an estimate next to measured data reads as a contradiction.Related issue
Closes #705
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
Automated —
cd server && yarn test(249 pass; 22 new insrc/lib/ga-suggestions.test.jscovering transactional exclusion, per-page aggregation, platform attribution, interleaving, the no-ecommerce fallback, dismissal, de-duplication and page-summary extraction).Against a connected property:
POST /api/integrations/google-analytics/sync).Analytics · <page>badge and an evidence badge, with the reasoning in the tooltip.Verified against a live connected property before opening this: three candidates in six seconds, each carrying the engines that referred it and the page's own words rather than its slug.
Two honest gaps in that live run, both covered by unit tests instead: the property reports no conversions, so it exercised the momentum path and the no-ecommerce fallback but not
revenue_blind_spot; and the coverage filter changed nothing there, because none of the 80 tracked prompts overlapped those pages.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/andserver/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)supabase/schema.sqlregenerated viabash supabase/build-schema.sh