# visionOS and SwiftUI
> Track window groups and immersive spaces in visionOS apps on Apple Vision Pro using SwiftUI context entities and events.
> Source: https://docs.snowplow.io/docs/events/ootb-data/visionos-swiftui/
> Documentation index: https://docs.snowplow.io/llms.txt

Use the window group and immersive space entities and events to understand user behavior within visionOS apps on Apple's Vision Pro headset.

Track the opening and dismissing of SwiftUI window groups using `OpenWindowEvent` and `DismissWindowEvent`. These events can be used in any SwiftUI app, not just visionOS. The event data is sent as a window group entity attached to these events.

Use the `OpenImmersiveSpaceEvent` and `DismissImmersiveSpaceEvent` to automatically add an immersive space entity to all events occurring within an immersive space. The entity will identify the immersive space in which the events occurred. This feature is enabled by default for the iOS tracker.

This table shows the support for VisionOS tracking across the main client-side [Snowplow tracker SDKs](/docs/sources/). Snowplow currently only supports visionOS apps via SwiftUI, not Unity.

| Tracker                                                        | Supported | Since version | Auto-tracking | Notes                            |
| -------------------------------------------------------------- | --------- | ------------- | ------------- | -------------------------------- |
| Web                                                            | ❌         |               |               |                                  |
| [iOS](/docs/sources/mobile-trackers/tracking-events/visionos/) | ✅         | 6.0.0         | ✅/❌           | Entities are automatically added |
| Android                                                        | ❌         |               |               |                                  |
| React Native                                                   | ❌         |               |               |                                  |
| Flutter                                                        | ❌         |               |               |                                  |
| Roku                                                           | ❌         |               |               |                                  |
| Unity                                                          | ❌         |               |               |                                  |
| Google Tag Manager                                             | ❌         |               |               |                                  |

## Available events

The following events track user interactions with SwiftUI windows and visionOS immersive spaces. These events have no properties themselves; the contextual data is captured in the attached entities.

### Open window

Tracks when a user opens a SwiftUI window or window group.

### `open_window`

**Type:** Event

Schema for an event for opening a SwiftUI window or window group.

**Properties:**

**Example warehouse query (Snowflake):**

```sql
select
unstruct_event_com_apple_swiftui_open_window_1 open_window_1
from
atomic.events
where
events.collector_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'open_window'
and events.event_vendor = 'com.apple.swiftui'
```

### Dismiss window

Tracks when a user closes or dismisses a SwiftUI window or window group.

### `dismiss_window`

**Type:** Event

Schema for an event for dismissing a SwiftUI window or window group.

**Properties:**

**Example warehouse query (Snowflake):**

```sql
select
unstruct_event_com_apple_swiftui_dismiss_window_1 dismiss_window_1
from
atomic.events
where
events.collector_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'dismiss_window'
and events.event_vendor = 'com.apple.swiftui'
```

### Open immersive space

Tracks when a user enters an immersive space in a visionOS app on Apple Vision Pro.

### `open_immersive_space`

**Type:** Event

Schema for an event for opening a visionOS immersive space.

**Properties:**

**Example warehouse query (Snowflake):**

```sql
select
unstruct_event_com_apple_swiftui_open_immersive_space_1 open_immersive_space_1
from
atomic.events
where
events.collector_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'open_immersive_space'
and events.event_vendor = 'com.apple.swiftui'
```

### Dismiss immersive space

Tracks when a user exits an immersive space in a visionOS app.

### `dismiss_immersive_space`

**Type:** Event

Schema for an event for dismissing a visionOS immersive space.

**Properties:**

**Example warehouse query (Snowflake):**

```sql
select
unstruct_event_com_apple_swiftui_dismiss_immersive_space_1 dismiss_immersive_space_1
from
atomic.events
where
events.collector_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'dismiss_immersive_space'
and events.event_vendor = 'com.apple.swiftui'
```

## Available entities

These entities provide context about the SwiftUI windows and visionOS immersive spaces where events occur.

### Window group

Describes a SwiftUI window group, including its identifier, title, and window style. This entity is attached to open and dismiss window events.

### `window_group`

**Type:** Schema

Schema for a window group entity, representing the SwiftUI window group that the event occurs in.

**Properties:**

| Property                | Description                                                                                                                                                               |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `window_id` _string_    | _Optional._ UUID for the current window within the group.                                                                                                                 |
| `id` _string_           | _Required._ A string that uniquely identifies the window group. Identifiers must be unique among the window groups in your app.                                           |
| `title_key` _string_    | _Optional._ A localized string key to use for the window's title in system menus and in the window's title bar. Provide a title that describes the purpose of the window. |
| `window_style` _string_ | _Optional._ A specification for the appearance and interaction of a window. Must be one of: `automatic`, `hiddenTitleBar`, `plain`, `titleBar`, `volumetric`,``           |

### Immersive space

Describes a visionOS immersive space, including its immersion style and upper limb visibility settings. This entity is automatically attached to all events that occur within an immersive space.

### `immersive_space`

**Type:** Schema

Schema for an immersive space entity, representing the VisionOS immersive space that the event occurs in.

**Properties:**

| Property                         | Description                                                                                                                                                  |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `view_id` _string_               | _Optional._ UUID for the view of the immersive space.                                                                                                        |
| `id` _string_                    | _Required._ The identifier of the immersive space to present.                                                                                                |
| `immersion_style` _string_       | _Optional._ The style of an immersive space. Must be one of: `automatic`, `full`, `mixed`, `progressive`,``                                                  |
| `upper_limb_visibility` _string_ | _Optional._ Preferred visibility of the user's upper limbs, while an immersive space scene is presented. Must be one of: `automatic`, `visible`, `hidden`,`` |
