Nativescript-plugin-firebase: Using analytics throws some warnings

Created on 14 Oct 2020  路  9Comments  路  Source: EddyVerbruggen/nativescript-plugin-firebase

If I try to use analytics importing firebase like this, it doesn't have analytics in autocomplete:

import { firebase } from '@nativescript/firebase';

So, I'm importing it like this:

import * as firebase from '@nativescript/firebase';
With this kind of import, it does provide analytics in autocomplete, but there's warnings being shown while building the app:

WARNING in ./app/services/xxx.service.ts 20:12-30
"export 'analytics' (imported as 'firebase') was not found in '@nativescript/firebase'
 @ ./app/modules/main/services/yyy.service.ts
 @ ./app/app.module.ts
 @ ./main.ts

I'm using @nativescript/firebase version 11.0.0.

Most helpful comment

@timdoege thanks for the tip, this fixed it for me for various packages. I was importing directly from @nativescript/firebase and while Visual Studio seems happy with that (doesn't complain there is no export) it fails while building. Importing from the subfolder of the package fixes it.

Seems this is only for the packages that have their own folder in https://github.com/EddyVerbruggen/nativescript-plugin-firebase/tree/master/src as for example firestore can be imported directly from @nativescript/firebase, not @nativescript/firebase/firestore.

So as of now, I think you have to import individually:

  • admob
  • analytics
  • crashlytics
  • functions
  • inappmessaging
  • messaging
  • mlkit
  • performance
  • storage

All 9 comments

same here

I also have TypeError: Cannot read property 'setScreenName' of undefined

```TypeError: Cannot read property 'setScreenName' of undefined
at FirebaseAnalyticsService.logPageView (file: app/shared/services/firebase-analytics.service.ts:29:23)
at AnalyticsService.logPageView (file: app/shared/services/analytics.service.ts:18:27)
at MainComponent.ngOnInit (file: app/pages/main/main.component.ts:182:19)
at callHook (file: node_modules/@angular/core/fesm2015/core.js:3105:0)
at callHooks (file: node_modules/@angular/core/fesm2015/core.js:3075:0)
at executeInitAndCheckHooks (file: node_modules/@angular/core/fesm2015/core.js:3027:0)
at refreshView (file: node_modules/@angular/core/fesm2015/core.js:7333:0)
at refreshEmbeddedViews (file: node_modules/@angular/core/fesm2015/core.js:8419:0)
at refreshView (file: node_modules/@angular/core/fesm2015/core.js:7342:0)
at refreshEmbeddedViews (file: node_modules/@angular/core/fesm2015/core.js:8419:0)
at refreshView (file: node_modules/@angular/core/fesm2015/core.js:7342:0)
at refreshComponent (file: node_modules/@angular/core/fesm2015/core.js:8465:0)
at refreshChildComponents (file: node_modules/@angular/core/fesm2015/core.js:7126:0)
at refreshView (file: node_modules/@angular/core/fesm2015/core.js:7368:0)
at renderComponentOrTemplate (file: node_modules/@angular/core/fesm2015/core.js:7432:0)

```
logPageView(name: string): void {
firebase.analytics.setScreenName({ <-----here is the 29th line
screenName: name
});
}

I tried both
import * as firebase from '@nativescript/firebase';
and
import { analytics } from '@nativescript/firebase';

@EddyVerbruggen it's happened after upgrading to "@nativescript/firebase": "^11.0.0"

Import analytics like this instead:

import { analytics } from '@nativescript/firebase/analytics';

@timdoege thanks for the tip, this fixed it for me for various packages. I was importing directly from @nativescript/firebase and while Visual Studio seems happy with that (doesn't complain there is no export) it fails while building. Importing from the subfolder of the package fixes it.

Seems this is only for the packages that have their own folder in https://github.com/EddyVerbruggen/nativescript-plugin-firebase/tree/master/src as for example firestore can be imported directly from @nativescript/firebase, not @nativescript/firebase/firestore.

So as of now, I think you have to import individually:

  • admob
  • analytics
  • crashlytics
  • functions
  • inappmessaging
  • messaging
  • mlkit
  • performance
  • storage

According to @tomtastico answer, it seems like there's issues happening on version 11.0.0 about importing analytics without using deep imports.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vchimev picture vchimev  路  3Comments

jlooper picture jlooper  路  3Comments

thunder413 picture thunder413  路  3Comments

ButterMeWaffle picture ButterMeWaffle  路  4Comments

WaseemAhmadZ picture WaseemAhmadZ  路  3Comments