Preserve ability to disable analytics behavior, explicitly document this option

This commit is contained in:
Robin North
2018-01-24 11:26:13 +00:00
parent cc384b9b16
commit f642eec047
3 changed files with 27 additions and 30 deletions

View File

@@ -9,14 +9,16 @@ module.exports = function(options) {
this.options.switches = this.options.switches || {}
this.options.switchesOptions = this.options.switchesOptions || {}
this.options.history = this.options.history || true
this.options.analytics = (typeof this.options.analytics === "function") ? this.options.analytics : function() {
if (window._gaq) {
_gaq.push(["_trackPageview"])
this.options.analytics = (typeof this.options.analytics === "function" || this.options.analytics === false) ?
this.options.analytics :
function() {
if (window._gaq) {
_gaq.push(["_trackPageview"])
}
if (window.ga) {
ga("send", "pageview", {page: location.pathname, title: document.title})
}
}
if (window.ga) {
ga("send", "pageview", {page: location.pathname, title: document.title})
}
}
this.options.scrollTo = (typeof this.options.scrollTo === "undefined") ? 0 : this.options.scrollTo;
this.options.cacheBust = (typeof this.options.cacheBust === "undefined") ? true : this.options.cacheBust
this.options.debug = this.options.debug || false