Skip to main content

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:

FieldTypeDescription
eventTypestringType of event that occurred
panelNamestringName of the panel that emitted
dataobjectEvent-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​

FieldTypeDescription
errorobjectTop-level error object
error.typestringError category — "general:error" for auth errors
error.timestampstringISO 8601 timestamp of when the error occurred
error.payloadobjectError detail
error.payload.messagestringHuman-readable error description
error.payload.codeintegerHTTP status code (e.g., 401)
error.payload.detailsobjectAdditional context
error.payload.details.panelstringPanel type that encountered the error
error.payload.details.urlstringAPI 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 setDataToPanel to restore panel data access