diff --git a/Sources/Snowplow/VisionOS/Entities/ImmersiveSpaceEntity.swift b/Sources/Snowplow/VisionOS/Entities/ImmersiveSpaceEntity.swift index c0a9a7cbe..d59fa4830 100644 --- a/Sources/Snowplow/VisionOS/Entities/ImmersiveSpaceEntity.swift +++ b/Sources/Snowplow/VisionOS/Entities/ImmersiveSpaceEntity.swift @@ -95,7 +95,7 @@ public class ImmersiveSpaceEntity: SelfDescribingJson { } /// - Parameter id: A localized string key to use for the window's title in system menus and in the window's title bar. - /// - Parameter viewId: UUID for the view of the immersive space. + /// - Parameter viewId: UUID for the view of the immersive space. Generated by the tracker if not provided. /// - Parameter immersionStyle: A specification for the appearance and interaction of a window. /// - Parameter upperLimbVisibility: A specification for the appearance and interaction of a window. public init( @@ -105,7 +105,7 @@ public class ImmersiveSpaceEntity: SelfDescribingJson { upperLimbVisibility: UpperLimbVisibility? = nil ) { self.id = id - self.viewId = viewId + self.viewId = viewId ?? UUID() self.immersionStyle = immersionStyle self.upperLimbVisibility = upperLimbVisibility super.init(schema: swiftuiImmersiveSpaceSchema, andData: [:]) diff --git a/Tests/VisionOS/TestVisionOSEvents.swift b/Tests/VisionOS/TestVisionOSEvents.swift index ffc39e1ac..31cc0b735 100644 --- a/Tests/VisionOS/TestVisionOSEvents.swift +++ b/Tests/VisionOS/TestVisionOSEvents.swift @@ -73,6 +73,10 @@ class TestVisionOSEvents: XCTestCase { let entities = trackedEvents[0].entities XCTAssertEqual(1, getImmersiveSpaceEntities(entities).count) + + let spaceEntity = getImmersiveSpaceEntities(entities)[0] as? ImmersiveSpaceEntity + let viewId = spaceEntity!.viewId + XCTAssertNotNil(viewId) } func testTrackDismissImmersiveSpace() {