import { IAnalytics , IAnalyticsUser , IEventArgs , IPageEvent , TraitsMap } from "../IAnalytics" ; import { Heartbeats } from "polar-firebase/src/firebase/om/Heartbeats" ; import { Firebase } from "../../firebase/Firebase" ; import { Logger } from "polar-shared/src/logger/Logger" ; import { UserTraits } from "../../datastore/firebase/UserTraits" ; const log = Logger . create ( ) ; export class FirestoreAnalytics implements IAnalytics { public event ( event ) { const name = `${ event . category }/${ event . action }` ; } public event2 ( event , data ? ) { } public identify ( user ) { } public page ( event ) { this . event2 ( 'pageView' , event ) ; } public traits ( traits ) { UserTraits . write ( traits ) . catch ( err => console . error ( "Failed to write traits: " , err ) ) ; } public version ( version ) { } public heartbeat ( ) { const doWrite = async ( ) => { const uid = await Firebase . currentUserID ( ) ; await Heartbeats . write ( uid ) ; } ; doWrite ( ) . catch ( err => log . error ( err ) ) ; } public logout ( ) { } }