Skip to content

Commit

Permalink
feat: deprecate disableEventLogging add disableAutoamticEventLogging …
Browse files Browse the repository at this point in the history
…and disableCustomEventLogging options (#167)
  • Loading branch information
suthar26 authored Jun 19, 2023
1 parent f26bbca commit 12f7e2d
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 27 deletions.
15 changes: 11 additions & 4 deletions DevCycle/DVCClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public class DVCClient {
var configCompletionHandlers: [ClientInitializedHandler] = []
var initialized: Bool = false
var eventQueue: EventQueue = EventQueue()

private let defaultFlushInterval: Int = 10000
private var flushEventsInterval: Double = 10.0
private var enableEdgeDB: Bool = false
Expand All @@ -52,6 +51,8 @@ public class DVCClient {
private var inactivityWorkItem: DispatchWorkItem?
private var variableInstanceDictonary = [String: NSMapTable<AnyObject, AnyObject>]()
private var isConfigCached: Bool = false
private var disableAutomaticEventLogging: Bool = false
private var disableCustomEventLogging: Bool = false

private var variableQueue = DispatchQueue(label: "com.devcycle.VariableQueue")

Expand All @@ -76,14 +77,16 @@ public class DVCClient {
Log.level = options.logLevel
self.flushEventsInterval = Double(self.options?.flushEventsIntervalMs ?? self.defaultFlushInterval) / 1000.0
self.enableEdgeDB = options.enableEdgeDB
self.disableAutomaticEventLogging = options.disableAutomaticEventLogging
self.disableCustomEventLogging = options.disableCustomEventLogging
} else {
Log.level = .error
}

self.lastIdentifiedUser = self.user

self.setup(service: service, callback: callback)

#if os(iOS) || os(tvOS)
NotificationCenter.default.addObserver(self,
selector: #selector(appMovedToBackground),
Expand Down Expand Up @@ -301,7 +304,9 @@ public class DVCClient {
}

if (!self.closed) {
self.eventQueue.updateAggregateEvents(variableKey: variable.key, variableIsDefaulted: variable.isDefaulted)
if(!self.disableAutomaticEventLogging){
self.eventQueue.updateAggregateEvents(variableKey: variable.key, variableIsDefaulted: variable.isDefaulted)
}
}

return variable
Expand Down Expand Up @@ -384,7 +389,9 @@ public class DVCClient {
Log.error("DVCClient is closed, cannot log new events.")
return
}
self.eventQueue.queue(event)
if(!self.disableCustomEventLogging){
self.eventQueue.queue(event)
}
}


Expand Down
13 changes: 13 additions & 0 deletions DevCycle/Models/DVCOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class DVCOptions {
var disableConfigCache: Bool = false
var configCacheTTL: Int = 604800000
var disableRealtimeUpdates: Bool = false
var disableAutomaticEventLogging: Bool = false
var disableCustomEventLogging: Bool = false

public class OptionsBuilder {
var options: DVCOptions
Expand All @@ -27,11 +29,22 @@ public class DVCOptions {
return self
}

@available(*, deprecated, message: "Use disableAutomaticEventLogging or disableCustomEventLogging")
public func disableEventLogging(_ disable: Bool) -> OptionsBuilder {
self.options.disableEventLogging = disable
return self
}

public func disableAutomaticEventLogging(_ disable: Bool) -> OptionsBuilder{
self.options.disableAutomaticEventLogging = disable
return self
}

public func disableCustomEventLogging(_ disable: Bool) -> OptionsBuilder{
self.options.disableCustomEventLogging = disable
return self
}

public func logLevel(_ level: LogLevel) -> OptionsBuilder {
self.options.logLevel = level
return self
Expand Down
Loading

0 comments on commit 12f7e2d

Please sign in to comment.