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

visionOS Operating System & Version along with Automatic Events #627

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading