Error: Cannot read property 'userAgent' of undefined