From 9bfb52dcc60e7d18c67cc7ebd53cca28cdb5c62c Mon Sep 17 00:00:00 2001 From: Andrey Belonogov Date: Mon, 9 Nov 2026 12:36:38 -0800 Subject: [PATCH] feat(events): default the event max age to 24 hours Persisted events not yet delivered are discarded after 24 hours by default, instead of 7 days. LDConfig.eventMaxAge still overrides it. Co-authored-by: Cursor --- LaunchDarkly/LaunchDarkly/Models/LDConfig.swift | 6 +++--- LaunchDarkly/LaunchDarkly/ObjectiveC/ObjcLDConfig.swift | 2 +- LaunchDarkly/LaunchDarklyTests/Models/LDConfigSpec.swift | 2 +- .../LaunchDarklyTests/ServiceObjects/EventStoreSpec.swift | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/LaunchDarkly/LaunchDarkly/Models/LDConfig.swift b/LaunchDarkly/LaunchDarkly/Models/LDConfig.swift index 6b77481c..6410e6e0 100644 --- a/LaunchDarkly/LaunchDarkly/Models/LDConfig.swift +++ b/LaunchDarkly/LaunchDarkly/Models/LDConfig.swift @@ -237,8 +237,8 @@ public struct LDConfig { /// The default maximum number of bytes of events the SDK can persist, for all environments together. (20 MiB) static let eventCapacityBytes = 20 * 1024 * 1024 - /// The default maximum age of persisted events. (7 days) - static let eventMaxAge: TimeInterval = 7 * 24 * 60 * 60 + /// The default maximum age of persisted events. (24 hours) + static let eventMaxAge: TimeInterval = 24 * 60 * 60 /// The default behavior for the SDK is to keep events in memory only. static let eventPersistence = EventPersistence.disabled @@ -402,7 +402,7 @@ public struct LDConfig { /// How long the SDK keeps events it has persisted but not yet reported, where `eventPersistence` keeps events across launches. Events /// older than this are discarded rather than reported, and so is everything the SDK stored for an environment whose mobile key the - /// application stopped using. A value of zero or less means the default. (Default: 7 days) + /// application stopped using. A value of zero or less means the default. (Default: 24 hours) /// /// It has no effect where `eventPersistence` is `.disabled`. public var eventMaxAge: TimeInterval = Defaults.eventMaxAge diff --git a/LaunchDarkly/LaunchDarkly/ObjectiveC/ObjcLDConfig.swift b/LaunchDarkly/LaunchDarkly/ObjectiveC/ObjcLDConfig.swift index e3eae1aa..7e529850 100644 --- a/LaunchDarkly/LaunchDarkly/ObjectiveC/ObjcLDConfig.swift +++ b/LaunchDarkly/LaunchDarkly/ObjectiveC/ObjcLDConfig.swift @@ -61,7 +61,7 @@ public final class ObjcLDConfig: NSObject { set { config.eventCapacityBytes = newValue } } - /// How long the SDK keeps persisted events it has not yet reported before discarding them, which also removes what it stored for a mobile key the application stopped using. No effect where `eventPersistence` is `.disabled`. (Default: 7 days) + /// How long the SDK keeps persisted events it has not yet reported before discarding them, which also removes what it stored for a mobile key the application stopped using. No effect where `eventPersistence` is `.disabled`. (Default: 24 hours) @objc public var eventMaxAge: TimeInterval { get { config.eventMaxAge } set { config.eventMaxAge = newValue } diff --git a/LaunchDarkly/LaunchDarklyTests/Models/LDConfigSpec.swift b/LaunchDarkly/LaunchDarklyTests/Models/LDConfigSpec.swift index db179191..52618dc2 100644 --- a/LaunchDarkly/LaunchDarklyTests/Models/LDConfigSpec.swift +++ b/LaunchDarkly/LaunchDarklyTests/Models/LDConfigSpec.swift @@ -76,7 +76,7 @@ final class LDConfigSpec: XCTestCase { XCTAssertEqual(config.eventCapacity, LDConfig.Defaults.eventCapacity) XCTAssertEqual(config.eventPersistence, LDConfig.Defaults.eventPersistence) XCTAssertEqual(config.eventCapacityBytes, 20 * 1024 * 1024) - XCTAssertEqual(config.eventMaxAge, 7 * 24 * 60 * 60) + XCTAssertEqual(config.eventMaxAge, 24 * 60 * 60) XCTAssertEqual(config.eventDeliveryDelay, 2) XCTAssertEqual(config.connectionTimeout, LDConfig.Defaults.connectionTimeout) XCTAssertEqual(config.eventFlushInterval, LDConfig.Defaults.eventFlushInterval) diff --git a/LaunchDarkly/LaunchDarklyTests/ServiceObjects/EventStoreSpec.swift b/LaunchDarkly/LaunchDarklyTests/ServiceObjects/EventStoreSpec.swift index ecaf0ecf..eff12e45 100644 --- a/LaunchDarkly/LaunchDarklyTests/ServiceObjects/EventStoreSpec.swift +++ b/LaunchDarkly/LaunchDarklyTests/ServiceObjects/EventStoreSpec.swift @@ -1915,7 +1915,7 @@ final class EventStoreSpec: QuickSpec { it("keeps a batch younger than the maximum age") { _ = store.stage(EventStoreSpec.payload("recent")) _ = store.closeBatch() - try EventStoreSpec.age(try EventStoreSpec.onlyBatchFile(in: store), byDays: 6) + try EventStoreSpec.age(try EventStoreSpec.onlyBatchFile(in: store), byDays: 0.5) expect(store.discardExpired()) == 0 expect(store.pendingBatches().count) == 1 @@ -1987,7 +1987,7 @@ final class EventStoreSpec: QuickSpec { let old = logLeftBy("gone") let young = logLeftBy("recent") try EventStoreSpec.age(old, byDays: 8) - try EventStoreSpec.age(young, byDays: 1) + try EventStoreSpec.age(young, byDays: 0.5) expect(store.discardExpired()) == 1 @@ -2030,7 +2030,7 @@ final class EventStoreSpec: QuickSpec { let inUse = try EventStoreSpec.environment("app.in-use", in: root, events: 1) let otherApplication = try EventStoreSpec.environment("other.abandoned", in: root, events: 1) try EventStoreSpec.age(contentsOf: abandoned, byDays: 8) - try EventStoreSpec.age(contentsOf: inUse, byDays: 1) + try EventStoreSpec.age(contentsOf: inUse, byDays: 0.5) try EventStoreSpec.age(contentsOf: otherApplication, byDays: 30) expect(store.discardExpired()) == 2