Disable analytics and hovercards (#58954)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Cookies from '@/frame/components/lib/cookies'
|
||||
import { ANALYTICS_ENABLED } from '@/frame/lib/constants'
|
||||
import { parseUserAgent } from './user-agent'
|
||||
import { Router } from 'next/router'
|
||||
import { isLoggedIn } from '@/frame/components/hooks/useHasAccount'
|
||||
@@ -436,8 +437,7 @@ function initPrintEvent() {
|
||||
}
|
||||
|
||||
export function initializeEvents() {
|
||||
return
|
||||
// eslint-disable-next-line no-unreachable
|
||||
if (!ANALYTICS_ENABLED) return
|
||||
if (initialized) return
|
||||
initialized = true
|
||||
initPageAndExitEvent() // must come first
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import dotenv from 'dotenv'
|
||||
import { test, expect } from '@playwright/test'
|
||||
import { turnOffExperimentsInPage, dismissCTAPopover } from '../helpers/turn-off-experiments'
|
||||
import { HOVERCARDS_ENABLED, ANALYTICS_ENABLED } from '../../frame/lib/constants'
|
||||
|
||||
// This exists for the benefit of local testing.
|
||||
// In GitHub Actions, we rely on setting the environment variable directly
|
||||
@@ -347,6 +348,8 @@ test('sidebar custom link functionality works', async ({ page }) => {
|
||||
})
|
||||
|
||||
test.describe('hover cards', () => {
|
||||
test.skip(!HOVERCARDS_ENABLED, 'Hovercards are disabled')
|
||||
|
||||
test('hover over link', async ({ page }) => {
|
||||
await page.goto('/pages/quickstart')
|
||||
await turnOffExperimentsInPage(page)
|
||||
@@ -691,6 +694,8 @@ test.describe('test nav at different viewports', () => {
|
||||
})
|
||||
|
||||
test.describe('survey', () => {
|
||||
test.skip(!ANALYTICS_ENABLED, 'Analytics are disabled')
|
||||
|
||||
test('happy path, thumbs up and enter comment and email', async ({ page }) => {
|
||||
let fulfilled = 0
|
||||
let hasSurveyPressedEvent = false
|
||||
|
||||
@@ -34,3 +34,6 @@ export const minimumNotFoundHtml = `
|
||||
• <a href=https://docs.github.com/site-policy/privacy-policies/github-privacy-statement>Privacy</a>
|
||||
</small>
|
||||
`.replace(/\n/g, '')
|
||||
|
||||
export const ANALYTICS_ENABLED = false
|
||||
export const HOVERCARDS_ENABLED = false
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect } from 'react'
|
||||
import { HOVERCARDS_ENABLED } from '@/frame/lib/constants'
|
||||
|
||||
// We postpone the initial delay a bit in case the user didn't mean to
|
||||
// hover over the link. Perhaps they just dragged the mouse over on their
|
||||
@@ -450,6 +451,8 @@ export function LinkPreviewPopover() {
|
||||
// This is to track if the user entirely tabs out of the window.
|
||||
// For example if they go to the address bar.
|
||||
useEffect(() => {
|
||||
if (!HOVERCARDS_ENABLED) return
|
||||
|
||||
function windowBlur() {
|
||||
popoverHide()
|
||||
}
|
||||
@@ -460,6 +463,8 @@ export function LinkPreviewPopover() {
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!HOVERCARDS_ENABLED) return
|
||||
|
||||
function showPopover(event: MouseEvent) {
|
||||
const target = event.currentTarget as HTMLLinkElement
|
||||
popoverShow(target)
|
||||
|
||||
Reference in New Issue
Block a user