Skip to content

Fixed gift-link usage count wiring and display#29004

Open
jonatansberg wants to merge 1 commit into
mainfrom
ber-3746-gift-link-usage-count
Open

Fixed gift-link usage count wiring and display#29004
jonatansberg wants to merge 1 commit into
mainfrom
ber-3746-gift-link-usage-count

Conversation

@jonatansberg

Copy link
Copy Markdown
Member

ref https://linear.app/ghost/issue/BER-3746/integrate-gift-link-usage-tracking-with-analytics

Fixes the gift-link usage count surface in post analytics, found during end-to-end integration of the gift-link analytics stack. These are corrections to code merged in #28897.

What

  • Column contract fix. The usage hook matched Tinybird rows on gift, but the pipe returns gift_link (renamed in Added gift dimension to the web analytics data files #28854), so the lookup never found its row and the count was always 0. Now matches on gift_link.
  • Hook test. Added a unit test pinning the pipe→hook column contract. The Tinybird response is untyped (data as unknown as …), so a dimension rename can't be caught by the compiler — the test is the guard.
  • Web-analytics gating. The count is web-analytics-derived, so the hook is gated on web_analytics_enabled and the whole gift-link card is hidden when web analytics is off.
  • State handling. The hook now surfaces loading/error so the card hides the count while loading or on error instead of rendering a misleading 0. A resolved zero (no link yet, or a link with no visits) is a valid count and still shows.

Dependency

Depends on #28854 (datafiles) for the gift_link column and the api_gift_link_visits_v2 pipe — merge after that lands.

ref https://linear.app/ghost/issue/BER-3746/integrate-gift-link-usage-tracking-with-analytics

- the usage hook matched rows on `gift` but the Tinybird pipe returns `gift_link`,
  so the lookup never found its row and the count was always zero; matched on
  `gift_link` and added a unit test pinning the pipe->hook column contract, since
  the Tinybird response is untyped and a rename can't be caught by the compiler
- gated the hook on web_analytics_enabled and hid the whole gift-link card when
  web analytics is off, since the count is web-analytics-derived and meaningless
  without it
- surfaced `loading`/`error` from the hook so the card hides the count while
  loading or on error instead of rendering a misleading "0"; a resolved zero
  (no link yet, or a link with no visits) is a valid count and still shows
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ber-3746-gift-link-usage-count

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Jun 30, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 2afdb4d

Command Status Duration Result
nx run-many --target=build --projects=tag:publi... ✅ Succeeded 1s View ↗
nx run-many -t test:unit -p @tryghost/posts,@tr... ✅ Succeeded 2m 52s View ↗
nx run @tryghost/admin:build ✅ Succeeded 1m 48s View ↗
nx run-many -t lint -p @tryghost/posts,@tryghos... ✅ Succeeded 19s View ↗
nx run ghost:build:assets ✅ Succeeded 2s View ↗
nx run ghost:build:tsc ✅ Succeeded 7s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-30 15:41:54 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant