Skip to content

V2: Introduce cache cap, backoff when retrying previously failed events#286

Open
kkostov wants to merge 9 commits into
mainfrom
feat/improve-cache-v2
Open

V2: Introduce cache cap, backoff when retrying previously failed events#286
kkostov wants to merge 9 commits into
mainfrom
feat/improve-cache-v2

Conversation

@kkostov
Copy link
Copy Markdown
Contributor

@kkostov kkostov commented May 12, 2026

This PR fixes #284 by capping the maximum number of events we keep in cache and introducing a back-off retry mechanism for previously failed batches.

  • TelemetryManagerConfiguration has been extended to allow apps to configure this behaviour as needed:

    Property Type Default Description
    cacheLimit Int 10_000 Maximum events held in memory
    transmitInterval TimeInterval 10 Seconds between transmission attempts
    maxBackoffInterval TimeInterval 300 Upper bound for the exponential backoff delay
    let config = TelemetryManagerConfiguration(appID: "<your-app-id>", namespace: "com.example")
    config.cacheLimit = 5_000
    config.transmitInterval = 30  
    config.maxBackoffInterval = 600
    TelemetryDeck.initialize(config: config)
  • Fixed a possible race where during didEnterForeground, signalCache is updated on the main queue while events can be pushed and popped from other queues.

  • If the SDK gets one of the following response codes when transmitting events, it will not attempt to send these events again (they will be permanently dropped): 400, 401, 403, 404, 413, 422, 501, 505.

Comment thread Sources/TelemetryDeck/Signals/SignalManager.swift
@kkostov kkostov force-pushed the feat/improve-cache-v2 branch 2 times, most recently from 0a5d30c to abafe2a Compare May 14, 2026 17:50
@kkostov kkostov force-pushed the feat/improve-cache-v2 branch from abafe2a to 530f576 Compare May 14, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Current implementation of SignalCache is a DNS DoS machine

2 participants