IntelliWidgets.js SDK
This reference documents the available methods in IntelliProve's browser-side JavaScript SDK, IntelliWidgets.js.
Include the IntelliWidgets.js script on the page of your site where you want to use the widgets. It should always be loaded directly from https://cdn.intelliprove.com, rather than included in a bundle or hosted yourself. This ensures you and your customers get the latest updates and improvements live without needing an intervention from your end.
If preferred or required, we also provide support for the installation of our SDK as a package. This can be installed using the npm command into your front-end project. Please note that this approach requires you to manually update the version of our SDK every now and then to make sure you have the latest improvements.
IntelliProveWidgets(action_token, locale)
Use IntelliProveWidgets(action_token, locale) to create an instance of the IntelliProveWidgets object. The IntelliProveWidgets object is the entrypoint to the rest of the IntelliWidgets.js SDK.
A valid user action token is required when calling this constructor, as it identifies the user to IntelliProve.
Replace the placeholder action token in the example with a valid user action token, created with your API key.
Property | Description |
---|---|
action_token string | Valid user-authenticated JWT action token |
locale nullable string enum | Two-letter language code for preferred user language Values: "en" (default), "fr", "nl" |
IntelliProveWidgets.loaded()
hoe Use IntelliProveWidgets.loaded() to verify that IntelliWidgets.js loaded successfully.
If the loading of IntelliWidgets.js failed, this will result in an error when creating widgets.
intelli.mountWidget(selector, name, config, variation="", themeOverrides={})
The intelli.mountWidget method creates a new widget and attaches it to the DOM.
First you need to create a container DOM element on your platforms website. intelli.mountWidget accepts a CSS selector (e.g., #biomarker-tile).
Check out the widget overview for a full list of the available widgets.
Adjust the appearance of the widget by overriding the theming variables.
Property | Description |
---|---|
selector string | The CSS selector where your widget will be mounted. |
name string | The name from one of the available widget types. |
config object | Configurations for creating the widget. |
variation optional string | Widget variation, if applicable. |
themeOverrides optional object | Custom styling variables applied to the widget. Refer to Widget Appearance for more information. |
Exceptions
IntelliActionTokenError, IntelliWidgetNotFoundError, IntelliInvalidParameterError, IntelliUnexpectedError, IntelliSdkLoadingError
intelli.changeLanguage(locale)
The intelli.changeLanguage(locale) method allows you change the locale for all active widgets.
Newly created widgets will have the new locale by default.
Property | Description |
---|---|
locale string enum | Two-letter language code for preferred user language Values: "en", "nl", "fr" |
The IntelliWidgets.js SDK may raise exceptions for a few reasons, such as authentication errors, invalid parameters or loading errors. We recommend writing code that gracefully handles all possible API exceptions. Check the error message for more information.
Below you find an overview of the various errors that are defined.
Error | Description | Fix |
---|---|---|
IntelliActionTokenError | The provided action token is invalid | Request a new action token. |
IntelliWidgetNotFoundError | The widget or variation of the widget is not found | Verify the method input values. Check the error message for more information. |
IntelliInvalidParameterError | The parameter or value that was provided is invalid | Verify the method input values. Check the error message for more information. |
IntelliUnexpectedError | An unexpected error occurred | Check the error message for more information. If the problem persists, please contact the support team. |
IntelliSdkLoadingError | The SDK failed to load properly | Reload the page. If the problem persists, please contact the support team. |