This code does work to measure it and capture it in a variable. I am measuring the time it takes the bot to generate a reply (user.timeBotReply) and the time it takes to show the user a response (user.timeResponse), because there are AI tasks in between. Not sure how I can use "Track Event" to show this in the Analytics because it is limited
const timerStart = new Date(user.timerStart);
const timerReply = new Date(user.timerReply);
const timerEnd = new Date(user.timerEnd);
// Calculate time differences
const timerBotReply = timerReply - timerStart;
const timerResponse = timerEnd - timerStart;
// Convert to seconds for readability
const timerBotReplyInSeconds = timerBotReply / 1000;
const timerResponseInSeconds = timerResponse / 1000;
// Log the results
console.log(
Timer Bot Reply: ${timerBotReply} milliseconds (${timerBotReplyInSeconds} seconds)
);
console.log(
Timer Response: ${timerResponse} milliseconds (${timerResponseInSeconds} seconds)
);
user.timerResponse = timerResponseInSeconds;
user.timerBotReply = timerBotReplyInSeconds;