Vendor Javascript

Vendor files allow you to include third-party resources as part of your integration

Directory Location

sample-integration/
├── vendor/
|    └── google.js

Summary

Vendor files are javascript files that are loaded alongside your integration. They can be used to inject third-party javascript libraries such as the google maps API.

You can specify vendor files by including them in the javascript property of the configuration.

When an integration is first started or reloaded, any javascript files specified by the javascript property in your config will be executed. This gives you an opportunity to load third party scripts.

onSettingsChange(callback)

optional | function

Parameter

Description

callback

Function to be called when the user updates settings for the integration.

You can register a callback to the onSettingsChange event by passing a callback to the onSettingsChange method. This callback will be invoked anytime the user updates settings for the integration. The callback function being invoked will be passed three parameters.

callback(integration, userConfig, userOptions)

required | function

Parameter

Description

integration

the integration object passed into the init function

userConfig

a user configuration object which contains settings information for the integration

userOptions

a user options object which contains the user's current option values for the integration

integration

The integration variable contains all information about the integration including userOptions and userConfig.

userConfig

The userConfig object contains information about the integration such as whether or not the user is subscribed, the color chosen by the user, and cache options for this integration.

userOptions

Contains the option values for the current user. For example, if you have an integration option called apiKey you could pass this apiKey to another API.

Example

The following code provides an example of how you would setup your vendor.js file to take advantage of the onSettingsChange callback.

If you want to run some javascript and ensure it runs only once, you can add a flag to indicate that the code has already run and then check the flag before running your code.

Last updated