Repository navigation
Keep page feedback from readers who decline cookies #480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eugenia-scandit
wants to merge
11
commits into
main
Choose a base branch
from
feat/docs-feedback-no-consent
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
644e23e
Keep page feedback from readers who decline cookies
eugenia-scandit dda39cf
Fall back only when PostHog is absent, and say where feedback goes
eugenia-scandit 3f47958
Mention the vote in the fallback note, and don't claim delivery
eugenia-scandit bb216ea
Stop holding the vote once the fallback has sent it
eugenia-scandit 144c40b
Read the feedback endpoint and token from the _PROD variables
eugenia-scandit ca0ec60
Revert "Read the feedback endpoint and token from the _PROD variables"
eugenia-scandit f66ca3c
Say which job sets the feedback endpoint, and hold no vote during the…
eugenia-scandit 1688b8e
Restore a vote held across a failed request only if nobody voted mean…
eugenia-scandit 1a874cf
Hold the thumbs while a comment is being sent
eugenia-scandit fcd5e9c
Merge main into feat/docs-feedback-no-consent
eugenia-scandit 4de262f
Say that not-loaded also covers PostHog without a capture method
eugenia-scandit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /** | ||
| * The fallback for a comment PostHog could not take because it is not loaded. | ||
| * | ||
| * WHY THIS EXISTS. The widget's events go to PostHog, which is loaded BEHIND | ||
| * the consent banner: until a reader accepts cookies, `window.posthog` does | ||
| * not exist and the capture reports `not-loaded`. So a reader who declines | ||
| * and then spends two minutes writing us a paragraph leaves no trace of it | ||
| * anywhere. | ||
| * | ||
| * ONLY WHEN POSTHOG IS NOT LOADED. Never beside a successful capture, so a | ||
| * consenting reader's comment is not recorded twice under two timestamps; and | ||
| * never when the reader has explicitly opted out of capturing in PostHog (or | ||
| * when PostHog threw and that cannot be ruled out). An opt-out is a refusal, | ||
| * not a delivery problem to route around. | ||
| * | ||
| * WHERE IT GOES. An Apps Script Web App deployed to accept anonymous requests, | ||
| * which appends the comment to a spreadsheet. The endpoint must accept | ||
| * requests from a reader's browser without any sign-in. The widget's note | ||
| * tells the reader this before they send, whenever this path applies. | ||
| * | ||
| * WHAT IT SENDS. The four fields the widget already sends to PostHog, plus | ||
| * the token, and nothing else in the body. Like any web request, it also | ||
| * carries the browser's IP address and user agent to the receiving server. | ||
| */ | ||
|
|
||
| type DirectFeedback = { | ||
| url: string; | ||
| title: string; | ||
| helpful: boolean | null; | ||
| comment: string; | ||
| }; | ||
|
|
||
| /** | ||
| * `no-cors`, and what that costs. | ||
| * | ||
| * An Apps Script Web App does not answer a cross-origin preflight, so a normal | ||
| * JSON POST never leaves the browser. `text/plain` keeps the request "simple" | ||
| * and no-cors lets it through — at the price of an opaque response we cannot | ||
| * read. So this reports whether the request was DISPATCHED, not whether it | ||
| * arrived. | ||
| * | ||
| * An Apps Script that answers with an error, or was redeployed to a new URL, | ||
| * still resolves here. So on this path the widget's copy says only that the | ||
| * note was sent ("Thanks — your note was sent."), never that it reached the | ||
| * team. | ||
| */ | ||
| export async function sendDirectFeedback( | ||
| endpoint: string, | ||
| token: string, | ||
| payload: DirectFeedback, | ||
| ): Promise<boolean> { | ||
| if (!endpoint) return false; | ||
| try { | ||
| await fetch(endpoint, { | ||
| method: 'POST', | ||
| mode: 'no-cors', | ||
| // Deliberately text/plain: application/json would trigger a preflight | ||
| // the Web App cannot answer. | ||
| headers: { 'Content-Type': 'text/plain;charset=utf-8' }, | ||
| // `keepalive` so the request is still dispatched if the reader navigates | ||
| // away mid-send (no-cors cannot confirm it arrived). | ||
| keepalive: true, | ||
| body: JSON.stringify({ ...payload, token }), | ||
| }); | ||
| return true; | ||
|
moritzhartmeier marked this conversation as resolved.
|
||
| } catch { | ||
| // Offline, blocked, or refused. The caller tells the reader plainly and | ||
| // keeps their text in the box. | ||
| return false; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a privacy/consent review: the disclosure no longer matches where the data goes. For a reader who declined cookies, this sends the comment, page URL and title to
script.google.com, and the request carries their IP and user agent. That's a different processor and different storage (a spreadsheet) than the consent banner covers. The widget's note (index.tsx:376) still says the comment is "sent to our analytics tool with this page's address", which is no longer accurate on this path.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partly addressed, still open: this needs a privacy/consent sign-off.
The disclosure now matches the destination (7c8da0b, 5507dce): on the fallback path, the note says the comment, the vote and the page's address and title go to a Google Apps Script form that adds them to a spreadsheet, and that the request carries the browser's IP address and user agent. On the analytics path, the note is unchanged.
What code can't settle: a reader who declines the cookie banner is exactly who the fallback sends to. That's the point of this PR, so someone responsible for privacy and consent needs to confirm it's acceptable before this ships.