Skip to content

Commit

Permalink
Merge pull request #627 from ay8s/task/visionos
Browse files Browse the repository at this point in the history
visionOS Operating System & Version along with Automatic Events
  • Loading branch information
zihejia authored Feb 2, 2024
2 parents ffd0d35 + 3750264 commit 9438b4a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/AutomaticEvents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protocol AEDelegate: AnyObject {
func increment(property: String, by: Double)
}

#if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) || os(visionOS)
import Foundation
import UIKit
import StoreKit
Expand Down
6 changes: 5 additions & 1 deletion Sources/AutomaticProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

#if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) || os(visionOS)
import UIKit
#elseif os(macOS)
import Cocoa
Expand Down Expand Up @@ -58,6 +58,9 @@ class AutomaticProperties {
let screenSize = watchDevice.screenBounds.size
p["$screen_width"] = Int(screenSize.width)
p["$screen_height"] = Int(screenSize.height)
#elseif os(visionOS)
p["$os"] = "visionOS"
p["$os_version"] = UIDevice.current.systemVersion
#endif

let infoDict = Bundle.main.infoDictionary ?? [:]
Expand All @@ -68,6 +71,7 @@ class AutomaticProperties {
p["$lib_version"] = AutomaticProperties.libVersion()
p["$manufacturer"] = "Apple"
p["$model"] = AutomaticProperties.deviceModel()

return p
}()

Expand Down
6 changes: 3 additions & 3 deletions Sources/MixpanelInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ open class MixpanelInstance: CustomDebugStringConvertible, FlushDelegate, AEDele

/// The minimum session duration (ms) that is tracked in automatic events.
/// The default value is 10000 (10 seconds).
#if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) || os(visionOS)
open var minimumSessionDuration: UInt64 {
get {
return automaticEvents.minimumSessionDuration
Expand Down Expand Up @@ -223,7 +223,7 @@ open class MixpanelInstance: CustomDebugStringConvertible, FlushDelegate, AEDele
let sessionMetadata: SessionMetadata
let flushInstance: Flush
let trackInstance: Track
#if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) || os(visionOS)
let automaticEvents = AutomaticEvents()
#endif
init(apiToken: String?, flushInterval: Double, name: String, trackAutomaticEvents: Bool, optOutTrackingByDefault: Bool = false,
Expand Down Expand Up @@ -307,7 +307,7 @@ open class MixpanelInstance: CustomDebugStringConvertible, FlushDelegate, AEDele
registerSuperProperties(superProperties)
}

#if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) || os(visionOS)
if !MixpanelInstance.isiOSAppExtension() && trackAutomaticEvents {
automaticEvents.delegate = self
automaticEvents.initializeEvents(instanceName: self.name)
Expand Down

0 comments on commit 9438b4a

Please sign in to comment.