Pluggable integrations that enhance Sentry JavaScript SDKs with additional error tracking, monitoring, and debugging capabilities.
—
Legacy class-based integration for caching events when offline and sending them when connection is restored. This integration is deprecated in favor of the offline transport wrapper.
Deprecation Notice: Use the offline transport wrapper instead of this integration for new projects.
/**
* Caches offline errors and sends when connected
* @deprecated Use offline transport wrapper instead
*/
class Offline implements Integration {
/** Integration identifier */
static id: string;
/** Integration name */
readonly name: string;
/** Current hub instance */
hub?: Hub;
/** Maximum number of events to store while offline */
maxStoredEvents: number;
/** Event cache using LocalForage */
offlineEventStore: LocalForage;
/**
* Creates offline integration instance
* @param options - Configuration options
*/
constructor(options?: { maxStoredEvents?: number });
/**
* Sets up offline event processing
* @param addGlobalEventProcessor - Function to add event processor
* @param getCurrentHub - Function to get current hub
*/
setupOnce(
addGlobalEventProcessor: (callback: EventProcessor) => void,
getCurrentHub: () => Hub
): void;
}Controls the maximum number of events cached while offline:
This integration requires the localforage library for client-side storage:
sentry/offlineEventStoreThe integration monitors browser connectivity:
navigator.onLine propertyWhen offline (navigator.onLine === false):
When online:
The integration listens for browser online/offline events:
import { Offline } from '@sentry/integrations';
import * as Sentry from '@sentry/browser';
// Basic offline support with default settings
Sentry.init({
dsn: 'YOUR_DSN',
integrations: [
new Offline()
]
});
// Custom cache size
Sentry.init({
dsn: 'YOUR_DSN',
integrations: [
new Offline({
maxStoredEvents: 50 // Store up to 50 events
})
]
});
// Simulate offline behavior
// Events captured while offline are cached:
navigator.onLine = false; // Simulate offline
Sentry.captureMessage('This will be cached');
navigator.onLine = true; // Simulate back online
// Cached events are automatically sentEvents are stored with UUID keys and contain the complete normalized event data:
type Item = {
key: string;
value: Event
};The integration enforces storage limits:
Storage operations are wrapped with error handling:
Recommended approach for new implementations:
import * as Sentry from '@sentry/browser';
import { makeOfflineTransport } from '@sentry/browser';
Sentry.init({
dsn: 'YOUR_DSN',
transport: makeOfflineTransport(/* transport options */)
});The transport wrapper provides:
Requires modern browser features:
This integration is primarily useful for Single Page Applications where users may experience intermittent connectivity issues and you want to ensure error events are not lost during offline periods.
Install with Tessl CLI
npx tessl i tessl/npm-sentry--integrations