Skip to content

Instantly share code, notes, and snippets.

@LMG23
Created January 17, 2023 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LMG23/cac1338a1a0c58e022d9474e27a4a6ae to your computer and use it in GitHub Desktop.
Save LMG23/cac1338a1a0c58e022d9474e27a4a6ae to your computer and use it in GitHub Desktop.
window.usabilla_live('setEventCallback', function(category, action, label, value, userData){
function flat(source, target) {
Object.keys(source).forEach(function (k) {
if (source[k]!== null && typeof source[k] === 'object') {
flat(source[k], target);
return;
}
target[k] = source[k];
});
}
if(action === "Feedback:Success" || (action === "Campaign:Page Switch" && userData.end)) {
var userDataFlat = {};
flat(userData, userDataFlat);
for(var i in userDataFlat) {
console.log(i +" => " + userDataFlat[i]);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment