Here are a few tips and tricks that can help developing solutions using embedded dashboards:
1. Make use of the browser console
The browser developer tools console offer several useful commands:
cluvioHelp()
prints a brief help message in the console giving an overview of the available actions and events
cluvioHelp("changeParameters")
gives few examples of the postMessage to send to apply filters
2. Debugging sharingSecret behavior
In the browser developer tools, the global variable cluvioDecodedSecret
gives you a good way to check what the Cluvio embed sees as the actual sharingSecret JWT token value. Check this out any time you are getting unexpected behavior or see errors.
3. Handling sharingSecret expiration
It is a good practice to provide a relatively short expiration in the sharingSecret to keep the validity of the embed links under control - 10 minutes or 1 hour is typically good value for most use cases.
Once the sharingSecret expires, you can control the behavior in several ways:
1. (default) the embed will switch to display an error
2. the embed can continue to show the data, but will no longer update itself - a good option for applications that are not SPA (single-page applications), where the user is used to refresh a page to see new data. This can be accomplished using a keep_open_after_expiration: true
attribute in the sharingSecret.
3. handle the expiration event (sharingSecretExpired
) in your JavaScript code and generate a new sharingSecret, using a call to your backend endpoint, and once received use the updateSharingSecret
action to update the embed with the new sharingSecret value without any page reloads. Typically you would want to combine this with the keep_open_after_expiration: true
setting to avoid the user seeing errors while fetching the new sharingSecret.