diff --git a/app/javascript/packs/articlePage.jsx b/app/javascript/packs/articlePage.jsx index ed001fb8a..b8234150f 100644 --- a/app/javascript/packs/articlePage.jsx +++ b/app/javascript/packs/articlePage.jsx @@ -1,5 +1,4 @@ import { h, render } from 'preact'; -import ahoy from 'ahoy.js'; import { Snackbar, addSnackbarItem } from '../Snackbar'; import { addFullScreenModeControl } from '../utilities/codeFullscreenModeSwitcher'; import { initializeDropdown } from '../utilities/dropdownUtils'; @@ -88,26 +87,13 @@ function showAnnouncer() { document.getElementById('article-copy-link-announcer').hidden = false; } -// Temporary Ahoy Stats for displaying comments section either on page load or after scrolling -function trackCommentsSectionDisplayed() { - const callback = (entries, observer) => { - entries.forEach((entry) => { - if (entry.isIntersecting) { - ahoy.track('Comment section viewable', { page: location.href }); - observer.disconnect(); - } - if (location.hash === '#comments') { - //handle focus event on text area - const element = document.getElementById('text-area'); - const event = new FocusEvent('focus'); - element.dispatchEvent(event); - } - }); - }; - - const target = document.getElementById('comments'); - const observer = new IntersectionObserver(callback, {}); - observer.observe(target); +function focusOnComments() { + if (location.hash === '#comments') { + //handle focus event on text area + const element = document.getElementById('text-area'); + const event = new FocusEvent('focus'); + element.dispatchEvent(event); + } } function copyArticleLink() { @@ -175,6 +161,6 @@ targetNode && embedGists(targetNode); setupDisplayAdDropdown(); initializeUserSubscriptionLiquidTagContent(); +focusOnComments(); // Temporary Ahoy Stats for comment section clicks on controls trackCommentClicks('comments'); -trackCommentsSectionDisplayed();