How to log errors with Sentry when offline?
While they're offline you obviously can't send any data to Sentry server but you can, for example, store those errors in LocalStorage until a user gets online again. And when they are online send these errors to Sentry.
Sentry provides an offline caching transport . Sample usage from a browser-based application:
import * as Sentry from "@sentry/browser";
Sentry.init({
dsn: "https://...",
transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport),
transportOptions: {
// Caching options, e.g. maxQueueSize.
},
});
From the documentation:
To enable offline events caching, use makeBrowserOfflineTransport to wrap existing transports and queue events using the browsers' IndexedDB storage. Once your application comes back online, all events will be sent together.
Offline caching is not supported in IE due to a lack of IndexedDB features.