EventManager
TheEventManager handles event subscriptions and dispatching within a AppSession. It provides methods for subscribing to various event types from the MentraOS platform.
You access the EventManager through the events property of a AppSession instance:
Event Handler Methods
onTranscription()
Registers a handler for real-time speech transcription events.handler: Callback function that receivesTranscriptionDataobjects
onHeadPosition()
Registers a handler for head position change events.handler: Callback function that receivesHeadPositionobjects
onButtonPress()
Registers a handler for hardware button press events on the glasses.handler: Callback function that receivesButtonPressobjects
onPhoneNotifications()
Registers a handler for notifications received from the connected phone.handler: Callback function that receivesPhoneNotificationobjects
onGlassesBattery()
Registers a handler for glasses battery update events.handler: Callback function that receivesGlassesBatteryUpdateobjects
onPhoneBattery()
Registers a handler for phone battery update events.handler: Callback function that receivesPhoneBatteryUpdateobjects
onVoiceActivity()
Registers a handler for Voice Activity Detection (VAD) events.handler: Callback function that receivesVadobjects
onLocation()
An event handler for raw location updates. Use theLocationManager to access location data, as it provides a simple interface for both streaming and polling.
handler: Callback function that receivesLocationUpdateobjects
onCalendarEvent()
Registers a handler for calendar event notifications.handler: Callback function that receivesCalendarEventobjects
onAudioChunk()
Registers a handler for raw audio data chunks. Requires explicit subscription.handler: Callback function that receivesAudioChunkobjects
System Event Handlers
onConnected()
Registers a handler for when the WebSocket connection is successfully established and authenticated.handler: Callback function that receives optionalAppSettingsupon connection
onDisconnected()
Registers a handler for when the WebSocket connection is closed or lost.handler: Callback function that receives a reason string
onError()
Registers a handler for WebSocket or SDK-level errors.handler: Callback function that receives aWebSocketErroror standard Error object
onSettingsUpdate()
Registers a handler for when the application settings are updated by the user via MentraOS Cloud.handler: Callback function that receives the complete updatedAppSettingsarray
onSettingChange()
Registers a handler that triggers only when a specific setting’s value changes.key: The key of the setting to monitorhandler: Callback function that receives the new value and the previous value (or undefined initially)
Generic Event Handler
on()
Generic event handler for any StreamType. Use specific methods above where possible.type: TheStreamTypeto listen forhandler: Callback function that receives data of the appropriate type for the specified StreamType

