dify/web/utils/gtag.ts
CodingOnStar 59772c2493 feat: integrate Google Analytics event tracking and update CSP for script sources
- Added types for Google Analytics gtag and implemented event tracking in user registration flows.
- Updated Content Security Policy to allow 'wasm-unsafe-eval' in script sources.
- Refactored GA component to improve nonce handling and script loading strategy.
- Cleaned up UTM info cookies after successful user registration.
2025-12-30 14:39:28 +08:00

13 lines
308 B
TypeScript

/**
* Send Google Analytics event
* @param eventName - event name
* @param eventParams - event params
*/
export const sendGAEvent = (
eventName: string,
eventParams?: GtagEventParams,
): void => {
if (typeof window !== 'undefined' && window.gtag)
window.gtag('event', eventName, eventParams)
}