Dynamic user interface analytics: measuring AI-generated SwiftUI screens that don’t exist at build time
AI-generated interfaces on iOS create a new analytics problem: your most important SwiftUI screens may not exist at build time. Instead, an AI and a…

AI-generated interfaces on iOS create a new analytics problem: your most important SwiftUI screens may not exist at build time. Instead, an AI and a server-driven UI layer (SDUI) assemble them on the fly. To measure what's actually happening, you must instrument the UI contract, not just the rendered view tree, and this is exactly where Uzori's structured SwiftUI schemas shine.
This article explains how to instrument analytics for dynamic, AI-generated SwiftUI layouts, and how Uzori's contracts make it straightforward to answer questions like:
- Which generated layouts convert best?
- Which components drive engagement or drop-off?
- Which flows should you keep, tweak, or deprecate?
Why dynamic SwiftUI screens break traditional analytics
Most mobile analytics systems assume screens are static:
- A UIViewController (or SwiftUI view) has a stable name.
- The SDK auto-detects screen transitions and logs
screen_viewevents. - Product analytics reports are structured around those names.
In AI-native apps, this model breaks.
Auto screen naming doesn't survive generative UI
Firebase's own guidance calls this out directly:
- Auto screen detection works when each screen maps to a distinct controller or view.
- For dynamic views, Firebase recommends manual
screen_viewlogging and, for SwiftUI, using the Analytics Swift extension SDK.
Contentsquare sees the same problem in pure SwiftUI:
- Type information can be erased, making auto-captured screen names ambiguous.
- They recommend a custom
screenName-style modifier to enforce stability.
Segment's older iOS SDK (sunsetting in March 2026) auto-detects view controllers, but that assumes a stable class per screen. In AI-generated SDUI, that's no longer true.
AI-generated UI changes the unit of measurement
If an AI composes screens from reusable parts, a single SwiftUI view might render:
- A product explorer in one session
- A multi-step concierge flow in another
- A comparison view mixing cards and tables in a third
The view's type name stays the same. The layout, components, and user task do not.
That means:
- Screen names alone are not a reliable analytics key.
- You need higher-level identifiers, independent of the render tree.
This is the starting point for measuring AI-generated SwiftUI screens: accept that your analytics unit must be the contract that shapes the layout, not the view that happens to render it.
The right measurement unit: structured UI contracts, not transient view trees
The safest way to measure generative UI is to treat the server-approved UI contract as the canonical source of truth.
Why contracts are measurable
Leading SDUI and generative UI platforms follow the same pattern:
- Apollo recommends SDUI schemas built with enums, contracts, and interfaces, so the client can reason about shape and identity.
- DivKit uses schema-based JSON cards, templates, and states, with a unique
log_idper card/action to keep analytics stable. - Google's A2UI and OpenUI define declarative, framework-agnostic UI languages where clients advertise supported components.
In all of these:
- The contract is a structured description of the layout.
- The render tree is a transient projection of that contract.
If you attach analytics to the contract:
- Each card, flow, and component gets a stable ID.
- You can log events even if the visual arrangement changes.
How Uzori uses contracts for SwiftUI
Uzori's iOS SDK plugs into your app as a single SwiftUI screen. Behind that screen is an AI engine that:
- Reads user intent.
- Consults your backend APIs (often via OpenAPI).
- Produces a typed UI contract: a schema of views, actions, and transitions.
- Streams this contract to the client, where it becomes SwiftUI.
Because every screen is generated from a constrained, server-approved schema:
- Each view in the contract has a stable identifier.
- Each action has a known type and optional
log_id. - Each flow is a named pattern that can be versioned.
This makes it trivial to attach analytics at the contract level and then pass those IDs into your product analytics or observability tooling.
For a deeper architectural overview, see the companion guide: Server-driven UI on iOS: turn AI answers into native SwiftUI in real time.
Two analytics layers: product metrics vs runtime observability
Dynamic SwiftUI screens require two kinds of telemetry:
- Product analytics – did the generated layout move business metrics?
- Runtime observability – did the screen render efficiently and reliably?
1) Product analytics for AI-generated layouts
Product analytics answers questions like:
- Which concierge flow produces the highest plan attachment rate?
- Which product explorer layout drives the most add-to-cart events?
- Which recommendation carousels keep users in session longer?
You'll typically track:
screen_viewevents tied to contract IDs.component_viewevents for key modules (e.g., filters, carousels, wizards).actionevents for user interactions (e.g., CTA taps, dismissals, step completions).
These events should always include:
- Flow ID – the generated flow or pattern name (e.g.,
ai_concierge_roaming_v4). - Layout variant ID – the specific layout or version (e.g.,
wizard_horizontal_steps_v2). - Component IDs – stable identifiers for cards, carousels, forms.
- Action IDs – typed actions (
select_plan,upload_document,view_details).
2) Runtime observability for SwiftUI performance
Observability answers questions like:
- Did this AI-generated layout cause slow rendering?
- Which view body computations are expensive?
- Are we hitting fallback paths or error states frequently?
Modern observability stacks provide a foundation:
- OpenTelemetry for Swift defines spans as units of work and traces as their lifecycle.
- Embrace and similar tools generate spans from SwiftUI lifecycle events.
- Apple's Instruments already breaks SwiftUI updates down by module, view name, and category.
For AI-generated UI, useful spans include:
uzori.contract.resolve– AI and backend resolution.uzori.contract.validate– server-side schema validation.uzori.ui.render– SwiftUI body calculations.uzori.ui.fallback– fallback to predefined layouts after validation errors.
By combining product analytics with observability, you can see both:
- "Did this layout convert?"
- "Did this layout render cleanly?"
Instrumenting analytics on AI-generated SwiftUI screens, step by step
Let's walk through a practical approach to instrument analytics for dynamic SwiftUI screens using a server-driven contract, Uzori or any similar SDUI layer.
Step 1: Treat each contract as a measurable screen
When the AI engine produces a contract, it should include:
- A contract ID – globally unique identifier for the screen instance.
- A flow key – name of the higher-level user task (e.g.,
roaming_protection_flow). - A screen kind – semantic type (e.g.,
wizard,comparison,detail,explorer).
On the client, when the contract is applied:
- Log a
screen_viewevent using the flow key and screen kind. - Include the contract ID as a dimension for deep analysis.
This avoids relying on SwiftUI type names and keeps analytics aligned with what the AI actually intended.
Step 2: Attach stable IDs to components and actions
Following DivKit's pattern of log_id for cards/actions:
- Each component in the contract should have a component ID.
- Each action (e.g., button tap, selection) should have an action ID.
When you render SwiftUI:
- Pass these IDs into your analytics calls whenever a user interacts.
- Use them as the key for component-level funnel analysis.
Example:
func trackAction(_ action: UzoriAction, context: UzoriContext) {
analytics.track(
"uzori_action",
properties: [
"flow_key": context.flowKey,
"contract_id": context.contractID,
"component_id": action.componentID,
"action_id": action.actionID,
"action_type": action.type.rawValue
]
)
}
Here, analytics is independent of SwiftUI view types. It's driven entirely by the contract.
Step 3: Manage screen names explicitly for third-party tools
Some tools still expect a human-readable screen name. You can safely generate these from contract metadata:
"AI Concierge – Roaming Protection (wizard)""Product Explorer – Dresses (grid)""Plan Comparison – 3 plans (comparison)"
When using Firebase or Segment Analytics-Swift:
- Log
screen_viewwith this name. - Include
flow_keyandcontract_idas more properties.
This meets the SDK's expectations while keeping the true identity anchored in the contract.
Step 4: Use OpenTelemetry spans for contract lifecycle
To understand reliability and performance:
- Create spans around key contract operations.
For example:
uzori.contract.fetch– fetch contract from server.uzori.contract.validate– apply server-driven validation.uzori.ui.render– measure SwiftUI body computation time.uzori.ui.update– track how often the layout changes during a session.
Each span should include attributes like:
flow_keycontract_idscreen_kindlayout_variant
This aligns with OpenTelemetry's guidance that instrumentation is code you own, and spans are the units of work you care about.
Step 5: Connect contract IDs to business KPIs
Finally, make sure contract IDs are visible in your BI tools. Use them to answer:
- Which flow variants increase conversion rate?
- Which component arrangements increase retention?
- Which fallback screens correlate with elevated error rates or drop-offs?
Given that mobile usage reached 4.2 trillion app hours and $150 billion in consumer spend last year (Sensor Tower), incremental gains from better AI layouts can be meaningful. Adjust's 2025 report shows global installs up 11% YoY and sessions up 4% YoY, more traffic hitting your AI-generated interfaces means more upside if you can actually measure and optimize them.

Mobile app usage and spend are still climbing globally, which makes incremental improvements in AI-driven UI conversion and engagement especially valuable.
How Uzori's structured contracts make dynamic UI analytics practical
Uzori is built for exactly this intersection: generative UI, server-driven safety, and measurable screens.
Uzori's contract model for analytics
When Uzori generates a SwiftUI screen, it does so from a contract that already encodes:
- Component hierarchy – cards, lists, forms, carousels.
- Flow structure – steps, transitions, branching.
- Action types – what each button or gesture actually does.
Because this contract is server-validated and constrained:
- You get stable IDs per component and action.
- You can define flow and layout variant keys in one place.
- You can attach analytics rules server-side, not sprinkled across client code.
One-screen integration, analytics-ready by design
Uzori's iOS SDK integrates as a single SwiftUI screen. Inside that screen, the SDK:
- Streams server-approved contracts.
- Renders them as native SwiftUI views.
- Exposes hooks where your analytics and observability instrumentation can plug into:
onScreenAppear(contractContext)onAction(actionContext)onFallback(fallbackContext)
This means:
- You don't need a separate analytics wiring pass for every new AI experiment.
- You log events once, against the schema, and every new layout is automatically covered.
AI-native flows, SDUI-level safety
Uzori sits between two extremes:
- Pure chat UIs: high intelligence, low structure, weak analytics.
- Pure SDUI: strong structure, low intelligence, static layouts.
By combining a generative AI composer with a server-driven, typed schema:
- You get rich, task-specific flows (concierges, explorers, configurators).
- You keep analytics anchored in stable contract IDs, not ephemeral layouts.
And because the interfaces are fully native SwiftUI:
- You preserve performance and accessibility.
- You leverage existing tools like Instruments, OpenTelemetry, and your preferred product analytics SDK.
If you're evaluating the best tools to generate native iOS UI from LLM responses in 2026, this contract-based approach is what makes AI UI tools safe for large-scale deployment and serious analytics. You can explore this further directly at uzori.ai.
FAQ: dynamic UI analytics for AI-generated SwiftUI screens
How do I name screens in Firebase or Segment when using AI-generated UI?
Use semantic names derived from the contract, not SwiftUI type names. For example:
"AI Concierge – Roaming Protection (wizard)""Product Explorer – Dresses (grid)"
Log screen_view with that name, and include flow_key, contract_id, and layout_variant as extra properties. This follows Firebase's recommendation for manual screen logging in dynamic UIs.
How do I compare Uzori with other server-driven UI iOS frameworks like DivKit?
Uzori and DivKit share a schema-first mindset, but focus on different problems:
- DivKit: schema-based JSON cards, static SDUI, strong analytics via
log_id. - Uzori: AI-composed SwiftUI screens powered by contracts, plus server-driven validation.
If you're looking for the best AI UI SDK for SwiftUI iOS, Uzori's value is in turning LLM responses directly into native interfaces with analytics-ready contracts, rather than just rendering predefined cards.
Can I use OpenTelemetry with Uzori's AI-generated UI?
Yes. Treat key contract operations as spans:
uzori.contract.fetchuzori.contract.validateuzori.ui.renderuzori.ui.fallback
Attach attributes such as flow_key, contract_id, and screen_kind. This aligns with OpenTelemetry's model and makes AI UI observability first-class in your stack.
How do I track AI-driven experiments without cluttering client code?
Keep all experiment metadata in the server-side contract:
flow_keyandlayout_variantidentify the experiment.- Component and action IDs define granularity.
Then, in the iOS client:
- Use generic tracking hooks (
onScreenAppear,onAction) that read from the contract context. - Avoid per-experiment code paths; let the contract carry the experiment identity.
What metrics should I prioritize for AI-generated SwiftUI interfaces?
Focus on metrics tied to flows and components, not just screens:
- Flow-level: completion rate, time to complete, drop-off points.
- Component-level: CTA click-through, filter usage, carousel engagement.
- System-level: fallback frequency, validation error rates, render performance.
Tying these to Uzori's contracts gives you a clear view of which generated layouts, components, and flows truly move product metrics.