Skip to content

Commit 6591c36

Browse files
committed
Add visit tracker to roadmap
1 parent 41de9c4 commit 6591c36

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/components/FrameRenderer/renderer.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {
33
renderResourceProgress,
44
ResourceType,
55
} from '../../lib/resource-progress';
6+
import { isLoggedIn } from '../../lib/jwt';
7+
import { httpPost } from '../../lib/http';
68

79
export class Renderer {
810
resourceId: string;
@@ -104,6 +106,19 @@ export class Renderer {
104106
});
105107
}
106108

109+
trackVisit() {
110+
if (!isLoggedIn()) {
111+
return;
112+
}
113+
114+
window.setTimeout(() => {
115+
httpPost(`${import.meta.env.PUBLIC_API_URL}/v1-visit`, {
116+
resourceId: this.resourceId,
117+
resourceType: this.resourceType,
118+
}).then(() => null);
119+
}, 0);
120+
}
121+
107122
onDOMLoaded() {
108123
if (!this.prepareConfig()) {
109124
return;
@@ -112,6 +127,8 @@ export class Renderer {
112127
const urlParams = new URLSearchParams(window.location.search);
113128
const roadmapType = urlParams.get('r');
114129

130+
this.trackVisit();
131+
115132
if (roadmapType) {
116133
this.switchRoadmap(`/jsons/roadmaps/${roadmapType}.json`);
117134
} else {

0 commit comments

Comments
 (0)