Visits Log User IDs report

I see inconsistent behaviour for Visits Log and User IDs report.
A new user visit does not consistently show up under Visits Log. Sometimes it does, other times it does not. A user logged into application for the very first time after tracking was enabled, but visit did not show up under Visits log. A few minutes later the same user logged in again and then visit showed up under Visits log.

However, both times her user ID did not show up under User IDs report

Some of the other users are showing up under User IDs report. Some of them showed up immediately after their visit, and showed up a few minutes after their visit.
Appreciate any pointers

Below is my JS Tracking code

try {
var piwikTracker = Piwik.getTracker(pkBaseURL + ‘piwik.php’, piwikcode);

piwikTracker.setCustomVariable (1, ‘sunetid’, ‘&APP_USER.’);

alert('APP_PAGE_ID : ’ + ‘&APP_PAGE_ID.’);

   //101 logout page
   if (&APP_PAGE_ID. == 101) {

catch( err ) {}