Added gift link filter to web analytics#28987
Conversation
ref https://linear.app/ghost/issue/BER-3746/integrate-gift-link-usage-tracking-with-analytics - adds a "Gift link" filter (used / not used) under Location on the web traffic tab, in both site-wide (stats) and per-post analytics - gated behind the giftLinks labs flag, both in the filter UI and in the URL <-> filter sync, so a stale gift_link query param can't apply an invisible, unremovable filter when the flag is off - emits gift_link=used / gift_link=not_used, consuming the gift_link dimension added in #28854; "not used" needs value-aware pipe support there to return correct data (the current presence-based pipes only resolve "used") Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughBoth 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run-many --target=build --projects=tag:publi... |
✅ Succeeded | 3s | View ↗ |
nx run-many -t test:unit -p @tryghost/posts,@tr... |
✅ Succeeded | 3m 20s | View ↗ |
nx run @tryghost/admin:build |
✅ Succeeded | 2m 2s | View ↗ |
nx run ghost:build:assets |
✅ Succeeded | 2s | View ↗ |
nx run-many -t lint -p @tryghost/posts,@tryghos... |
✅ Succeeded | 22s | View ↗ |
nx run ghost:build:tsc |
✅ Succeeded | 6s | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-06-30 10:09:00 UTC
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/posts/src/views/PostAnalytics/components/stats-filter.tsx`:
- Around line 36-39: The gift link filter in stats-filter.tsx is forwarding raw
values from GIFT_LINK_OPTIONS through buildFilterParams, so “not used” currently
sends gift_link=not_used even though the intended semantics are used/non-empty
and not used/empty. Update the frontend gating around the giftLinks path in
PostAnalytics (including the filter option handling and any related usage in
buildFilterParams) so this option is only enabled once the backend supports both
literal values, and keep the flag off until the backend behavior is ready.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d2adb8cf-e50c-42bc-895b-540b79b7a9bd
📒 Files selected for processing (4)
apps/posts/src/hooks/use-filter-params.tsapps/posts/src/views/PostAnalytics/components/stats-filter.tsxapps/stats/src/hooks/use-filter-params.tsapps/stats/src/views/Stats/components/stats-filter.tsx
| const GIFT_LINK_OPTIONS = [ | ||
| {value: 'used', label: 'used'}, | ||
| {value: 'not_used', label: 'not used'} | ||
| ]; |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Verify backend handling of the literal gift_link values.
buildFilterParams forwards the raw option value, so selecting not used sends gift_link=not_used (and used sends gift_link=used). Per the comment at Lines 33-35 the intended semantics are "used → non-empty gift_link, not used → empty", which only holds once the value-aware backend handling from #28854 lands. Until then the not used path will return incorrect data. Since this is gated behind giftLinks, confirm the flag stays off until the backend supports both values.
Also applies to: 125-125
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/posts/src/views/PostAnalytics/components/stats-filter.tsx` around lines
36 - 39, The gift link filter in stats-filter.tsx is forwarding raw values from
GIFT_LINK_OPTIONS through buildFilterParams, so “not used” currently sends
gift_link=not_used even though the intended semantics are used/non-empty and not
used/empty. Update the frontend gating around the giftLinks path in
PostAnalytics (including the filter option handling and any related usage in
buildFilterParams) so this option is only enabled once the backend supports both
literal values, and keep the flag off until the backend behavior is ready.
ref https://linear.app/ghost/issue/BER-3746/integrate-gift-link-usage-tracking-with-analytics - #28854 now resolves the gift_link param by value: 'false'/'0' selects traffic with no gift link ("not used"), any other value selects gift-link traffic ("used") - updates the filter option values from used/not_used to true/false so "not used" sends gift_link=false and returns the correct data instead of being treated as "used" - labels are unchanged ("used" / "not used"); only the underlying query value changed Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

ref https://linear.app/ghost/issue/BER-3746/integrate-gift-link-usage-tracking-with-analytics
What
Adds a Gift link filter on the Web traffic tab, under Location in the filter dropdown, in both site-wide analytics (
apps/stats) and per-post analytics (apps/posts). Selecting it produces an editable chip — Gift link · is · [used ▾] — where only the value (used/not used) is changeable.It's a static binary select (not a Tinybird-backed option list), and is gated behind the
giftLinkslabs flag.How
gift_linkselectfield (optionsused/not used) added to bothstats-filter.tsxfiles, right afterlocation, shown only when thegiftLinkslabs flag is on.gift_linkadded toSUPPORTED_FILTER_FIELDSso the filter round-trips through the URL (bookmark/shareable) into the Tinybird query params. The URL ⇄ filter sync is also gated on the labs flag, so a stalegift_linkparam (e.g. a shared link) can't apply an invisible, unremovable filter when the flag is off.web.tsxviews already forward non-audience filters generically.used→gift_link=true,not used→gift_link=false. The pipes resolvegift_link == 'false' || '0'as "no gift link", any other value as "has a gift link".Backend dependency
Consumes the
gift_linkdimension + value-aware endpoint logic from #28854 — that PR must be merged/deployed first. As of its latest revision, #28854 wiresgift_linkinto every endpoint this filter hits (api_kpis_v2,api_top_pages_v3,api_top_locations_v2,api_active_visitors_v2,filtered_sessions_v2), so both used and not used return correct data with the value encoding above.Testing
tsc --noEmit: ✅ both apps🤖 Generated with Claude Code