If you are using Firebase as your backend, you can integrate Metric by using Firebase Cloud Functions. Firebase Cloud Functions allow you to run server-side code in response to events and HTTPS requests. Metric can send data to your Firebase Cloud Function through a webhook, which allows you to store the data in your Firebase database.
To use the example function, follow these steps:
- Clone the repository from GitHub.
- Paste the code into the
index.tsfile in the src/ folder of your Firebase Cloud Functions project.
- Update the value of
FIREBASE_COLLECTION_NAMEto the name of the collection where you want to store the data.
- Make sure cloud functions are enabled in the Firebase console.
- Deploy the function using
npm run deployor
firebase deploy --only functions.
- Note the URL mentioned under the function name in the Firebase console.
- Add the URL to the webhook section of the Metric dashboard.
That's it! Your Firebase Cloud Function is now ready to receive data from Metric.
Using Firebase Cloud Functions is an easy and scalable way to integrate Metric with your Firebase backend. The example function in our GitHub repository provides a starting point for your integration, and you can customize it to meet your specific needs.