vue-matomo
Advanced tools
Comparing version 0.2.0 to 0.3.0
/*! | ||
* vue-matomo v0.2.0 | ||
* vue-matomo v0.3.0 | ||
* (c) 2018 Dennis Ruhe | ||
@@ -39,2 +39,30 @@ * Released under the MIT License. | ||
var ClickListener = function ClickListener(matomo) { | ||
this.matomo = matomo; | ||
}; | ||
ClickListener.prototype.bind = function bind (document) { | ||
document.addEventListener('click', this.handle.bind(this)); | ||
}; | ||
ClickListener.prototype.extractDomain = function extractDomain (url) { | ||
return url.replace('http://','').replace('https://','').split('/')[0] | ||
}; | ||
ClickListener.prototype.handle = function handle (e) { | ||
if (e.target.nodeName.toLowerCase() === 'a' && | ||
this.isExternalUrl(e.target.href)) { | ||
this.matomo.trackLink(e.target.href); | ||
} | ||
}; | ||
ClickListener.prototype.isExternalUrl = function isExternalUrl (url) { | ||
console.log('url ' + url); | ||
return this.extractDomain(location.href) !== this.extractDomain(url); | ||
}; | ||
var bindListeners = function (matomo) { | ||
new ClickListener(matomo).bind(document); | ||
}; | ||
var defaultOptions = { | ||
@@ -71,2 +99,5 @@ requireConsent: false, | ||
// Bind event listeners | ||
bindListeners(matomo); | ||
// Track page navigations if router is specified | ||
@@ -73,0 +104,0 @@ if (options.router) { |
/*! | ||
* vue-matomo v0.2.0 | ||
* vue-matomo v0.3.0 | ||
* (c) 2018 Dennis Ruhe | ||
@@ -35,2 +35,30 @@ * Released under the MIT License. | ||
var ClickListener = function ClickListener(matomo) { | ||
this.matomo = matomo; | ||
}; | ||
ClickListener.prototype.bind = function bind (document) { | ||
document.addEventListener('click', this.handle.bind(this)); | ||
}; | ||
ClickListener.prototype.extractDomain = function extractDomain (url) { | ||
return url.replace('http://','').replace('https://','').split('/')[0] | ||
}; | ||
ClickListener.prototype.handle = function handle (e) { | ||
if (e.target.nodeName.toLowerCase() === 'a' && | ||
this.isExternalUrl(e.target.href)) { | ||
this.matomo.trackLink(e.target.href); | ||
} | ||
}; | ||
ClickListener.prototype.isExternalUrl = function isExternalUrl (url) { | ||
console.log('url ' + url); | ||
return this.extractDomain(location.href) !== this.extractDomain(url); | ||
}; | ||
var bindListeners = function (matomo) { | ||
new ClickListener(matomo).bind(document); | ||
}; | ||
var defaultOptions = { | ||
@@ -67,2 +95,5 @@ requireConsent: false, | ||
// Bind event listeners | ||
bindListeners(matomo); | ||
// Track page navigations if router is specified | ||
@@ -69,0 +100,0 @@ if (options.router) { |
/*! | ||
* vue-matomo v0.2.0 | ||
* vue-matomo v0.3.0 | ||
* (c) 2018 Dennis Ruhe | ||
@@ -41,2 +41,30 @@ * Released under the MIT License. | ||
var ClickListener = function ClickListener(matomo) { | ||
this.matomo = matomo; | ||
}; | ||
ClickListener.prototype.bind = function bind (document) { | ||
document.addEventListener('click', this.handle.bind(this)); | ||
}; | ||
ClickListener.prototype.extractDomain = function extractDomain (url) { | ||
return url.replace('http://','').replace('https://','').split('/')[0] | ||
}; | ||
ClickListener.prototype.handle = function handle (e) { | ||
if (e.target.nodeName.toLowerCase() === 'a' && | ||
this.isExternalUrl(e.target.href)) { | ||
this.matomo.trackLink(e.target.href); | ||
} | ||
}; | ||
ClickListener.prototype.isExternalUrl = function isExternalUrl (url) { | ||
console.log('url ' + url); | ||
return this.extractDomain(location.href) !== this.extractDomain(url); | ||
}; | ||
var bindListeners = function (matomo) { | ||
new ClickListener(matomo).bind(document); | ||
}; | ||
var defaultOptions = { | ||
@@ -73,2 +101,5 @@ requireConsent: false, | ||
// Bind event listeners | ||
bindListeners(matomo); | ||
// Track page navigations if router is specified | ||
@@ -75,0 +106,0 @@ if (options.router) { |
/*! | ||
* vue-matomo v0.2.0 | ||
* vue-matomo v0.3.0 | ||
* (c) 2018 Dennis Ruhe | ||
@@ -7,2 +7,2 @@ * Released under the MIT License. | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.VueMatomo=e.VueMatomo||{})}(this,function(e){"use strict";var n={requireConsent:!1,trackInitialView:!0,trackerFileName:"piwik"};e.default=function(r,e){void 0===e&&(e={});var t,a,o,i=Object.assign({},n,e);(t=i,a=t.host+"/"+t.trackerFileName+".js",o=new Promise(function(e,t){var o=document.createElement("script");o.async=!0,o.defer=!0,o.src=a,(document.head||document.getElementsByTagName("head")[0]).appendChild(o),o.onload=e,o.onerror=t}),o.catch(function(e){var t="[vue-matomo] An error occurred trying to load "+e.target.src+". If the file exists you may have an ad- or trackingblocker enabled.";console.error(t)}),o).then(function(){var e=i.host,t=i.siteId,o=i.trackerFileName,n=window.Piwik.getTracker(e+"/"+o+".php",t);r.prototype.$piwik=n,r.prototype.$matomo=n,i.requireConsent&&n.requireConsent(),i.trackInitialView&&n.trackPageView(),i.router&&i.router.afterEach(function(e,t){var o=window.location,r=o.protocol;":"!==r.slice(-1)&&(r+=":");var a=r+"//"+o.host+e.path;n.setCustomUrl(a),n.trackPageView(e.name)})})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.VueMatomo=e.VueMatomo||{})}(this,function(e){"use strict";var c=function(e){this.matomo=e};c.prototype.bind=function(e){e.addEventListener("click",this.handle.bind(this))},c.prototype.extractDomain=function(e){return e.replace("http://","").replace("https://","").split("/")[0]},c.prototype.handle=function(e){"a"===e.target.nodeName.toLowerCase()&&this.isExternalUrl(e.target.href)&&this.matomo.trackLink(e.target.href)};var a={requireConsent:!(c.prototype.isExternalUrl=function(e){return console.log("url "+e),this.extractDomain(location.href)!==this.extractDomain(e)}),trackInitialView:!0,trackerFileName:"piwik"};e.default=function(r,e){void 0===e&&(e={});var t,n,o,i=Object.assign({},a,e);(t=i,n=t.host+"/"+t.trackerFileName+".js",o=new Promise(function(e,t){var o=document.createElement("script");o.async=!0,o.defer=!0,o.src=n,(document.head||document.getElementsByTagName("head")[0]).appendChild(o),o.onload=e,o.onerror=t}),o.catch(function(e){var t="[vue-matomo] An error occurred trying to load "+e.target.src+". If the file exists you may have an ad- or trackingblocker enabled.";console.error(t)}),o).then(function(){var e=i.host,t=i.siteId,o=i.trackerFileName,a=window.Piwik.getTracker(e+"/"+o+".php",t);r.prototype.$piwik=a,r.prototype.$matomo=a,i.requireConsent&&a.requireConsent(),i.trackInitialView&&a.trackPageView(),new c(a).bind(document),i.router&&i.router.afterEach(function(e,t){var o=window.location,r=o.protocol;":"!==r.slice(-1)&&(r+=":");var n=r+"//"+o.host+e.path;a.setCustomUrl(n),a.trackPageView(e.name)})})},Object.defineProperty(e,"__esModule",{value:!0})}); |
/*! | ||
* vue-piwik v0.1.6 | ||
* vue-piwik v0.1.5 | ||
* (c) 2018 Dennis Ruhe | ||
@@ -47,6 +47,2 @@ * Released under the MIT License. | ||
if (options.requireConsent) { | ||
piwik.requireConsent(); | ||
} | ||
// Register first page view | ||
@@ -58,4 +54,2 @@ piwik.trackPageView(); | ||
options.router.afterEach(function (to, from) { | ||
// Unfortunately the window location is not yet updated here | ||
// We need to make our own ulr using the data provided by the router | ||
var loc = window.location; | ||
@@ -62,0 +56,0 @@ var url = loc.protocol + '://' + loc.host + to.path; |
/*! | ||
* vue-piwik v0.1.6 | ||
* vue-piwik v0.1.5 | ||
* (c) 2018 Dennis Ruhe | ||
@@ -43,6 +43,2 @@ * Released under the MIT License. | ||
if (options.requireConsent) { | ||
piwik.requireConsent(); | ||
} | ||
// Register first page view | ||
@@ -54,4 +50,2 @@ piwik.trackPageView(); | ||
options.router.afterEach(function (to, from) { | ||
// Unfortunately the window location is not yet updated here | ||
// We need to make our own ulr using the data provided by the router | ||
var loc = window.location; | ||
@@ -58,0 +52,0 @@ var url = loc.protocol + '://' + loc.host + to.path; |
/*! | ||
* vue-piwik v0.1.6 | ||
* vue-piwik v0.1.5 | ||
* (c) 2018 Dennis Ruhe | ||
@@ -49,6 +49,2 @@ * Released under the MIT License. | ||
if (options.requireConsent) { | ||
piwik.requireConsent(); | ||
} | ||
// Register first page view | ||
@@ -60,4 +56,2 @@ piwik.trackPageView(); | ||
options.router.afterEach(function (to, from) { | ||
// Unfortunately the window location is not yet updated here | ||
// We need to make our own ulr using the data provided by the router | ||
var loc = window.location; | ||
@@ -64,0 +58,0 @@ var url = loc.protocol + '://' + loc.host + to.path; |
/*! | ||
* vue-piwik v0.1.6 | ||
* vue-piwik v0.1.5 | ||
* (c) 2018 Dennis Ruhe | ||
@@ -7,2 +7,2 @@ * Released under the MIT License. | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.VuePiwik=e.VuePiwik||{})}(this,function(e){"use strict";e.default=function(o,n){var e,i,t;void 0===n&&(n={}),(e=n,i=e.host+"/piwik.js",t=new Promise(function(e,t){var o=document.createElement("script");o.async=!0,o.defer=!0,o.src=i,(document.head||document.getElementsByTagName("head")[0]).appendChild(o),o.onload=e,o.onerror=t}),t.catch(function(e){console.error("Error loading script",e)}),t).then(function(){var e=n.host,t=n.siteId,i=window.Piwik.getTracker(e+"/piwik.php",t);o.prototype.$piwik=i,n.requireConsent&&i.requireConsent(),i.trackPageView(),n.router&&n.router.afterEach(function(e,t){var o=window.location,n=o.protocol+"://"+o.host+e.path;i.setCustomUrl(n),i.trackPageView(e.name)})})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.VuePiwik=e.VuePiwik||{})}(this,function(e){"use strict";e.default=function(o,i){var e,n,t;void 0===i&&(i={}),(e=i,n=e.host+"/piwik.js",t=new Promise(function(e,t){var o=document.createElement("script");o.async=!0,o.defer=!0,o.src=n,(document.head||document.getElementsByTagName("head")[0]).appendChild(o),o.onload=e,o.onerror=t}),t.catch(function(e){console.error("Error loading script",e)}),t).then(function(){var e=i.host,t=i.siteId,n=window.Piwik.getTracker(e+"/piwik.php",t);(o.prototype.$piwik=n).trackPageView(),i.router&&i.router.afterEach(function(e,t){var o=window.location,i=o.protocol+"://"+o.host+e.path;n.setCustomUrl(i),n.trackPageView(e.name)})})},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "vue-matomo", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Link your Piwik/Matomo installation", | ||
@@ -5,0 +5,0 @@ "author": "Dennis Ruhe <dennis@amazingsystems.nl>", |
import bootstrap from './bootstrap' | ||
import ClickListener from './listeners/click' | ||
const bindListeners = function (matomo) { | ||
new ClickListener(matomo).bind(document) | ||
} | ||
const defaultOptions = { | ||
@@ -30,2 +35,5 @@ requireConsent: false, | ||
// Bind event listeners | ||
bindListeners(matomo) | ||
// Track page navigations if router is specified | ||
@@ -32,0 +40,0 @@ if (options.router) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27714
18
532