Skip to content

Commit fcfed9f

Browse files
dplewisTomWFox
andcommitted
Parse.Cloud.onLiveQueryEvent Documentation (#666)
* Parse.Cloud.onLiveQueryEvent Documentation closes: #628 I plan on adding more parameters on the server like sessionToken and connectedAt timestamp. If you can think of any other parameters / events that would help with monitoring I can open a PR with them * Update _includes/cloudcode/cloud-code.md Co-Authored-By: Tom Fox <tomfox@surprises.io> * Add 2.8.0 changes * Update _includes/cloudcode/cloud-code.md Co-Authored-By: Tom Fox <tomfox@surprises.io>
1 parent bc2b130 commit fcfed9f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

_includes/cloudcode/cloud-code.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,44 @@ Parse.Cloud.beforeLogin(async request => {
469469
- On sign up
470470
- If the login credentials are incorrect
471471
472+
# LiveQuery Triggers
473+
474+
*Available only on parse-server cloud code starting 2.6.2*
475+
476+
Sometimes you may want to monitor Live Query Events to be used with a 3rd Party such as datadog. The `onLiveQueryEvent` trigger can log events triggered, number of clients connected, number of subscriptions and errors.
477+
478+
```javascript
479+
Parse.Cloud.onLiveQueryEvent(({
480+
event,
481+
client,
482+
sessionToken,
483+
useMasterKey,
484+
installationId,
485+
clients,
486+
subscriptions,
487+
error
488+
}) => {
489+
if (event !== 'ws_disconnect') {
490+
return;
491+
}
492+
// Do your magic
493+
});
494+
```
495+
*client, sessionToken, useMasterKey and installationId are available on parse-server cloud code 3.8.0+*
496+
497+
To learn more, read the [Parse LiveQuery Protocol Specification](https://github.com/parse-community/parse-server/wiki/Parse-LiveQuery-Protocol-Specification)
498+
499+
## Events
500+
501+
* connect
502+
* subscribe
503+
* unsubscribe
504+
* ws_connect
505+
* ws_disconnect
506+
* ws_disconnect_error
507+
508+
"connect" differs from "ws_connect", the former means that the client completed the connect procedure as defined by Parse Live Query protocol, where "ws_connect" just means that a new websocket was created.
509+
472510
# Using the Master Key in cloud code
473511
Set `useMasterKey:true` in the requests that require master key.
474512

0 commit comments

Comments
 (0)