Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove is_foreground from event producer #135

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions Sources/Confidence/ConfidenceAppLifecycleProducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class ConfidenceAppLifecycleProducer: ConfidenceEventProducer, Confidence
// Context Keys
private static var versionNameContextKey = "app_version"
private static var buildNumberContextKey = "app_build"
private static var isForegroundContextKey = "is_foreground"
// Event Names
private static let appLaunchedEventName = "app-launched"
private static let appInstalledEventName = "app-installed"
Expand Down Expand Up @@ -88,13 +87,12 @@ public class ConfidenceAppLifecycleProducer: ConfidenceEventProducer, Confidence
UserDefaults.standard.setValue(currentBuild, forKey: Self.userDefaultBuildNameKey)
}

private func updateContext(isForeground: Bool) {
private func updateContext() {
nickybondarenko marked this conversation as resolved.
Show resolved Hide resolved
withLock { [weak self] in
guard let self = self else {
return
}
var context = self.currentProducedContext.value
context.updateValue(.init(boolean: isForeground), forKey: Self.isForegroundContextKey)
let context = self.currentProducedContext.value
self.currentProducedContext.send(context)
}
}
Expand All @@ -107,10 +105,6 @@ public class ConfidenceAppLifecycleProducer: ConfidenceEventProducer, Confidence

@objc func notificationResponse(notification: NSNotification) {
switch notification.name {
case UIApplication.didEnterBackgroundNotification:
updateContext(isForeground: false)
case UIApplication.willEnterForegroundNotification:
updateContext(isForeground: true)
case UIApplication.didBecomeActiveNotification:
track(eventName: Self.appLaunchedEventName, shouldFlush: true)
default:
Expand Down
Loading