Removed tracking 'comments section viewable' ahoy event (#19354)
* Removed tracking 'comments section viewable' ahoy event * Returned focus on comments when there is an anchor
This commit is contained in:
parent
0f495f2952
commit
025cbeb35a
1 changed files with 8 additions and 22 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue