File size: 607 Bytes
68465df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import {useEffect} from "react"

import {useDeployment} from "@/services/deployment"
import {disableAnalytics, initAnalytics} from "@/utils/analytics"

export const FirebaseAnalyticsSetup = () => {
  const {activeDeployment, selectionResolved} = useDeployment()
  const telemetryEnabled = selectionResolved && activeDeployment.manifest.telemetry

  useEffect(() => {
    const updateCollection = telemetryEnabled ? initAnalytics : disableAnalytics
    updateCollection().catch((err) => console.warn("Firebase Analytics configuration failed:", err))
  }, [telemetryEnabled])

  return null
}