File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
src/components/FrameRenderer Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 3
3
renderResourceProgress ,
4
4
ResourceType ,
5
5
} from '../../lib/resource-progress' ;
6
+ import { isLoggedIn } from '../../lib/jwt' ;
7
+ import { httpPost } from '../../lib/http' ;
6
8
7
9
export class Renderer {
8
10
resourceId : string ;
@@ -104,6 +106,19 @@ export class Renderer {
104
106
} ) ;
105
107
}
106
108
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
+
107
122
onDOMLoaded ( ) {
108
123
if ( ! this . prepareConfig ( ) ) {
109
124
return ;
@@ -112,6 +127,8 @@ export class Renderer {
112
127
const urlParams = new URLSearchParams ( window . location . search ) ;
113
128
const roadmapType = urlParams . get ( 'r' ) ;
114
129
130
+ this . trackVisit ( ) ;
131
+
115
132
if ( roadmapType ) {
116
133
this . switchRoadmap ( `/jsons/roadmaps/${ roadmapType } .json` ) ;
117
134
} else {
You can’t perform that action at this time.
0 commit comments