feat: Implement the tracker
This commit is contained in:
@@ -34,6 +34,8 @@ import {
|
||||
REVIEW_HELP_MOD
|
||||
} from "../config";
|
||||
|
||||
import { BACKEND_URL } from "../config";
|
||||
|
||||
import { Queue } from "../utils/queue";
|
||||
|
||||
interface IProps {
|
||||
@@ -103,6 +105,18 @@ const ReviewPageWithRouter = withRouter(
|
||||
[ReviewType.QUEUE]: () => vocabByQueueW(),
|
||||
}[reviewType];
|
||||
|
||||
// Track the start of a session
|
||||
fetch(`${BACKEND_URL}/api/tracker`, {
|
||||
headers: new Headers({
|
||||
"Content-Type": "application/json",
|
||||
}),
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
session: window.sessionStorage.getItem("tracker_session"),
|
||||
event: "START_LEARNING",
|
||||
}),
|
||||
});
|
||||
|
||||
getVocab().then((res: IVocab[]) => {
|
||||
// Check if we received any vocabulary
|
||||
if (res.length === 0) {
|
||||
@@ -145,6 +159,18 @@ const ReviewPageWithRouter = withRouter(
|
||||
cancelReview = () => {
|
||||
this.closeDialog();
|
||||
|
||||
// Track the cancellation of a learning session
|
||||
fetch(`${BACKEND_URL}/api/tracker`, {
|
||||
headers: new Headers({
|
||||
"Content-Type": "application/json",
|
||||
}),
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
session: window.sessionStorage.getItem("tracker_session"),
|
||||
event: "CANCEL_LEARNING",
|
||||
}),
|
||||
});
|
||||
|
||||
// Show the drawer button again
|
||||
this.props.drawerButtonState(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user