mirror of
https://github.com/langgenius/dify.git
synced 2026-02-09 23:20:12 -05:00
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:
3
web/utils/client.ts
Normal file
3
web/utils/client.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export const isServer = typeof window === 'undefined'
|
||||
|
||||
export const isClient = typeof window !== 'undefined'
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user