Repository navigation
Record the Push permission answer after a Smart Alert acceptance - #103
Conversation
Once the permission request an acceptance starts settles, the alert posts the browser's answer to the alerts endpoint: `granted` or `denied`, read from Notification.permission. A prompt closed without an answer leaves permission at default and records nothing, so it stays an acceptance with no answer. The Smart Alert report uses these to count grants and denials. Rebuilt lib and dist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6709aeb3a5
ℹ️ 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".
Client-side navigation can show another section while the permission request is pending, which replaced the controller's section and page before the answer was recorded. The acceptance's section and page are now kept for the answer. Rebuilt lib and dist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the identity registration after a grant succeeds, the alert posts a `registered` interaction with the identity id the identities endpoint returned, under the acceptance's section and page. It reads a clone of the response body, so the response subscribe() returns stays readable. A failed or rejected registration records nothing. Rebuilt lib and dist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The answer used to be posted only after the whole subscription settled: the service worker, the browser subscription and the identity registration. A visitor who allowed Push and left the page in that window counted as having no answer. Push#subscribe now takes an optional onPermission callback that gets the answer before subscribing and registering, and the alert posts it from there. Permission is still requested first, inside the click. Rebuilt lib and dist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the visitor allows Push from the alert, the alert keeps the acceptance's section and page in localStorage until the Push identity is saved. If the page closes or registration fails first, the next page that loads the alert subscribes and registers without asking again, since permission is already granted, and records `registered` under the original acceptance. show() waits for it, so the alert doesn't appear meanwhile. Only a grant from the alert leaves the mark, so permission the visitor gave another tool on the site never subscribes them to Hellotext. The mark is dropped once permission is no longer granted, and a failure keeps it for the next page. WebKit skips its user gesture check for PushManager.subscribe once permission is granted, so this works in Safari too. Rebuilt lib and dist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e7a20c47c4
ℹ️ 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".
If the registration after a grant failed, the pending mark stayed, and a later Hellotext.push.unsubscribe() didn't clear it. Permission stays granted after unsubscribing, so the next page resubscribed the visitor without a click, reversing their opt-out. Push#unsubscribe now fires push:unsubscribed once the visitor has no subscription, including when there was none to remove, and the alert drops its mark on it. The resume also re-reads the mark after Push restoration, in case another tab unsubscribed meanwhile. Rebuilt lib and dist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As soon as the browser answers the permission prompt an acceptance opens, the alert posts the answer to the alerts endpoint as
grantedordenied.Push#subscribetakes an optionalonPermissioncallback that receives the answer before the subscription is created and registered, so a visitor who allows Push and leaves the page mid-registration still counts as a grant. Permission is still requested first, inside the click. When the identity registration that follows a grant succeeds, it also postsregisteredwith the identity id the identities endpoint returned. All three use the section and page saved at the click, so a client-side navigation that shows another section mid-prompt doesn't change them.defaultand records nothing.granted.registeredon that page. The alert keeps the granted acceptance (section and page) in localStorage until the identity is saved. If the page closes or registration fails first, the next page that loads the alert subscribes and registers without asking again, since permission is already granted, and postsregisteredunder the original acceptance.show()waits for it. Only a grant from the alert leaves the mark, so permission given to another tool on the site never subscribes the visitor. WebKit skips its user gesture check inPushManager.subscribeonce permission is granted (source), so this works in Safari too.subscribe()returns stays readable.Push#unsubscribefires a newpush:unsubscribedevent once the visitor has no subscription (including when there was none), and the alert drops its pending mark on it, so a resume never reverses an opt-out. The resume also re-reads the mark after Push restoration, in case another tab unsubscribed. Documented indocs/push.md.onPermissionis typed inindex.d.tsand documented indocs/push.md. A call that joins a pendingsubscribe()is not given the answer.Needs hellotext/hellotext#6934 deployed before release, otherwise the endpoint answers the new kinds with 422 (the SDK only warns in the console).
Rebuilt lib and dist.
🤖 Generated with Claude Code