Skip to content

Attribute markdown and ask events to their space - #4501

Open
nolannbiron wants to merge 2 commits into
mainfrom
nolann/attribute-markdown-events-to-space
Open

Attribute markdown and ask events to their space#4501
nolannbiron wants to merge 2 commits into
mainfrom
nolann/attribute-markdown-events-to-space

Conversation

@nolannbiron

Copy link
Copy Markdown
Member

page_markdown_request and the ask_question the middleware emits for ?ask= carried only a displayContext, so they were stored with an empty spaceId and an unparseable siteSpaceId. Any space- or section-scoped query dropped them, and the markdown traffic of a space read as zero.

They now reuse the eventLocation the middleware already builds from the URL resolution — the one rss_request has used since #4242 — carrying space, siteSpace, siteSection, siteShareKey and revision.

The two llms_request branches deliberately keep their own location. llms.txt and llms-full.txt walk every section and site-space of the site, so stamping the single space the URL resolved to would attribute a site-wide document to one of them.

ask_question also gains the goal. It was already parsed off the query string to be encoded into the rewrite target, but never put on the event, so eventAskGoal was always empty.

pageId

The TODO also asked for pageId. It is not derivable from the URL — PublishedSiteContent has no page — and the only path→page endpoints return a full page object. Resolving it in the middleware costs one extra API call per document served, on routes that are otherwise fully cache-served, and it has to complete before the tracking call can be sent — which on Vercel puts a network round-trip in front of a waitUntil that has no lifecycle-extension primitive today.

It belongs on resolvePublishedContentByUrl, which the middleware already calls on every request. Follow-up in gitbook-x.

`page_markdown_request` and the `ask_question` the middleware emits for `?ask=`
carried only a displayContext, so they were stored with an empty spaceId and an
unparseable siteSpaceId. Any space- or section-scoped query dropped them, and the
markdown traffic of a space read as zero.

Reuse the location the middleware already builds, as `rss_request` does. The
llms branches keep theirs: llms.txt spans every section and site-space, so a
single spaceId would attribute a site-wide document to one of them.

`ask_question` also gains the goal, which was parsed off the query string to be
encoded in the rewrite and then dropped from the event.

The pageId the TODO asked for is not in the URL, and resolving it in the
middleware costs a request per document served; it is left to the API to return
alongside the space.
@changeset-bot

changeset-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1cfc0c1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
gitbook Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

@argos-ci

argos-ci Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v2-cloudflare (Inspect) ⚠️ Changes detected (Review) 17 changed, 6 ignored Aug 14, 2026, 12:47 PM
v2-cloudflare (Inspect) ✅ No changes detected 1 ignored Aug 14, 2026, 12:49 PM

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