[PULSE-52] Top Referrers favicons, display names, and merge by name #22
Reference in New Issue
Block a user
No description provided.
Delete Branch "staging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Work Item
PULSE-52
Summary
Changes
getReferrerFaviconreturns null for Direct/Unknown; addedgetReferrerDisplayName(heuristic: hostname → main label + capitalize, withREFERRER_DISPLAY_OVERRIDESfor ChatGPT, LinkedIn, X, YouTube, etc.); addedmergeReferrersByDisplayNameto group by display name, sum pageviews, keep one referrer per group; expanded subdomain-skip set for label derivation.onErrorfallback; display names viagetReferrerDisplayName; merge viamergeReferrersByDisplayNamefor card and "View All" modal; tooltip still shows actual referrer.mergeReferrersByDisplayNameandgetReferrerDisplayNamefor PDF Top Referrers table so export uses merged rows and friendly names.Test Plan
[ ] Open a site dashboard with Top Referrers data; confirm domain referrers show favicons and "Direct" shows globe icon.
[ ] Confirm friendly names (e.g. Google, Kagi, ChatGPT) and that unknown domains get a derived name (e.g. "Example" from example.com).
[ ] If multiple referrer strings map to the same name (e.g. chatgpt.com and https://chatgpt.com/...), confirm a single row with combined pageviews in card and "View All" modal.
[ ] Hover a row; tooltip shows actual referrer. Export PDF; Top Referrers table shows merged rows and same display names.
Greptile Overview
Greptile Summary
This PR improves how referrers are presented across the dashboard and exports:
lib/utils/icons.tsx.TopReferrers.tsxto render favicons with a fallback icon, show friendly display names, and merge duplicate sources into a single row.ExportModal.tsxso the “Top Referrers” table uses the same merged rows and friendly names.CHANGELOG.mdand bumpspackage.jsonversion.Main concerns are around stability/correctness of merging and favicon failure caching: the UI currently keys favicon failures by the raw referrer string even though merged groups can change which referrer string is retained, and the merge/display-name heuristic won’t merge certain non-URL referrer variants that fail URL parsing.
Confidence Score: 3/5
Important Files Changed
Sequence Diagram
5 files reviewed, 3 comments
Edit Code Review Agent Settings | Greptile
Favicon failures not stable
faviconFailedis keyed by the rawreferrerstring, but the list is merged by display name andmergeReferrersByDisplayNamecan swap whichreferreris kept for a group (it picks the maxSingle row). That means a group whose favicon URL consistently fails can keep retrying if the representativereferrerchanges (e.g., modal fetch vs card data), causing repeated failing requests and flicker.Consider keying failures by a stable group key (e.g. hostname or display name) rather than the chosen representative referrer string.
Prompt To Fix With AI
@@ -88,0 +161,4 @@* Merges referrer rows that share the same display name (e.g. chatgpt.com and https://chatgpt.com/...),* summing pageviews and keeping one referrer per group for icon/tooltip. Sorted by pageviews desc.*/export function mergeReferrersByDisplayName(Merge misses non-URLs
mergeReferrersByDisplayNamegroups bygetReferrerDisplayName(), butgetReferrerDisplayNamereturns the original trimmed string whengetReferrerHostname()fails. If the backend sometimes returns referrers in slightly different non-URL formats (e.g.example.com/vsexample.comwithout a scheme so URL parsing fails), those won’t merge and you’ll still get duplicates.If you intend to merge “domain-ish” strings that don’t parse as URLs, you likely need to normalize those cases before grouping.
Prompt To Fix With AI
@@ -3,3 +3,3 @@"version": "0.1.0-alpha","version": "0.3.0-alpha","private": true,"scripts": {Version bump impacts releases
This PR bumps
package.jsonto0.3.0-alphaand updates the changelog links forv0.3.0-alpha. If your release/versioning flow expects versions to only change during an actual release/tag step, this will make future release automation or comparisons inconsistent.Please confirm this version bump is intended for this PR (vs. leaving version unchanged until release).
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI