added twig variable checking for admin
updated error logging for better debugging of JS