forked from offlegacy/event-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
28 lines (23 loc) · 826 Bytes
/
Copy pathtypes.ts
File metadata and controls
28 lines (23 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { TaskResult } from "../types";
export type Batch<TTaskResult extends TaskResult = TaskResult> = TTaskResult[];
export type OnFlush<TTaskResult extends TaskResult = TaskResult> = (
batch: Batch<TTaskResult>,
isBrowserClosing: boolean,
) => void | Promise<void>;
export type OnError = (error: Error) => void | Promise<void>;
export type FlushType = "interval" | "batchFull" | "pageLeave" | "unknown";
export type BatchConfig<TTaskResult extends TaskResult = TaskResult> =
| {
enable: false;
}
| {
enable: true;
interval?: number;
thresholdSize?: number;
onFlush: OnFlush<TTaskResult>;
onError?: OnError;
};
export interface SchedulerConfig<TTaskResult extends TaskResult = TaskResult> {
isTrackerInitialized: () => boolean;
batch: BatchConfig<TTaskResult>;
}