I want add firebase SKD to web app for tracking events of my web app. I added firebase SDK code to the body of index.html file :
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.3.0/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/8.3.0/firebase-analytics.js"></script>
<script>
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
var firebaseConfig = {
apiKey: "******",
authDomain: "******",
projectId: "*****",
storageBucket: "*****",
messagingSenderId: "****",
appId: "*****",
measurementId: "****"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
then I tried to track one event of one of page of our web app using:
I run:
import firebase from 'firebase/app' (works)
I run:
import "firebase/analytics"; (works)
I run : const analytics = firebase.analytics(); (got the error)
or I run : firebase.analytics().logEvent('notification_received'); (got the same error)
It shows the error :Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app). ▼ 19 stack frames were expanded.
Aucun commentaire:
Enregistrer un commentaire