@dbp-toolkit/matomo
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "@dbp-toolkit/matomo", | ||
"homepage": "https://gitlab.tugraz.at/dbp/web-components/toolkit/-/tree/master/packages/matomo", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"main": "src/index.js", | ||
@@ -22,2 +22,4 @@ "license": "LGPL-2.1-or-later", | ||
"chai": "^4.2.0", | ||
"eslint": "^7.3.1", | ||
"eslint-plugin-jsdoc": "^30.6.4", | ||
"i18next-scanner": "^3.0.0", | ||
@@ -53,5 +55,6 @@ "karma": "^5.1.0", | ||
"watch-dev": "rollup -c --watch --environment BUILD:development", | ||
"test": "rollup -c --environment BUILD:test && karma start --singleRun" | ||
"test": "rollup -c --environment BUILD:test && karma start --singleRun", | ||
"lint": "eslint ." | ||
}, | ||
"gitHead": "6ab6a5ca873837c6bff208e637612759bf97ecd0" | ||
"gitHead": "91f47e1c02f864028f9537c84781106645cee797" | ||
} |
@@ -1,3 +0,1 @@ | ||
import {i18n} from './i18n.js'; | ||
import {LitElement} from "lit-element"; | ||
import DBPLitElement from '@dbp-toolkit/common/dbp-lit-element'; | ||
@@ -7,2 +5,6 @@ import {EventBus} from '@dbp-toolkit/common'; | ||
function pushEvent(event) { | ||
window._paq = window._paq || []; | ||
window._paq.push(event); | ||
} | ||
@@ -57,12 +59,11 @@ export class MatomoElement extends DBPLitElement { | ||
window._paq = window._paq || []; | ||
_paq.push(['setCustomVariable', 1, "GitCommit", buildInfo.info, "visit"]); | ||
_paq.push(['enableHeartBeatTimer']); | ||
_paq.push(['disableCookies']); | ||
_paq.push(['trackPageView']); | ||
_paq.push(['enableLinkTracking']); | ||
pushEvent(['setCustomVariable', 1, "GitCommit", buildInfo.info, "visit"]); | ||
pushEvent(['enableHeartBeatTimer']); | ||
pushEvent(['disableCookies']); | ||
pushEvent(['trackPageView']); | ||
pushEvent(['enableLinkTracking']); | ||
(function (endpoint, siteId) { | ||
_paq.push(['setTrackerUrl', endpoint+'matomo.php']); | ||
_paq.push(['setSiteId', siteId]); | ||
pushEvent(['setTrackerUrl', endpoint+'matomo.php']); | ||
pushEvent(['setSiteId', siteId]); | ||
@@ -80,12 +81,12 @@ var g = document.createElement('script'); | ||
window.addEventListener('locationchanged', function(e) { | ||
_paq.push(['setReferrerUrl', e.detail.referrerUrl]); | ||
_paq.push(['setCustomUrl', location.href]); | ||
// _paq.push(['setDocumentTitle', '']); | ||
_paq.push(['trackPageView']); | ||
pushEvent(['setReferrerUrl', e.detail.referrerUrl]); | ||
pushEvent(['setCustomUrl', location.href]); | ||
// pushEvent(['setDocumentTitle', '']); | ||
pushEvent(['trackPageView']); | ||
// make Matomo aware of newly added content | ||
var content = document.getElementById('content'); | ||
_paq.push(['MediaAnalytics::scanForMedia', content]); | ||
_paq.push(['FormAnalytics::scanForForms', content]); | ||
_paq.push(['trackContentImpressionsWithinNode', content]); | ||
pushEvent(['MediaAnalytics::scanForMedia', content]); | ||
pushEvent(['FormAnalytics::scanForForms', content]); | ||
pushEvent(['trackContentImpressionsWithinNode', content]); | ||
}); | ||
@@ -95,9 +96,13 @@ | ||
window.addEventListener('error', function(e) { | ||
_paq.push(['trackEvent', 'Error', e.error.message + '\n' + e.error.stack]); | ||
pushEvent(['trackEvent', 'Error', e.error.message + '\n' + e.error.stack]); | ||
}); | ||
window.addEventListener('unhandledrejection', function(e) { | ||
pushEvent(['trackEvent', 'UnhandledRejection', e.reason]); | ||
}); | ||
this.isRunning = true; | ||
if (this.lastEvent.length > 0) { | ||
console.log('MatomoElement* (' + this.isRunning + '): ' + this.lastEvent[1] + ', ' + this.lastEvent[2]); | ||
_paq.push(this.lastEvent); | ||
pushEvent(this.lastEvent); | ||
this.lastEvent = []; | ||
@@ -118,3 +123,3 @@ } | ||
if (this.isRunning) { | ||
_paq.push(event); | ||
pushEvent(event); | ||
} else { | ||
@@ -121,0 +126,0 @@ this.lastEvent = event; |
45371
19
338
19