Added first round of analytics and event tracking BOD-190

This commit is contained in:
Patrick Fic
2020-07-17 08:27:28 -07:00
parent 3f0394760a
commit a54a85b96c
73 changed files with 433 additions and 208 deletions

View File

@@ -2,28 +2,31 @@ import React from "react";
import { useQuery, useMutation } from "@apollo/react-hooks";
import {
QUERY_ALL_ASSOCIATIONS,
UPDATE_ASSOCIATION
UPDATE_ASSOCIATION,
} from "../../graphql/associations.queries";
import AlertComponent from "../alert/alert.component";
import ProfileShopsComponent from "./profile-shops.component";
import { logImEXEvent } from "../../firebase/firebase.utils";
export default function ProfileShopsContainer() {
const { loading, error, data, refetch } = useQuery(QUERY_ALL_ASSOCIATIONS);
const [updateAssocation] = useMutation(UPDATE_ASSOCIATION);
const updateActiveShop = activeShopId => {
data.associations.forEach(record => {
const updateActiveShop = (activeShopId) => {
logImEXEvent("profile_change_active_shop");
data.associations.forEach((record) => {
updateAssocation({
variables: {
assocId: record.id,
assocActive: record.id === activeShopId ? true : false
}
assocActive: record.id === activeShopId ? true : false,
},
});
});
refetch();
};
if (error) return <AlertComponent type="error" message={error.message} />;
if (error) return <AlertComponent type='error' message={error.message} />;
return (
<ProfileShopsComponent
loading={loading}