Proposed Bugfix: PWA Service Worker Having HTML Inserted Into JavaScript

I’m currently using https://wordpress.org/plugins/pwa/ on a site which then has /?wp_service_worker=1 being called. This is expected to be a fully JavaScript-based response, but I’m seeing the HTML code for the HubSpot tracking being inserted at the top of this response.

Upon initial investigation, it seems like /inc/class-leadin.php has add_leadin_frontend_scripts() being called on wp_enqueue_scripts and login_enqueue_scripts which should be used for enqueuing CSS & JS when the add_page_analytics() function that’s called at the end of it actually just outputs HTML directly. It seems this is going against the expected WordPress conventions and breaking PWA (and possibly other plugins) as a result.

Really, wp_footer should be used instead of wp_enqueue_scripts and login_footer instead of login_enqueue_scripts since it’s outputting HTML that we want to be included before the page’s </body> tag.