[Firebase Web Analytics] Integrate Fibase with outsystems
Forge component by Bogdan Boglea
Application Type
Reactive
Service Studio Version
11.10.4 (Build 36716)
Platform Version
10.0.1108.0

Hi guys please can give me help with this isue

i must integrate firebase with outsystem, using javascript but when i put the following code this is not  available to import FIREBASE source to use it, how can import in outsystem a source???


<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.2.1/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.2.1/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: "AIzaSyC5_u_C2G2nZjmy6dz3rHMmIjrplEfJCCY",
authDomain: "loguser-1e5e8.firebaseapp.com",
databaseURL: "https://loguser-1e5e8-default-rtdb.firebaseio.com",
projectId: "loguser-1e5e8",
storageBucket: "loguser-1e5e8.appspot.com",
messagingSenderId: "552481183860",
appId: "1:552481183860:web:c941d2f887316c7388d921",
measurementId: "G-GSXRYVCY4L"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>

i try to import using another way but the error is the same

var head1 = document.getElementsByTagName('body')[0];


var script_src1= 'https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js';

var new_script1 = document.createElement('script');


var script_src2= 'https://www.gstatic.com/firebasejs/8.2.1/firebase-analytics.js';

var new_script2 = document.createElement('script');



new_script1.type = 'text/javascript';

new_script1.src= script_src1;


new_script2.type = 'text/javascript';

new_script2.src= script_src2;



head1.appendChild(new_script1);

head1.appendChild(new_script2); 


Hi Andy,


As written in the component description, you don't need to include the JavaScript code by yourself, since the component is already designed to be a wrapper around it.

You just need to specify the values of the firebaseConfig variables in the webblock FirebaseAnalytics input parameters. This webblock should be put at the bottom of the screen you want the analytics to be enabled in. After that, you just need to call the LogEvent server action to send events to Firebase.

Hope this answers your question.


Regards,

Bogdan

Hello Good Morning

i have a apk that use pwa it is not compatible with cordova i can not use the firebase for mobile, i find your solution but this solution work with  web block i can not use web block in my pwa apk, this is way because i must use javascript for to adapt your solution, this is the only way. is there  a way to make a javascript to call the src and use firebase components???

i am try this way


var head1 = document.getElementsByTagName('body')[0];


var script_src1= 'src="https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js";';

var new_script1 = document.createElement('script');


var script_src2= 'src="https://www.gstatic.com/firebasejs/8.2.1/firebase-analytics.js";';

var new_script2 = document.createElement('script');



new_script1.type = 'text/javascript';

new_script1.src= script_src1;


new_script2.type = 'text/javascript';

new_script2.src= script_src2;



head1.appendChild(new_script1);

head1.appendChild(new_script2); 



var script_src3= 'firebase.initializeApp("");';

var new_script3 = document.createElement('script');


    


head1.appendChild(new_script3);  


but i have the following error :



Andy,


My component is designed only for Web applications (see the name Firebase Web Analytics), for mobile I suggest to take a look on other components: https://www.outsystems.com/forge/component-overview/4991/firebase-mobile


Regards,

Bogdan

thanks but the pwa is not compatible with firebase mobile, that is the problem , i explain this before

Ok I understand, but as I don't have much experience on that part I'm sorry to say I can't help you further. Maybe since PWA is available in both browsers/mobile, you should look into Ionic or other framework out there.

thanks for your time bogdan!!


Strange advice Ionic, since we are working with Outsystems.....

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.