Pass gift through the page hit pipeline#742
Draft
jonatansberg wants to merge 1 commit into
Draft
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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
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.
9b85789 to
a1e6503
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.)