angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Analytics not working for prod builds

Open smarth55 opened this issue 6 years ago • 3 comments

Version info

Angular: 9.0.0-rc.9 Firebase: 7.7.0 AngularFire: 5.3.0

How to reproduce these conditions

Following the documentation, add the AngularFireAnalyticsModule to the root module of the application. Run npm run build -- --prod.

Steps to set up and reproduce I updated by running ng update --all and then ran locally with npm run start. The correct bundles were produced and the analytics console was showing events. I deployed the application for production and checked the analytics console and nothing was being tracked.

Debug output

** Errors in the JavaScript console ** none

** Screenshots ** It looks like the bundles are being created by webpack, but are never requested. I actually did this two different ways. The first was just like the documentation: add the module and it should fire a page_view event, but I noticed that the analytics bundle was never requested from the server:

(it should be 4.*.js) Screen Shot 2020-01-22 at 10 56 15 AM

I next added {provide: CONFIG, useValue: {send_page_view: false}} and manually called this.analytics.logEvent('page_view'); in my root component and now I see the analytics bundle: Screen Shot 2020-01-22 at 10 48 33 AM

I'm not sure if this is an ivy issue or not, but when I build for develop, everything works fine without manually logging the event.

Expected behavior

If the documentation is correct, I should see a page_view event after adding the module to my imports.

Actual behavior

No page_view events are being triggered with --prod.

smarth55 avatar Jan 22 '20 16:01 smarth55

Likely an IVY issue, will be cutting AngularFire v6 RC soon with ng 9 support. Keep an eye out for that.

jamesdaniels avatar Jan 24 '20 21:01 jamesdaniels

No issues here with 9 + Ivy.

jimmykane avatar Jan 27 '20 12:01 jimmykane

Should be addressed in 6.0.0-rc.0, though you might need the work around in #2303 until I drop the next RC. Please reopen if you're still having troubles.

jamesdaniels avatar Feb 02 '20 05:02 jamesdaniels