Unresponsive Gestures [BB]

Detect root ScreenView load from UIC as an unresponsive state.

Display Name
Unresponsive Gestures [BB]
Internal Name
CUST.E_UNRESPONSIVE_GESTURES_BB
Advanced Mode
true
Description
Detect root ScreenView load from UIC as an unresponsive state
ImageSrc
default.gif
DisplayInPortal
false
DisplayInSessionList
false

JavaScriptâ„¢: (Advanced Mode only)

function CUST$E_UNRESPONSIVE_GESTURES_BB()
{
    var ugDetected = false;
    var offsetThreshold = 100; //in ms

    //Detect root ScreenView load from UIC as an unresponsive state
    //Event offset in UIC reset on each page so it is unreliable
    //when the page changes
    if($P["TL.STEP_SCREENVIEW_TYPE"].firstValue().toUpperCase() == "LOAD"
          && $P["TL.STEP_SCREENVIEW_NAME"].firstValue().toUpperCase() == "ROOT") 
    {
        ugDetected = true;
        $F.setFact("TL.F_E_LAST_GESTURE_OFFSET_BB", "-1");
        $F.setFact("TL.F_E_LAST_GESTURE_BB", "");
    }
    else
    {
        if($P["TL.STEP_MESSAGE_TYPE"].patternFound() && $P["TL.STEP_OFFSET"].patternFound())
        {
            var lastGestureOffset = $F.factCount("TL.F_E_LAST_GESTURE_OFFSET_BB") > 0 ? parseInt($F.getLastFact("TL.F_E_LAST_GESTURE_OFFSET_BB").Value) : -1;
            var lastGestureType = $F.factCount("TL.F_E_LAST_GESTURE_BB") > 0 ? $F.getLastFact("TL.F_E_LAST_GESTURE_BB").Value : "";
            var messageType = $P["TL.STEP_MESSAGE_TYPE"].firstValue();
            var offset = parseInt($P["TL.STEP_OFFSET"].firstValue());
            var tooLong = lastGestureOffset != -1 && (offset - lastGestureOffset) >= offsetThreshold;
            var isExpectedMessageType = false;
            
            //Detect unresponsive gesture (gesture not followed by the expected type within the threshold [default 100ms])
            if(lastGestureOffset != -1)
            {
              switch(lastGestureType)
              {
                case "pinch":
                  isExpectedMessageType = messageType == "1";
                  break;
                case "swipe":
                  isExpectedMessageType = messageType == "1" || messageType == "2";
                  break;
                case "tap":
                case "doubleTap":
                case "tapHold":
                default:
                  isExpectedMessageType = messageType == "4";
                  break;
              }

              ugDetected = !isExpectedMessageType && tooLong;
            }

            //If we see a gesture, track its timestamp for the next call of this event
            if(messageType == "11")
            {
                lastGestureOffset = offset;
                if($P["TL.P_SESSIONS_0_MESSAGE_STEP_ENTRY_IN_REQUEST"].patternFound())
                  $F.setFact("TL.F_E_LAST_GESTURE_BB", $P["TL.P_SESSIONS_0_MESSAGE_STEP_ENTRY_IN_REQUEST"].firstValue());
                else
                  $F.setFact("TL.F_E_LAST_GESTURE_BB", "");
            }
            else
                $F.setFact("TL.F_E_LAST_GESTURE_OFFSET_BB", "-1");
        }
    }

    if (ugDetected) 
        $F.setFact("CUST.F_E_UNRESPONSIVE_GESTURES_BB", "TLT$NULL");
}