Skip to main content

addEventSubscriber(eventHandler)

Captures Command AI events to be handled in your code / stored in your database. Ask the Command AI team if you're interested in this feature.

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!

Example

// The function that handles Command AI events
const myHandler = (eventName, eventData) => {
sendToSegment({ name: eventName, ...eventData });
};

// Subscribe to Command AI events
const unsubPromise = window.CommandBar.addEventSubscriber(myHandler);

// Later, call the function returned by the promise
// to unsubscribe your handler from Command AI events.
unsubPromise.then((unsub) => unsub());

Method parameters

eventHandler Required

function

A function for handling events generated by Command AI. It should have the following signature:

eventHandler Properties

eventName Required

string

The name of the event type. Here are the different event types:

  • NEW EVENTS NEEDED

Note that we will likely add more eventNames in the future, so your code should be robust to receiving events with an unknown eventName.

eventData Required

object

Event attributes (will differ based on the type of event). In addition to the data below, any eventData you pass to boot() will be added to each event. Each data object includes its event type as a property.