MCPcopy Index your code
hub / github.com/github/docs / initPageAndExitEvent

Function initPageAndExitEvent

components/lib/events.ts:236–263  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

234}
235
236function initPageAndExitEvent() {
237 sendPage() // Initial page hit
238
239 // Regular page exits
240 window.addEventListener('scroll', trackScroll)
241 document.addEventListener('visibilitychange', () => {
242 if (document.visibilityState === 'hidden') {
243 sendExit()
244 }
245 })
246
247 // Client-side routing
248 const pushState = history.pushState
249 history.pushState = function (state, title, url) {
250 // Don't trigger page events on query string or hash changes
251 const newPath = url?.toString().replace(location.origin, '').split('?')[0]
252 const shouldSendEvents = newPath !== location.pathname
253 if (shouldSendEvents) {
254 sendExit()
255 }
256 const result = pushState.call(history, state, title, url)
257 if (shouldSendEvents) {
258 sendPage()
259 resetPageParams()
260 }
261 return result
262 }
263}
264
265function initClipboardEvent() {
266 ;['copy', 'cut', 'paste'].forEach((verb) => {

Callers 1

initializeEventsFunction · 0.85

Calls 3

sendPageFunction · 0.85
sendExitFunction · 0.85
resetPageParamsFunction · 0.85

Tested by

no test coverage detected