Skip to content

Commit dbcdc1b

Browse files
authored
Merge pull request #37090 from github/repo-sync
Repo sync
2 parents e2ce1a8 + b4bd574 commit dbcdc1b

File tree

6 files changed

+47
-10
lines changed

6 files changed

+47
-10
lines changed

src/events/components/dotcom-cookies.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { isHeadless } from './is-headless'
2+
13
// We cannot use Cookies.get() on the frontend for httpOnly cookies
24
// so we need to make a request to the server to get the cookies
35

46
type DotcomCookies = {
5-
dotcomUsername?: string
67
isStaff?: boolean
78
}
89

@@ -19,6 +20,8 @@ const LOCAL_STORAGE_KEY = 'dotcomCookies'
1920
// If a user is staff and they didn't happen to be logged in when these cookies were saved,
2021
// we can instruct them as needed to update the cookies and correctly set the isStaff flag.
2122
async function fetchCookies(): Promise<DotcomCookies> {
23+
if (isHeadless()) return { isStaff: false }
24+
2225
// Return the cached object if we have it in memory.
2326
if (cachedCookies) {
2427
return cachedCookies
@@ -63,7 +66,6 @@ async function fetchCookies(): Promise<DotcomCookies> {
6366
console.error('Error fetching cookies:', err)
6467
// On failure, return default values.
6568
const defaultCookies: DotcomCookies = {
66-
dotcomUsername: '',
6769
isStaff: false,
6870
}
6971
cachedCookies = defaultCookies
@@ -81,8 +83,3 @@ export async function getIsStaff(): Promise<boolean> {
8183
const cookies = await fetchCookies()
8284
return cookies.isStaff || false
8385
}
84-
85-
export async function getDotcomUsername(): Promise<string> {
86-
const cookies = await fetchCookies()
87-
return cookies.dotcomUsername || ''
88-
}

src/events/components/events.ts

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Router } from 'next/router'
55
import { isLoggedIn } from 'src/frame/components/hooks/useHasAccount'
66
import { getExperimentVariationForContext } from './experiments/experiment'
77
import { EventType, EventPropsByType } from '../types'
8+
import { isHeadless } from './is-headless'
89

910
const COOKIE_NAME = '_docs-events'
1011

@@ -73,6 +74,8 @@ export function sendEvent<T extends EventType>({
7374
eventGroupKey?: string
7475
eventGroupId?: string
7576
} & EventPropsByType[T]) {
77+
if (isHeadless()) return
78+
7679
const body = {
7780
type,
7881

src/events/components/is-headless.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Basic checks for if the browser is actually a headless browser robot
2+
3+
declare global {
4+
interface Window {
5+
GHDOCSPLAYWRIGHT: any
6+
}
7+
}
8+
9+
export function isHeadless(): boolean {
10+
if (window.GHDOCSPLAYWRIGHT) return false
11+
if (navigator.webdriver) return true
12+
if (/headless/i.test(navigator.userAgent)) return true
13+
if (/headless/i.test(navigator.appVersion)) return true
14+
if (!window.outerHeight || !window.innerHeight) return true
15+
if (navigator.languages?.length === 0) return true
16+
if (navigator.mimeTypes?.length === 0) return true
17+
return false
18+
}

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

+8
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,10 @@ test.describe('survey', () => {
664664
// See https://github.com/microsoft/playwright/issues/12231
665665
})
666666

667+
await page.addInitScript(() => {
668+
window.GHDOCSPLAYWRIGHT = 1
669+
})
670+
667671
await page.goto('/get-started/foo/for-playwright')
668672

669673
// The label is visually an SVG. Finding it by its `for` value feels easier.
@@ -709,6 +713,10 @@ test.describe('survey', () => {
709713
// See https://github.com/microsoft/playwright/issues/12231
710714
})
711715

716+
await page.addInitScript(() => {
717+
window.GHDOCSPLAYWRIGHT = 1
718+
})
719+
712720
await page.goto('/get-started/foo/for-playwright')
713721

714722
await page.locator('[for=survey-yes]').click()

src/frame/middleware/api.ts

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ router.get('/cookies', (req, res) => {
6464
noCacheControl(res)
6565
const cookies = {
6666
isStaff: Boolean(req.cookies?.staffonly?.startsWith('yes')) || false,
67-
dotcomUsername: req.cookies?.dotcom_user || '',
6867
}
6968
return res.json(cookies)
7069
})

src/ghes-releases/lib/enterprise-dates.json

+14-2
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,22 @@
173173
},
174174
"3.19": {
175175
"releaseDate": "2025-11-11",
176-
"deprecationDate": "2026-12-02"
176+
"deprecationDate": "2026-12-09"
177177
},
178178
"3.20": {
179179
"releaseDate": "2026-02-17",
180-
"deprecationDate": "2027-03-10"
180+
"deprecationDate": "2027-03-17"
181+
},
182+
"3.21": {
183+
"releaseDate": "2026-05-12",
184+
"deprecationDate": "2027-06-02"
185+
},
186+
"3.22": {
187+
"releaseDate": "2026-08-04",
188+
"deprecationDate": "2027-08-25"
189+
},
190+
"3.23": {
191+
"releaseDate": "2026-11-10",
192+
"deprecationDate": "2027-12-08"
181193
}
182194
}

0 commit comments

Comments
 (0)