1+ import '../scss/index.scss'
2+
13import { initializeApp } from "firebase/app" ;
2- import { getAnalytics } from "firebase/analytics" ;
4+ import { getAnalytics , logEvent } from "firebase/analytics" ;
35
6+ // See: https://firebase.google.com/docs/web/learn-more#config-object
47const firebaseConfig = {
5- apiKey : "AIzaSyDJMVkse8Mla3rqrVak1qkfXYxlh2AmUd8" ,
6- authDomain : "bvarga-fe600.firebaseapp.com" ,
7- projectId : "bvarga-fe600" ,
8- storageBucket : "bvarga-fe600.appspot.com" ,
9- messagingSenderId : "443364341536" ,
10- appId : "1:443364341536:web:d7b91d4ecfa7618f594945" ,
11- measurementId : "G-PB70YSPDG1"
8+ apiKey : "AIzaSyDJMVkse8Mla3rqrVak1qkfXYxlh2AmUd8" ,
9+ authDomain : "bvarga-fe600.firebaseapp.com" ,
10+ projectId : "bvarga-fe600" ,
11+ storageBucket : "bvarga-fe600.appspot.com" ,
12+ messagingSenderId : "443364341536" ,
13+ appId : "1:443364341536:web:d7b91d4ecfa7618f594945" ,
14+ measurementId : "G-PB70YSPDG1"
1215} ;
13-
16+
17+ // Initialize Firebase
1418const app = initializeApp ( firebaseConfig ) ;
15- const analytics = getAnalytics ( app ) ;
19+
20+ // Initialize Analytics and get a reference to the service
21+ const analytics = getAnalytics ( app ) ;
22+
23+ function trackButtonClick ( obj ) {
24+ const event = obj . innerText || obj . textContent ;
25+ logEvent ( analytics , "click" , { name : event } ) ;
26+ }
27+
28+ function trackSocialButtonClick ( obj ) {
29+ const event = obj . getAttribute ( 'aria-label' ) ;
30+ logEvent ( analytics , "click-social" , { name : event } ) ;
31+ }
32+
33+ function copyLink ( url ) {
34+ window . navigator . clipboard . writeText ( url ) ;
35+ confirm ( "Page URL copied to the clipboard." )
36+ }
37+
38+ // Attach Event Handlers
39+ document . addEventListener ( 'DOMContentLoaded' , ( ) => {
40+ document . querySelectorAll ( '.clazz-button-container a' ) . forEach ( a => {
41+ a . addEventListener ( 'click' , ( e ) => {
42+ trackButtonClick ( a ) ;
43+ } ) ;
44+ } ) ;
45+
46+ document . querySelectorAll ( '.clazz-social-links a' ) . forEach ( a => {
47+ a . addEventListener ( 'click' , ( e ) => {
48+ trackSocialButtonClick ( a ) ;
49+ } ) ;
50+ } ) ;
51+
52+ document . querySelectorAll ( '.clazz-copy-link' ) . forEach ( a => {
53+ a . addEventListener ( 'click' , ( e ) => {
54+ e . preventDefault ( ) ;
55+ copyLink ( window . location . href ) ;
56+ } ) ;
57+ } ) ;
58+ } ) ;
0 commit comments