Prism’s analytics layer is provider-agnostic: you implementDocumentation Index
Fetch the complete documentation index at: https://docs.prism.byescaleira.com/llms.txt
Use this file to discover all available pages before exploring further.
PrismAnalyticsProvider once for your chosen backend, inject it into your view hierarchy with .prismAnalytics(_:), and every Prism component automatically fires structured PrismAnalyticsEvent values as users interact with your app.
Implementing PrismAnalyticsProvider
The protocol has a single requirement: atrack(_:) method that receives a PrismAnalyticsEvent and forwards it to your backend.
PrismAnalyticsEvent carries three fields:
| Field | Type | Description |
|---|---|---|
name | String | The event name, e.g. "button_tap". |
parameters | [String: String] | Key-value metadata. |
timestamp | Date | When the event was created (defaults to Date.now). |
Registering the provider
Call.prismAnalytics(_:) on any view to inject the provider into the SwiftUI environment. All descendant views in the hierarchy inherit it.
Tracking screen views
Apply.prismTrackScreen(_:) to a view to fire a screen_view event when the view appears:
.prismTrack(.screenView(name: "Home")).
Tracking any event manually
Use.prismTrack(_:) to fire a specific PrismAnalyticsEvent when a view appears:
Built-in automatic events
Prism components fire these events automatically when the provider is registered. You do not need to add any extra code.button_tap
Fired when a Prism button is tapped.
label, test_id.
screen_view
Fired on view appearance via .prismTrackScreen(_:).
screen_name, route.
field_interaction
Fired when a text field receives or loses focus.
test_id, action (e.g., "focus" or "blur").
carousel_scroll
Fired when a carousel advances to a new item.
test_id, index.
tab_select
Fired when a tab is selected in a Prism tab view.
test_id, tab.
menu_action
Fired when a menu item is activated.
test_id, action.
Custom events
UsePrismAnalyticsEvent.custom(_:parameters:) to define events that don’t map to any built-in category:
All parameter values are
String. Convert numeric or boolean values with String(value) before passing them as parameters.