Add Presence API announcement, docs, and changelog#3010
Conversation
Appwrite WebsiteProject ID: Website (appwrite/website)Project ID: Tip Git integration provides automatic deployments with optional PR comments |
Greptile SummaryThis PR introduces the Appwrite Presence API by adding an announcement blog post, a changelog entry, a full Realtime reference page, an auth-product guide, and an update to the channels reference table.
Confidence Score: 3/5The reference page and auth guide contain multiple places where copying the provided snippets produces broken behavior, making this risky to publish as-is. The 'while connected' cleanup claim describes a mechanism with no supporting API or code, the heartbeat example calls update() without expiresAt so the record never slides forward, and subscribe handlers in three SDK tabs use event strings that will never match any real event. docs/apis/realtime/presence/+page.markdoc and docs/products/auth/presence/+page.markdoc need the most attention; the blog post and changelog are largely cosmetic. Important Files Changed
Reviews (10): Last reviewed commit: "Update src/routes/docs/apis/realtime/pre..." | Re-trigger Greptile |
|
@ArnabChatterjee20k I'm still working on some more updates, will ping on Discord once ready |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
| - **A heartbeat timer** (for example every 30 seconds) to push the `expiresAt` forward and keep the record alive while the user is active. | ||
|
|
||
| ```client-web | ||
| async function setStatus(status, metadata = {}) { | ||
| await presences.update({ | ||
| presenceId, | ||
| status, | ||
| metadata | ||
| }); | ||
| } | ||
|
|
||
| window.addEventListener('focus', () => setStatus('online')); | ||
| window.addEventListener('blur', () => setStatus('away')); | ||
| ``` | ||
|
|
||
| There is no fixed heartbeat interval enforced by the server, so pick whichever cadence matches your UX. Anything shorter than the `expiresAt` you choose will keep the presence alive without gaps. |
There was a problem hiding this comment.
Heartbeat use case uses
update(), which won't slide expiresAt forward
Line 92 says the heartbeat timer's goal is "to push the expiresAt forward," but setStatus calls presences.update() without passing expiresAt. The reference docs explicitly describe the heartbeat pattern as using upsert() to slide expiresAt forward. An update() call that omits expiresAt leaves the original timestamp unchanged, so presences will still expire despite an active heartbeat loop. Either replace presences.update() with presences.upsert(), or explicitly pass an updated expiresAt value.
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
| This gives you two ways to keep a presence alive, and you pick whichever fits your UI: | ||
|
|
||
| - **Heartbeat.** Upsert on focus, route change, or a periodic timer to push `expiresAt` forward. Best when presence should persist briefly across short disconnects (a quick network blip, a tab switch) or when you write presence from server code that has no live socket. | ||
| - **While connected.** If you keep a Realtime connection open, presence written over that connection is cleaned up automatically when the connection closes. Best for "online while the tab is open" UIs where you do not want to manage a heartbeat yourself. |
There was a problem hiding this comment.
"While connected" cleanup is undocumented and likely incorrect
Line 32 claims "If you keep a Realtime connection open, presence written over that connection is cleaned up automatically when the connection closes." However, all presence write operations in every code example use the Presences REST service — not the WebSocket. The Appwrite Realtime SDK is a subscriber-only mechanism; there is no API shown (no connection-id parameter, no opt-in flag) for tying a REST-written presence record to a WebSocket session's lifetime. A developer who relies on this "auto-cleanup on disconnect" behavior and skips the heartbeat/TTL pattern will find their presence records surviving tab close or network drop unchanged, leaving stale "online" indicators until the default expiresAt elapses. Either the mechanism that links a presence record to a connection needs to be described with working code, or this bullet should be removed and only the heartbeat pattern documented.


What does this PR do?
(Provide a description of what this PR does.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)
Related PRs and Issues
(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)
Have you read the Contributing Guidelines on issues?
(Write your answer here.)