dify/web/app/components/base/analytics-consent/cloud-analytics-boundary.tsx
Coding On Star 8d293023cc
feat: gate cloud analytics behind cookie consent (#39408)
Co-authored-by: CodingOnStar <hanxujiang@dify.com>
2026-07-23 02:40:54 +00:00

28 lines
725 B
TypeScript

import type { CloudAnalyticsBoundaryState } from './cloud-analytics-state'
import Script from '@/next/script'
import { GoogleAnalyticsTagScripts, GoogleConsentDefaults } from '../ga'
export function CloudAnalyticsBoundary({
cookieYesSiteKey,
enabled,
nonce,
}: CloudAnalyticsBoundaryState) {
if (!enabled) return null
const cookieYesScriptSrc = `https://cdn-cookieyes.com/client_data/${cookieYesSiteKey}/script.js`
return (
<>
<GoogleConsentDefaults nonce={nonce} />
<Script
id="cookieyes"
strategy="beforeInteractive"
type="text/javascript"
src={cookieYesScriptSrc}
nonce={nonce}
/>
<GoogleAnalyticsTagScripts nonce={nonce} />
</>
)
}