onPanelEvent
Description
Observable field that emits panel-specific events from the SDK.
Type
assocArray
Usage
m.lib.observeField("onPanelEvent", "onPanelEvent")
function onPanelEvent(event as Object)
eventData = event.getData()
print "Panel event received: " + formatJson(eventData)
end function
Data Structure
The structure of the event data depends on the specific panel and event type. Common fields include:
| Field | Type | Description |
|---|---|---|
eventType | string | Type of event that occurred |
panelName | string | Name of the panel that emitted |
data | object | Event-specific data |
Authentication Error Events
When a panel receives an authentication error (HTTP 401) from the API, the SDK surfaces it through onPanelEvent. The SDK deduplicates concurrent errors across panels — only one event fires per refresh cycle. If fresh credentials are not received within the retry limit, the affected panel falls back to its own error UI.
Data Structure
| Field | Type | Description |
|---|---|---|
error | object | Top-level error object |
error.type | string | Error category — "general:error" for auth errors |
error.timestamp | string | ISO 8601 timestamp of when the error occurred |
error.payload | object | Error detail |
error.payload.message | string | Human-readable error description |
error.payload.code | integer | HTTP status code (e.g., 401) |
error.payload.details | object | Additional context |
error.payload.details.panel | string | Panel type that encountered the error |
error.payload.details.url | string | API endpoint URL that returned the error |
Handling Authentication Errors
When you receive an authentication error, refresh your credentials and pass updated values to the panel using setDataToPanel:
m.lib.observeField("onPanelEvent", "onPanelEvent")
function onPanelEvent(event as Object)
eventData = event.getData()
if eventData?.error?.payload?.code = 401
' Refresh credentials, then push updated values to the affected panel
refreshedHeaders = getRefreshedAuthHeaders()
m.lib.setDataToPanel = {
"<panelType>": {
"authHeaders": refreshedHeaders
}
}
end if
end function
Replace <panelType> with the panel type string from eventData.error.payload.details.panel and supply whatever header fields the panel accepts via setDataToPanel.
Best Practices
- Monitor all panel events to understand user interactions
- Implement proper error handling for event data
- Use event types to route to appropriate handlers
- Log events for debugging and analytics
- Handle authentication errors promptly — refresh credentials and call
setDataToPanelto restore panel data access