observeSessionAnalytics
Introduction
The observeSessionAnalytics() view modifier enables the SDK to properly manage session analytics when your app transitions between foreground and background states. By attaching this modifier to your root view, the SDK can pause analytics beacons when the app is backgrounded and resume them when it returns to the foreground.
Syntax
func observeSessionAnalytics() -> some View
Code Example
import MaestroKit
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.observeSessionAnalytics()
}
}
}
Notes
- Apply this modifier to your root view so the SDK can observe
scenePhasechanges. - This is optional — the SDK functions without it, but session analytics beacons will not automatically pause when the app is backgrounded.
- The SDK manages session lifecycle (start, beacon, end) internally. This modifier only provides the app lifecycle hook.
- Beacon interval is configured remotely via server configuration.