Added first round of analytics and event tracking BOD-190
This commit is contained in:
@@ -2,23 +2,35 @@ import axios from "axios";
|
||||
import phone from "phone";
|
||||
import { all, call, put, select, takeLatest } from "redux-saga/effects";
|
||||
import { client } from "../../App/App.container";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import {
|
||||
CONVERSATION_ID_BY_PHONE,
|
||||
CREATE_CONVERSATION,
|
||||
} from "../../graphql/conversations.queries";
|
||||
import { INSERT_CONVERSATION_TAG } from "../../graphql/job-conversations.queries";
|
||||
import { selectBodyshop } from "../user/user.selectors";
|
||||
import {
|
||||
sendMessageFailure,
|
||||
sendMessageSuccess,
|
||||
setSelectedConversation,
|
||||
} from "./messaging.actions";
|
||||
import MessagingActionTypes from "./messaging.types";
|
||||
import { selectBodyshop } from "../user/user.selectors";
|
||||
|
||||
export function* onToggleChatVisible() {
|
||||
yield takeLatest(MessagingActionTypes.TOGGLE_CHAT_VISIBLE, toggleChatLogging);
|
||||
}
|
||||
export function* toggleChatLogging() {
|
||||
try {
|
||||
yield logImEXEvent("messaging_toggle_popup");
|
||||
} catch (error) {
|
||||
console.log("Error in sendMessage saga.", error);
|
||||
}
|
||||
}
|
||||
export function* onOpenChatByPhone() {
|
||||
yield takeLatest(MessagingActionTypes.OPEN_CHAT_BY_PHONE, openChatByPhone);
|
||||
}
|
||||
export function* openChatByPhone({ payload }) {
|
||||
logImEXEvent("messaging_open_by_phone");
|
||||
const { phone_num, jobid } = payload;
|
||||
const bodyshop = yield select(selectBodyshop);
|
||||
try {
|
||||
@@ -69,6 +81,8 @@ export function* onSendMessage() {
|
||||
}
|
||||
export function* sendMessage({ payload }) {
|
||||
try {
|
||||
yield logImEXEvent("messaging_send_message");
|
||||
|
||||
const response = yield call(axios.post, "/sms/send", payload);
|
||||
if (response.status === 200) {
|
||||
yield put(sendMessageSuccess(payload));
|
||||
@@ -82,5 +96,9 @@ export function* sendMessage({ payload }) {
|
||||
}
|
||||
|
||||
export function* messagingSagas() {
|
||||
yield all([call(onSendMessage), call(onOpenChatByPhone)]);
|
||||
yield all([
|
||||
call(onSendMessage),
|
||||
call(onOpenChatByPhone),
|
||||
call(onToggleChatVisible),
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user