Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
nuget.enableUsabilla = function (obfuscatedPath) {
// If there is an obfuscated path, hook into the outgoing AJAX request containing the feedback and obfuscate
// the URL data. This approach was provided by the Usabilla technical support.
if (obfuscatedPath) {
var obfuscatedUrl = document.createElement('a');
obfuscatedUrl.href = window.location.href;
if (obfuscatedPath.substring(0, 1) != "/") {
obfuscatedUrl.pathname = "/" + obfuscatedPath;
} else {
obfuscatedUrl.pathname = obfuscatedPath;
}
window.usabilla_live("setEventCallback", function (category, action, label, value, eventdata) {
if (action != "Feedback:Open") {
return;
}
function sendWithObfuscation(vData) {
var data = JSON.parse(vData);
data.url = obfuscatedUrl.href;
vData = JSON.stringify(data);
arguments[0] = vData;
realSend.apply(this, arguments);
}
var realSend = XMLHttpRequest.prototype.send;
var ub_window = document.getElementById("lightningjs-frame-usabilla_live_feedback").contentWindow;
ub_window.XMLHttpRequest.prototype.send = sendWithObfuscation;
if (window.XDomainRequest) {
realSend = XDomainRequest.prototype.send;
ub_window.XDomainRequest.prototype.send = sendWithObfuscation;
}
});
}
// Hide the default feedback button.
window.usabilla_live("hide");
// Wire-up and show the custom feedback button.
document.getElementById("usbl-integrated-button").addEventListener("click", function (event) {
event.preventDefault();
window.usabilla_live("click");
});
document.getElementById("usabilla-button").style.display = "block";
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment