Reporter
Reporter is responsible for batching and transmitting collected signals to the Sentinel backend (POST /sen/ss). It supports both time-based and size-based flush triggers, with automatic retry on failure.
Responsibilities
| Responsibility | Detail |
|---|---|
| Batch flush | Sends accumulated signals when a threshold is met |
| Time-based interval | Periodic forced flush at signalThresholdMs intervals |
| Size-based trigger | Immediate flush when unsent signal count exceeds signalThresholdSize |
| Token rotation | Stores any new token returned by the server |
| Config propagation | Forwards any new config from the server to Sentinel.updateConfig() |
| Retry with back-off | Uses RetryQueue for resilient delivery |
Flush Triggers
| Trigger | Condition | Force? |
|---|---|---|
| Signal added | unsentSignals.length >= sizeThreshold | No (respects threshold) |
| Interval timer | Every timeThresholdMs milliseconds | Yes (flushes any pending signals) |
| App foreground | AppStateCollector detects tab activation | Yes |
Public API
| Method | Signature | Description |
|---|---|---|
start | () => void | Begin periodic flushing (requires thresholds to be set) |
stop | () => void | Stop periodic flushing |
flushIfNeeded | (force?: boolean) => Promise<void> | Flush signals if threshold met, or immediately if force = true |
setThresholds | (thresholds: ReporterThresholds) => void | Update time/size thresholds and reschedule interval |
Flush Payload
interface ReporterRequest {
data: {
token: string;
signals: Array<Signal>;
};
}
Signals are sliced to sizeThreshold per flush call. The request is sent to POST /sen/ss on the fsp domain.
Flush Response
interface ReporterResponse {
data: {
token: string;
config: SentinelConfig;
};
}
On success:
- New token is stored via
TokenManager. - New config is applied via
Sentinel.updateConfig()→ConfigManager. - Sent signal IDs are removed from
SignalStore.
Concurrency Control
The reporter uses a isFlushing flag to prevent overlapping flush calls. If flushIfNeeded is called while a flush is in progress, a pendingFlush flag is set. Once the current flush completes, the pending flush is re-triggered.
Retry Strategy
Each flush is wrapped in a RetryQueue:
| Parameter | Value |
|---|---|
| Max attempts | 3 |
| Base delay | 200 ms |
| Back-off | Exponential (200ms → 400ms → 800ms) |
If all retries fail, sen.reporter_flush_failed is logged and the signals remain in the store for the next attempt.
Threshold Lifecycle
Thresholds are initially null. start() is a no-op until setThresholds() has been called. This prevents premature flushing before the server config arrives.
When thresholds are updated while the reporter is running, the interval timer is rescheduled with the new timeThresholdMs.
Last updated: 2026-02-24