Skip to content

Commit

Permalink
feat: rename DevCycleOptions.flushEventsIntervalMs to eventFlushInter…
Browse files Browse the repository at this point in the history
…valMS
  • Loading branch information
jonathannorris committed Aug 10, 2023
1 parent b6aea5b commit 9d8baeb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DevCycle/DevCycleClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class DevCycleClient {
internal func initialize(service: DevCycleServiceProtocol, callback: ClientInitializedHandler?) {
if let options = self.options {
Log.level = options.logLevel
self.flushEventsInterval = Double(self.options?.flushEventsIntervalMs ?? self.defaultFlushInterval) / 1000.0
self.flushEventsInterval = Double(self.options?.eventFlushIntervalMS ?? self.defaultFlushInterval) / 1000.0
self.enableEdgeDB = options.enableEdgeDB
self.disableAutomaticEventLogging = options.disableAutomaticEventLogging
self.disableCustomEventLogging = options.disableCustomEventLogging
Expand Down
10 changes: 8 additions & 2 deletions DevCycle/Models/DevCycleOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import Foundation

public class DevCycleOptions {
var flushEventsIntervalMs: Int?
var eventFlushIntervalMS: Int?
var disableEventLogging: Bool?
var logLevel: LogLevel = .error
var enableEdgeDB: Bool = false
Expand All @@ -25,8 +25,14 @@ public class DevCycleOptions {
}

// Controls the interval between flushing events to the DevCycle servers in milliseconds, defaults to 10 seconds.
public func eventFlushIntervalMS(_ interval: Int? = 10000) -> OptionsBuilder {
self.options.eventFlushIntervalMS = interval
return self
}

@available(*, deprecated, message: "Use eventFlushIntervalMS")
public func flushEventsIntervalMs(_ interval: Int? = 10000) -> OptionsBuilder {
self.options.flushEventsIntervalMs = interval
self.options.eventFlushIntervalMS = interval
return self
}

Expand Down
11 changes: 8 additions & 3 deletions DevCycle/ObjC/ObjCDevCycleOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public class ObjCLogLevel: NSObject {

@objc(DevCycleOptions)
public class ObjCDevCycleOptions: NSObject {
@available(*, deprecated, message: "Use eventFlushIntervalMS")
@objc public var flushEventsIntervalMs: NSNumber?
@objc public var eventFlushIntervalMS: NSNumber?
@objc public var disableEventLogging: NSNumber?
@objc public var logLevel: NSNumber?
@objc public var enableEdgeDB: NSNumber?
Expand All @@ -27,9 +29,12 @@ public class ObjCDevCycleOptions: NSObject {

func buildDevCycleOptions() -> DevCycleOptions {
var optionsBuilder = DevCycleOptions.builder()
if let flushEventsIntervalMs = self.flushEventsIntervalMs,
let interval = flushEventsIntervalMs as? Int {
optionsBuilder = optionsBuilder.flushEventsIntervalMs(interval)
if let eventFlushIntervalMS = self.eventFlushIntervalMS,
let interval = eventFlushIntervalMS as? Int {
optionsBuilder = optionsBuilder.eventFlushIntervalMS(interval)
} else if let flushEventsIntervalMs = self.flushEventsIntervalMs,
let interval = flushEventsIntervalMs as? Int {
optionsBuilder = optionsBuilder.eventFlushIntervalMS(interval)
}

if let disableEventLogging = self.disableEventLogging,
Expand Down
11 changes: 6 additions & 5 deletions DevCycleTests/Models/DevCycleOptionsTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class DevCycleOptionsTest: XCTestCase {
func testOptionsAreNil() {
let options = DevCycleOptions()
XCTAssertNil(options.disableEventLogging)
XCTAssertNil(options.flushEventsIntervalMs)
XCTAssertNil(options.eventFlushIntervalMS)
}

func testBuilderReturnsOptions() {
let options = DevCycleOptions.builder()
.disableEventLogging(false)
.flushEventsIntervalMs(1000)
.eventFlushIntervalMS(1000)
.enableEdgeDB(true)
.configCacheTTL(172800000)
.disableConfigCache(true)
Expand All @@ -26,7 +26,7 @@ class DevCycleOptionsTest: XCTestCase {
.apiProxyURL("localhost:4000")
.build()
XCTAssertNotNil(options)
XCTAssert(options.flushEventsIntervalMs == 1000)
XCTAssert(options.eventFlushIntervalMS == 1000)
XCTAssertFalse(options.disableEventLogging!)
XCTAssert(options.enableEdgeDB)
XCTAssert(options.configCacheTTL == 172800000)
Expand All @@ -42,7 +42,7 @@ class DevCycleOptionsTest: XCTestCase {
.disableEventLogging(false)
.build()
XCTAssertNotNil(options)
XCTAssertNil(options.flushEventsIntervalMs)
XCTAssertNil(options.eventFlushIntervalMS)
XCTAssertFalse(options.disableEventLogging!)
XCTAssertFalse(options.enableEdgeDB)
XCTAssertFalse(options.disableRealtimeUpdates)
Expand All @@ -51,9 +51,10 @@ class DevCycleOptionsTest: XCTestCase {
func testDeprecatedDVCOptions() {
let options = DVCOptions.builder()
.disableEventLogging(false)
.flushEventsIntervalMs(2000)
.build()
XCTAssertNotNil(options)
XCTAssertNil(options.flushEventsIntervalMs)
XCTAssert(options.eventFlushIntervalMS == 2000)
XCTAssertFalse(options.disableEventLogging!)
XCTAssertFalse(options.enableEdgeDB)
XCTAssertFalse(options.disableRealtimeUpdates)
Expand Down

0 comments on commit 9d8baeb

Please sign in to comment.