Pass gift through the page hit pipeline#742
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
WalkthroughThe page-hit request, raw, and processed payload schemas now include an optional nullable Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ 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 |
c4b255c to
9b85789
Compare
9b85789 to
a1e6503
Compare
There was a problem hiding this comment.
💡 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".
a1e6503 to
95c51f3
Compare
There was a problem hiding this comment.
💡 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".
95c51f3 to
8015d8b
Compare
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 `@src/schemas/v1/page-hit-processed.ts`:
- Line 166: The processed payload mapping in PageHitProcessed still forwards
pageHitRaw.payload.gift_link directly, which can leave it undefined instead of
normalizing to null. Update the page-hit processing transform to apply the same
fallback used in the request-to-raw path so that missing gift_link values become
null consistently in the processed output.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 05ef0f0b-5e3b-4d8d-970d-c8e3e296f8f6
📒 Files selected for processing (5)
src/schemas/v1/page-hit-processed.tssrc/schemas/v1/page-hit-raw.tssrc/schemas/v1/page-hit-request.tssrc/transformations/page-hit-transformations.tstest/unit/transformations/page-hit-transformations.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/schemas/v1/page-hit-raw.ts
| member_status: pageHitRaw.payload.member_status, | ||
| post_uuid: pageHitRaw.payload.post_uuid, | ||
| post_type: pageHitRaw.payload.post_type, | ||
| gift_link: pageHitRaw.payload.gift_link, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Normalize missing raw gift_link to null here too.
PageHitRaw.payload.gift_link is optional upstream, so the batch/raw path can still hand you undefined. Copying it through directly breaks the PR’s “absent => null” contract for processed payloads. Use the same fallback as the request→raw transform.
Suggested fix
- gift_link: pageHitRaw.payload.gift_link,
+ gift_link: pageHitRaw.payload.gift_link ?? null,📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| gift_link: pageHitRaw.payload.gift_link, | |
| gift_link: pageHitRaw.payload.gift_link ?? null, |
🤖 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 `@src/schemas/v1/page-hit-processed.ts` at line 166, The processed payload
mapping in PageHitProcessed still forwards pageHitRaw.payload.gift_link
directly, which can leave it undefined instead of normalizing to null. Update
the page-hit processing transform to apply the same fallback used in the
request-to-raw path so that missing gift_link values become null consistently in
the processed output.
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_link` 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_link` (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.
8015d8b to
819aaa5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 819aaa5fb3
ℹ️ 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".
| member_status: request.body.payload.member_status, | ||
| post_uuid: request.body.payload.post_uuid, | ||
| post_type: request.body.payload.post_type, | ||
| gift_link: request.body.payload.gift_link ?? null, |
There was a problem hiding this comment.
Read the gift token from the producer field
When Ghost sends the new gift-link dimension as payload.gift (as described by this change and allowed by the request schema's additionalProperties), this transform only reads payload.gift_link, so gift_link becomes null and the raw/processed events never carry the token to Tinybird. For gift-link page hits this makes the new per-link analytics silently report as non-gift traffic unless the producer is changed to the different field name.
Useful? React with 👍 / 👎.
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 thepage_hitpayload, so the data can:Why this PR is needed
The proxy rebuilds the payload field-by-field (
pageHitRawPayloadFromRequest→transformPageHitRawToProcessed), so any field not explicitly threaded is silently dropped before it reaches Tinybird. This wiresgiftthrough end-to-end:schemas/v1/page-hit-raw.ts—giftonPayloadSchema(optional, nullable).transformations/page-hit-transformations.ts— copied inpageHitRawPayloadFromRequest(), defaulting tonull.schemas/v1/page-hit-processed.ts— onPageHitProcessedSchemaand the payload rebuilt intransformPageHitRawToProcessed().schemas/v1/page-hit-request.ts— declared explicitly (validation already admits it viaadditionalProperties: true) + anulldefault.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
giftis 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.ghost_head) and the Tinybird data-files (_mv_hitscolumn, segment, per-link endpoint) are separate PRs on the Ghost repo. This PR is a safe no-op until those land.Tests
tscclean.page-hit-transformations.test.ts: the "all fields present" case now assertsgiftpassthrough, plus a new case for the absent →nulldefault. (The 2 pre-existingSaltStoreFactoryfailures are unrelated Firestore/GCP-env tests.)