Skip to content

Commit

Permalink
Track Rage Click "selector"
Browse files Browse the repository at this point in the history
  • Loading branch information
nicjansma committed Sep 29, 2017
1 parent c662a32 commit 28024a6
Showing 1 changed file with 45 additions and 5 deletions.
50 changes: 45 additions & 5 deletions perfbar.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ var UW = unsafeWindow;
var frameStartTime = performance.now();

// rage clicks
var rageClicks = 0;
var rageClicks = [];

/**
* requestAnimationFrame callback
Expand All @@ -460,8 +460,49 @@ var UW = unsafeWindow;
frameStartTime = performance.now();
}

function onRageClick() {
tb.update("Realtime", "Rage Clicks", ++rageClicks, {
function onRageClick(e) {
var path = "";
var node = jQuery(e.target);
var stop = false;

while (node.length && !stop) {
var realNode = node[0];
var name = realNode.localName;

if (!name) {
break;
}

name = name.toLowerCase();

// if it has an ID, stop here
if (node.attr('id')) {
name = name + "#" + node.attr('id');
stop = true;
}

if (node.attr('class')) {
name = name + "." + node.attr('class').trim().split(" ")[0].trim();;
}

var parent = node.parent();

path = name + (path ? '>' + path : '');
node = parent;
}

rageClicks.push({
when: performance.now(),
x: e.clientX,
y: e.clientY,
path: path
});

if (BOOMR.sendMetric) {
BOOMR.sendMetric("Rage Clicks", 1);
}

tb.update("Realtime", "Rage Clicks", rageClicks.length, {
color: "red"
});
}
Expand Down Expand Up @@ -858,7 +899,6 @@ var UW = unsafeWindow;
_this.removeEventListener(eventName, rage);
}, delay)


var rage = function(e) {
e.stopPropagation();
if (!_this.style) {
Expand Down Expand Up @@ -4961,7 +5001,7 @@ function initEmbeddedBoomerang() {

if ((sameClicks + 1) >= RAGE_CLICK_THRESHOLD) {
rageClicks++;
BOOMR.fireEvent("rage_click");
BOOMR.fireEvent("rage_click", e);
}
}
else {
Expand Down

0 comments on commit 28024a6

Please sign in to comment.