LogRocket integration
Command AI's integration with LogRocket works in two directions:
- Command AI —> LogRocket: send Command AI-generated events to LogRocket, so you have a fuller picture of user engagement
- LogRocket —> Command AI: use LogRocket user traits and events for Who and When targeting in Command AI
Once configured, the integration will "just work" — no maintenance required. You will not need to make any code changes to handle new traits.
Sending Command AI events to LogRocket
This is a 1-step integration!
Navigate to Integrations and click Enable on the LogRocket integration card.
How does this work? What pages will events be sent from?
Events generated by Command AI will now flow to LogRocket from any page in your product where (a) Command AI is booted and (b) LogRocket is installed.
Why don’t I see events flowing through?
Command AI sends events to LogRocket via LogRocket.track()
. If you use a different LogRocket SDK version, you can do the following:
-
Disable the integration
-
After you
init
Command AI, put the following code in your app:window.CommandBar.addEventSubscriber((eventName, eventData) => {
// replace the line below with your SDK method
LogRocket.track();
});
Using LogRocket data and events in Command AI
You can (1) send LogRocket user events to Command AI; and (2) send LogRocket events to Command AI
Sending properties to Command AI
You can send any of the existing user properties that you send to LogRocket to Command AI Here’s a simplified code snippet:
// Your existing user properties
var userId = '123456',
var userProperties = {
name: "Roger Rocket",
email: "roger@logrocket.com",
plan: "pro",
role: "admin",
...
};
// Passed to LogRocket
LogRocket.identify(userId, userProperties);
// And additionally sent to Command AI:
window.CommandBar.boot(userID, userProperties);
// Adding one-off or session only properties to Command AI is easy too:
window.CommandBar.addMetadata("userIsWorkspaceOwner", true);
Sending events to Command AI
All events sent to LogRocket can also be relayed to Command AI. This allows you to treat any LogRocket event the same way as a natively-generated Command AI event.
// Many companies using PostHog events have a globally available function
// to track events. The simplest way to ingest all events is to add a
// Command AI SDK call to trackEvent to this function.
const reportEvent = (event, eventProperties) => {
LogRocket.track(event, eventProperties);
window.CommandBar.trackEvent(event, eventProperties);
};