refactor(web): extract isServer/isClient utility & upgrade Node.js to 22.12.0 (#30803)

Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com>
This commit is contained in:
yyh
2026-01-12 12:57:43 +08:00
committed by GitHub
parent f9a21b56ab
commit 9161936f41
14 changed files with 40 additions and 20 deletions

3
web/utils/client.ts Normal file
View File

@@ -0,0 +1,3 @@
export const isServer = typeof window === 'undefined'
export const isClient = typeof window !== 'undefined'

View File

@@ -1,3 +1,5 @@
import { isServer } from '@/utils/client'
/**
* Send Google Analytics event
* @param eventName - event name
@@ -7,7 +9,7 @@ export const sendGAEvent = (
eventName: string,
eventParams?: GtagEventParams,
): void => {
if (typeof window === 'undefined' || typeof (window as any).gtag !== 'function') {
if (isServer || typeof (window as any).gtag !== 'function') {
return
}
(window as any).gtag('event', eventName, eventParams)