MOBILE-4367 courses: Log dashboard and my courses

main
Noel De Martin 2023-07-27 10:17:05 +09:00
parent f670c6a9b9
commit 68b7a3ede9
3 changed files with 29 additions and 5 deletions

View File

@ -27,6 +27,7 @@ import { CoreBlockDelegate } from '@features/block/services/block-delegate';
import { CoreTime } from '@singletons/time'; import { CoreTime } from '@singletons/time';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { Translate } from '@singletons'; import { Translate } from '@singletons';
import { CoreUtils } from '@services/utils/utils';
/** /**
* Page that displays the dashboard page. * Page that displays the dashboard page.
@ -61,11 +62,13 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy {
}, CoreSites.getCurrentSiteId()); }, CoreSites.getCurrentSiteId());
this.logView = CoreTime.once(async () => { this.logView = CoreTime.once(async () => {
await CoreUtils.ignoreErrors(CoreCourses.logView('dashboard'));
CoreAnalytics.logEvent({ CoreAnalytics.logEvent({
type: CoreAnalyticsEventType.VIEW_ITEM_LIST, type: CoreAnalyticsEventType.VIEW_ITEM,
ws: 'core_my_view_page', ws: 'core_my_view_page',
name: Translate.instant('core.courses.mymoodle'), name: Translate.instant('core.courses.mymoodle'),
data: { category: 'course' }, data: { category: 'course', page: 'dashboard' },
url: '/my/', url: '/my/',
}); });
}); });

View File

@ -79,11 +79,13 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective {
}); });
this.logView = CoreTime.once(async () => { this.logView = CoreTime.once(async () => {
await CoreUtils.ignoreErrors(CoreCourses.logView('my'));
CoreAnalytics.logEvent({ CoreAnalytics.logEvent({
type: CoreAnalyticsEventType.VIEW_ITEM_LIST, type: CoreAnalyticsEventType.VIEW_ITEM,
ws: 'core_enrol_get_users_courses', ws: 'core_my_view_page',
name: Translate.instant('core.courses.mycourses'), name: Translate.instant('core.courses.mycourses'),
data: { category: 'course' }, data: { category: 'course', page: 'my' },
url: '/my/courses.php', url: '/my/courses.php',
}); });
}); });

View File

@ -1280,6 +1280,18 @@ export class CoreCoursesProvider {
return true; 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. * Search courses.
* *
@ -1928,3 +1940,10 @@ export type EnrolGuestValidatePasswordWSResponse = {
hint?: string; // Password hint (if enabled) hint?: string; // Password hint (if enabled)
warnings?: CoreWSExternalWarning[]; warnings?: CoreWSExternalWarning[];
}; };
/**
* Params of core_my_view_page WS.
*/
type CoreMyViewPageWSParams = {
page: 'my' | 'dashboard'; // My page to trigger a view event.
};