获取更多动态,关注公众号:黑客下午茶

Shutdown and Draining

大多数 SDK 的默认行为是在后台通过网络异步发送事件。这意味着如果应用程序意外关闭,某些事件可能会丢失。SDK 提供了应对这种情况的机制。

The close method optionally takes a timeout in milliseconds and returns a promise that resolves when all pending events are flushed, or the timeout kicks in.

Copied
Sentry.close(2000).then(function() {
  process.exit();
});

After a call to close, the current client cannot be used anymore. It's important to only call close immediately before shutting down the application.

Alternatively, the flush method drains the event queue while keeping the client enabled for continued use.

You can edit this page on GitHub.