Error with Implementing Analytics in Google Cloud Function


#1

It looks like the server is crashing due to a Jovo Object not being set. It looks like it works locally on my Webhook but not when bundled and deployed to a Cloud Function

Error: Jovo object is not set at GoogleAnalytics.sendError (/srv/node_modules/jovo-analytics-googleanalytics/dist/src/GoogleAnalytics.js:98:19) at Middleware.run (/srv/node_modules/jovo-core/dist/src/core/Middleware.js:76:30) at <anonymous> at process._tickDomainCallback (internal/process/next_tick.js:229:7)  
         receiveTimestamp:  "2020-06-17T16:02:37.786737065Z"   
         resource: {…}   
         severity:  "ERROR"   
         textPayload:  "Error: Jovo object is not set
        at GoogleAnalytics.sendError (/srv/node_modules/jovo-analytics-googleanalytics/dist/src/GoogleAnalytics.js:98:19)
        at Middleware.run (/srv/node_modules/jovo-core/dist/src/core/Middleware.js:76:30)
        at <anonymous>
        at process._tickDomainCallback (internal/process/next_tick.js:229:7)"
        }

#2

Investigating! cc @Kaan_Kilic


#3

Does it work correctly without the Google Analytics integration?


#4

Hey @Adnan_Aga,

That doesn’t seem to be a issue with Google Analytics. Somewhere in your app is a bug that is triggered while executing either the setup, request, or platform.init middleware. That error is picked up by the Google Analytics integration to log it. But, at that point the Jovo object isn’t initialized which causes the error you posted here. I guess we should handle that more gracefully.

To help you fix your bug, it would be nice to have the following info:

  1. which integrations to you use
  2. set your JOVO_LOG_LEVEL to VERBOSE (e.g. in your app.js file: process.env.JOVO_LOG_LEVEL = 'VERBOSE'; and run through a request which triggers the error. After that post your Logs here.

#5

Hey @Kaan_Kilic

  1. Firestore, GoogleSheetsCMS, GoogleAnalytics()
  2. It seems sporadic but Im trying to recreate it