Added google analytics tracking.

This commit is contained in:
Patrick Fic
2021-03-09 17:03:19 -08:00
parent 3e1dd78c85
commit b5176b4d61
12 changed files with 163 additions and 10 deletions

View File

@@ -1,5 +1,7 @@
import * as Analytics from "expo-firebase-analytics";
import * as firebase from "firebase/app";
import "firebase/auth";
import { store } from "../redux/store";
//const config = JSON.parse(process.env.REACT_APP_FIREBASE_CONFIG);
// const config = {
@@ -52,3 +54,25 @@ export const updateCurrentUser = (userDetails) => {
}, reject);
});
};
export const logImEXEvent = (eventName, additionalParams, stateProp = null) => {
const state = stateProp || store.getState();
const eventParams = {
shop:
(state.user && state.user.bodyshop && state.user.bodyshop.shopname) ||
null,
user:
(state.user && state.user.currentUser && state.user.currentUser.email) ||
null,
...additionalParams,
};
console.log(
"%c[Analytics]",
"background-color: green ;font-weight:bold;",
eventName,
eventParams
);
Analytics.logEvent(eventName, eventParams);
};
//export const ExpoAnalytics = Analytics;