Skip to main content

logout()

logout() ends a MonitorDog SDK user session.

Role

When logout() is called, the SDK internally performs the following work in order.

Send logout activity event
-> Remove SDK access token
-> Clean up SDK session/auth state

Parameters

logout() does not take any parameters.

await detector.logout();

The SDK performs logout processing based on the access token and user state stored at login() time.

Return Value

logout() does not return a value.

In general, customer application code first stops the running detector with stop(), then calls await detector.logout(). If the detector instance will no longer be used, call dispose() as well to fully release resources.

Difference from dispose()

logout() means user session termination. When possible, it sends a logout activity event and then cleans up the SDK token and session state.

dispose() immediately releases resources used by the detector instance. Call it when the SDK will no longer be used, such as page exit, React component unmount, or detector instance disposal.

For flows that require session termination semantics, such as user logout, the recommended flow is to call logout() after stop(), then call dispose() in finally if the instance should also be discarded.

try {
detector.stop();
await detector.logout();
} finally {
detector.dispose();
}

Notes

  • Call logout() after the user logs out of the customer website.
  • logout() does not directly delete the customer session cookie or customer backend session.
  • If the detector is running, it throws a DETECTOR_RUNNING error.
  • Stop a running detector first with stop().
  • logout() cleans up the MonitorDog SDK access token and session state.
  • If logout() fails, it is still a good idea to call dispose() in finally for screen teardown flows that need to release detector resources.
  • To run the same detector instance again, call login() and then start() again.