Skip to content

Commit 933c270

Browse files
authored
Disable analytics and hovercards (#58954)
1 parent dd812b3 commit 933c270

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

src/events/components/events.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Cookies from '@/frame/components/lib/cookies'
2+
import { ANALYTICS_ENABLED } from '@/frame/lib/constants'
23
import { parseUserAgent } from './user-agent'
34
import { Router } from 'next/router'
45
import { isLoggedIn } from '@/frame/components/hooks/useHasAccount'
@@ -436,8 +437,7 @@ function initPrintEvent() {
436437
}
437438

438439
export function initializeEvents() {
439-
return
440-
// eslint-disable-next-line no-unreachable
440+
if (!ANALYTICS_ENABLED) return
441441
if (initialized) return
442442
initialized = true
443443
initPageAndExitEvent() // must come first

src/fixtures/tests/playwright-rendering.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import dotenv from 'dotenv'
22
import { test, expect } from '@playwright/test'
33
import { turnOffExperimentsInPage, dismissCTAPopover } from '../helpers/turn-off-experiments'
4+
import { HOVERCARDS_ENABLED, ANALYTICS_ENABLED } from '../../frame/lib/constants'
45

56
// This exists for the benefit of local testing.
67
// In GitHub Actions, we rely on setting the environment variable directly
@@ -347,6 +348,8 @@ test('sidebar custom link functionality works', async ({ page }) => {
347348
})
348349

349350
test.describe('hover cards', () => {
351+
test.skip(!HOVERCARDS_ENABLED, 'Hovercards are disabled')
352+
350353
test('hover over link', async ({ page }) => {
351354
await page.goto('/pages/quickstart')
352355
await turnOffExperimentsInPage(page)
@@ -691,6 +694,8 @@ test.describe('test nav at different viewports', () => {
691694
})
692695

693696
test.describe('survey', () => {
697+
test.skip(!ANALYTICS_ENABLED, 'Analytics are disabled')
698+
694699
test('happy path, thumbs up and enter comment and email', async ({ page }) => {
695700
let fulfilled = 0
696701
let hasSurveyPressedEvent = false

src/frame/lib/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ export const minimumNotFoundHtml = `
3434
&bull; <a href=https://docs.github.com/site-policy/privacy-policies/github-privacy-statement>Privacy</a>
3535
</small>
3636
`.replace(/\n/g, '')
37+
38+
export const ANALYTICS_ENABLED = false
39+
export const HOVERCARDS_ENABLED = false

src/links/components/LinkPreviewPopover.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useEffect } from 'react'
2+
import { HOVERCARDS_ENABLED } from '@/frame/lib/constants'
23

34
// We postpone the initial delay a bit in case the user didn't mean to
45
// hover over the link. Perhaps they just dragged the mouse over on their
@@ -450,6 +451,8 @@ export function LinkPreviewPopover() {
450451
// This is to track if the user entirely tabs out of the window.
451452
// For example if they go to the address bar.
452453
useEffect(() => {
454+
if (!HOVERCARDS_ENABLED) return
455+
453456
function windowBlur() {
454457
popoverHide()
455458
}
@@ -460,6 +463,8 @@ export function LinkPreviewPopover() {
460463
}, [])
461464

462465
useEffect(() => {
466+
if (!HOVERCARDS_ENABLED) return
467+
463468
function showPopover(event: MouseEvent) {
464469
const target = event.currentTarget as HTMLLinkElement
465470
popoverShow(target)

0 commit comments

Comments
 (0)