MOBILE-4368 analytics: Log searches
parent
333c2b9c6d
commit
fbe1d36ae8
|
@ -45,6 +45,8 @@ import { AddonModDataModuleHandlerService } from '../../services/handlers/module
|
||||||
import { AddonModDataPrefetchHandler } from '../../services/handlers/prefetch';
|
import { AddonModDataPrefetchHandler } from '../../services/handlers/prefetch';
|
||||||
import { AddonModDataComponentsCompileModule } from '../components-compile.module';
|
import { AddonModDataComponentsCompileModule } from '../components-compile.module';
|
||||||
import { AddonModDataSearchComponent } from '../search/search';
|
import { AddonModDataSearchComponent } from '../search/search';
|
||||||
|
import { CoreUrlUtils } from '@services/utils/url';
|
||||||
|
import { CoreTime } from '@singletons/time';
|
||||||
|
|
||||||
const contentToken = '<!-- CORE-DATABASE-CONTENT-GOES-HERE -->';
|
const contentToken = '<!-- CORE-DATABASE-CONTENT-GOES-HERE -->';
|
||||||
|
|
||||||
|
@ -114,6 +116,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
protected entryChangedObserver?: CoreEventObserver;
|
protected entryChangedObserver?: CoreEventObserver;
|
||||||
protected ratingOfflineObserver?: CoreEventObserver;
|
protected ratingOfflineObserver?: CoreEventObserver;
|
||||||
protected ratingSyncObserver?: CoreEventObserver;
|
protected ratingSyncObserver?: CoreEventObserver;
|
||||||
|
protected logSearch?: () => void;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected content?: IonContent,
|
protected content?: IonContent,
|
||||||
|
@ -404,6 +407,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
// Add data to search object.
|
// Add data to search object.
|
||||||
if (modalData) {
|
if (modalData) {
|
||||||
this.search = modalData;
|
this.search = modalData;
|
||||||
|
this.logSearch = CoreTime.once(() => this.performLogSearch());
|
||||||
this.searchEntries(0);
|
this.searchEntries(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -420,6 +424,8 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.fetchEntriesData();
|
await this.fetchEntriesData();
|
||||||
|
|
||||||
|
this.logSearch?.();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true);
|
CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -535,6 +541,31 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp
|
||||||
this.analyticsLogEvent('mod_data_view_database');
|
this.analyticsLogEvent('mod_data_view_database');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log search.
|
||||||
|
*/
|
||||||
|
protected async performLogSearch(): Promise<void> {
|
||||||
|
if (!this.database || !this.search.searching) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const params: Record<string, unknown> = {
|
||||||
|
perpage: AddonModDataProvider.PER_PAGE,
|
||||||
|
search: !this.search.searchingAdvanced ? this.search.text : '',
|
||||||
|
sort: this.search.sortBy,
|
||||||
|
order: this.search.sortDirection,
|
||||||
|
advanced: this.search.searchingAdvanced ? 1 : 0,
|
||||||
|
filter: 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
// @todo: Add advanced search parameters. Leave them empty if not using advanced search.
|
||||||
|
|
||||||
|
this.analyticsLogEvent('mod_data_search_entries', {
|
||||||
|
data: params,
|
||||||
|
url: CoreUrlUtils.addParamsToUrl(`/mod/data/view.php?d=${this.database.id}`, params),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -56,6 +56,7 @@ import {
|
||||||
import { AddonModGlossaryModuleHandlerService } from '../../services/handlers/module';
|
import { AddonModGlossaryModuleHandlerService } from '../../services/handlers/module';
|
||||||
import { AddonModGlossaryPrefetchHandler } from '../../services/handlers/prefetch';
|
import { AddonModGlossaryPrefetchHandler } from '../../services/handlers/prefetch';
|
||||||
import { AddonModGlossaryModePickerPopoverComponent } from '../mode-picker/mode-picker';
|
import { AddonModGlossaryModePickerPopoverComponent } from '../mode-picker/mode-picker';
|
||||||
|
import { CoreTime } from '@singletons/time';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays a glossary entry page.
|
* Component that displays a glossary entry page.
|
||||||
|
@ -86,6 +87,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
|
||||||
protected sourceUnsubscribe?: () => void;
|
protected sourceUnsubscribe?: () => void;
|
||||||
protected observers?: CoreEventObserver[];
|
protected observers?: CoreEventObserver[];
|
||||||
protected checkCompletionAfterLog = false; // Use CoreListItemsManager log system instead.
|
protected checkCompletionAfterLog = false; // Use CoreListItemsManager log system instead.
|
||||||
|
protected logSearch?: () => void;
|
||||||
|
|
||||||
getDivider?: (entry: AddonModGlossaryEntry) => string;
|
getDivider?: (entry: AddonModGlossaryEntry) => string;
|
||||||
showDivider: (entry: AddonModGlossaryEntry, previous?: AddonModGlossaryEntry) => boolean = () => false;
|
showDivider: (entry: AddonModGlossaryEntry, previous?: AddonModGlossaryEntry) => boolean = () => false;
|
||||||
|
@ -226,6 +228,10 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
|
||||||
|
|
||||||
this.hasOfflineRatings = hasOfflineRatings;
|
this.hasOfflineRatings = hasOfflineRatings;
|
||||||
this.hasOffline = this.hasOfflineEntries || this.hasOfflineRatings;
|
this.hasOffline = this.hasOfflineEntries || this.hasOfflineRatings;
|
||||||
|
|
||||||
|
if (this.isSearch && this.logSearch) {
|
||||||
|
this.logSearch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -424,11 +430,23 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
|
||||||
search(query: string): void {
|
search(query: string): void {
|
||||||
this.loadingMessage = Translate.instant('core.searching');
|
this.loadingMessage = Translate.instant('core.searching');
|
||||||
this.showLoading = true;
|
this.showLoading = true;
|
||||||
|
this.logSearch = CoreTime.once(() => this.performLogSearch(query));
|
||||||
|
|
||||||
this.entries?.getSource().search(query);
|
this.entries?.getSource().search(query);
|
||||||
this.loadContent();
|
this.loadContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log search.
|
||||||
|
*
|
||||||
|
* @param query Text entered on the search box.
|
||||||
|
*/
|
||||||
|
protected async performLogSearch(query: string): Promise<void> {
|
||||||
|
this.analyticsLogEvent('mod_glossary_get_entries_by_search', {
|
||||||
|
data: { mode: 'search', hook: query, fullsearch: 1 },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -65,6 +65,7 @@ export class CoreCoursesListPage implements OnInit, OnDestroy {
|
||||||
protected courseIds = '';
|
protected courseIds = '';
|
||||||
protected isDestroyed = false;
|
protected isDestroyed = false;
|
||||||
protected logView: () => void;
|
protected logView: () => void;
|
||||||
|
protected logSearch?: () => void;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.currentSiteId = CoreSites.getRequiredCurrentSite().getId();
|
this.currentSiteId = CoreSites.getRequiredCurrentSite().getId();
|
||||||
|
@ -159,7 +160,7 @@ export class CoreCoursesListPage implements OnInit, OnDestroy {
|
||||||
try {
|
try {
|
||||||
if (this.searchMode) {
|
if (this.searchMode) {
|
||||||
if (this.searchText) {
|
if (this.searchText) {
|
||||||
await this.search(this.searchText);
|
await this.searchCourses();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await this.loadCourses(true);
|
await this.loadCourses(true);
|
||||||
|
@ -247,6 +248,7 @@ export class CoreCoursesListPage implements OnInit, OnDestroy {
|
||||||
this.courses = [];
|
this.courses = [];
|
||||||
this.searchPage = 0;
|
this.searchPage = 0;
|
||||||
this.searchTotal = 0;
|
this.searchTotal = 0;
|
||||||
|
this.logSearch = CoreTime.once(() => this.performLogSearch());
|
||||||
|
|
||||||
const modal = await CoreDomUtils.showModalLoading('core.searching', true);
|
const modal = await CoreDomUtils.showModalLoading('core.searching', true);
|
||||||
await this.searchCourses().finally(() => {
|
await this.searchCourses().finally(() => {
|
||||||
|
@ -268,6 +270,23 @@ export class CoreCoursesListPage implements OnInit, OnDestroy {
|
||||||
this.fetchCourses();
|
this.fetchCourses();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log search.
|
||||||
|
*/
|
||||||
|
protected async performLogSearch(): Promise<void> {
|
||||||
|
if (!this.searchMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoreAnalytics.logEvent({
|
||||||
|
type: CoreAnalyticsEventType.VIEW_ITEM_LIST,
|
||||||
|
ws: 'core_course_search_courses',
|
||||||
|
name: Translate.instant('core.courses.availablecourses'),
|
||||||
|
data: { search: this.searchText, category: 'course' },
|
||||||
|
url: `/course/search.php?search=${this.searchText}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load more courses.
|
* Load more courses.
|
||||||
*
|
*
|
||||||
|
@ -305,6 +324,8 @@ export class CoreCoursesListPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
this.searchPage++;
|
this.searchPage++;
|
||||||
this.canLoadMore = this.courses.length < this.searchTotal;
|
this.canLoadMore = this.courses.length < this.searchTotal;
|
||||||
|
|
||||||
|
this.logSearch?.();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.loadMoreError = true; // Set to prevent infinite calls with infinite-loading.
|
this.loadMoreError = true; // Set to prevent infinite calls with infinite-loading.
|
||||||
!this.isDestroyed && CoreDomUtils.showErrorModalDefault(error, 'core.courses.errorsearching', true);
|
!this.isDestroyed && CoreDomUtils.showErrorModalDefault(error, 'core.courses.errorsearching', true);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
autocorrect="off" [spellcheck]="false" [autoFocus]="false" [lengthCheck]="0" searchArea="CoreTag"></core-search-box>
|
autocorrect="off" [spellcheck]="false" [autoFocus]="false" [lengthCheck]="0" searchArea="CoreTag"></core-search-box>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
<ion-col class="ion-no-padding" size="12" size-sm="6" *ngIf="collections && collections.length > 1">
|
<ion-col class="ion-no-padding" size="12" size-sm="6" *ngIf="collections && collections.length > 1">
|
||||||
<core-combobox [selection]="collectionId" (onChange)="searchTags($event)" [disabled]="searching">
|
<core-combobox [selection]="collectionId" (onChange)="searchTags(query, $event)" [disabled]="searching">
|
||||||
<ion-select-option class="ion-text-wrap" [value]="0">
|
<ion-select-option class="ion-text-wrap" [value]="0">
|
||||||
{{ 'core.tag.inalltagcoll' | translate }}
|
{{ 'core.tag.inalltagcoll' | translate }}
|
||||||
</ion-select-option>
|
</ion-select-option>
|
||||||
|
|
|
@ -45,6 +45,7 @@ export class CoreTagSearchPage implements OnInit {
|
||||||
searching = false;
|
searching = false;
|
||||||
|
|
||||||
protected logView: () => void;
|
protected logView: () => void;
|
||||||
|
protected logSearch?: () => void;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.logView = CoreTime.once(async () => {
|
this.logView = CoreTime.once(async () => {
|
||||||
|
@ -112,6 +113,8 @@ export class CoreTagSearchPage implements OnInit {
|
||||||
*/
|
*/
|
||||||
async fetchTags(): Promise<void> {
|
async fetchTags(): Promise<void> {
|
||||||
this.cloud = await CoreTag.getTagCloud(this.collectionId, undefined, undefined, this.query);
|
this.cloud = await CoreTag.getTagCloud(this.collectionId, undefined, undefined, this.query);
|
||||||
|
|
||||||
|
this.logSearch?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,11 +143,17 @@ export class CoreTagSearchPage implements OnInit {
|
||||||
* Search tags.
|
* Search tags.
|
||||||
*
|
*
|
||||||
* @param query Search query.
|
* @param query Search query.
|
||||||
|
* @param collectionId Collection ID to use.
|
||||||
* @returns Resolved when done.
|
* @returns Resolved when done.
|
||||||
*/
|
*/
|
||||||
searchTags(query: string): Promise<void> {
|
searchTags(query: string, collectionId?: number): Promise<void> {
|
||||||
this.searching = true;
|
this.searching = true;
|
||||||
this.query = query;
|
this.query = query;
|
||||||
|
if (collectionId !== undefined) {
|
||||||
|
this.collectionId = collectionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.logSearch = CoreTime.once(() => this.performLogSearch());
|
||||||
CoreApp.closeKeyboard();
|
CoreApp.closeKeyboard();
|
||||||
|
|
||||||
return this.fetchTags().catch((error) => {
|
return this.fetchTags().catch((error) => {
|
||||||
|
@ -154,4 +163,21 @@ export class CoreTagSearchPage implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log search.
|
||||||
|
*/
|
||||||
|
protected async performLogSearch(): Promise<void> {
|
||||||
|
if (!this.query) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CoreAnalytics.logEvent({
|
||||||
|
type: CoreAnalyticsEventType.VIEW_ITEM_LIST,
|
||||||
|
ws: 'core_tag_get_tag_cloud',
|
||||||
|
name: Translate.instant('core.tag.searchtags'),
|
||||||
|
data: { category: 'tag' },
|
||||||
|
url: `/tag/search.php&query=${this.query}&tc=${this.collectionId}&go=${Translate.instant('core.search')}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue