MOBILE-4368 analytics: Support download file events
parent
2d2cc2f5f9
commit
791da4500b
|
@ -61,7 +61,7 @@ export class CoreAnalyticsService extends CoreDelegate<CoreAnalyticsHandler> {
|
|||
*
|
||||
* @param event Event data.
|
||||
*/
|
||||
async logEvent(event: CoreAnalyticsViewEvent | CoreAnalyticsPushEvent): Promise<void> {
|
||||
async logEvent(event: CoreAnalyticsAnyEvent): Promise<void> {
|
||||
const site = CoreSites.getCurrentSite();
|
||||
if (!site) {
|
||||
return;
|
||||
|
@ -126,12 +126,18 @@ export enum CoreAnalyticsEventType {
|
|||
VIEW_ITEM = 'view_item', // View some page or data that mainly contains one item.
|
||||
VIEW_ITEM_LIST = 'view_item_list', // View some page or data that mainly contains a list of items.
|
||||
PUSH_NOTIFICATION = 'push_notification', // Event related to push notifications.
|
||||
DOWNLOAD_FILE = 'download_file', // A file was downloaded.
|
||||
}
|
||||
|
||||
/**
|
||||
* Any type of event data.
|
||||
*/
|
||||
export type CoreAnalyticsAnyEvent = CoreAnalyticsViewEvent | CoreAnalyticsPushEvent | CoreAnalyticsDownloadFileEvent;
|
||||
|
||||
/**
|
||||
* Event data, including calculated data.
|
||||
*/
|
||||
export type CoreAnalyticsEvent = (CoreAnalyticsViewEvent | CoreAnalyticsPushEvent) & {
|
||||
export type CoreAnalyticsEvent = CoreAnalyticsAnyEvent & {
|
||||
siteId: string;
|
||||
};
|
||||
|
||||
|
@ -158,3 +164,11 @@ export type CoreAnalyticsPushEvent = {
|
|||
eventName: string; // Name of the event.
|
||||
data: CorePushNotificationsNotificationBasicData;
|
||||
};
|
||||
|
||||
/**
|
||||
* Data specific for the DOWNLOAD_FILE events.
|
||||
*/
|
||||
export type CoreAnalyticsDownloadFileEvent = {
|
||||
type: CoreAnalyticsEventType.DOWNLOAD_FILE;
|
||||
fileUrl: string;
|
||||
};
|
||||
|
|
|
@ -55,6 +55,7 @@ import { lazyMap, LazyMap } from '../utils/lazy-map';
|
|||
import { asyncInstance, AsyncInstance } from '../utils/async-instance';
|
||||
import { CorePath } from '@singletons/path';
|
||||
import { CorePromisedValue } from '@classes/promised-value';
|
||||
import { CoreAnalytics, CoreAnalyticsEventType } from './analytics';
|
||||
|
||||
/*
|
||||
* Factory for handling downloading files and retrieve downloaded files.
|
||||
|
@ -764,6 +765,11 @@ export class CoreFilepoolProvider {
|
|||
extension: fileEntry.extension,
|
||||
});
|
||||
|
||||
CoreAnalytics.logEvent({
|
||||
type: CoreAnalyticsEventType.DOWNLOAD_FILE,
|
||||
fileUrl: CoreUrlUtils.unfixPluginfileURL(fileUrl, site.getURL()),
|
||||
});
|
||||
|
||||
// Add the anchor again to the local URL.
|
||||
return fileEntry.toURL() + (anchor || '');
|
||||
}).finally(() => {
|
||||
|
|
|
@ -542,7 +542,10 @@ export class CoreUrlUtilsProvider {
|
|||
return url;
|
||||
}
|
||||
|
||||
// Not a pluginfile URL. Treat webservice/pluginfile case.
|
||||
// Check tokenpluginfile first.
|
||||
url = url.replace(/\/tokenpluginfile\.php\/[^/]+\//, '/pluginfile.php/');
|
||||
|
||||
// Treat webservice/pluginfile case.
|
||||
url = url.replace(/\/webservice\/pluginfile\.php\//, '/pluginfile.php/');
|
||||
|
||||
// Make sure the URL doesn't contain the token.
|
||||
|
|
Loading…
Reference in New Issue