mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-25 10:14:20 +02:00
Add visit tracker to roadmap
This commit is contained in:
@@ -3,6 +3,8 @@ import {
|
|||||||
renderResourceProgress,
|
renderResourceProgress,
|
||||||
ResourceType,
|
ResourceType,
|
||||||
} from '../../lib/resource-progress';
|
} from '../../lib/resource-progress';
|
||||||
|
import { isLoggedIn } from '../../lib/jwt';
|
||||||
|
import { httpPost } from '../../lib/http';
|
||||||
|
|
||||||
export class Renderer {
|
export class Renderer {
|
||||||
resourceId: string;
|
resourceId: string;
|
||||||
@@ -104,6 +106,19 @@ export class Renderer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trackVisit() {
|
||||||
|
if (!isLoggedIn()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.setTimeout(() => {
|
||||||
|
httpPost(`${import.meta.env.PUBLIC_API_URL}/v1-visit`, {
|
||||||
|
resourceId: this.resourceId,
|
||||||
|
resourceType: this.resourceType,
|
||||||
|
}).then(() => null);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
onDOMLoaded() {
|
onDOMLoaded() {
|
||||||
if (!this.prepareConfig()) {
|
if (!this.prepareConfig()) {
|
||||||
return;
|
return;
|
||||||
@@ -112,6 +127,8 @@ export class Renderer {
|
|||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const roadmapType = urlParams.get('r');
|
const roadmapType = urlParams.get('r');
|
||||||
|
|
||||||
|
this.trackVisit();
|
||||||
|
|
||||||
if (roadmapType) {
|
if (roadmapType) {
|
||||||
this.switchRoadmap(`/jsons/roadmaps/${roadmapType}.json`);
|
this.switchRoadmap(`/jsons/roadmaps/${roadmapType}.json`);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user