Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

724 B
Raw Blame
'use client'

import { useEffect } from 'react'
import { useAnalyticsConsent } from '@/app/components/base/analytics-consent/consent-store'
import { sendWebAppAmplitudeEvent, setWebAppAmplitudeOptOut } from './web-app-client'
import { registerWebAppEventTracker } from './web-app-event'

export function WebAppAmplitudeProvider() {
  const consent = useAnalyticsConsent()

  useEffect(() => {
    if (consent !== 'granted') {
      setWebAppAmplitudeOptOut(true)
      return
    }

    setWebAppAmplitudeOptOut(false)
    const unregisterTracker = registerWebAppEventTracker(sendWebAppAmplitudeEvent)

    return () => {
      unregisterTracker()
      setWebAppAmplitudeOptOut(true)
    }
  }, [consent])

  return null
}