[angular-16-irish-monitor | WIP]: Piwik service: add new methods to test events

This commit is contained in:
argirok 2023-10-24 12:47:28 +03:00
parent 606df73c74
commit 33b763ca38
1 changed files with 16 additions and 0 deletions

View File

@ -69,6 +69,22 @@ export class PiwikService {
}
private doTrackEvent(properties: EnvProperties, title, siteId, pageURL, eventCategory, eventAction, eventName, eventValue = 0): Observable<any> {
let ua = this.getUserAgent();
let referrer = this.getReferrer();
let piwikId = ((siteId != null) ? siteId : properties.piwikSiteId);
if (typeof location !== 'undefined' && piwikId) {
var url =`${properties.piwikBaseUrl}${piwikId}&rec=1&url=${encodeURIComponent(pageURL)}&action_name=${encodeURIComponent(title)}&e_c=${encodeURIComponent(eventCategory)}&e_a=${encodeURIComponent(eventAction)}&e_n=${encodeURIComponent(eventName)}&e_v=${encodeURIComponent(eventValue)}`
+((ua != null && ua.length > 0) ? ('&ua=' + StringUtils.URIEncode(ua)) : '') +
((referrer != null && referrer.length > 0) ? ('&urlref=' + StringUtils.URIEncode(referrer)) : '');
// console.log(trackingApiUrl)
console.log(url)
// return of(new Object()); // for testing
return this.http.get(url, {responseType: 'blob'});
}
}
private getUserAgent() {
if (typeof navigator !== 'undefined') {
return navigator.userAgent;