Skip to content

Pass gift through the page hit pipeline#742

Open
jonatansberg wants to merge 1 commit into
mainfrom
ber-3728-gift-id-passthrough
Open

Pass gift through the page hit pipeline#742
jonatansberg wants to merge 1 commit into
mainfrom
ber-3728-gift-id-passthrough

Conversation

@jonatansberg

@jonatansberg jonatansberg commented Jun 24, 2026

Copy link
Copy Markdown
Member

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

Ghost's Gift Links feature is moving usage tracking off a bespoke DB counter and onto the existing web-analytics pipeline, so gift numbers are measured the same way as every other page view. Gift reads carry one new dimension — gift (the gift-link token) — on the page_hit payload, so the data can:

  • segment "gift traffic" in the normal reports, and
  • count usage per individual link.

Why this PR is needed

The proxy rebuilds the payload field-by-field (pageHitRawPayloadFromRequesttransformPageHitRawToProcessed), so any field not explicitly threaded is silently dropped before it reaches Tinybird. This wires gift through end-to-end:

  • schemas/v1/page-hit-raw.tsgift on PayloadSchema (optional, nullable).
  • transformations/page-hit-transformations.ts — copied in pageHitRawPayloadFromRequest(), defaulting to null.
  • schemas/v1/page-hit-processed.ts — on PageHitProcessedSchema and the payload rebuilt in transformPageHitRawToProcessed().
  • schemas/v1/page-hit-request.ts — declared explicitly (validation already admits it via additionalProperties: true) + a null default.

Covers both the inline and batch worker paths, since both run through these transforms. Absent on non-gift hits, where it defaults to null.

Notes for review

  • gift is the gift-link token, a bearer credential — but first-party data the site owner already minted and shareable by design, so storing it in their own analytics is acceptable. Worth a thought on error-log / retention.
  • Producer (Ghost ghost_head) and the Tinybird data-files (_mv_hits column, segment, per-link endpoint) are separate PRs on the Ghost repo. This PR is a safe no-op until those land.

Tests

tsc clean. page-hit-transformations.test.ts: the "all fields present" case now asserts gift passthrough, plus a new case for the absent → null default. (The 2 pre-existing SaltStoreFactory failures are unrelated Firestore/GCP-env tests.)

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jonatansberg, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 51 minutes and 54 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 36a77442-8c72-486c-beeb-a137b6b2d9fe

📥 Commits

Reviewing files that changed from the base of the PR and between a1e6503 and 95c51f3.

📒 Files selected for processing (5)
  • src/schemas/v1/page-hit-processed.ts
  • src/schemas/v1/page-hit-raw.ts
  • src/schemas/v1/page-hit-request.ts
  • src/transformations/page-hit-transformations.ts
  • test/unit/transformations/page-hit-transformations.test.ts

Walkthrough

The page-hit request, raw, and processed payload schemas now include an optional nullable gift field. The request payload defaults now set gift to null when omitted. The request-to-raw transformation copies gift from the request body with a null fallback, and the raw-to-processed transformation copies gift into the processed payload. Unit tests were updated for the populated and missing gift cases.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: threading the gift field through the page hit pipeline.
Description check ✅ Passed The description is directly about adding gift passthrough to page-hit analytics and matches the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ber-3728-gift-id-passthrough

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.

@jonatansberg jonatansberg force-pushed the ber-3728-gift-id-passthrough branch from c4b255c to 9b85789 Compare June 24, 2026 10:49
@jonatansberg jonatansberg changed the title Pass gift_id through the page hit pipeline Pass gift through the page hit pipeline Jun 24, 2026
@jonatansberg jonatansberg force-pushed the ber-3728-gift-id-passthrough branch from 9b85789 to a1e6503 Compare June 24, 2026 13:45
@jonatansberg jonatansberg marked this pull request as ready for review June 25, 2026 14:50
@jonatansberg jonatansberg requested a review from cmraible as a code owner June 25, 2026 14:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1e6503b9d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/schemas/v1/page-hit-processed.ts
ref https://linear.app/ghost/issue/BER-3746/integrate-gift-link-usage-tracking-with-analytics

Ghost is moving gift-link usage tracking onto the existing web-analytics
pipeline. Gift reads now carry a `gift` field (the gift-link token) on the
page_hit payload so the data can segment gift traffic and count per-link usage.

The proxy rebuilds the payload field-by-field, so an un-threaded field is
silently dropped before it reaches Tinybird. This threads `gift` (optional,
nullable) through the raw schema, the raw-payload transform, the processed
schema, and the request schema/defaults — covering both the inline and batch
worker paths. Absent on non-gift hits, where it defaults to null.
@jonatansberg jonatansberg force-pushed the ber-3728-gift-id-passthrough branch from a1e6503 to 95c51f3 Compare June 25, 2026 14:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 95c51f3892

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/transformations/page-hit-transformations.ts
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