Skip to content

Commit 2e264a5

Browse files
committed
fix: nits
1 parent c3f9c5b commit 2e264a5

File tree

6 files changed

+9
-20
lines changed

6 files changed

+9
-20
lines changed

Sources/Amplitude/Amplitude.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ public class Amplitude {
119119

120120
func onExitForeground() {
121121
inForeground = false
122-
_ = self.flush()
122+
if configuration.flushEventsOnClose == true {
123+
_ = self.flush()
124+
}
123125
}
124126

125127
public func apply(closure: (Plugin) -> Void) {

Sources/Amplitude/Plugins/Mac/MacOSLifecycleMonitor.swift

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,22 @@
6464
}
6565

6666
func applicationDidBecomeActive(notification: NSNotification) {
67-
analytics?.apply { (ext) in
67+
amplitude?.apply { (ext) in
6868
if let validExt = ext as? MacOSLifecycle {
6969
validExt.applicationDidBecomeActive()
7070
}
7171
}
7272
}
7373

7474
func applicationWillResignActive(notification: NSNotification) {
75-
analytics?.apply { (ext) in
75+
amplitude?.apply { (ext) in
7676
if let validExt = ext as? MacOSLifecycle {
7777
validExt.applicationWillResignActive()
7878
}
7979
}
8080
}
8181
}
8282

83-
extension AmplitudeDestinationPlugin: MacOSLifecycle {
84-
public func applicationWillEnterForeground(application: UIApplication?) {
85-
let timestamp = NSDate().timeIntervalSince1970
86-
self.amplitude?.onEnterForeground(timestamp: timestamp)
87-
}
88-
89-
public func applicationDidEnterBackground(application: UIApplication?) {
90-
self.amplitude?.onExitForeground()
91-
}
92-
}
93-
9483
extension AmplitudeDestinationPlugin: MacOSLifecycle {
9584
public func applicationDidBecomeActive() {
9685
let timestamp = NSDate().timeIntervalSince1970

Sources/Amplitude/Plugins/Vendors/AppUtil.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
#endif
1414

15-
#if os(watchOS)
15+
#if os(macOS)
1616
internal class MacOSVendorSystem: VendorSystem {
1717
override var requiredPlugin: Plugin {
1818
return MacOSLifecycleMonitor()

Sources/Amplitude/Plugins/Vendors/VendorSystem.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ internal class VendorSystem {
1313
return MacOSVendorSystem()
1414
#elseif os(watchOS)
1515
return WatchOSVendorSystem()
16-
#elseif os(Linux)
17-
return LinuxVendorSystem()
1816
#else
1917
return VendorSystem()
2018
#endif

Sources/Amplitude/Plugins/iOS/IOSLifecycleMonitor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst)
99

1010
import Foundation
11-
import UIKit
11+
import SwiftUI
1212

1313
public protocol IOSLifecycle {
1414
func applicationDidEnterBackground(application: UIApplication?)

Sources/Amplitude/Plugins/watchOS/WatchOSLifecycleMonitor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
// from iOS, so ignore until we've been backgrounded at least once.
6868
if wasBackgrounded == false { return }
6969

70-
analytics?.apply { (ext) in
70+
amplitude?.apply { (ext) in
7171
if let validExt = ext as? WatchOSLifecycle {
7272
validExt.applicationWillEnterForeground(watchExtension: watchExtension)
7373
}
@@ -78,7 +78,7 @@
7878
// make sure to denote that we were backgrounded.
7979
wasBackgrounded = true
8080

81-
analytics?.apply { (ext) in
81+
amplitude?.apply { (ext) in
8282
if let validExt = ext as? WatchOSLifecycle {
8383
validExt.applicationDidEnterBackground(watchExtension: watchExtension)
8484
}

0 commit comments

Comments
 (0)