Merge pull request #3757 from NoelDeMartin/MOBILE-4367
MOBILE-4367 courses: Log dashboard and my courses
This commit is contained in:
		
						commit
						a0467daf64
					
				| @ -27,6 +27,7 @@ import { CoreBlockDelegate } from '@features/block/services/block-delegate'; | ||||
| import { CoreTime } from '@singletons/time'; | ||||
| import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; | ||||
| import { Translate } from '@singletons'; | ||||
| import { CoreUtils } from '@services/utils/utils'; | ||||
| 
 | ||||
| /** | ||||
|  * Page that displays the dashboard page. | ||||
| @ -61,11 +62,13 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy { | ||||
|         }, CoreSites.getCurrentSiteId()); | ||||
| 
 | ||||
|         this.logView = CoreTime.once(async () => { | ||||
|             await CoreUtils.ignoreErrors(CoreCourses.logView('dashboard')); | ||||
| 
 | ||||
|             CoreAnalytics.logEvent({ | ||||
|                 type: CoreAnalyticsEventType.VIEW_ITEM_LIST, | ||||
|                 type: CoreAnalyticsEventType.VIEW_ITEM, | ||||
|                 ws: 'core_my_view_page', | ||||
|                 name: Translate.instant('core.courses.mymoodle'), | ||||
|                 data: { category: 'course' }, | ||||
|                 data: { category: 'course', page: 'dashboard' }, | ||||
|                 url: '/my/', | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
| @ -79,11 +79,13 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective { | ||||
|         }); | ||||
| 
 | ||||
|         this.logView = CoreTime.once(async () => { | ||||
|             await CoreUtils.ignoreErrors(CoreCourses.logView('my')); | ||||
| 
 | ||||
|             CoreAnalytics.logEvent({ | ||||
|                 type: CoreAnalyticsEventType.VIEW_ITEM_LIST, | ||||
|                 ws: 'core_enrol_get_users_courses', | ||||
|                 type: CoreAnalyticsEventType.VIEW_ITEM, | ||||
|                 ws: 'core_my_view_page', | ||||
|                 name: Translate.instant('core.courses.mycourses'), | ||||
|                 data: { category: 'course' }, | ||||
|                 data: { category: 'course', page: 'my' }, | ||||
|                 url: '/my/courses.php', | ||||
|             }); | ||||
|         }); | ||||
|  | ||||
| @ -1280,6 +1280,18 @@ export class CoreCoursesProvider { | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Report a dashboard or my courses page view event. | ||||
|      * | ||||
|      * @param page Page to view. | ||||
|      */ | ||||
|     async logView(page: 'my' | 'dashboard'): Promise<void> { | ||||
|         const site = CoreSites.getRequiredCurrentSite(); | ||||
|         const params: CoreMyViewPageWSParams = { page }; | ||||
| 
 | ||||
|         await site.write('core_my_view_page', params); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Search courses. | ||||
|      * | ||||
| @ -1928,3 +1940,10 @@ export type EnrolGuestValidatePasswordWSResponse = { | ||||
|     hint?: string; // Password hint (if enabled)
 | ||||
|     warnings?: CoreWSExternalWarning[]; | ||||
| }; | ||||
| 
 | ||||
| /** | ||||
|  * Params of core_my_view_page WS. | ||||
|  */ | ||||
| type CoreMyViewPageWSParams = { | ||||
|     page: 'my' | 'dashboard'; // My page to trigger a view event.
 | ||||
| }; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user