chemerisuk / cordova-plugin-firebase-analytics

Cordova plugin for Firebase Analytics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logged Event not reflected in firebase events console.

navaneethsaj opened this issue · comments

I am logging the custom events (eg: game_over, user_registered etc) using logEvent(). I am getting the status "OK" in the success callback. However, I cannot see the events being logged on the events page in the Firebase console. But I am seeing some predefined(page_views, app_started etc) events working.

My code snippet.

@Injectable({
  providedIn: 'root'
})
export class FirebaseService {
  constructor(
    private firebaseAnalytics: FirebaseAnalytics,
    private platform: Platform) {
    this.platform.ready().then(() => {
      this.logEventWithMsg('game_started', {
        username: localStorage.getItem('username') || 'Guest',
        login_id: localStorage.getItem('loginid') || 'Guest'
      });
    }).catch(e => {
      console.error(e);
    });
  }

  public logEventWithMsg(event: string, msg: any) {
    try {
      this.firebaseAnalytics.logEvent(event, { msg })
        .then((res: any) => console.log({ res }))
        .catch((error: any) => console.error({ error }));
    } catch (error) {
      console.log(error);
    }
  }
}

Kindly help.

Kindly help @chemerisuk