usnistgov / oar-pdr

The NIST Open Access to Research (OAR) Public Data Repository (PDR) system software
11 stars 10 forks source link

Feature/odd 790 ga code config #110

Closed chuanlin2018 closed 4 years ago

chuanlin2018 commented 4 years ago

http://mml.nist.gov:8080/browse/ODD-790

This change removes the Google Analytics code from index.html and dynamically adds it to app.component. Because of this change, the Google Analytics function in footer links became unnecessary and was removed.

RayPlante commented 4 years ago

@chuanlin2018 The server-side rendering is producing the following error:

Error appending google analytics
ReferenceError: document is not defined
    at GoogleAnalyticsService../src/app/shared/ga-service/google-analytics.servi
ce.ts.GoogleAnalyticsService.appendGaTrackingCode (/var/www/html/dist/server.js:
148238:13)
    at AppComponent../src/app/app.component.ts.AppComponent.ngAfterViewInit (/va
r/www/html/dist/server.js:136835:24)
    at callProviderLifecycles (/var/www/html/dist/server.js:23788:18)
    at callElementProvidersLifecycles (/var/www/html/dist/server.js:23762:13)
    at callLifecycleHooksChildrenFirst (/var/www/html/dist/server.js:23752:29)
    at Object.checkAndUpdateView (/var/www/html/dist/server.js:24688:5)
    at ViewRef_.detectChanges (/var/www/html/dist/server.js:23060:22)
    at /var/www/html/dist/server.js:19694:63
    at Array.forEach (<anonymous>)
    at ApplicationRef.tick (/var/www/html/dist/server.js:19694:25)
this.gaCode UA-115121490-8

To replicate this, run under oar-docker and look at the log, data/logs/pdr/lps.log.

It looks like the code is trying to access document which does not exist on the server. Your GA related code should use an inBrowser guard around it.

chuanlin2018 commented 4 years ago

Looks like I need to disable the function for server side.

Did we have the same problem for SDP?