UNPKG

1.67 kBTypeScriptView Raw
1import { Event, EventProcessor, Hub, Integration } from '@sentry/types';
2declare type LocalForage = {
3 setItem<T>(key: string, value: T, callback?: (err: any, value: T) => void): Promise<T>;
4 iterate<T, U>(iteratee: (value: T, key: string, iterationNumber: number) => U, callback?: (err: any, result: U) => void): Promise<U>;
5 removeItem(key: string, callback?: (err: any) => void): Promise<void>;
6 length(): Promise<number>;
7};
8export declare type Item = {
9 key: string;
10 value: Event;
11};
12/**
13 * cache offline errors and send when connected
14 */
15export declare class Offline implements Integration {
16 /**
17 * @inheritDoc
18 */
19 static id: string;
20 /**
21 * @inheritDoc
22 */
23 readonly name: string;
24 /**
25 * the current hub instance
26 */
27 hub?: Hub;
28 /**
29 * maximum number of events to store while offline
30 */
31 maxStoredEvents: number;
32 /**
33 * event cache
34 */
35 offlineEventStore: LocalForage;
36 /**
37 * @inheritDoc
38 */
39 constructor(options?: {
40 maxStoredEvents?: number;
41 });
42 /**
43 * @inheritDoc
44 */
45 setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void;
46 /**
47 * cache an event to send later
48 * @param event an event
49 */
50 private _cacheEvent;
51 /**
52 * purge excess events if necessary
53 */
54 private _enforceMaxEvents;
55 /**
56 * purge event from cache
57 */
58 private _purgeEvent;
59 /**
60 * purge events from cache
61 */
62 private _purgeEvents;
63 /**
64 * send all events
65 */
66 private _sendEvents;
67}
68export {};
69//# sourceMappingURL=offline.d.ts.map
\No newline at end of file