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

@@ -9,19 +9,20 @@ import { toggleModalVisible } from "../../redux/modals/modals.actions";
import { selectNoteUpsert } from "../../redux/modals/modals.selectors";
import { selectCurrentUser } from "../../redux/user/user.selectors";
import NoteUpsertModalComponent from "./note-upsert-modal.component";
import { logImEXEvent } from "../../firebase/firebase.utils";
const mapStateToProps = createStructuredSelector({
currentUser: selectCurrentUser,
noteUpsertModal: selectNoteUpsert
noteUpsertModal: selectNoteUpsert,
});
const mapDispatchToProps = dispatch => ({
toggleModalVisible: () => dispatch(toggleModalVisible("noteUpsert"))
const mapDispatchToProps = (dispatch) => ({
toggleModalVisible: () => dispatch(toggleModalVisible("noteUpsert")),
});
export function NoteUpsertModalContainer({
currentUser,
noteUpsertModal,
toggleModalVisible
toggleModalVisible,
}) {
const { t } = useTranslation();
const [insertNote] = useMutation(INSERT_NEW_NOTE);
@@ -40,32 +41,36 @@ export function NoteUpsertModalContainer({
}
}, [existingNote, form]);
const handleFinish = values => {
const handleFinish = (values) => {
if (existingNote) {
logImEXEvent("job_note_update");
updateNote({
variables: {
noteId: existingNote.id,
note: values
}
}).then(r => {
note: values,
},
}).then((r) => {
notification["success"]({
message: t("notes.successes.updated")
message: t("notes.successes.updated"),
});
});
if (refetch) refetch();
toggleModalVisible();
} else {
logImEXEvent("job_note_insert");
insertNote({
variables: {
noteInput: [
{ ...values, jobid: jobId, created_by: currentUser.email }
]
}
}).then(r => {
{ ...values, jobid: jobId, created_by: currentUser.email },
],
},
}).then((r) => {
if (refetch) refetch();
toggleModalVisible();
notification["success"]({
message: t("notes.successes.create")
message: t("notes.successes.create"),
});
});
}
@@ -82,8 +87,7 @@ export function NoteUpsertModalContainer({
onCancel={() => {
toggleModalVisible();
}}
destroyOnClose
>
destroyOnClose>
<Form form={form} onFinish={handleFinish} initialValues={existingNote}>
<NoteUpsertModalComponent />
</Form>