-
Notifications
You must be signed in to change notification settings - Fork 2.2k
-
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"
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 3 replies
-
They should be tree-shaking... what version of AngularFire are you using?
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.
All reactions
-
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)... 🤷♂️
Beta Was this translation helpful? Give feedback.
All reactions
-
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.
Beta Was this translation helpful? Give feedback.