Initialization
import { getAnalytics } from "firebase/analytics" ;
const analytics = getAnalytics ( ) ;
Log an event
import { getAnalytics, logEvent } from "firebase/analytics" ;
const analytics = getAnalytics ( ) ;
logEvent ( analytics, 'notification_received' ) ;
Log an event with custom parameters
import { getAnalytics, logEvent } from "firebase/analytics" ;
const analytics = getAnalytics ( ) ;
logEvent ( analytics, 'select_content' , {
content_type: 'image' ,
content_id: 'P12453' ,
items: [ { name: 'Kittens' } ]
} ) ;
Set user properties
import { getAnalytics, setUserProperties } from "firebase/analytics" ;
const analytics = getAnalytics ( ) ;
setUserProperties ( analytics, { favorite_food: 'apples' } ) ;