Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile 4368 #3726

Merged
merged 7 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions scripts/langindex.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@
"addon.calendar.currentmonth": "local_moodlemobileapp",
"addon.calendar.daynext": "calendar",
"addon.calendar.dayprev": "calendar",
"addon.calendar.dayviewtitle": "calendar",
"addon.calendar.defaultnotificationtime": "local_moodlemobileapp",
"addon.calendar.deleteallevents": "calendar",
"addon.calendar.deleteevent": "calendar",
"addon.calendar.deleteoneevent": "calendar",
"addon.calendar.detailedmonthviewtitle": "calendar",
"addon.calendar.durationminutes": "calendar",
"addon.calendar.durationnone": "calendar",
"addon.calendar.durationuntil": "calendar",
Expand Down Expand Up @@ -369,6 +371,7 @@
"addon.mod_assign.gradelocked": "assign",
"addon.mod_assign.gradenotsynced": "local_moodlemobileapp",
"addon.mod_assign.gradeoutof": "assign",
"addon.mod_assign.grading": "assign",
"addon.mod_assign.gradingstatus": "assign",
"addon.mod_assign.groupsubmissionsettings": "assign",
"addon.mod_assign.hiddenuser": "assign",
Expand Down Expand Up @@ -425,6 +428,7 @@
"addon.mod_assign.submittedlate": "assign",
"addon.mod_assign.submittedovertime": "assign",
"addon.mod_assign.submittedundertime": "assign",
"addon.mod_assign.subpagetitle": "assign",
"addon.mod_assign.syncblockedusercomponent": "local_moodlemobileapp",
"addon.mod_assign.timelimit": "assign",
"addon.mod_assign.timemodified": "assign",
Expand Down Expand Up @@ -2235,6 +2239,7 @@
"core.play": "local_moodlemobileapp",
"core.previous": "moodle",
"core.proceed": "moodle",
"core.publicprofile": "moodle",
"core.pulltorefresh": "local_moodlemobileapp",
"core.qrscanner": "local_moodlemobileapp",
"core.question.answer": "question",
Expand Down Expand Up @@ -2347,9 +2352,9 @@
"core.settings.disabled": "lesson",
"core.settings.disallowed": "message",
"core.settings.displayformat": "local_moodlemobileapp",
"core.settings.enableanalytics": "local_moodlemobileapp",
"core.settings.enableanalyticsdescription": "local_moodlemobileapp",
"core.settings.enabledownloadsection": "local_moodlemobileapp",
"core.settings.enablefirebaseanalytics": "local_moodlemobileapp",
"core.settings.enablefirebaseanalyticsdescription": "local_moodlemobileapp",
"core.settings.enablerichtexteditor": "local_moodlemobileapp",
"core.settings.enablerichtexteditordescription": "local_moodlemobileapp",
"core.settings.encryptedpushsupported": "local_moodlemobileapp",
Expand Down
15 changes: 15 additions & 0 deletions src/addons/badges/pages/issued-badge/issued-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import { ActivatedRoute } from '@angular/router';
import { CoreSwipeNavigationItemsManager } from '@classes/items-management/swipe-navigation-items-manager';
import { AddonBadgesUserBadgesSource } from '@addons/badges/classes/user-badges-source';
import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreTime } from '@singletons/time';

/**
* Page that displays the list of calendar events.
Expand All @@ -38,6 +40,7 @@ export class AddonBadgesIssuedBadgePage implements OnInit, OnDestroy {

protected badgeHash = '';
protected userId!: number;
protected logView: (badge: AddonBadgesUserBadge) => void;

courseId = 0;
user?: CoreUserProfile;
Expand All @@ -58,6 +61,16 @@ export class AddonBadgesIssuedBadgePage implements OnInit, OnDestroy {
);

this.badges = new CoreSwipeNavigationItemsManager(source);

this.logView = CoreTime.once((badge) => {
CoreAnalytics.logEvent({
type: CoreAnalyticsEventType.VIEW_ITEM,
ws: 'core_badges_view_user_badges',
name: badge.name,
data: { id: badge.uniquehash, category: 'badges' },
url: `/badges/badge.php?hash=${badge.uniquehash}`,
});
});
}

/**
Expand Down Expand Up @@ -105,6 +118,8 @@ export class AddonBadgesIssuedBadgePage implements OnInit, OnDestroy {
this.course = undefined;
}
}

this.logView(badge);
} catch (message) {
CoreDomUtils.showErrorModalDefault(message, 'Error getting badge data.');
}
Expand Down
17 changes: 17 additions & 0 deletions src/addons/badges/pages/user-badges/user-badges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import { CoreNavigator } from '@services/navigator';
import { CoreListItemsManager } from '@classes/items-management/list-items-manager';
import { AddonBadgesUserBadgesSource } from '@addons/badges/classes/user-badges-source';
import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreTime } from '@singletons/time';
import { Translate } from '@singletons';

/**
* Page that displays the list of calendar events.
Expand All @@ -39,6 +42,8 @@ export class AddonBadgesUserBadgesPage implements AfterViewInit, OnDestroy {

@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;

protected logView: () => void;

constructor() {
let courseId = CoreNavigator.getRouteNumberParam('courseId') ?? 0; // Use 0 for site badges.
const userId = CoreNavigator.getRouteNumberParam('userId') ?? CoreSites.getCurrentSiteUserId();
Expand All @@ -52,6 +57,16 @@ export class AddonBadgesUserBadgesPage implements AfterViewInit, OnDestroy {
CoreRoutedItemsManagerSourcesTracker.getOrCreateSource(AddonBadgesUserBadgesSource, [courseId, userId]),
AddonBadgesUserBadgesPage,
);

this.logView = CoreTime.once(() => {
CoreAnalytics.logEvent({
type: CoreAnalyticsEventType.VIEW_ITEM_LIST,
ws: 'core_badges_view_user_badges',
name: Translate.instant('addon.badges.badges'),
data: { courseId: this.badges.getSource().COURSE_ID, category: 'badges' },
url: '/badges/mybadges.php',
});
});
}

/**
Expand Down Expand Up @@ -95,6 +110,8 @@ export class AddonBadgesUserBadgesPage implements AfterViewInit, OnDestroy {

try {
await this.badges.reload();

this.logView();
} catch (message) {
CoreDomUtils.showErrorModalDefault(message, 'Error loading badges');

Expand Down
29 changes: 24 additions & 5 deletions src/addons/blog/pages/entries/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ import { CoreMainMenuDeepLinkManager } from '@features/mainmenu/classes/deep-lin
import { CoreTag } from '@features/tag/services/tag';
import { CoreUser, CoreUserProfile } from '@features/user/services/user';
import { IonRefresher } from '@ionic/angular';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreNavigator } from '@services/navigator';
import { CoreSites } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils';
import { CoreTime } from '@singletons/time';

/**
* Page that displays the list of blog entries.
Expand All @@ -43,7 +46,7 @@ export class AddonBlogEntriesPage implements OnInit {
protected canLoadMoreEntries = false;
protected canLoadMoreUserEntries = true;
protected siteHomeId: number;
protected fetchSuccess = false;
protected logView: () => void;

loaded = false;
canLoadMore = false;
Expand All @@ -61,6 +64,25 @@ export class AddonBlogEntriesPage implements OnInit {
constructor() {
this.currentUserId = CoreSites.getCurrentSiteUserId();
this.siteHomeId = CoreSites.getCurrentSiteHomeId();

this.logView = CoreTime.once(async () => {
await CoreUtils.ignoreErrors(AddonBlog.logView(this.filter));

CoreAnalytics.logEvent({
type: CoreAnalyticsEventType.VIEW_ITEM_LIST,
ws: 'core_blog_view_entries',
name: this.title,
data: {
...this.filter,
category: 'blog',
},
url: CoreUrlUtils.addParamsToUrl('/blog/index.php', {
...this.filter,
modid: this.filter.cmid,
cmid: undefined,
}),
});
});
}

/**
Expand Down Expand Up @@ -200,10 +222,7 @@ export class AddonBlogEntriesPage implements OnInit {

await Promise.all(promises);

if (!this.fetchSuccess) {
this.fetchSuccess = true;
CoreUtils.ignoreErrors(AddonBlog.logView(this.filter));
}
this.logView();
} catch (error) {
CoreDomUtils.showErrorModalDefault(error, 'addon.blog.errorloadentries', true);
this.loadMoreError = true; // Set to prevent infinite calls with infinite-loading.
Expand Down
3 changes: 0 additions & 3 deletions src/addons/blog/services/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import { Injectable } from '@angular/core';
import { CoreSite, CoreSiteWSPreSets } from '@classes/site';
import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications';
import { CoreTagItem } from '@features/tag/services/tag';
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
Expand Down Expand Up @@ -104,8 +103,6 @@ export class AddonBlogProvider {
* @returns Promise to be resolved when done.
*/
async logView(filter: AddonBlogFilter = {}, siteId?: string): Promise<CoreStatusWithWarningsWSResponse> {
CorePushNotifications.logViewListEvent('blog', 'core_blog_view_entries', filter, siteId);

const site = await CoreSites.getSite(siteId);

const data: AddonBlogViewEntriesWSParams = {
Expand Down
32 changes: 31 additions & 1 deletion src/addons/calendar/components/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ import {
} from '@classes/items-management/swipe-slides-dynamic-items-manager-source';
import { CoreSwipeSlidesDynamicItemsManager } from '@classes/items-management/swipe-slides-dynamic-items-manager';
import moment from 'moment-timezone';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreTime } from '@singletons/time';
import { Translate } from '@singletons';

/**
* Component that displays a calendar.
Expand Down Expand Up @@ -81,6 +85,7 @@ export class AddonCalendarCalendarComponent implements OnInit, DoCheck, OnDestro
// Observers and listeners.
protected undeleteEventObserver: CoreEventObserver;
protected managerUnsubscribe?: () => void;
protected logView: () => void;

constructor(differs: KeyValueDiffers) {
this.currentSiteId = CoreSites.getCurrentSiteId();
Expand All @@ -107,6 +112,29 @@ export class AddonCalendarCalendarComponent implements OnInit, DoCheck, OnDestro

this.hiddenDiffer = this.hidden;
this.filterDiffer = differs.find(this.filter ?? {}).create();

this.logView = CoreTime.once(() => {
const month = this.manager?.getSelectedItem();
if (!month) {
return;
}

const params = {
course: this.filter?.courseId,
time: month.moment.unix(),
};

CoreAnalytics.logEvent({
type: CoreAnalyticsEventType.VIEW_ITEM_LIST,
ws: 'core_calendar_get_calendar_monthly_view',
name: Translate.instant('addon.calendar.detailedmonthviewtitle', { $a: this.periodName }),
data: {
...params,
category: 'calendar',
},
url: CoreUrlUtils.addParamsToUrl('/calendar/view.php?view=month', params),
});
});
}

@HostBinding('attr.hidden') get hiddenAttribute(): string | null {
Expand All @@ -124,7 +152,7 @@ export class AddonCalendarCalendarComponent implements OnInit, DoCheck, OnDestro
const source = new AddonCalendarMonthSlidesItemsManagerSource(this, moment({
year: this.initialYear,
month: this.initialMonth ? this.initialMonth - 1 : undefined,
}));
}).startOf('month'));
this.manager = new CoreSwipeSlidesDynamicItemsManager(source);
this.managerUnsubscribe = this.manager.addListener({
onSelectedItemUpdated: (item) => {
Expand Down Expand Up @@ -176,6 +204,8 @@ export class AddonCalendarCalendarComponent implements OnInit, DoCheck, OnDestro
await this.manager?.getSource().fetchData();

await this.manager?.getSource().load(this.manager?.getSelectedItem());

this.logView();
} catch (error) {
CoreDomUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevents', true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import { AddonCalendarHelper, AddonCalendarFilter } from '../../services/calenda
import { AddonCalendarOffline } from '../../services/calendar-offline';
import { CoreCategoryData, CoreCourses } from '@features/courses/services/courses';
import { CoreConstants } from '@/core/constants';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { CoreUrlUtils } from '@services/utils/url';
import { CoreTime } from '@singletons/time';
import { Translate } from '@singletons';

/**
* Component that displays upcoming events.
Expand Down Expand Up @@ -54,6 +58,7 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, DoCheck, On
protected lookAhead = 0;
protected timeFormat?: string;
protected differ: KeyValueDiffer<unknown, unknown>; // To detect changes in the data input.
protected logView: () => void;

// Observers.
protected undeleteEventObserver: CoreEventObserver;
Expand Down Expand Up @@ -84,6 +89,23 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, DoCheck, On
);

this.differ = differs.find([]).create();

this.logView = CoreTime.once(() => {
const params = {
course: this.filter?.courseId,
};

CoreAnalytics.logEvent({
type: CoreAnalyticsEventType.VIEW_ITEM_LIST,
ws: 'core_calendar_get_calendar_upcoming_view',
name: Translate.instant('addon.calendar.upcomingevents'),
data: {
...params,
category: 'calendar',
},
url: CoreUrlUtils.addParamsToUrl('/calendar/view.php?view=upcoming', params),
});
});
}

/**
Expand Down Expand Up @@ -148,8 +170,9 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, DoCheck, On
try {
await Promise.all(promises);

this.fetchEvents();
await this.fetchEvents();

this.logView();
} catch (error) {
CoreDomUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevents', true);
}
Expand Down
2 changes: 2 additions & 0 deletions src/addons/calendar/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
"currentmonth": "Current Month",
"daynext": "Next day",
"dayprev": "Previous day",
"dayviewtitle": "Day view: {{$a}}",
"defaultnotificationtime": "Default notification time",
"deleteallevents": "Delete all events",
"deleteevent": "Delete event",
"deleteoneevent": "Delete this event",
"detailedmonthviewtitle": "Detailed month view: {{$a}}",
"durationminutes": "Duration in minutes",
"durationnone": "Without duration",
"durationuntil": "Until",
Expand Down
Loading
Loading