Is it possible? I'd like to explore using GTM's custom functions to send events to a separate GA4 app data stream. Before I get to that point, I first need a data stream added to a property. Creating an Android data stream in GA4's dashboard also provisions and creates a Google Cloud project. Using the GA4 data stream creation method returns API call to analyticsadmin.properties.dataStreams.create failed with error: Only web streams may be created on Admin API. To create app streams, use the Firebase API.
As mentioned, the end goal is to have a single Firebase project send events to second, unassociated data stream without adding any extra Firebase projects or data streams.
Related
I am currently creating a marketplace mobile application from scratch and I'm using React Native for the front-end part and Firebase for the backend (using Firebase and Firestore).
I am wondering wether :
I should create a RESTful API using cloud functions and express to create API endpoints (that would connect to firebase and firestore) that I'd call from my redux actions in my React Native app (using redux thunk).
or, I should call firebase and firestore directly from redux actions.
I see couple pros and cons for each method.
Restful API pros :
Safer as I can check and manipulate submitted data more easily
Custom API reply (I can manipulate the return data)
Restful API cons :
Probably slower as I would have to call an API endpoint that will then call firebase and/or firestore.
Won't be as easy to set listeners on firestore data
What do you think about it ?
Which option should I choose knowing that I predict that the app will get a few thousand users daily. I want it to be as fast and safe as possible and be able to set listeners for notifications purposes.
In my opinion you should mix them, if you have to manage users, products or etc. Firebase produces client and admin sdk that has different roles. If you haven't need manage any data of products or users or etc. you can simply use client sdk.
My advise is you can use admin sdk on API (server-side) and feel free to use client sdk on your clients.
Use as managements on API, listening data, realtime chat etc. via client sdk.
You can check admin and client sdk. Also npm packages for React Native here.
Mixing will be of help, you can try:
Listen for small amounts of data using the client SDK
Write and sort data using the cloud functions
In my experience, writing to a firebase database that uses ordered ids (in my case) leads to some huge problems in the long run. I lost a good chunk of data when my app accidentally wrote to a root index instead of a child index when the app was resumed from inactivity because the android system cleared the RAM.
Also, for notification, use Firebase Cloud Messaging.
I have a node script that formats a google sheets document using the google drive api and google-spreadsheet npm package. It retrieves data from one sheet in the document and then formats it into a nice dashboard.
However the data it retrieves from that particular sheet is dynamic and will change over time and it would be quite inconvenient to my other partners if I have to be at my pc to run the script for them whenever they populate more data into the sheet.
Considering cloud functions are triggered by a HTTP request, I assume I'd some how have to run an anonymous app that captures the state of a google sheet, then calls the HTTP. However I'm not sure what kind of app I'd have to create that could track a google sheets in real time?
Is this possible and if so what would be the correct method to go about such a task?
Cheers.
I'd like to find a way to run a Firebase Cloud function that is
triggered by the state change of a google sheets document.
You could use an AppScript simple trigger like onEdit() to call an HTTP Cloud Function by using the UrlFetchApp Class.
More details on HTTP Cloud Functions here.
Note that you could use the same approach to directly read/write from/to Firestore by calling the Firestore REST API.
When using firebase realtime database Node API (import "firebase-admin"), improper values (empty updates) are randomly delivered via query.on('value') as the initial update.
I rely proper data being delivered from the very first update. The reason why I'm using .on('value') is code reuse, in other places that require the data stream.
What is the contract on the data updates in firebase?
If I switch to .once('value') does it change the contract?
I have a Firestore database which I want to populate with data that is delivered by a live sports event API. This API offers to push the data, so I get new values every time some event happen in a selected game - so we don't have to pull new updates all the time.
However, the delivery method is a websocket which means, that we should open a web socket to a certain endpoint, and then we'll get the data updates.
How could we do this in Firebase? If it was just a simple webhook with an HTTP call, it would be easy to make a firebase functon that could receive the posted data.
But is it possible to do something similar with a web socket? I guess that keeping a Firebase Cloud Function running 24/7 with the web socket is not a good idea at all.
What you're describing is not supported by any Firebase products, and definitely not Cloud Functions. Cloud Functions doesn't support websockets at all, nor does it support any streaming. On top of that, the max lifetime of a function is 9 minutes.
If you absolutely need websockets, consider a different backend infrastructure instead, such as App Engine.
I'm trying to build a relatively simple application that has several different views, requires authentication, collects some user data, stores it in a database, and needs backend logic to manipulate that data and spit it back out to the user in a view.
The stack I've decided on is Vue for the frontend, with Express and Node for server side logic and Firebase for some of their services (namely auth, firestore, storage).
I haven't been able to find any examples of this stack (Vue, Express, Firebase) anywhere (I have however found Vue/Express or Vue/Firebase examples). My question is whether or not Express is obsolete here in that I can use Vue router to do my routing. Is the difference that one does the rendering server-side?
You could use Cloud Functions for Firebase as your backend and then limit your stack to Vue.js and Firebase.
From the doc:
Cloud Functions for Firebase lets you automatically run backend code
in response to events triggered by Firebase features and HTTPS
requests. Your code is stored in Google's cloud and runs in a managed
environment. There's no need to manage and scale your own servers.
For your specific need: "backend logic to manipulate that data and spit it back out to the user in a view." you have several possible approaches:
You manipulate the data with Cloud Functions (in the back end), write the results of this manipulation to the Real Time Database and setup some listeners in your Vue.js frontend (with the on() method) that will refresh your front end upon changes in the database
Use some HTTPS Cloud Functions that you call, from your Vue.js front-end, as REST API endpoints. You can use Axios for example. See the doc here.
One advantage of the first solution is that you can easily, by default, rely on the database security rules, while it would need some more extra work in the second case.