diff --git a/src/core/features/courses/pages/dashboard/dashboard.ts b/src/core/features/courses/pages/dashboard/dashboard.ts index cc0ad8382..a459879ee 100644 --- a/src/core/features/courses/pages/dashboard/dashboard.ts +++ b/src/core/features/courses/pages/dashboard/dashboard.ts @@ -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/', }); }); diff --git a/src/core/features/courses/pages/my/my.ts b/src/core/features/courses/pages/my/my.ts index 3f9ab7907..23612dac6 100644 --- a/src/core/features/courses/pages/my/my.ts +++ b/src/core/features/courses/pages/my/my.ts @@ -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', }); }); diff --git a/src/core/features/courses/services/courses.ts b/src/core/features/courses/services/courses.ts index c45c69da6..f67e8b274 100644 --- a/src/core/features/courses/services/courses.ts +++ b/src/core/features/courses/services/courses.ts @@ -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 { + 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. +};