Skip to content

Instantly share code, notes, and snippets.

@lennardtastic
Last active November 10, 2021 08:52
Show Gist options
  • Save lennardtastic/bc66c800c591665de22170d69035e033 to your computer and use it in GitHub Desktop.
Save lennardtastic/bc66c800c591665de22170d69035e033 to your computer and use it in GitHub Desktop.
JavaScript code for integrating Usabilla with SessionCam
/**
* Define the a object for keeping track of al custom variables that will be submitted to Usabilla
*/
var customUsbl = {};
// Define a basic set of variable. You can change these if you want 😄
var usernameUsbl = "McAwesome";
var idUsbl = "12afe34df";
//Define a basic set of variables for holding the SessionID and SessionRecording Link
var sessionCamIDUsbl = "";
var sessionCamLinkUsbl = "";
// Fill the customObj with the earlier created custom variables
customUsbl.UserName = usernameUsbl;
customUsbl.UserID = idUsbl;
//Send custom variables by assigning the customObj to the 'custom' object in Usabilla
//Resend if you changed/added values in the customUsbl
window.usabilla_live('data', {
'custom': customUsbl
});
/**
* Function for retrieving the SessionCamID and SessionRecording Link
* @return String containing the SessionCamID
*/
function getSessionCamUsbl() {
if (window.sessionCamRecorder) {
// Append or Overwrite the SessionCamID and SessionCamLink in the customUsbl object that is submitted to Usabilla with each feedback item campaign entry
sessionCamIDUsbl = window.sessionCamRecorder.sessionId();
sessionCamLinkUsbl = "https://console.sessioncam.com/Console/Recordings/PlaybackSession?sessionId=" + window.sessionCamRecorder.sessionId();
customUsbl.SessionCamID = sessionCamIDUsbl;
customUsbl.SessionCamLink = sessionCamLinkUsbl;
// Submit the updated customUsbl object to Usabilla in order to update the values
window.usabilla_live('data', {
'custom': customUsbl
});
} else {
setTimeout(function() {
// Append or Overwrite the SessionCamID and SessionCamLink in the customUsbl object that is submitted to Usabilla with each feedback item campaign entry
sessionCamIDUsbl = window.sessionCamRecorder.sessionId();
sessionCamLinkUsbl = "https://console.sessioncam.com/Console/Recordings/PlaybackSession?sessionId=" + window.sessionCamRecorder.sessionId();
console.log(sessionCamIDUsbl);
console.log(sessionCamLinkUsbl);
customUsbl.SessionCamID = sessionCamIDUsbl;
customUsbl.SessionCamLink = sessionCamLinkUsbl;
// Submit the updated customUsbl object to Usabilla in order to update the values
window.usabilla_live('data', {
'custom': customUsbl
});
}, 1000);
}
}
getSessionCamUsbl();
@lennardtastic
Copy link
Author

Updated check within window based on feedback from SessionCam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment