Skip to main content

Sending data to a custom destination

tip

If you're looking to export Command AI data to an analytics tool, you might be able to achieve this with one of our integrations!

To send data to a custom destination, you’ll need to use an event subscriber. This is a function that will be called whenever a Command AI analytics event is generated. Within the body of the function, you can filter the events to focus on the ones you want, and then send them to a data warehouse or analytics provider, or anything else.

Here’s an example of how to use .addEventSubscriber, and visit the SDK page addEventSubscriber for more info.

window.CommandBar.addEventSubscriber((eventName, eventData) => {
sendToCustombackend({ name: eventName, ...eventData });
});

Creating multiple event subscribers

Multiple event subscribers can be created when needed. For example, you could have one event subscriber to track analytics, and another event subscriber to close any other open modals in your app when Spotlight is opened.