Posts

Showing posts with the label Cloud Functions

Grab Google Analytics Data in remote account from Firebase Functions

Image
Although Google analytics Login is isolated from other Google services, you can easily access the analytics data from another service.  I am going to demonstrate how to retrieve google analytics data from firebase functions. You need to use googleAPI node package as an assistant. In coding, you have to use  JWT authentication in order to avoid async await issue in Google Cloud functions. Currently stable version of cloud functions is Nodejs 6. You have to download the service-account.json from Firebase or google cloud. In firebase, it is located at the following link. You have to generate a new private key. https://console.firebase.google.com/u/0/project/<project-id>/settings/serviceaccounts/adminsdk Make sure it contains the client email. That email need to be added in Analytics >>admin >> User Management Section as a user. https://analytics.google.com/analytics/web/ The code block in the batchGet fuctions will execute ...

Firebase Cloud Functions Triggers with Two varibles

Image
 Although firebase functions document not mentioned about how many varible values can be exhist in firebase onWrite() tirgger , I have used it upto 2 levles without any issue.  For an exaplen in the blow code , I have consider the change in list under the userId ,, The value will be wrriten under the varible of user.  exports.testFunctionName = functions.database.ref('/user-list/{user}/{pushId}').onWrite(( change,context) => {             const original =  change.after.val();             var pushId=context.params.pushId;                 var userId=context.params.user; ...