Notification texts go here Contact Us Buy Now!

How to log errors with Sentry when offline?

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.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.