Page feedback
The documentation site records page-level reactions and optional comments in the
page-feedback-v1-{environment} Elasticsearch index. The API derives the document
_id from a key the browser keeps, so later comment submissions and reaction
changes replace the same document. See Feedback identity.
The thumbs-up or thumbs-down selection writes a document with the reaction after
a short debounce, so quickly changing the selection records only the final
choice. The follow-up questionnaire writes the same document again with one or
more structured reasons, the reason-set version, and optional details. Readers
can select several reasons at once. One comment field applies to the whole
submission. It keeps its value when the reader switches between Yes and No.
Switching the reaction clears any selected reason that does not belong to the new
reason set. The browser stores that draft in sessionStorage for the current tab
and page so an accidental refresh can restore it, and clears it after a
successful submit. Submitting the questionnaire flushes any pending reaction write first.
This keeps abandoned questionnaires useful while ensuring the richer
submission wins.
Reasons are stored in the multi-valued reasons keyword field for filtering and
aggregation. reason_set_version identifies the questionnaire revision that
presented the option. Display labels may change without changing their stored value. Add a new
enum value when an option's meaning changes, and retain retired values so older
clients and historical documents remain valid.
Reason set version 2 presents these positive reasons in display order:
solvedProblem, easyToUnderstand, accurate, helpfulExamples,
easyToFind, and anotherReason. The negative reasons are outOfDate,
hardToUnderstand, inaccurate, codeSampleErrors, missingInformation, and
anotherReason. API pages use the same stored values
and reason_set_version. They pass surface="api" so labels and descriptions
talk about the spec and examples instead of a product how-to.
Every API page shows a beta banner. Where page feedback runs, its "let us know"
link opens the same feedback widget in a dialog, so a reader reports a problem
without leaving the page. The dialog holds a second instance of the widget with
surface="api". It sends the same request, to the same index and with the same
reasons, as the widget at the bottom of the page, and the page URL identifies the
page. Feedback from the dialog therefore has no marker that tells it apart.
Page feedback runs when the PAGE_FEEDBACK flag is on, the site is not
air-gapped, and the build type has the feedback API behind it
(GlobalLayoutViewModel.ShowPageFeedback). Anywhere else, and in a browser
without script or <dialog>, the link goes to the docs-content issue form with
the page URL filled in. A click with a modifier key opens that form in a new tab.
The banner sits outside #main-container, which boosted navigation swaps. After
each swap api-beta-banner.ts replaces, inserts or removes the banner to match
the new page, so the dialog always reports the page the reader is on.
The API stores pageUrl only when it is a site-relative path: it starts with one
/, has at most 2048 characters, and contains no whitespace, control character or
backslash. A browser drops tabs and line breaks from a URL and reads a backslash
as a slash, so a path with those characters could turn into a link to another
site wherever the stored URL is shown as a link.
The API does not check that the page exists, and stores pageTitle as sent. Treat
both as reader input in anything that displays them.
The browser creates two random UUIDs for each feedback: an id for the request path
and a feedbackKey for the request body. It keeps both in the draft and sends
them with every write. Whoever knows the key can replace the feedback, so the
feedbackKey travels in the body, and the API neither stores it nor writes it to
its logs.
The document _id, also stored as feedback_id, is a SHA-256 hash of the key and
the page URL. This has two effects:
- Sending the same key again for the same page replaces the same document. A reader can change their reaction until they submit the questionnaire, and retries create no duplicates.
- A key can't replace feedback on another page.
The API and the site deploy independently, so the key is optional. When a request
has no feedbackKey, the API uses the id in the path as the key. A site bundle
that predates the key keeps working with a new API, and a new bundle keeps working
with an API that ignores the field. A draft saved before keys existed keeps
sending no key, because its first write was made under the id alone.
For a request without a feedbackKey, the id in the path is still what replaces
the feedback, and it is part of the request URL. Such an id does not expire: sent
again without a key, it replaces that feedback for as long as the API accepts
requests without a feedbackKey. Treat request logs and traces that record the
URL as sensitive until the API rejects those requests, also after older bundles
stop sending them.
An id from the path and a feedbackKey hash differently, even when they hold the
same UUID. An id read from a request URL is therefore of no use as a
feedbackKey, and it stops working once the API rejects requests without one.
The browser discards the id and the key when the questionnaire is submitted. Feedback given after a refresh gets a new id and key, and is stored as a new document.
Documents written before this change have the browser's UUID as their _id.
This API version stores every write under a hash, also for a request without a
feedbackKey, so it never replaces one of those earlier documents. An earlier API
version stores under the id in the path. A known _id can therefore still replace
an earlier document while an instance of that version receives writes, during a
rolling deploy or after a rollback.
A reader's reaction and their questionnaire land in the same document only when
both writes derive the same _id. They derive different ones in two cases:
- The two writes reach different API versions, one that stores under the id in the path and one that stores under the hash. This can happen while the API is being deployed or rolled back.
- The site is rolled back while a reader has a draft open. The earlier bundle rewrites the draft without the key, so later writes for that draft carry none.
Each case leaves two documents for that reader: one with the reaction alone and one with the full feedback. The reader sees no error. Deploying the API before the site keeps the first case to readers who are mid-feedback during the API deploy.
PageFeedbackMapping defines the mapping with Elastic.Mapping attributes.
During API startup, PageFeedbackBootstrapService uses
Elastic.Ingest.Elasticsearch to create or update environment-specific
component and index templates. The generated context uses the API assembly
version as its mapping version. Bootstrap skips unchanged mapping hashes and
prevents an older API task from replacing templates installed by a newer task
during a rolling deployment.
The bootstrap service and runtime gateway share one ingest channel. Feedback
upserts use DirectWriteAsync and await the bulk item result before the API
responds. They do not use the channel's retry overload because the browser owns
the bounded retry UX. The first successful feedback write creates the concrete
index from the templates.
The generated mapping disables dynamic field mapping. Fields that are not part
of PageFeedbackDocument remain unindexed instead of changing the schema.
Templates only apply when an index is created, and this index has a fixed name.
An index created before a field was added keeps its old mapping, so the new
field is stored in _source but never indexed. After the templates, startup
therefore also puts the current mapping on the existing index
(PUT page-feedback-v1-{environment}/_mapping). A missing index is fine, because
the template applies on the first write. A rejected mapping is a bootstrap failure.
Documents written before a field reached the mapping stay unindexed for that
field until you run POST page-feedback-v1-{environment}/_update_by_query?conflicts=proceed.
Bootstrap failures are logged and ignored in dev so the local documentation
server can run without Elasticsearch. They prevent startup in staging, edge,
and prod.
Runtime credentials require permission to manage component and index templates,
create the environment's index, and write its documents. The mapping update also
needs the manage index privilege on page-feedback-v1-{environment}. Grant it
before you deploy a build that has the update, because without it Elasticsearch
answers 403 and bootstrap fails.
An added field needs no new index, because startup applies it in place. For an incompatible mapping change, such as a changed field type or a removed field, increment the schema version in the index name, deploy the new template, and migrate any documents that must be retained. Mixed task versions then write to separate versioned indices during a rolling deployment. The assembly mapping version is an additional downgrade guard for templates that retain the same schema-versioned name; it does not replace index versioning.
The web ACL can require a valid aws-waf-token cookie on /docs/_api/v1/page-feedback.
A request without one gets an HTTP 202 challenge that a plain fetch() can't solve.
When waf_integration_url is set on an environment in config/assembler.yml, the page
<head> loads the AWS WAF JavaScript SDK from that URL (Layout/_Head.cshtml). The SDK
fetches the token in the background and stores it in the cookie. Take the URL from the
AWS WAF console's Application integration page. Use the CloudFront (edge) script URL,
not the regional one. It belongs to the AWS account and is not tied to a web ACL, so
environments in the same account share it.
The URL is the jsapi.js script from the CAPTCHA integration tab. The
Intelligent threat integration tab only lists web ACLs that use the ACFP or ATP rule
groups or targeted Bot Control, and the docs web ACLs use common Bot Control. jsapi.js
loads challenge.js, which defines AwsWafIntegration a little later, so
waitForWafSdk in Assets/waf.ts waits up to 5 seconds for the global.
The <page-feedback> component and the design-system widget (Assets/ds/feedback.ts) send the PUT through AwsWafIntegration.fetch. If the
SDK doesn't appear in time, the submit shows the normal error state instead of sending
an unchallenged request.
Browser telemetry waits for the token before each export to /docs/_api/v1/o/{t,l,m},
so the web ACL can challenge those paths too. If the token can't be fetched within 5
seconds, exports go out without it. The telemetry SDK still starts at page load, so
instrumentation isn't delayed.
With no URL (local dev, isolated, codex, air-gapped) no script loads, page feedback uses
plain fetch, and telemetry doesn't wait.
External callers of other /docs/_api/v1/* paths can't run the SDK and stay on IP
rate limits.