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