From 933c270361342cc4c0a8fa0870cfbe4e37db43c8 Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Wed, 17 Dec 2025 13:37:22 -0800 Subject: [PATCH] Disable analytics and hovercards (#58954) --- src/events/components/events.ts | 4 ++-- src/fixtures/tests/playwright-rendering.spec.ts | 5 +++++ src/frame/lib/constants.ts | 3 +++ src/links/components/LinkPreviewPopover.tsx | 5 +++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/events/components/events.ts b/src/events/components/events.ts index 4cdf6a67db..9c37bf255c 100644 --- a/src/events/components/events.ts +++ b/src/events/components/events.ts @@ -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 diff --git a/src/fixtures/tests/playwright-rendering.spec.ts b/src/fixtures/tests/playwright-rendering.spec.ts index 385439074e..d1055d12a3 100644 --- a/src/fixtures/tests/playwright-rendering.spec.ts +++ b/src/fixtures/tests/playwright-rendering.spec.ts @@ -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 diff --git a/src/frame/lib/constants.ts b/src/frame/lib/constants.ts index 250450778c..2ae4904854 100644 --- a/src/frame/lib/constants.ts +++ b/src/frame/lib/constants.ts @@ -34,3 +34,6 @@ export const minimumNotFoundHtml = ` • Privacy `.replace(/\n/g, '') + +export const ANALYTICS_ENABLED = false +export const HOVERCARDS_ENABLED = false diff --git a/src/links/components/LinkPreviewPopover.tsx b/src/links/components/LinkPreviewPopover.tsx index 47b5e2d32b..c17deda009 100644 --- a/src/links/components/LinkPreviewPopover.tsx +++ b/src/links/components/LinkPreviewPopover.tsx @@ -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)