Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AngularFireAnalyticsModule has hard dependency on @angular/fire/auth #2734

Ludevik started this conversation in Ideas
Discussion options

I'd like to enable analytics on a simple static page. I am currently using only web hosting from firebase and no other features. I'd like to add analytics to my project.

I have simple setup like this:

imports: [
 ...
 AngularFireModule.initializeApp(environment.firebase),
 AngularFireAnalyticsModule
]

By importing AngularFireAnalyticsModule and building prod build i get 2 new chunks, one is firebase analytics and second one is firebase auth. Firebase analytics chunk is expected, but auth chunk is not. It has ~170kB which is quite heavy dependency for my simple app.

Problem is that UserTrackingService is not tree-shakable and is always bundled even when it is not used. UserTrackingService is importing and bringing whole firebase auth with it.

It would be nice if both UserTrackingService and ScreenTrackingService were tree-shakable.

Used versions:

 "@angular/common": "11.0.5",
 "@angular/compiler": "11.0.5",
 "@angular/core": "11.0.5",
 "@angular/fire": "6.1.4",
 "firebase": "8.0"
You must be logged in to vote

Replies: 1 comment 3 replies

Comment options

They should be tree-shaking... what version of AngularFire are you using?

You must be logged in to vote
3 replies
Comment options

It is in my post: "@angular/fire": "6.1.4", "firebase": "8.0"
For now i just made copypasta of analytics to my project and removed unused services.
If i understand treeshaking correctly, then they cannot be treeshaken, because there are imports in multiple places, for example AngularFireAnalyticsModule imports both ScreenTrackingService and UserTrackingService. Importing AngularFireAnalyticsModule brings all what is imported in that file.

Comment options

Sorry missed that, might've been a formatting issue over email / mobile. AngularFireAnalyticsModule doesn't provide UserTrackingService or ScreenTrackingService and they are marked as @Optional() in the constructor. We had solved a prior problem with them not being tree-shaken out due to the way the @Injectable was defined prior to 6.0.4 (#2604)... 🤷‍♂️

Comment options

Next time I'm poking around I'll give it a try, however I am pretty preoccupied with the next major version... so maybe some other community members could help out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /