Subscribe to platform events from your extension.
Platforms have the ability to send event notifications that you can subscribe to from your extension with the platformEventNotification capability. When you subscribe to an event name, your function will be executed each time the platform sends out a notification that the specific platform event has occurred.
Optionally, the platform may pass a generic data object specific to the event to your subscribed function as an argument.
tecton.sources.platformEventNotification(eventName: string, callback: (data?: any) => void): () => void;Listen for a platform event named 'EXAMPLE_EVENT'.
const unsubscribe = tecton.sources.platformEventNotification('EXAMPLE_EVENT', function(data) {
tecton.actions.showAlert({
message: `Platform Event Received: ${data}`,
styleType: 'info',
durationInMs: 3000
});
});Later, to stop listening:
unsubscribe();When using the platformEventNotification source, there are important details to keep in mind.
The platformEventNotification source allows you to listen for various user experience events emitted by the platform. Below is a list of the supported events you can subscribe to when integrating with the UUX platform:
LOGIN_OCCURRED: User has logged in. This event returns a userData object from the login event with information about the login.LOGOFF_OCCURRED: User has logged out or the platform has triggered a logout event due to timeout or inactivity.SESSION_STARTED: The platform has marked the session as authenticated. This event is triggered after the login event.SESSION_ENDED: The platform has marked the session as unauthenticated. This event is triggered after the logoff event.NAVIGATION_OCCURRED: User has navigated to a new page and routing has changed. This event returns a navigation data object with information about the route the user is leaving and the route the user is going to.MOBILE_APP_RESUMED: User has returned to the mobile app after putting it in the background.THEME_CHANGED: User has changed the theme in settings.LANGUAGE_CHANGED: User has changed the language in settings.OVERPANEL_OPENED: The platform overpanel has opened.OVERPANEL_CLOSED: The platform overpanel has closed.KEEP_ALIVE_SUCCEEDED: User’s activity has been detected and the keep alive has succeeded. Assuming activity is happening, this will be called every 30 seconds.KEEP_ALIVE_FAILED: User’s activity was detected but the api call for keep alive failed. UUX will retry 5 times, every 2 seconds until it succeeds. If it fails 5 consecutive times, the user will be logged off.All Pinion messages sent to the UUX platform are re-broadcast to extensions as platform events. When sending a Pinion message, you can include a custom event value. This event name will be prefixed with PINION_ and used to broadcast the message to extensions. For example, when sending a Pinion message with an event value of CUSTOM_EVENT, the event name broadcast to extensions will be PINION_CUSTOM_EVENT. If you send a payload and message value with the Pinion message, that data will be included in the event broadcast.
tecton.sources.platformEventNotification('PINION_CUSTOM_EVENT', function(data) {
doTheNeedful(data.payload);
tecton.actions.showAlert({
message: `Pinion Event Received: ${data.message}`,
styleType: 'info',
durationInMs: 3000
});
});
eventNamecallback