addEventSubscriber(eventHandler)
Captures CommandBar events to be handled in your code / stored in your database. Ask the CommandBar team if you're interested in this feature.
If you're looking to export CommandBar data to an analytics tool, you might be able to achieve this with one of our integrations!
Example
// The function that handles CommandBar events
const myHandler = (eventName, eventData) => {
sendToSegment({ name: eventName, ...eventData });
};
// Subscribe to CommandBar events
const unsubPromise = window.CommandBar.addEventSubscriber(myHandler);
// Later, call the function returned by the promise
// to unsubscribe your handler from CommandBar events.
unsubPromise.then((unsub) => unsub());
Method parameters
eventHandler Required
function
A function for handling events generated by CommandBar. 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 eventName
s 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.