Skip to content

Commit b446574

Browse files
committed
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
1 parent a1c8ab0 commit b446574

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

_includes/cloudcode/cloud-code.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,37 @@ 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 monitor Live Query Event to be used with a 3rd Party such as datadog. The `onLiveQueryEvent` trigger can be logging events triggered, number of clients connected, number of subscriptions and errors.
477+
478+
```javascript
479+
Parse.Cloud.onLiveQueryEvent(({
480+
event,
481+
clients,
482+
subscriptions,
483+
error
484+
}) => {
485+
if (event !== 'ws_disconnect') {
486+
return;
487+
}
488+
// Do your magic
489+
});
490+
```
491+
492+
## Events
493+
494+
* connect
495+
* subscribe
496+
* unsubscribe
497+
* ws_connect
498+
* ws_disconnect
499+
* ws_disconnect_error
500+
501+
"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.
502+
472503
# Using the Master Key in cloud code
473504
Set `useMasterKey:true` in the requests that require master key.
474505

0 commit comments

Comments
 (0)